Logging and playback - modulabs/gazebo-tutorial GitHub Wiki

Overview

์ด ์ง€์นจ์„œ๋Š” GUI ๋˜๋Š” ๋ช…๋ ์–ด ๋ผ์ธ์„ ์ด์šฉํ•˜์—ฌ ๋‹น์‹ ์˜ ์‹œ๋ฌผ๋ ˆ์ด์…˜์„ ๊ธฐ๋กํ•˜๊ณ , ์ดํ›„์— ๋‹ค์‹œ ์ œ๊ณตํ•˜๋Š” ๊ฐ€์ œ๋ณด์˜ ๋กœ๊น…๋Šฅ๋ ฅ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ™์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

Gazebo log files

๊ฐ€์ œ๋ณด ๋กœ๊ทธํ™”์ผ์€ ์••์ถ•๋œ .logํ™”์ผ ์ž…๋‹ˆ๋‹ค. ๊ทธํ™”์ผ์€ "world states"์‹œ๋ฆฌ์ฆˆ์— ์˜ํ•ด follow๋˜๊ณ ์žˆ๋Š” "whole world"์˜ ์ดˆ๊ธฐํ™”๋œ ์ „์ฒด ์„ค๋ช…์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

์ดˆ๊ธฐ์„ค๋ช…์€ scene ์—์„œ๋ถ€ํ„ฐ entities present ๊นŒ์ง€ world์•ˆ์˜ ๋ชจ๋“ ๊ฒƒ๋“ค์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค

๊ทธ์ดํ›„ , ๋งค๋ฒˆ ์‹œ๋ฌผ๋ ˆ์ด์…˜์—์„œ ๋ฐ”๊พธ๊ณ ,์ƒˆ๋กœ์šดworld ์ƒํƒœ๋Š” ๊ธฐ๋ก์ด ๋ฉ๋‹ˆ๋‹ค. ๋ฐ”๋€๋ถ€๋ถ„์— ๋Œ€ํ•œ ์ •๋ณด๋งŒ์„ ํฌํ•จํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์•„๋ž˜์•„ ๊ฐ™์ด world states๋Š” ์ข€๋” ๊ฐ„๋‹จํ•ด ์ง‘๋‹ˆ๋‹ค.

"the current simulation time and the number of physics iterations"๊ณผ ๊ฐ™์€ ์‹œ๋ฌผ๋ ˆ์ด์…˜ ํ†ต๊ณ„ ์ˆ˜์น˜ scene์—์„œ ๊ฐ๋ชจ๋ธ์˜ ํ˜„์ƒํƒœ,๋ชจ๋ธ์—์„œ joint ,link ์ƒํƒœ.์ด๊ฒƒ์€ ์ฆ‰๊ฐ์ ์ธ pose์™€ ๊ฐ™์€ ์ •๋ณด๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค. world์—์„œ ๊ฐ loght ์˜ ํ˜„์žฌpose

Tip: ๋‹น์‹ ์€ ์—ฌ๊ธฐ์„œ world์˜ ์ „์ฒด spec์„ ๋ฐœ๊ฒฌํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ์ง€์ง์„œ๋Š” ๋ช‡๊ฐ€์ง€ logํ™”์ผ์„ ๊ธฐ๋กํ• ๊ฒ๋‹ˆ๋‹ค, ๊ทธ๋ฆฌ๊ณ  ๋„ใ…Œ์— ๊ทธ๋“ค์•ˆ์˜ peek๋ฅผ ์ทจํ• ๊ฒƒ์ž…๋‹ˆ๋‹ค.

log ๊ธฐ๋ก

GUIํ™˜๊ฒฝ์—์„œ Logging ํ•˜๊ธฐ

  1. ๋‹น์‹ ์˜ ์‹œ๋ฌผ๋ ˆ์ด์…˜์„ ์‹œ์ž‘ํ•˜์„ธ์š” . ์—ฌ๊ธฐ ์˜ˆ์ œ์™€ ๊ฐ™์ด, ์šฐ๋ฆฌ๋Š” ๋ณต์ง„์ž๋ฅผ ๊ฐ€์ง„ ๋‹จ์ˆœํ•œ world ๋ฅผ ๊ฐ–๊ณ ์žˆ์Šต๋‹ˆ๋‹ค

  2. ์šฐ์ธก์ƒ๋‹จ์˜ logging icon ์„ ํด๋ฆญํ•˜์„ธ์š”, ๋˜๋Š” ๋ฐ์ดํ„ฐ ๋กœ๊ฑฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ ์œ„ํ•ด Ctrl+D๋ฅผ ์น˜์„ธ์š”

  3. ๋‹น์‹ ์€ ๋ธŒ๋กœ์šฐ์ ธ ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์„œ, ๋‹น์‹ ์˜ ๋กœ๊ทธํ™”์ผ์ด ์ €์žฅ๋  ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์„ ํƒํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋””ํดํŠธ๋กœ ๋กœ๊ทธํ™”์ผ์€ "~/.gazebo/log directory"์— ์ €์žฅ์ด ๋ฉ๋‹ˆ๋‹ค. ์ด ์˜ˆ์ œ์—์„œ, ์šฐ๋ฆฌ๋Š” ๊ทธ๊ฒƒ์„ ~/logs/double_pendulum/ ๋””๋ ‰ํ† ๋ฆฌ์— ์ €์žฅ์„ ํ• ๊ฒƒ์ž…๋‹ˆ๋‹ค.

  4. ์‹œ์ž‘์„ ์œ„ํ•ด ๋นจ๊ฐ„ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ์˜ค๋ฅธ์ชฝ์— ์ฆ๊ฐ€ํ•˜๊ณ  ์žˆ๋Š” ๋กœ๊ทธํ™”์ผ์˜ ๋ฐ”์ดํŠธ์ˆ˜๋ฅผ ๋ณด์•„์•ผ๋งŒ ํ•ฉ๋‹ˆ๋‹ค. 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.

  5. ์ค‘๋‹จ์„ ํ•˜๊ธฐ์œ„ํ•ด์„œ ๋‹ค์‹œ ์ ์ƒ‰๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

  6. ์ƒ์„ฑ๋œ ๋กœ๊ทธํ™”์ผ์„ ํŒจ๋ฅผ ๋ณด๊ธฐ์œ„ํ•ด ๊ธฐ๋ก์„ expend ํ•˜์„ธ์š”, ๊ทธ๊ฒƒ์€ ํƒ€์ž„์Šคํƒฌํ”„ ๋””๋ ‰ํ† ๋ฆฌ์— ์žˆ์„๊ฒ๋‹ˆ๋‹ค.

command line ํ™˜๊ฒฝ์—์„œ Logging ํ•˜๊ธฐ

์ปค๋ฉ˜๋“œ ๋ผ์ธ์œผ๋กœ๋ถ€ํ„ฐ, ๊ฐ€์ œ๋ณด์‹คํ–‰๋ถ€ํ„ฐ ๋๋‚ ๋•Œ๊นŒ์ง€ ๋ชจ๋“  ์‹œ๋ฌผ๋ ˆ์ด์…˜์„ ๋กœ๊ทธํ•˜๋Š”๊ฒƒ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. or to trigger logging from an arbitary time.

์ „์ฒด ์‹œ๋ฌผ๋ ˆ์ด์…˜ Logging ํ•˜๊ธฐ

์˜ˆ์ œ์™€ ๊ฐ™์ด , ๋‹น์‹ ์€ random_velocity.world์„ ๊ธฐ๋กํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ gazebo -r --record_path ~/logs/random_velocity worlds/random_velocity.world

๋‹น์‹ ์€ ๊ฐ€์ œ๋ณด ์‹คํ–‰ --help ์‹คํ–‰ํ•จ์œผ๋กœ์จ, ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ๋กœ๊น…์˜ต์…˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณผ์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค.

-p [--play] arg: Play a log file.

-r [ --record ]: ๊ฐ€์ œ๋ณด๊ฐ€ ์‹œ์ž‘๋˜๋Š” ์ˆœ๊ฐ„๋ถ€ํ„ฐ ๋๋‚ ๋•Œ ๊นŒ์ง€ ๊ธฐ๋กํ•˜๊ธฐ

--record_encoding arg: ๋ฐ์ดํ„ฐ ๋กœ๊ทธ๋ฅผ ์œ„ํ•œ ์••์ถ• ์ธ์ฝ”๋”ฉ ํฌ๋งท์€ ๋””ํดํŠธ๋Š” zlib์ด๋ฉฐ, bz2,txt๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค ๋กœ๊ทธํ™”์ผ์€ ๊ฐ€์ œ๋ณด๊ฐ€ ์ข…๋ฃŒ๋ ๋•Œ ๋๋‚ฉ๋‹ˆ๋‹ค. ๋‹น์‹ ์€ ์ฃผ์–ด์ง„ ํŒจ์Šค๋ฅผ ๋ณด๋ฉด ํ™”์ผ์ด ์ƒ์„ฑ๋˜์–ด์žˆ์Œ์„ ํ™•์ธํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. given:

$ ls ~/logs/random_velocity/
state.log

์‹œ๋ฌผ๋ ˆ์ด์…˜์˜ ๋กœ๊น…part

๊ฐ€๊ฐ€์ œ๋ณด๋Š” ๋˜ํ•œ gz ๋กœ๊ทธ ํˆด์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ์€ ๊ฐ€์ œ๋ณด๊ฐ€ ์‹คํ–‰์ค‘์ธ ์ƒํƒœ์—์„œ ์–ด๋–ค ์ˆœ๊ฐ„์— ๋กœ๊น…์‹œ์ž‘์„ ํ• ๋•Œ ์‚ฌ์šฉ๋ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํ„ฐ๋ฏธ๋„์„ ์‹คํ–‰ํ•˜๊ณ , ๊ธฐ๋ก์„ ์‹œ์ž‘ํ•˜๊ธฐ ์œ„ํ•ด ์•„๋ž˜ ๋‚ด์šฉ์„ ๋”ฐ๋ผ ํ•˜์„ธ์š” :

$ gz log -d 1

And to stop:

$ gz log -d 0

Check out gz log --help for other options.

Play back a log file

๋‹น์‹ ์ด ๋กœ๊ทธํ™”์ผ์„ ๊ฐ€์ง€๊ฒŒ ๋˜๋ฉด, ๋‹น์‹ฑ์€ ๊ทธใ„ฑ์„œ์„ ๋น„์ฃผ์–ผํ•˜๊ฒŒ ์žฌ์ƒํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜๋Š” ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ๊ทธ๊ฒƒ์„ introspectํ• ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

Visualize in GUI

ํ˜„์žฌ,GUI๋กœ ๋ถ€ํ„ฐ ๋กœ๊ทธํ™”์ผ์„ ์—ฌ๋Š”๊ฒƒ์€ ๊ฐ€๋Šฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค, ๊ทธ๋ž˜์„œ playback ์€ ์ปค๋งจ๋“œ๋ผ์ธ์œผ๋กœ ๋ถ€ํ„ฐ ์‹œ์ž‘์„ ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. 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.

๊ฐ€์ œ๋ณด๋Š” playback mode์—์„œ ์—ด๊ฒ๋‹ˆ๋‹ค. ๋‹น์‹  play, ๋ฉˆ์ถค๋“ฑ์„ ํ• ์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค

. 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 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 tools

์œ„์— ์–ธ๊ธ‰ํ•œ๋ฐ”์™€ ๊ฐ™์ด ,gzํˆดํˆด์€ ๋‹น์‹ ์˜ ๋กœ๊ทธํ™”์ผ์„ introspecting ๋ฅผ ์œ„ํ•ด ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์˜ต์…˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋กœ๊ทธ ํ•„ํ„ฐ๋ง์„ ์œ„ํ•ด์„œ ์ด ์ง€์นจ์„œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”, ์˜ˆ๋ฅผ ๋“ค๋ฉด

์—ฌ๊ธฐ, ๋‹น์‹ ์ด ์–ด๋–ป๊ฒŒ ์ €์žฅ๋œ ์ƒํƒœ๋ฅผ ๋ณผ์ˆ˜์žˆ๋Š”์ง€ ํ•œ๋ฒˆ ๋ณด์„ธ์š” We'll use -s to step through a recorded file, like this:

$ gz log -s -f ~/logs/double_pendulum/2016-01-25T15\:09\:49.677400/gzserver/state.log

๋‹น์‹ ์€ worldf๋ฅผ ๋Œ€ํ‘œํ•˜๋Š” ์ „์ฒด์ดˆ๊ธฐ sdf๋ฅผ ๋ณผ์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค, ์•„๋ž˜์™€ ๊ฐ™์ด You'll see the full initial SDF representation of the world, something like this:

<?xml version='1.0'?>
<gazebo_log>
<header>
<log_version>1.0</log_version>
<gazebo_version>7.0.0~pre1</gazebo_version>
<rand_seed>10622214</rand_seed>
<log_start>43 380000000</log_start>
<log_end>69 651000000</log_end>
</header>

<chunk encoding='txt'><![CDATA[
<sdf version ='1.6'>
<world name='default'>
  (...)
  <light name='sun' type='directional'>
    (...)
  </light>
  <model name='ground_plane'>
    (...)
  </model>
  <model name='double_pendulum_with_base'>
    (...)
  </model>
</world>
</sdf>]]></chunk>

--- ๋น ์ ธ๋‚˜๊ฐ€๊ธฐ ์œ„ํ•ด์„œ๋Š”  'q' , ๊ณ„์†ํ•˜๊ธฐ ์œ„ํ•ด์„  ์ŠคํŽ˜์ด์Šค๋ฐ”๋ฅผ ๋ˆ„๋ฅด์„ธ์š”

๋‹น์‹ ์€ ์ŠคํŽ˜์ด์Šค๋ฅผ ๋ˆŒ๋ €์„๋•Œ, ๋‹น์‹ ์€ ์Šคํ…๋ณ„๋กœ ๋ณผ์ˆ˜์žˆ๊ณ , ๋‹น์‹ ์€ ์ข€๋” ์ปดํŒฉํŠธํ•˜๊ฒŒ ํ™•์ธ์„ ํ• ์ˆ˜์žˆ์Šต๋‹ˆ๋‹ค ๋‹จ์ง€ world์—์„œ ๋ฐ”๋€๋ถ€๋ถ„์— ๋Œ€ํ•œ ์ •๋ณด๋งŒ์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜๋Š” ์ƒ˜ํ”Œ์ž…๋‹ˆ๋‹ค.

<chunk encoding='txt'><![CDATA[
<sdf version='1.6'>
<state world_name='default'>
<sim_time>43 380000000</sim_time>
<real_time>43 478499228</real_time>
<wall_time>1453763389 677873530</wall_time>
<iterations>43380</iterations>
<model name='double_pendulum_with_base'><pose>1.140 -1.074 -0.000 0.000 -0.000 0.000 </pose><scale>1.000 1.000 1.000</scale><link name='base'><pose>1.13998 -1.07367 -0.00000 0.00000 0.00000 -0.00042 </pose><velocity>-0.0000 0.0000 -0.0005 0.0004 0.0030 0.0001 </velocity></link><link name='lower_link'><pose>1.38969 -1.79815 1.41059 -2.45351 0.00000 -0.00042 </pose><velocity>0.0042 -0.2557 0.2659 1.9694 0.0048 0.0001 </velocity></link><link name='upper_link'><pose>1.13999 -1.07367 2.10000 2.33144 -0.00000 -0.00042 </pose><velocity>0.0063 -0.0008 -0.0005 -0.3739 0.0032 0.0001 </velocity></link></model><model name='ground_plane'><pose>0.000 0.000 0.000 0.000 -0.000 0.000 </pose><scale>1.000 1.000 1.000</scale><link name='link'><pose>0.00000 0.00000 0.00000 0.00000 -0.00000 0.00000 </pose><velocity>0.0000 0.0000 0.0000 0.0000 -0.0000 0.0000 </velocity></link></model></state></sdf>
]]></chunk>

--- Press space to continue, 'q' to quit ---

sun,ground๋Š” ์›€์ง์ž„์ด ์—†๊ธฐ๋•Œ๋ฌธ์— ์–ด๋– ํ•œ ์ •๋ณด๋„ ์—†์Œ์„ ํ™•์ธํ•˜์„ธ์š”

โš ๏ธ **GitHub.com Fallback** โš ๏ธ