Gazebo机器人仿真学习探索笔记二基本使用说明Word文档格式.docx
《Gazebo机器人仿真学习探索笔记二基本使用说明Word文档格式.docx》由会员分享,可在线阅读,更多相关《Gazebo机器人仿真学习探索笔记二基本使用说明Word文档格式.docx(18页珍藏版)》请在冰点文库上搜索。
road.world
robocup09_spl_field.world
robocup14_spl_field.world
robocup_3Dsim.world
rubble.world
initial_velocity.worldjoint_damping_demo.worldjoint_friction_demo.worldjoints.worldlift_drag_demo.worldlights.worldlinear_battery_demo.worldlogical_camera.worldmagnetometer.worldmud_bitmask.worldmud.worldmultilink_shape.worldnested_model.worldopenal.worldortho.worldosrf_elevator.worldpioneer2dx_camera.world
seesaw.world
imu_demo.world
shapes_bitmask.world
shapes_layers.worldshapes.worldsim_events.worldsimple_arm.worldsimple_gripper.worldsingle_rotor_demo.worldsonar_demo.worldsphere_atlas_demo.worldstacks.worldtimer_gui.worldtorsional_friction_demo.worldtransporter.worldtrigger.worldtwin_rotor_demo.worldunderwater.worldwillowgarage.world
wireless_sensors.world
pioneer2dx_laser_camera.worldpioneer2dx_laser.world
在ubuntu下默認的路徑爲:
/usr/share/gazebo-7/worlds/。
啓動一個示例,如下:
在CODE上查看代码片派生到我的代码片/usr/share/gazebo-7/worlds$gazebolift_drag_demo.world
啓動一個帶有天空的環境:
在CODE上查看代码片派生到我的代码片/usr/share/gazebo-7/worlds$gazeboempty_sky.world
在CODE上查看代码片派生到我的代码片<
?
xmlversion="
1.0"
?
>
<
sdfversion="
1.5"
worldname="
default"
scene>
sky>
clouds>
<
speed>
12<
/speed>
/clouds>
/sky>
/scene>
!
--Agloballightsource-->
include>
uri>
model:
//sun<
/uri>
/include>
--Agroundplane-->
//ground_plane<
/world>
/sdf>
注意這個環境中,天空中只有雲彩速度爲12,場景中還有光源和大地。
啓動一個帶有機器人模型的環境:
在CODE上查看代码片派生到我的代码片/usr/share/gazebo-7/worlds$gazebopioneer2dx_laser_camera.world
--Ground-->
--Pioneer2dxmodel-->
modelname="
pioneer2dx"
//pioneer2dx<
//hokuyo<
pose>
0.20.38000<
/pose>
//camera<
0.20.3000<
jointname="
camera_joint"
type="
revolute"
parent>
pioneer2dx:
:
chassis<
/parent>
child>
camera:
link<
/child>
axis>
xyz>
001<
/xyz>
limit>
lower>
0<
/lower>
upper>
/upper>
/limit>
/axis>
/joint>
laser_joint"
hokuyo:
/model>
參考上述模板,可以學習環境文件,主要由大地,光源,機器人模型,機器人模型包括本體,激光和攝像頭等具體配置。
除此之外,還有gzserver和gzclient。
gazebo命令实际上运行两个不同的可执行文件。
第一个称为gzserver,第二个称为gzclient。
gzserver可执行程序运行物理更新循环和传感器数据生成。
这是Gazebo的核心,可以独立
于图形界面使用。
您可能会在论坛中看到“runheadless”这个短语。
这个短语相当于只运行gzserver。
一个示例用例将涉及在不需要用户界面的云计算机上运行gzserver。
gzclient可执行文件运行基于QT的用户界面。
此应用程序提供了一个很好的可视化的模拟,并在各种模拟属性方便的控制。
當然,這兩個可以分別啓動。
gazebo使用的快捷鍵:
ActionOperationInstruction
MODE
EnterSelectionmode(defaultmode)EscpressEscformodetoselectmodelsandright-clickforcontextmenu
press"
r"
forRotate(model)modetpress"
t"
forTranslate(model)modepress"
s"
forScale(model)modepress"
n"
forSnap(model)mode
LogdataCtrl+dopendialogtorecordlogfilesMISCELLANEOUS
QuitGazeboCtrl+qpressCtrl+"
q"
toquitGazebo
注意這裏gazebo並不能與ROS通訊,如果需要可以使用下面命令:
在CODE上查看代码片派生到我的代码片rosrungazebo_rosgazeborosrungazebo_rosgzserverrosrungazebo_rosgzclientrosrungazebo_rosspawn_modelrosrungazebo_rosperfrosrungazebo_rosdebug啓動後可以看到:
在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+tStartGazebobyenteringthefollowingatthecommandprompt.
gazebo
RunGazebowitharobot
Let'
ssimulatesomethingabitmoreinterestingbyloadingaworldwithapioneer2dx.
Openaterminalandenterthefollowingcommand.
gazeboworlds/pioneer2dx.world
Wherearetheworldslocated?
Youmayhavenoticedthemysteriousworlds/pioneer2dx.world
argumentintheabovecommand.Thisinstructsgazebotofindthepioneer2dx.worldfile,andloaditonstart.
Worldfilesarelocatedinaversionedsystemdirectory,forexample/usr/share/gazebo-7onUbuntu.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.Yourestartthegzclientapplicationasoftenasyouwant,andevenrunmultipleinterfaces.
ThispagedescribeseachoftheitemsinvolvedinrunningaGazebosimulation.
WorldFiles
Theworlddescriptionfilecontainsalltheelementsinasimulation,includingrobots,lights,sensors,andstaticobjects.ThisfileisformattedusingSDF(SimulationDescriptionFormat),andtypicallyhasa.worldextension.
TheGazeboserver(gzserver
)readsthisfiletogenerateandpopulateaworld.
AnumberofexampleworldsareshippedwithGazebo.Theseworldsarelocatedin<
install_path>
/share/gazebo-<
version>
/worlds
ModelFiles
AmodelfileusesthesameSDFformatasworldfiles,butshouldonlycontainasingle<
model>
...<
.Thepurposeofthesefilesistofacilitatemodelreuse,andsimplifyworldfiles.Onceamodelfileiscreated,itcanbeincludedinaworldfileusingthefollowingSDFsyntax:
//model_file_name<
Anumberofmodelsareprovidedintheonlinemodeldatabase(inpreviousversions,someexamplemodelswereshippedwithGazebo).AssumingthatyouhaveanInternetconnectionwhenrunningGazebo,youcaninsertanymodelfromthedatabaseandthenecessarycontentwillbedownloadedatruntime.
EnvironmentVariables
Gazebousesanumberofenvironmentvariablestolocatefiles,andsetupcommunicationsbetweentheserverandclients.
StartingwithGazebo1.9.0,defaultvaluesthatworkformostcasesarecompiledin.Thismeansyoudon'
tneedtosetanyvariables.
Herearethevariables:
GAZEBO_MODEL_PATH
colon-separatedsetofdirectorieswhereGazebowillsearchformodelsGAZEBO_RESOURCE_PATH
colon-separatedsetofdirectorieswhereGazebowillsearchforotherresourcessuchasworldandmediafiles.
GAZEBO_MASTER_URI
URIoftheGazebomaster.ThisspecifiestheIPandportwheretheserverwillbestartedandtellstheclientswheretoconnectto.
GAZEBO_PLUGIN_PATH
colon-separatedsetofdirectorieswhereGazebowillsearchforthepluginsharedlibrariesatruntime.
GAZEBO_MODEL_DATABASE_URI
URIoftheonlinemodeldatabasewhereGazebowilldownloadmodelsfrom.
Thesedefaultsarealsoincludedinashellscript:
source<
/share/gazebo/setup.sh
IfyouwanttomodifyGazebo'
sbehavior,e.g.,byextendingthepathitsearchesformodels,youshouldfirstsourcetheshellscriptlistedabove,thenmodifythevariablesthatitsets.
GazeboServer
TheserveristheworkhorseofGazebo.Itparsesaworlddescriptionfilegivenonthecommandline,andthensimulatestheworldusingaphysicsandsensorengine.
Theservercanbestartedusingthefollowingcommand.Notethattheserverdoesnotincludeanygraphics;
it'
smeanttorunheadless.
gzserver<
world_filename>
The<
canbe:
relative