std_msgs.Header类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(301)

本文整理了Java中std_msgs.Header类的一些代码示例,展示了Header类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header类的具体详情如下:
包路径:std_msgs.Header
类名称:Header

Header介绍

暂无

代码示例

代码示例来源:origin: us.ihmc/IHMCAvatarInterfaces

public void onNewMessage(JointState message)
  {
    receivedClockMessage(message.getHeader().getStamp().totalNsecs());
  }
});

代码示例来源:origin: us.ihmc/IHMCROSTools

public void publish(RigidBodyTransform transform3d, long timeStamp, String parentFrame, String childFrame)
  {
   TransformStamped transformStamped = topicMessageFactory.newFromType(TransformStamped._TYPE);
   Transform transform = getRosTransform(transform3d);
   transformStamped.setTransform(transform);
   transformStamped.setChildFrameId(childFrame);
   Header header = transformStamped.getHeader();
   header.setStamp(Time.fromNano(timeStamp));
   header.setFrameId(parentFrame);
   header.setSeq(seq++);
   transformStamped.setHeader(header);
   
   
   TFMessage message = getMessage();
   
   List<TransformStamped> tfs = new ArrayList<TransformStamped>();
   tfs.add(transformStamped);
   message.setTransforms(tfs);
   publish(message);
  }
}

代码示例来源:origin: rosjava/rosjava_core

public static FrameTransform fromTransformStampedMessage(
  geometry_msgs.TransformStamped transformStamped) {
 Transform transform = Transform.fromTransformMessage(transformStamped.getTransform());
 String target = transformStamped.getHeader().getFrameId();
 String source = transformStamped.getChildFrameId();
 Time stamp = transformStamped.getHeader().getStamp();
 return new FrameTransform(transform, GraphName.of(source), GraphName.of(target), stamp);
}

代码示例来源:origin: us.ihmc/IHMCROSTools

private Header createHeaderMsg(long timestamp)
{
 Header header = newMessageFromType(Header._TYPE);
 header.setStamp(Time.fromNano(timestamp));
 header.setSeq(counter);
 counter++;
 return header;
}

代码示例来源:origin: rosjava/rosjava_core

public geometry_msgs.TransformStamped toTransformStampedMessage(
  geometry_msgs.TransformStamped result) {
 Preconditions.checkNotNull(time);
 result.getHeader().setFrameId(target.toString());
 result.getHeader().setStamp(time);
 result.setChildFrameId(source.toString());
 transform.toTransformMessage(result.getTransform());
 return result;
}

代码示例来源:origin: us.ihmc/ihmc-ros-tools

@Override
public synchronized void onNewMessage(sensor_msgs.Imu message)
{
 this.timeStamp = message.getHeader().getStamp().totalNsecs();
 this.seq_id = message.getHeader().getSeq();
 this.frameId = message.getHeader().getFrameId();
 RosTools.packRosQuaternionToEuclidQuaternion(message.getOrientation(), this.orientationEstimate);
 RosTools.packRosVector3ToEuclidTuple3D(message.getAngularVelocity(), this.angularVelocity);
 RosTools.packRosVector3ToEuclidTuple3D(message.getLinearAcceleration(), this.linearAcceleration);
 onNewMessage(timeStamp, seq_id, orientationEstimate, angularVelocity, linearAcceleration);
}

代码示例来源:origin: rosjava/rosjava_core

@Override
public void onNewMessage(rosjava_test_msgs.TestHeader message) {
 int seq = message.getHeader().getSeq();
 long stamp = message.getHeader().getStamp().totalNsecs();
 if (lastMessage != null) {
  int lastSeq = lastMessage.getHeader().getSeq();
  long lastStamp = lastMessage.getHeader().getStamp().totalNsecs();
  assertTrue(String.format("message seq %d <= previous seq %d", seq, lastSeq), seq > lastSeq);
  assertTrue(String.format("message stamp %d <= previous stamp %d", stamp, lastStamp),
    stamp > lastStamp);
 }
 lastMessage = message;
 latch.countDown();
}

代码示例来源:origin: us.ihmc/IHMCROSTools

@Override
  public synchronized void onNewMessage(PointCloud2 pointCloud)
  {
   growablePointCloud.clear();
   UnpackedPointCloud unpackedCloud=unpackPointsAndIntensities(pointCloud);
   for (int i = 0; i < unpackedCloud.getPoints().length; i++)
   {
     switch (PointType.fromFromFieldNames(pointCloud.getFields()))
     {
      case XYZI :
        if (includePoint(unpackedCloud.getPoints()[i], unpackedCloud.getIntensities()[i]))
         growablePointCloud.addPoint(unpackedCloud.getPoints()[i], unpackedCloud.getIntensities()[i]);
        break;
      case XYZRGB :
        if (includePoint(unpackedCloud.getPoints()[i], unpackedCloud.getPointColors()[i]))
         growablePointCloud.addPoint(unpackedCloud.getPoints()[i], unpackedCloud.getPointColors()[i]);
        break;
     }
   }
   System.out.println("Publishing " + pointCloud.getHeader().getSeq() + " " + growablePointCloud.size() + " points");
   publisher.publish(growablePointCloud.getPoints(), growablePointCloud.getColors(), pointCloud.getHeader().getFrameId());
   /*
    * Transform3d pinkBlobTransform = new Transform3d();
    * pinkBlobTransform.setTranslation(new Vector3d(growablePointCloud.getMeanPoint()));
    * tfPublisher.publish(pinkBlobTransform, pointCloud.getHeader().getStamp().totalNsecs(), "/multisense/left_camera_optical_frame", "pinkBlob");
    */
  }
};

代码示例来源:origin: rosjava/rosjava_core

private void publish(byte level, Object message) {
 rosgraph_msgs.Log logMessage = publisher.newMessage();
 logMessage.getHeader().setStamp(defaultNode.getCurrentTime());
 logMessage.setLevel(level);
 logMessage.setName(defaultNode.getName().toString());
 logMessage.setMsg(message.toString());
 // TODO(damonkohler): Should update the topics field with a list of all
 // published and subscribed topics for the node that created this logger.
 // This helps filter the rosoutconsole.
 publisher.publish(logMessage);
}

代码示例来源:origin: us.ihmc/ihmc-ros-tools

public void publish(long timestamp, RigidBodyTransform transform, Vector3DReadOnly linearVelocity, Vector3DReadOnly angularVelocity, String childFrame, String frameId)
{
 Odometry message = getMessage();
 Header header = createHeaderMsg(timestamp);
 header.setFrameId(frameId);
 message.setHeader(header);
 
 PoseWithCovariance poseWithCovariance = createPoseWithCovarianceMsg(transform);
 message.setPose(poseWithCovariance);
 
 TwistWithCovariance twistWithCovariance = createTwistWithCovariance(linearVelocity, angularVelocity);
 message.setTwist(twistWithCovariance);
 
 message.setChildFrameId(childFrame);
 
 publish(message);
}

代码示例来源:origin: rosjava/rosjava_core

public geometry_msgs.PoseStamped toPoseStampedMessage(GraphName frame, Time stamp,
  geometry_msgs.PoseStamped result) {
 result.getHeader().setFrameId(frame.toString());
 result.getHeader().setStamp(stamp);
 result.setPose(toPoseMessage(result.getPose()));
 return result;
}

代码示例来源:origin: us.ihmc/IHMCROSTools

@Override
public synchronized void onNewMessage(sensor_msgs.Imu message)
{
 this.timeStamp = message.getHeader().getStamp().totalNsecs();
 this.seq_id = message.getHeader().getSeq();
 this.frameId = message.getHeader().getFrameId();
 RosTools.packRosQuaternionToQuat4d(message.getOrientation(), this.orientationEstimate);
 RosTools.packRosVector3ToVector3d(message.getAngularVelocity(), this.angularVelocity);
 RosTools.packRosVector3ToVector3d(message.getLinearAcceleration(), this.linearAcceleration);
 onNewMessage(timeStamp, seq_id, orientationEstimate, angularVelocity, linearAcceleration);
}

代码示例来源:origin: us.ihmc/ihmc-ros-tools

private Header createHeaderMsg(long timestamp)
{
 Header header = newMessageFromType(Header._TYPE);
 header.setStamp(Time.fromNano(timestamp));
 header.setSeq(counter);
 counter++;
 return header;
}

代码示例来源:origin: us.ihmc/ihmc-ros-tools

@Override
  public synchronized void onNewMessage(PointCloud2 pointCloud)
  {
   growablePointCloud.clear();
   UnpackedPointCloud unpackedCloud=unpackPointsAndIntensities(pointCloud);
   for (int i = 0; i < unpackedCloud.getPoints().length; i++)
   {
     switch (PointType.fromFromFieldNames(pointCloud.getFields()))
     {
      case XYZI :
        if (includePoint(unpackedCloud.getPoints()[i], unpackedCloud.getIntensities()[i]))
         growablePointCloud.addPoint(unpackedCloud.getPoints()[i], unpackedCloud.getIntensities()[i]);
        break;
      case XYZRGB :
        if (includePoint(unpackedCloud.getPoints()[i], unpackedCloud.getPointColors()[i]))
         growablePointCloud.addPoint(unpackedCloud.getPoints()[i], unpackedCloud.getPointColors()[i]);
        break;
     }
   }
   System.out.println("Publishing " + pointCloud.getHeader().getSeq() + " " + growablePointCloud.size() + " points");
   publisher.publish(growablePointCloud.getPoints(), growablePointCloud.getColors(), pointCloud.getHeader().getFrameId());
   /*
    * Transform3d pinkBlobTransform = new Transform3d();
    * pinkBlobTransform.setTranslation(new Vector3d(growablePointCloud.getMeanPoint()));
    * tfPublisher.publish(pinkBlobTransform, pointCloud.getHeader().getStamp().totalNsecs(), "/multisense/left_camera_optical_frame", "pinkBlob");
    */
  }
};

代码示例来源:origin: rosjava/rosjava_core

private void updateTransform(geometry_msgs.TransformStamped transformStamped,
   ConnectedNode connectedNode, FrameTransformTree frameTransformTree) {
  transformStamped.getHeader().setStamp(connectedNode.getCurrentTime());
  transformStamped.getTransform().getRotation().setW(Math.random());
  transformStamped.getTransform().getRotation().setX(Math.random());
  transformStamped.getTransform().getRotation().setY(Math.random());
  transformStamped.getTransform().getRotation().setZ(Math.random());
  transformStamped.getTransform().getTranslation().setX(Math.random());
  transformStamped.getTransform().getTranslation().setY(Math.random());
  transformStamped.getTransform().getTranslation().setZ(Math.random());
  frameTransformTree.update(transformStamped);
 }
}

代码示例来源:origin: us.ihmc/IHMCROSTools

public void publish(long timestamp, RigidBodyTransform transform, Vector3f linearVelocity, Vector3f angularVelocity, String childFrame, String frameId)
{
 Odometry message = getMessage();
 Header header = createHeaderMsg(timestamp);
 header.setFrameId(frameId);
 message.setHeader(header);
 
 PoseWithCovariance poseWithCovariance = createPoseWithCovarianceMsg(transform);
 message.setPose(poseWithCovariance);
 
 TwistWithCovariance twistWithCovariance = createTwistWithCovariance(linearVelocity, angularVelocity);
 message.setTwist(twistWithCovariance);
 
 message.setChildFrameId(childFrame);
 
 publish(message);
}

代码示例来源:origin: us.ihmc/ihmc-ros-tools

public void publish(RigidBodyTransform transform3d, long timeStamp, String parentFrame, String childFrame)
  {
   TransformStamped transformStamped = topicMessageFactory.newFromType(TransformStamped._TYPE);
   Transform transform = getRosTransform(transform3d);
   transformStamped.setTransform(transform);
   transformStamped.setChildFrameId(childFrame);
   Header header = transformStamped.getHeader();
   header.setStamp(Time.fromNano(timeStamp));
   header.setFrameId(parentFrame);
   header.setSeq(seq++);
   transformStamped.setHeader(header);
   
   
   TFMessage message = getMessage();
   
   List<TransformStamped> tfs = new ArrayList<TransformStamped>();
   tfs.add(transformStamped);
   message.setTransforms(tfs);
   publish(message);
  }
}

代码示例来源:origin: us.ihmc/ihmc-avatar-interfaces

public void onNewMessage(JointState message)
  {
    receivedClockMessage(message.getHeader().getStamp().totalNsecs());
  }
});

代码示例来源:origin: rosjava/rosjava_core

@Override
 protected void loop() throws InterruptedException {
  geometry_msgs.TransformStamped message =
    connectedNode.getTopicMessageFactory()
      .newFromType(geometry_msgs.TransformStamped._TYPE);
  message.getHeader().setFrameId("world");
  message.setChildFrameId("turtle");
  message.getHeader().setStamp(connectedNode.getCurrentTime());
  message.getTransform().getRotation().setW(Math.random());
  message.getTransform().getRotation().setX(Math.random());
  message.getTransform().getRotation().setY(Math.random());
  message.getTransform().getRotation().setZ(Math.random());
  message.getTransform().getTranslation().setX(Math.random());
  message.getTransform().getTranslation().setY(Math.random());
  message.getTransform().getTranslation().setZ(Math.random());
  counter.incrementAndGet();
 }
});

代码示例来源:origin: us.ihmc/IHMCROSTools

public synchronized void onNewMessage(nav_msgs.Odometry msg)
 timeStamp = msg.getHeader().getStamp().totalNsecs();
 frameID = msg.getHeader().getFrameId();

相关文章