Gazebo机器人仿真学习探索笔记二基本使用说明.docx
《Gazebo机器人仿真学习探索笔记二基本使用说明.docx》由会员分享,可在线阅读,更多相关《Gazebo机器人仿真学习探索笔记二基本使用说明.docx(17页珍藏版)》请在冰豆网上搜索。
![Gazebo机器人仿真学习探索笔记二基本使用说明.docx](https://file1.bdocx.com/fileroot1/2022-11/29/0d4abf8e-47d2-4131-a9ac-e72650e0281a/0d4abf8e-47d2-4131-a9ac-e72650e0281a1.gif)
Gazebo机器人仿真学习探索笔记二基本使用说明
Gazebo機器人仿真學習探索筆記
(二)基本使用說明
在完成Gazebo7安裝後,需要熟悉Gazebo,方便之後使用。
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
~$gazebo
Gazebo7自帶了很多構建好的環境模型,可以直接使用,這些模型位置和安裝路徑相關:
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
relaybot@relaybot-desktop:
~$ls/usr/share/gazebo-7/worlds/
actor.worldpioneer2dx.world
blank.worldplane_demo.world
camera.worldplugin.world
cart_demo.worldpolyline.world
cessna_demo.worldpopulation.world
contact.worldpr2.world
depth_camera.worldpresentation.world
elevator.worldpressure_sensor.world
empty_1_0.worldprojector.world
empty_bullet.worldquad_rotor_demo_2.world
empty_sky.worldquad_rotor_demo.world
empty.worldrandom_velocity.world
everything.worldray_cpu.world
flocking.worldray_noise_plugin.world
force_torque_demo.worldroad_textures.world
friction_demo.worldroad.world
gripper.worldrobocup09_spl_field.world
heightmap_dem.worldrobocup14_spl_field.world
heightmap.worldrobocup_3Dsim.world
hydra_demo.worldrubble.world
imu_demo.worldseesaw.world
initial_velocity.worldshapes_bitmask.world
joint_damping_demo.worldshapes_layers.world
joint_friction_demo.worldshapes.world
joints.worldsim_events.world
lift_drag_demo.worldsimple_arm.world
lights.worldsimple_gripper.world
linear_battery_demo.worldsingle_rotor_demo.world
logical_camera.worldsonar_demo.world
magnetometer.worldsphere_atlas_demo.world
mud_bitmask.worldstacks.world
mud.worldtimer_gui.world
multilink_shape.worldtorsional_friction_demo.world
nested_model.worldtransporter.world
openal.worldtrigger.world
ortho.worldtwin_rotor_demo.world
osrf_elevator.worldunderwater.world
pioneer2dx_camera.worldwillowgarage.world
pioneer2dx_laser_camera.worldwireless_sensors.world
pioneer2dx_laser.world
在ubuntu下默認的路徑爲:
/usr/share/gazebo-7/worlds/。
啓動一個示例,如下:
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
/usr/share/gazebo-7/worlds$gazebolift_drag_demo.world
啓動一個帶有天空的環境:
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
/usr/share/gazebo-7/worlds$gazeboempty_sky.world
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
xmlversion="1.0"?
>
12
--Agloballightsource-->
model:
//sun
--Agroundplane-->
model:
//ground_plane
注意這個環境中,天空中只有雲彩速度爲12,場景中還有光源和大地。
啓動一個帶有機器人模型的環境:
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
/usr/share/gazebo-7/worlds$gazebopioneer2dx_laser_camera.world
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
xmlversion="1.0"?
>
--Ground-->
model:
//ground_plane
--Agloballightsource-->
model:
//sun
--Pioneer2dxmodel-->
model:
//pioneer2dx
model:
//hokuyo
0.20.38000
model:
//camera
0.20.3000
pioneer2dx:
:
pioneer2dx:
:
chassis
pioneer2dx:
:
camera:
:
link
001
0
0
pioneer2dx:
:
pioneer2dx:
:
chassis
pioneer2dx:
:
hokuyo:
:
link
001
0
0
參考上述模板,可以學習環境文件,主要由大地,光源,機器人模型,機器人模型包括本體,激光和攝像頭等具體配置。
除此之外,還有gzserver和gzclient。
gazebo命令实际上运行两个不同的可执行文件。
第一个称为gzserver,第二个称为gzclient。
gzserver可执行程序运行物理更新循环和传感器数据生成。
这是Gazebo的核心,可以独立于图形界面使用。
您可能会在论坛中看到“runheadless”这个短语。
这个短语相当于只运行gzserver。
一个示例用例将涉及在不需要用户界面的云计算机上运行gzserver。
gzclient可执行文件运行基于QT的用户界面。
此应用程序提供了一个很好的可视化的模拟,并在各种模拟属性方便的控制。
當然,這兩個可以分別啓動。
gazebo使用的快捷鍵:
ActionOperationInstruction
MODE
EnterSelectionmode(defaultmode)EscpressEscformodetoselectmodelsandright-clickforcontextmenu
EnterRotatemoderpress"r"forRotate(model)mode
EnterTranslatemodetpress"t"forTranslate(model)mode
EnterScalemodespress"s"forScale(model)mode
EnterSnapmodenpress"n"forSnap(model)mode
MODELS
DeletemodelDeletepressDeletewhenamodelisselectedtodeletefromscene
CopymodelCtrl+cpressCtrl+"c"whenmodelisselectedtocopy
PastemodelCtrl+vpressCtrl+"v"topastecopiedmodel
MANIPULATINGMODELS
Rotatemodelrpress"r"forRotatemode;clickmodel&rotateusingmarkers
Translatemodeltpress"t"forTranslatemode;clickmodel&translateusingmarkers
Scalemodelspress"s"forScalemode;clickmodel&scaleusingmarkers
Constrainalongaxisx/y/zholdkeywhilemanipulatingmodeltoconstrainmovementalongthataxis
Snapto45°whenrotatingCtrl+dragholdCtrlwhilerotatingmodeltorotatein45°increments
SnaptogridwhentranslatingCtrl+dragholdCtrlwhiletranslatingmodeltosnaptogrid
Snapto1mwhenscalingCtrl+dragholdCtrlwhilescalingmodetoscalein1mincrements
SnapwheninsertingCtrl+dragholdCtrlwhileinsertingmodeltoenablesnaptogrid
Snapmodelstogethernpress"n"forSnapmode;clickonelink,thenasecondtosnapfirstlinktosecond
GUILAYOUT
HidetoolbarsCtrl+hhide/showtoptoolbarandbottomtimepanel
EnterfullscreenF11enter/exitfullscreen
ActionOperationInstruction
EDITORS
OpenModelEditorCtrl+mopenModelEditortoconstructoreditmodels
OpenSchematicView(ModelEditor)Ctrl+eopenSchematicViewinModelEditor
OpenBuildingEditorCtrl+bopenBuildingEditortoconstructbuildings
Showfloorplan(BuildingEditor)fshow/hidefloorplaninBuildingEditor2DView
Showbuildingfeatures(BuildingEditor)gshow/hidebuildingfeaturesinBuildingEditor2DView
Newcanvas(bothEditors)Ctrl+ncreatenewcanvas
Savemodel(bothEditors)Ctrl+ssavemodelforlateruse
Saveas(bothEditors)Ctrl+Shift+ssavemodelforlateruse&giveitaname
Exit(bothEditors)Ctrl+xexitEditor
WORLD
SaveworldCtrl+spressCtrl+"s"tosaveworldforlateruse
SaveasCtrl+Shift+spressCtrl+Shift+"s"tosaveworldforlateruse&giveitaname
ResetworldCtrl+rpressCtrl+"r"toresetworldtoitsoriginalstate
ResetmodelposesCtrl+Shift+rpressCtrl+Shift+"r"toresetmodelstotheiroriginalposes
DATA
VisualizetopicsCtrl+topendialogwithlistoftopicscurrentlyadvertized
LogdataCtrl+dopendialogtorecordlogfiles
MISCELLANEOUS
QuitGazeboCtrl+qpressCtrl+"q"toquitGazebo
注意這裏gazebo並不能與ROS通訊,如果需要可以使用下面命令:
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
rosrungazebo_rosgazebo
rosrungazebo_rosgzserver
rosrungazebo_rosgzclient
rosrungazebo_rosspawn_model
rosrungazebo_rosperf
rosrungazebo_rosdebug
啓動後可以看到:
[html]viewplaincopyprint?
在CODE上查看代码片派生到我的代码片
~$rostopiclist
/clock
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/rosout
/rosout_agg
具體在之後筆記中再補充。
附件:
官網教程。
RunGazebo
ThesethreestepswillrunGazebowithadefaultworld.
InstallGazebo.
Openaterminal.OnmostUbuntusystemsyoucanpressCTRL+ALT+t
StartGazebobyenteringthefollowingatthecommandprompt.
gazebo
RunGazebowitharobot
Let'ssimulatesomethingabitmoreinterestingbyloadingaworldwithapioneer2dx.
Openaterminalandenterthefollowingcommand.
gazeboworlds/pioneer2dx.world
Wherearetheworldslocated?
Youmayhavenoticedthemysteriousworlds/pioneer2dx.world
argumentintheabovecommand.Thisinstructsgazebotofindthepioneer2dx.worldfile,andloaditonstart.
Worldfilesarelocatedinaversionedsystemdirectory,forexample/usr/share/gazebo-7
onUbuntu.IfyouhaveGazebo7.0installedonUbuntu,inaterminaltypethefollowingtoseeacompletelistofworlds.
ls/usr/share/gazebo-7/worlds
ForaGazebo7.0installationonOSXusingHomebrew,typethefollowingtoseeacompletelistofworlds.
ls/usr/local/share/gazebo-7/worlds
Clientandserverseparation
Thegazebo
commandactuallyrunstwodifferentexecutablesforyou.Thefirstiscalledgzserver,andthesecondgzclient.
Thegzserver
executablerunsthephysicsupdate-loopandsensordatageneration.ThisisthecoreofGazebo,andcanbeusedindependentlyofagraphicalinterface.Youmayseethephrase"runheadless"thrownaboutintheforums.Thisphraseequatestorunningonlythegzserver.Anexampleusecasewouldinvolverunninggzserveronacloudcomputerwhereauserinterfaceisnotneeded.
Thegzclient
executablerunsaQTbaseduserinterface.Thisapplicationprovidesanicevisualizationofsimulation,nvenientcontrolsovervarioussimulationproperties.
Tryrunningeachoftheseexecutables.Openaterminalandruntheserver:
gzserver
Openanotherterminalandrunthegraphicalclient:
gzclient
AtthispointyoushouldseetheGazebouserinterface.Yourestartthegzclient
applicationasoftenasyouwant,andevenrunmultipleinterfaces.
ThispagedescribeseachoftheitemsinvolvedinrunningaGazebosimulation.
WorldFiles
Theworlddescriptionfilecontainsalltheelementsinasimulation,includingrobots,lights,sensors,andstaticobjects.ThisfileisformattedusingSDF(SimulationDescriptionFormat),andtypicallyhasa.world
extension.
TheGazeboserver(gzserver
)readsthisfiletogenerateandpo