1. How to change topic names and frame ID in rosbag file - tkkim-robot/SLAM_Wiki GitHub Wiki
ROSBAG Modification
You can simply download the demo rosbag file in "HumanDisk/Autoware_Data/190614_MappingData". If you just want demo file, skip this section. The instructions below are for newly recorded custom data.
Change Topic Names
In hdl_graph_slam, the GPS topic name must be in the list:
- /gps/geopoint (geographic_msgs/GeoPointStamped)
- /gps/navsat (sensor_msgs/NavSatFix)
- /gpsimu_driver/nmea_sentence (nmea_msgs/Sentence)
And the IMU topic name must be :
- /gpsimu_driver/imu_data (sensor_msgs/Imu)
I am using the rosbag file recorded in DGIST. The file 'first.bag' could be found at :
- Access NAS. The IP now in July 2019 is (10.40.4.38). You should input ID and password.
- Go to folder HumanDisk.
- Go to folder "Autoware_Data/190614_MappingData".
- Download "first.bag" to your local.
In "first.bag", the GPS topic is "/nmea_sentece (nmea_msgs/Sentence)" and IMU topic is "/imu_raw (sensor_msgs/IMU). So you must change the topic names in the rosbag file. I will introduce a way of python implementation.
- Open any editor, copy the lines below:
from rosbag import Bag
with Bag('first_modified.bag', 'w') as Y:
for topic, msg, t in Bag('first.bag'):
if topic == '/velodyne_points':
Y.write('/velodyne_points', msg, t)
if topic == '/imu_raw':
Y.write('/gpsimu_driver/imu_data', msg, t)
if topic == '/nmea_sentence':
Y.write('/gpsimu_driver/nmea_sentence', msg, t)
- Save the python code above, and run it by python. Make sure 'first.bag' file is in same directory.
- Check 'first_modified.bag' is created in the same directory.
Change frame_id In IMU
In "first_modified.bag", the IMU topic's frame_id is "3dm_gx5_15", which will yield an error of "failed to transform". So, you should change the frame_id of IMU. I will introduce "bag_tools" to solve it.
First, install "bag_tools". The instuctions is here: http://wiki.ros.org/bag_tools
Then, run scripts in terminal :
rosrun bag_tools change_frame_id.py -o first_modified_imu.bag -i first_modified.bag -f /velodyne -t /gpsimu_driver/imu_data
The xxx_modified_imu.bag, which are modified for hdl_graph_slam, are saved to the "HumanDisk/Autoware_Data/190614_MappingData".