Gazebo机器人仿真学习探索笔记六工具和实用程序.docx
- 文档编号:5726725
- 上传时间:2022-12-31
- 格式:DOCX
- 页数:12
- 大小:532.97KB
Gazebo机器人仿真学习探索笔记六工具和实用程序.docx
《Gazebo机器人仿真学习探索笔记六工具和实用程序.docx》由会员分享,可在线阅读,更多相关《Gazebo机器人仿真学习探索笔记六工具和实用程序.docx(12页珍藏版)》请在冰豆网上搜索。
Gazebo机器人仿真学习探索笔记六工具和实用程序
Gazebo機器人仿真學習探索筆記(六)工具和实用程序
Gazebo附带了许多工具和实用程序。
这些教程说明了这些可用的工具,以及如何使用它们。
主要有:
1记录和播放
2日志过滤
3应用力/扭矩
4HDF5数据集
官网介绍通俗具体,非常容易,请参考附件。
附件--官方教程
Loggingandplayback
Overview
ThistutorialexplainshowtousetheGazebologgingcapabilitiestorecordyoursimulationandthenreproduceitafterwards,usingeithertheGUIorthecommandline.
Gazebologfiles
Gazebologfilesarecompressed.logfileswhichcontainaninitialfulldescriptionofthewholeworld,followedbyaseriesof"worldstates".
Theinitialdescriptioncontainscompleteinformationabouteverythingintheworld,fromthescenetotheentitiespresent.
Afterthat,everytimesomethingchangesinsimulation,anewworldstateisrecorded.Worldstatesaremuchsimpler,astheyonlycontaininformationaboutwhatchanged,suchas:
Simulationstatisticssuchasthecurrentsimulationtimeandthenumberofphysicsiterations.
Currentstateofeachmodelinthescene,aswellasthestateofeachlinkandjointinthemodel.Thisincludesinformationsuchasinstantaneouspose,velocity,accelerationandforces.
Currentposeofeachlightintheworld.
Tip:
Youcanfindthewholespecfortheworldstatehere.
Inthistutorialwewillrecordafewlogfilesandthentakeapeekinsidethemattheend.
Recordalog
LoggingfromtheGUI
Startyoursimulation.Here,asanexample,wehaveasimpleworldwithadoublependulum.
Clickontheloggingicononthetopright,orhitCtrl+DtobringuptheDataLogger.
YoucanchoosethedirectorywhereyourlogfilewillbesavedbyclickingtheBrowsebutton.Bydefault,logfilesGotothe~/.gazebo/logdirectory.Inthisexample,wewillsaveitinthe~/logs/double_pendulum/directory.
Clickontheredbuttontostartrecording.Youshouldseethenumberofbytesinyourlogfileincreasingontheright.
Note:
Forefficiency,onlymodelsandlightswhichmoveovertimearelogged.Ifyoursceneisstatic,thenumberofbytesinyourlogfilewillnotincrease.Thisalsomeansthatthenumberofsamplesinyourlogfilemaybedifferentfromthenumberofiterationsinsimulation.
Clickontheredbuttonagaintostoplogging.
ExpandRecordingstoseethepathtothestate.logfilewhichwasgenerated.Itwillbeinsideatime-stampeddirectory.
Loggingfromthecommandline
Fromthecommandline,itispossibletologthewholesimulationfromthemomentGazebostartsrunninguntilitstops,ortotriggerloggingfromanarbitarytime.
Loggingthewholesimulation
Asanexample,youcanrecordtherandom_velocity.worldasfollows:
gazebo-r--record_path~/logs/random_velocityworlds/random_velocity.world
Youcanseealistofalloftheavailableloggingoptionsbyrunninggazebo--help.
-p[--play]arg:
Playalogfile.
-r[--record]:
RecordalogfromthemomentGazeboisopeneduntilitisclosed.
--record_encodingarg:
Compressionencodingformatforlogdata.Theoptionsarezlib(default),bz2andtxt.
ThelogfilewillonlybeterminatedwhenGazeboisclosed.Youcancheckthefilewascreatedbylookingintothepathgiven:
$ls~/logs/random_velocity/
state.log
Loggingpartofthesimulation
Gazeboalsoprovidesthegzlogtool,whichcanbeusedtotriggerloggingatanymoment.WhileGazeboisrunning,openanotherterminalandrunthefollowingtostartrecording:
gzlog-d1
Andtostop:
gzlog-d0
Checkoutgzlog--helpforotheroptions.
Playbackalogfile
Onceyouhavealogfile,youcanreplayitvisuallyorintrospectitinseveralways.
VisualizeinGUI
Currently,itisnotpossibletoopenalogfilefromtheGUI,soplaybackmustbestartedfromthecommandline.SimplystartGazebousingthe-poptiontospecifyalogfile,suchastheonewerecordedearlier:
gazebo-u-p~/logs/double_pendulum/2016-01-25T15\:
09\:
49.677400/gzserver/state.log
Tip:
The-uoptionstartsthelogpaused.
Gazebowillopeninplaybackmode.Youcanplay,pause,rewindandstepthroughtheplayback.
UsePlay/Pausetostoptheplayback.
UseRewind/Forwardtoskiptothebeginning/endofthefile.
UseStepback/Stepforwardtoskipsamples.Thenumberofsamplesskippedeachtimeyoupressastepbuttoncanbechangedintheboxbelow.Samplesmightbeanynumberofiterationsandsecondsapart.
Dragthecurrenttimemarkeranddropittoskipthroughthelog.
Inputacurrenttimeontherighttoskiptothatsample.
Commandlinetools
Asmentionedabove,thegzlogtoolprovidesseveraloptionsforintrospectingyourlogfile.Checkoutthistutorialforlogfiltering,forexample.
Here,let'squicklygooverhowyouwouldtakealookattherecordedstates.
We'lluse-stostepthrougharecordedfile,likethis:
gzlog-s-f~/logs/double_pendulum/2016-01-25T15\:
09\:
49.677400/gzserver/state.log
You'llseethefullinitialSDFrepresentationoftheworld,somethinglikethis:
xmlversion='1.0'?
>
[CDATA[ (...) (...) (...) (...) ]]> ---Pressspacetocontinue,'q'toquit--- Asyoupressspace,youwillstepthroughthesubsequentstates.You'llnotethatthestatesaremorecompactandonlycontaininformationaboutwhathaschangedintheworld.Here'sanexampleofastate: [CDATA[ ]]> ---Pressspacetocontinue,'q'toquit--- Notethatthere'snoinformationforthesunortheground_plane,sincetheyarenotmoving. Logfiltering Introduction StatelogsarerecordingsofworldstateinformationfromGazebo.Stateincludespose,velocity,acceleration,andforcesappliedtoalllinksofallmodels.Gazebowillonlyrecordstateinformationformodelsthatchangeovertime.Astatelogfilecontainsaheader,theinitialworlddescription,andatimeseriesofstate. GazeboLogCommandlinetool Gazeboshipswithaloggingutilitythatisaccessedviathegzlogcommand. Viewthehelpinformationusing: gzhelplog or gzlog-h ExampleUsage Tip: Checkoutthetutorialonloggingandplaybackforanoverviewofwaystorecordalog. Step1: Createastatelogfile Startbyremovingoldlogfiles rm-rf~/.gazebo/log/* WewillusethePR2worldtocreateastatelogfile. StartbyrunningtheGazeboserverwiththe-rcommandlineoption gzserver-rworlds/pr2.world Afterafewseconds,stoptheserverusingctrl-c. Anewtimestampeddirectoryshouldexistin~/.gazebo/logwithonesubdirectoryandastate.logfile.Hereisanexample ~/.gazebo/log/2013-07-25T07\: 29\: 05.122275/gzserver/state.log YoucanverifythislogfilebyreplayingitinGazebo. gazebo-p~/.gazebo/log/*/gzserver/state.log Step2: Filterastatelogfile Thegzlogcommandlinetoolprovidesmechanismsforsteppingthroughalogfileandechoingthecontentsofalogfiletoscreen.Theechotoscreenfeaturecanbecombinedwithafiltertoproducealogfilethatcontainsspecificinformationsuchasjusttheposeofmodelsandlinks. Tryechoingtherecordedstatelogfiletoscreen. gzlog-e-f~/.gazebo/log/*/gzserver/state.log Youshouldseealotofinformationscrollby. Nowlet'sremoveallvelocity,acceleration,andforceinformationfromthelogfile.Thiswillleavejustposeinformation. gzlog-e-f~/.gazebo/log/*/gzserver/state.log--filter*.pose/*.pose The--filteroptionisaflexiblecommandlineargumenttoextractinformationfromalogfile. ItisalsopossibletofilterbasedonsimulationtimeusingaHzfilter.Forexample,wecanoutputstateinformationat30Hzusing: gzlog-e-f~/.gazebo/log/*/gzserver/state.log-z30 Thesefilterscanbecombinedandpipedtoafileforplayback.Thismaytakesometimedependingonthesizeofthestate.log. gzlog-e-f~/.gazebo/log/*/gzserver/state.log-z30--filter*.pose/*.pose>/tmp/filtered_state.log ThislogfilecanthenbereplayedinGazebo gazebo-p/tmp/filtered_state.log ApplyingForce/Torque Introduction Thistutorialwillexplainhowtoapplyforceand/ortorquetomodelsduringsimulationusingthegraphicaluserinterface. Applyingforceandtorqueexamples Let'sgothroughanexampleofapplyingforceandtorquetosimplemodels.OpenGazeboandfromtheinserttab,insertaSimpleArmintothescene.Then,fromthetoptoolbar,insertabox.Makesurethesimulationisnotpaused. Applyforcetoalink Wewantto
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Gazebo 机器人 仿真 学习 探索 笔记 工具 实用程序
![提示](https://static.bdocx.com/images/bang_tan.gif)