1、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 tutori
2、al we will record a few log files and then take a peek inside them at the end.Record a logLogging from the GUIStart 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
3、 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
4、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 si
5、mulation.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 lineFrom the command line, it is possible to log the whole simulation from the moment Gazebo starts
6、running until it stops, or to trigger logging from an arbitary time.Logging the whole simulationAs an example, you can record the random_velocity.world as follows:gazebo -r -record_path /logs/random_velocity worlds/random_velocity.worldYou can see a list of all of the available logging options by ru
7、nning 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 c
8、an check the file was created by looking into the path given:$ ls /logs/random_velocity/state.logLogging part of the simulationGazebo 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 recor
9、ding:gz log -d 1And to stop:gz log -d 0Check out gz log -help for other options.Play back a log fileOnce you have a log file, you can replay it visually or introspect it in several ways.Visualize in GUICurrently, it is not possible to open a log file from the GUI, so playback must be started from th
10、e 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 The -u option starts the log paused.Gazebo will open in playback mode. You can play, pause, rewind and s
11、tep through the playback.Use Play / Pause to stop the playback.Use Rewind / Forward to skip to the beginning / end of the file.Use Step back / Step forward to skip samples. The number of samples skipped each time you press a step button can be changed in the box below. Samples might be any number of
12、 iterations and seconds apart.Drag the current time marker and drop it to skip through the log.Input a current time on the right to skip to that sample.Command line toolsAs mentioned above, the gz log tool provides several options for introspecting your log file. Check out this tutorial for log filt
13、ering, for example.Here, lets quickly go over how you would take a look at the recorded states.Well use -s to step through a recorded file, like this:gz log -s -f /logs/double_pendulum/2016-01-25T15:Youll see the full initial SDF representation of the world, something like this:gazebo_logheaderlog_v
14、ersion1.0gazebo_version7.0.0pre1rand_seed10622214log_start43 380000000log_end69 651000000/headerchunk encoding=txt!CDATAsdf version =1.6world name=default (.) model name=ground_plane/modeldouble_pendulum_with_base/world/sdf/chunk- Press space to continue, q to quit -As you press space, you will step
15、 through the subsequent states. Youll note that the states are more compact and only contain information about what has changed in the world. Heres an example of a state:sdf version=state world_name=sim_time/sim_timereal_time43 478499228wall_time1453763389 677873530iterations43380pose1.140 -1.074 -0
16、.000 0.000 -0.000 0.000 scale1.000 1.000 1.000link name=base1.13998 -1.07367 -0.00000 0.00000 0.00000 -0.00042 -0.0000 0.0000 -0.0005 0.0004 0.0030 0.0001 /linklower_link1.38969 -1.79815 1.41059 -2.45351 0.00000 -0.00042 0.0042 -0.2557 0.2659 1.9694 0.0048 0.0001 upper_link1.13999 -1.07367 2.10000 2
17、.33144 -0.00000 -0.00042 0.0063 -0.0008 -0.0005 -0.3739 0.0032 0.0001 0.000 0.000 0.000 0.000 -0.000 0.000 link0.00000 0.00000 0.00000 0.00000 -0.00000 0.00000 0.0000 0.0000 0.0000 0.0000 -0.0000 0.0000 Note that theres no information for the sun or the ground_plane, since they are not moving.Log fi
18、lteringIntroductionState logs are recordings of world state information from Gazebo. State includes pose, velocity, acceleration, and forces applied to all links of all models. Gazebo will only record state information for models that change over time. A state log file contains a header, the initial
19、 world description, and a time series of state.Gazebo Log Command line toolGazebo ships with a logging utility that is accessed via the gz log command.View the help information using:gz help logorgz log -hExample Usage Check out the tutorial on logging and playback for an overview of ways to record
20、a log.Step 1: Create a state log fileStart by removing old log filesrm -rf /.gazebo/log/*We will use the PR2 world to create a state log file.Start by running the Gazebo server with the -r command line optiongzserver -r worlds/pr2.worldAfter a few seconds, stop the server using ctrl-c.A new time sta
21、mped directory should exist in /.gazebo/log with one subdirectory and a state.log file. Here is an example/.gazebo/log/2013-07-25T07:29:05.122275/gzserver/state.logYou can verify this log file by replaying it in Gazebo.gazebo -p /.gazebo/log/*/gzserver/state.logStep 2: Filter a state log fileThe gz
22、log command line tool provides mechanisms for stepping through a log file and echoing the contents of a log file to screen. The echo to screen feature can be combined with a filter to produce a log file that contains specific information such as just the pose of models and links.Try echoing the reco
23、rded state log file to screen.gz log -e -f /.gazebo/log/*/gzserver/state.logYou should see a lot of information scroll by.Now lets remove all velocity, acceleration, and force information from the log file. This will leave just pose information.gz log -e -f /.gazebo/log/*/gzserver/state.log -filter
24、*.pose/*.poseThe -filter option is a flexible command line argument to extract information from a log file.It is also possible to filter based on simulation time using a Hz filter. For example, we can output state information at 30 Hz using:gz log -e -f /.gazebo/log/*/gzserver/state.log -z 30These f
25、ilters can be combined and piped to a file for playback. This may take some time depending on the size of the state.log.gz log -e -f /.gazebo/log/*/gzserver/state.log -z 30 -filter *.pose/*.pose /tmp/filtered_state.logThis log file can then be replayed in Gazebogazebo -p /tmp/filtered_state.logApply
26、ing Force/TorqueThis tutorial will explain how to apply force and/or torque to models during simulation using the graphical user interface.Applying force and torque examplesLets go through an example of applying force and torque to simple models. Open Gazebo and from the insert tab, insert a Simple Arm into the scene. Then, from the top toolbar, insert a box. Make sure the simulation is not paused.Apply force to a linkWe want to
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1