rviz and ROS
The setup was hard and not obvious for me. These notes help you to get started fast.
Moving things in rviz
As the first step, I wanted to move something in rviz.
Moving anything is surprisingly a very hard task for a novice who doesn't know about the right way.
The right way is likely to use the transformation frames (TF). All the objects are connected to framed and ROS tracks the frames.
The test program
send_tf_events.py uses the frame named
world as the main fixed frame, and rotates the frame
imu_sensor1. The tool
rviz visualizes the rotation.
The two things are important.
- The component
TFshould be added into the interface.
- The name of the main fixed frame should be set to
Rviz finds the rotation frame
imu_sensor1 somehow self.
Recording and replaying the motion
ROS provides the tool rosbag.
I've made a sample recording in the file
If you want to play the same motion twice, reset
rviz (there is a button). The
TF-events have a timestamp. Without reset,
rviz ignores the events "from the past".
Decoding the structure of the bag-files
I plan to generate
bag-files self without
ROS libraries installed.
There is documentation for the
bag format, but it is not enough. To fully understand the structure, I've written bag-to-xml converter
bag_to_xml.py, which works for my samples. Usage:
$ cat file.bag | python bag_to_xml.py >file.xml
The raw data for a message mostly corresponds to the message structure. The two things I don't understand are:
- The field
Headeris always 0.
- There is always the value 1 of the type
- The documentation for the bag header record says that it "is 4096 bytes long". According to the samples, the magic constant is actually 4104.