Ros2JointStateMessage#

Fully qualified name: isaacsim::ros2::core::Ros2JointStateMessage

class Ros2JointStateMessage : public isaacsim::ros2::core::Ros2Message#

Class implementing a sensor_msgs/msg/JointState message.

Provides functionality to read and write ROS 2 JointState messages that contain joint positions, velocities, and efforts for articulated mechanisms.

Subclassed by isaacsim::ros2::core::Ros2JointStateMessageImpl

Public Functions

virtual void writeData(
const double &timeStamp,
omni::physics::tensors::IArticulationView *articulation,
pxr::UsdStageWeakPtr stage,
std::vector<float> &jointPositions,
std::vector<float> &jointVelocities,
std::vector<float> &jointEfforts,
std::vector<uint8_t> &dofTypes,
const double &stageUnits,
) = 0#

Write the message field values from the given arguments.

Sets the joint names, positions, velocities, efforts, and timestamp in a ROS 2 JointState message.

Parameters:
  • timeStamp – [in] Time (seconds).

  • articulation – [in] Articulation handler.

  • stage – [in] USD stage.

  • jointPositions – [in] Joint positions.

  • jointVelocities – [in] Joint velocities.

  • jointEfforts – [in] Joint efforts.

  • dofTypes – [in] Articulation DOF types.

  • stageUnits – [in] Unit scale of the stage.

virtual void writeData(
const double &timeStamp,
const std::vector<std::string> &jointNames,
const std::vector<double> &jointPositions,
const std::vector<double> &jointVelocities,
const std::vector<double> &jointEfforts,
const std::vector<uint8_t> &dofTypes,
double stageMetersPerUnit,
) = 0#

Write the message from joint state arrays (e.g.

from Isaac Read Joint State node).

Sets the joint names, positions, velocities, efforts, and timestamp from the given arrays. Does not use articulation or stage. Use when publishing from OmniGraph inputs.

Parameters:
  • timeStamp – [in] Time (seconds).

  • jointNames – [in] Joint name strings (size n).

  • jointPositions – [in] Joint positions (rad or m), size n.

  • jointVelocities – [in] Joint velocities (rad/s or m/s), size n.

  • jointEfforts – [in] Joint efforts (Nm or N), size n.

  • dofTypes – [in] Per-DOF type: 0 = revolute, 1 = prismatic; size n.

  • stageMetersPerUnit – [in] Stage meters per USD unit (e.g. 0.01 for cm).

virtual void readData(
std::vector<char*> &jointNames,
double *jointPositions,
double *jointVelocities,
double *jointEfforts,
double &timeStamp,
) = 0#

Read the message field values.

Extracts joint names, positions, velocities, efforts, and timestamp from a ROS 2 JointState message.

The size of the arrays to store the joint positions, velocities, and efforts must be equal to the number of joints (see Ros2JointStateMessage::getNumJoints) of the message before calling this method.

Parameters:
  • jointNames – [out] Joint names.

  • jointPositions – [out] Joint positions.

  • jointVelocities – [out] Joint velocities.

  • jointEfforts – [out] Joint efforts.

  • timeStamp – [out] Time (seconds).

virtual size_t getNumJoints() = 0#

Get the number of joints in the message.

Returns the number of joints in the message, derived from the size of the name field array.

Returns:

Number of joints.

virtual bool checkValid() = 0#

Check that the message field arrays have the same size.

Verifies that the joint names, positions, velocities, and efforts arrays all have the same size, indicating a valid message.

Returns:

Whether the message field arrays have the same size.

inline void *getPtr()#

Retrieves the message pointer.

Returns the pointer to the underlying ROS 2 message if it has been properly created and initialized.

Note

This method does not perform type checking - the caller is responsible for proper casting to the appropriate message type.

Returns:

Pointer to the message or nullptr if not initialized.

virtual const void *getTypeSupportHandle() = 0#

Gets the type support handle for the message.

Returns a pointer to the ROS IDL message type support data structure. The actual type depends on the message category:

  • Topic: rosidl_message_type_support_t

  • Service: rosidl_service_type_support_t

  • Action: rosidl_action_type_support_t

Returns:

Pointer to the type support structure or nullptr.

Protected Attributes

void *m_msg = nullptr#

Message pointer.