ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Can not tell for sure from the image and code posted, but you seem to be trying to visualize the transform between imu and map frames in rviz. You seem to have some transform between the two, but that part of your code is not posted here, to make it work like you have it now you would have to use the "quaternion" you get from the imu to calculate the transform and publish it.

For debugging that would be fine, I guess. In the end you probably don't want your imu node to publish this transform, it's probably not the only sensor you will use for your localization and it would get quite messy if every sensor is connected to some base_link and is publishing it's own transform. So you will probably use some node that will take in all the sensors and calculate the transform based on all of them. One such node is the robot_localization package.

If you want to visualize the heading of your imu in rviz, there are several options. You could install the rviz imu plugin and use that. Or you could publish some message alongside the IMU message that are easier to visualize in Rviz. Like for example the PoseStamped from geometry_msgs. Just define a pose_msg the same way you did imu_msg and a publisher for pub_pose similar to pub_imu and add the following lines to the end of publish_imu function

self.pose_msg.header = self.imu_msg.header
self.pose_msg.pose.orientation = self.imu_msg.orientation
self.pub_pose.publish(self.pose_msg)

Then you should be able to add the pose visualization to rviz. Open rviz, click the "Add" option in the "displays" panel, switch to the "By topic" tab and add the pose message to the displays.


Also you probably should remove the sequence counting and setting from your node. Ros will handle counting and setting the sequence on its own. One relevant ros answers question regarding that.

Can not tell for sure from the image and code posted, but you seem to be trying to visualize the transform between imu and map frames in rviz. You seem to have some transform between the two, but that part of your code is not posted here, to make it work like you have it now you would have to use the "quaternion" you get from the imu to calculate the transform and publish it.

For debugging debugging, that would be fine, I guess. In the end you probably don't want your imu node to publish this transform, it's probably not the only sensor you will use for your localization and it would get quite messy if every sensor is connected to some base_link and is publishing it's own transform. So you will probably use some node that will take in all the sensors and calculate the transform based on all of them. One such node is the robot_localization package.

If you want to visualize the heading of your imu in rviz, there are several options. You could install the rviz imu plugin and use that. Or you could publish some message alongside the IMU message that are easier to visualize in Rviz. Like for example the PoseStamped from geometry_msgs. Just define a pose_msg the same way you did imu_msg and a publisher for pub_pose similar to pub_imu and add the following lines to the end of publish_imu function

self.pose_msg.header = self.imu_msg.header
self.pose_msg.pose.orientation = self.imu_msg.orientation
self.pub_pose.publish(self.pose_msg)

Then you should be able to add the pose visualization to rviz. Open rviz, click the "Add" option in the "displays" panel, switch to the "By topic" tab and add the pose message to the displays.


Also you probably should remove the sequence counting and setting from your node. Ros will handle counting and setting the sequence on its own. One relevant ros answers question regarding that.

that.