In this lecture, we are going to take a break from coding and go over Ross bag files.
Bag files are used to record data coming in over Ross so that you can play it back at a later time.
Bank files are incredibly useful when it comes to robots, which are difficult to deploy and test,
as well as review how your developed robot code responded to certain situations.
We're going to first go ahead and create our own bank file and then the resources section.
I will also have available a bank file from an autonomous surface vehicle I worked on a while back so
you can see data from a real robot play back as it did when we deployed it.
So far back file we are going to create.
We're just going to record information from the nodes we created in the previous sections project where
we created in RPM and Speed Publisher Node, which had values we could change via parameters.
So I can go ahead and open up.
VISCO just to remind you of what this looked like.
So in this launch file, I ran two different nodes our RPM, pub node and our speed pub node, and we
can change parameters such as the wheel radius.
So I'll go ahead and open up a terminal, change into my workspace directory, source it and launch
the project.
Now I'm going to open a new terminal tab and double check that our code is running properly by listing
our topics and we can see them there and we can check that it's publishing using the RAS two topic Echo
Command.
All right, So our publishers are running, so let's open a new terminal.
Where we will record our bank file.
To record the bank file, we're going to use the Ross to bag record command.
You can see what type of options we have with the ROS commands on the corresponding ROS index page.
We'll discuss packages and the ROS index page in the upcoming lecture, but for now we're just going
to quickly go through some of these Ros to bag commands.
For now, I'm going to use the dash a flag to record all topics.
If we only wanted to record certain topics we would type them out instead.
So for example, slash speed or slash RPM.
But again, for now I'm just going to use the dash a flag.
Then I'm going to use the dash o flag to specify the output name, which in this case I'll set to test
dot bag because if not, the default name will be the current date and time stamp.
Note that it will save the bag in our current terminal directory.
So in this case I'm actually within our ROS to py workspace directory.
I'm actually going to quickly go ahead and change into our home directory and I'm going to go ahead
and hit enter.
So you'll see it begin subscribing to all of the different topics.
Let's create some variety in our bag file by changing our wheel size parameter.
So I'm going to go open up a another terminal tab.
And run Ra Super am set to change our wheel radius side.
Oh, and make sure to set it to a double instead of an integer.
So we set the parameter successfully and we see that it's gone ahead and changed here in our file,
and we could go ahead and change that one more time just to add some more variety.
And we see it change again.
So I'm going to go ahead and stop this bag file by hitting control C.
And we can go ahead and stop these other terminals from running the launch file and echoing the topic
information.
So let's go ahead and clear this up.
So go ahead and clear the screens.
And I'll go ahead and close these first two terminals.
So now if we go into our home directory.
We can see this test bag folder and if we open it up, it has two files in it metadata, a L and a DB
three file, which is an SQLite version of what a saving are.
Ros data.
So to find more information about what's in this bag, we can use the Ross to bag info command on that
bag file.
And here we can see things such as the bag size.
We can see the storage type is sky three.
The duration of the bag file.
When we took the bag file as well as the number of messages, topic information and a little bit of
information into each individual topic.
So in this case we see we got information from ROS out RPM and the speed topics.
So keep in mind I stopped at my speed publisher.
So if I do ROS two topic list, we don't see that speed in RPM topic being published to.
Let's go ahead and play this bag file back to get the information from it.
So go ahead and clear the screen and do Ros to bag play and I will do dash L which will loop the bag
file once it finishes.
It'll go back to the beginning and I do test dot bag.
So we can see that our ROS bag is playing.
And now if I do Ross to topic list again, we see that now we have our RPM and speed topics that are
coming from the bag file and we can actually go ahead and echo them.
So here we see the initial value that was coming from our speed publisher, and eventually we should
see the values change because we changed the parameters midway through recording this back file.
So here we see it changes to 5.23, and then we should see it change again to.
10.47.
All right.
So go ahead and stop these.
Now, I know this isn't the coolest bag file ever, so I prepared a bag file with data from an autonomous
surface vehicle I worked with a while back, which I have in my downloads folder.
So go ahead and clear the screen.
And again, you can just grab this from the resources folder.
So I have it here in my downloads folder, this marine surface vehicle bag, I've already gone ahead
and unzipped it, so if I go into my downloads folder.
We can see it there.
And again, I'm not playing anything in the background, so if I do Ross to topic list, we only get
our basic topics out.
But if I do Ross to bag Play, Dash L and the name of the bag file, we can see it playing.
And now if I run Ross to topic list again, we see several different topics such as Things for the Fix,
which is the GPS of the robot, the IMU information, as well as the velocity and camera information
that was coming from this particular robotic system.
And of course, we can always go ahead and check this out by doing a Ross two topic echo slash fix.
Here we can see latitude and longitude coordinates of this particular robot.
So as a little side challenge.
See if you can figure out where this robot was when this bag file was being taken.
So go ahead and stop this with control C.
And now notice we have camera information, but we can't just really echo that, right?
If I do, Ross, too, topic Echo and I do this when the front camera, USB camera.
We had a series of numbers just being printed to this screen endlessly.
Now this is the actual pixel information and color mappings within the image.
But in the next lecture, we'll be learning how to utilize tools to help us visualize some of this type
of information we may be getting from our robots.
Then the last thing I want to cover were some of the improvements made related to bag files in the latest
Ross Humboldt distribution.
If you head over to the Ross to Humble page, you will see the changes made since Fox in Galactic and
in the Ross to back section.
We see there is now support for setting the start time of a bag file as well as playing in pausing bag
files as well as a burst mode.
If you're doing things such as training or testing neural network models.
You can also edit bag files to do things such as remove certain topics or merge multiple bag files together.
All right.
With that, let's review what we learned about bag files.
In this lecture, we learned how to use the bank file terminal commands in ROS two.
This includes the ROS two bag record command, which we can specify topics or use the dash a flag to
record all topics and then use the dash o flag to name the bag file output.
We also learned about the ROS to bag info command which will give us information about a bag file.
Then we can actually go ahead and play the bag file back using the ROS to bag play command.
We use the dash WL flag for this command to loop the playback over so the bag file doesn't just stop
playing once it reaches the end.
Instead recycles back at the beginning.