The marker location is determined from the laser scan data which is in the reference
frame of the
base_laser. Technically, RViz will do the conversion for us, but
as an exercise, was worth transforming the location in the
base_laser frame to
odom before publishing data for use by RViz.
The steps taken were as follows:
Include the necessary headers
Include relevant header files declaring the necessary message types.
Declare the buffer for storage
Declare the buffer, and listener in the header file. The buffer stores the
transform related data, and has the public member function
that we will be using to get the transform between two frames.
Declare relevant messages
geometry_msgs::TransformStamped message, transformStamped, and
lookupTransform() function to get the transform. The point here is
that the frames dont need the ‘/’ in front, and the first parameter is the frame
that we want to transform to or said differently, the target frame. The full
specification of the function can be found
“Stamp” the data
Finally we need to “stamp” the source point before passing to the
function. The api of
geometry_msgs/PoseStamped can be found
Now we have the location of the pillar originally in the
transformed to the
The full source code can be found
Dont forget to make the necessary changes to the CMakefile and package.xml files.
Also, found small issues with the ROS
thus made a quick edit. Basically the prior post had
the specifications of the parameters to
- ROS Wiki, tf2 Tutorials. Writing a tf2 listener.
- Fankhauser, P., Dominic, J., and Wermelinger, Martin.(2017) Course 3, Programming for Robotics (ROS).