Robotics StackExchange | Archived questions

ROS1 to ROS2: JointStateConstPtr

Im trying to port some code from ros1 to ros2 (industrial_core) disclaimer: I’m new to ROS.

I hit an issue that isnt covered the migration guide.

I notice in the OLD ROS1 SENSORMSGSMESSAGEJOINTSTATEH include, it has things like

typedef … JointStateConstPtr;

but in the headers with ROS2’s sensor_msgs package, it does not. What am I supposed to do about that sort of stuff?

For example, I think maybe I’m supposed to convert all references of

trajectory_msgs::msg::JointTrajectoryConstPtr

to

trajectory_msgs::msg::JointTrajectory::ConstPtr ??

But that seems a bit hokey

Asked by Phil Brown on 2023-01-27 14:00:07 UTC

Comments

Answers

This is poorly documented (Good documentation would include WHY!) But it seems like I'm supposed to use

trajectory_msgs::msg::JointTrajectory::SharedPtr

Because ConstPtr is there but "deprecated". Again, no explanation of WHY, which is... confusing, to say the least.

Also, I THINK Im supposed to remove the original "&".

So, whereas original ROS1 client code would have

const trajectory_msgs::JointTrajectoryConstPtr& traj,

ROS2 syntax would be

const trajectory_msgs::msgs::JointTrajectory::SharedPtr traj,

I THINK. Not sure yet though.

Asked by Phil Brown on 2023-01-29 12:59:13 UTC

Comments