Gazebo機器人仿真學習探索筆記(六)
工具和实用程序
Gazebo附带了许多工具和实用程序。 这些教程说明了这些可用的工具,以及如何使用它们。 主要有: 1 记录和播放 2 日志过滤 3 应用力/扭矩 4 HDF5数据集
官网介绍通俗具体,非常容易,请参考附件。
附件--官方教程
Logging and playback Overview
This tutorial explains how to use the Gazebo logging capabilities to record your simulation and then reproduce it afterwards, using either the GUI or the command line.
Gazebo log files
Gazebo log files are compressed .log files which contain an initial full description of the whole world, followed by a series of \
The initial description contains complete information about everything in the world, from the scene to the entities present.
After that, every time something changes in simulation, a new world state is recorded. World states are much simpler, as they only contain information about what changed, such as:
Simulation statistics such as the current simulation time and the number of physics iterations.
Current state of each model in the scene, as well as the state of each link and joint in the model. This includes information such as instantaneous pose, velocity, acceleration and forces.
Current pose of each light in the world.
Tip: You can find the whole spec for the world state here.
In this tutorial we will record a few log files and then take a peek inside them at the end.
Record a log
Logging from the GUI
Start your simulation. Here, as an example, we have a simple world with a double pendulum.
Click on the logging icon on the top right, or hit Ctrl+D to bring up the Data Logger.
You can choose the directory where your log file will be saved by clicking the Browse button. By default, log files Go to the ~/.gazebo/log directory. In this example, we will save it in the ~/logs/double_pendulum/ directory.
Click on the red button to start recording. You should see the number of bytes in your log file increasing on the right.
Note: For efficiency, only models and lights which move over time are logged. If your scene is static, the number of bytes in your log file will not increase. This also means that the number of samples in your log file may be different from the number of iterations in simulation. Click on the red button again to stop logging.
Expand Recordings to see the path to the state.log file which was generated. It will be inside a time-stamped directory.
Logging from the command line
From the command line, it is possible to log the whole simulation from the moment Gazebo starts running until it stops, or to trigger logging from an arbitary time.
Logging the whole simulation
As an example, you can record the random_velocity.world as follows:
gazebo -r --record_path ~/logs/random_velocity worlds/random_velocity.world You can see a list of all of the available logging options by running gazebo --help.
-p [--play] arg: Play a log file.
-r [ --record ]: Record a log from the moment Gazebo is opened until it is closed.
--record_encoding arg: Compression encoding format for log data. The options are zlib (default), bz2 and txt.
The log file will only be terminated when Gazebo is closed. You can check the file was created by looking into the path given:
$ ls ~/logs/random_velocity/ state.log
Logging part of the simulation
Gazebo also provides the gz log tool, which can be used to trigger logging at any moment. While Gazebo is running, open another terminal and run the following to start recording:
gz log -d 1 And to stop:
gz log -d 0
Check out gz log --help for other options.
Play back a log file
Once you have a log file, you can replay it visually or introspect it in several ways.
Visualize in GUI
Currently, it is not possible to open a log file from the GUI, so playback must be started from the command line. Simply start Gazebo using the -p option to specify a log file, such as the one we recorded earlier:
gazebo -u -p ~/logs/double_pendulum/2016-01-25T15\\:09\\:49.677400/gzserver/state.log Tip: The -u option starts the log paused.
Gazebo will open in playback mode. You can play, pause, rewind and step through the playback.