Tutorial: Using Gazebo plugins with ROS
2015-10-04 00:20
1616 查看
Tutorial:UsingGazebopluginswithROS
参考:http://gazebosim.org/tutorials?tut=ros_gzplugins
GazebopluginsgiveyourURDFmodelsgreaterfunctionalityandcantieinROSmessagesandservicecallsforsensoroutputandmotorinput.Inthistutorialweexplainbothhowtosetuppreexistingpluginsandhowtocreateyourowncustompluginsthatcan
workwithROS.
插件的作用就是使得可以利用仿真环境下的传感器输出消息,同时传递电机等一些输入消息。。相当于我可以获知仿真下激光与视觉才仿真环境下的感知,我也可以发送指令控制仿真环境下的机器人移动。在本教程中,我们将解释如何安装预先存在的插件和如何创建自己的自定义插件。
首先要建立传感器的urdf文件,再加入gazebo的文件描述好相应的传感器参数消息,同时加入插件。(理解好插件,相当于干驱动层之上的消息发布与接收。插件就是为了建立驱动层与消息层的连接).
previoustutorialonURDFs.
插件依据使用的目的可以添加在
Addingaplugintothe
Thefollowingisanexampleofapluginfora
Intheaboveexamplethepluginwasaddedtothe
SDFterminology,itassumesthereferenceisthe
SDFNote:
Delvingalittledeeperintheconversionprocess,yourURDFisconvertedtoaSDFbeforebeingparsedbyGazebo.Anyelementsinsidethe
tutorialonURDFsaredirectlyinsertedintothe
RefertotheSDFdocumentationformoreinformationonhowthisfeaturecanbeused.
Addingaplugintothe
Similarto
Addingaplugintothe
Thisisaccomplishedinthesamewayasa
Pluginsavailableingazebo_plugins 预先安装的可用插件
Thefollowingsectionsdocumentallofthepluginsavailableinthe
Thenamesofeachsectionisderivedfromthepluginclassname.Forexample,"BlockLaser"isfromthe
Iftherearesomesectionsblank,itmeansthatthisauthorgottiredofdocumentingeverypluginandyoushouldfillintheareawithyourexperienceshouldyouhaveknowledgeandexamplesofhowtousetheparticularplugin.
CameraInfoandImageROSmessagesasdescribedinsensormsgs.
totheURDFfilethatrepresentsthecamera.Wearejustusingasimpleredboxtorepresentthecamera,thoughtypicallyyoucoulduseameshfileforabetterrepresentation.
创建urdf文件表示一个红色盒子代表相机。
AXacropropertyisalsodefined:
YoushouldbeabletolaunchtheRRBotandseearedboxattachedtotheendofthearm.
NextwewillreviewtheGazebopluginthatgivesusthecamerafunctionalityandpublishestheimagetoaROSmessage.IntheRRBotwehavebeenfollowingtheconventionofputtingGazeboelementsinthe
在gazebo文件中添加插件相机的特征参数。参考系,传感器类型,更新速率,相机名称,水平镜头视角成像参数(尺寸格式),最近与最远有效视场,噪声。
Let'sdiscusssomeofthepropertiesofthisplugin...
Thelinkname"camera_link"mustmatchthenameofthelinkweaddedtotheXacroURDF. 需要与robot模型link名称对应
Thesensorname"camera1"mustbeuniquefromallothersensornames.ThenameisnotusedmanyplacesexceptforwithinGazebopluginsyoucanaccess 名字唯一
NumberoftimespersecondanewcameraimageistakenwithinGazebo.Thisisthemaximumupdateratethesensorwillattemptduringsimulationbutitcouldfallbehindthistargetrateifthephysicssimulationrunsfasterthanthesensorgenerationcan
keepup.
Fillinthesevaluestomatchthemanufacturer'sspecsonyourphysicalcamerahardware.Onethingtonoteisthatthepixelsareassumedtobesquare. 硬件相机参数,像素假定方块
Additionally,thenearandfarclipsaresimulation-specificparametersthatgiveanupperandlowerboundtothedistanceinwhichthecamerascanseeobjectsinthesimulation.Thisisspecifiedinthecamera'soptometryframe.
Thisiswheretheactual
Herewedefinetherostopicthecamerawillbepublishingto,forboththeimagetopicandthecamerainfotopic.ForRRBot,youshouldsubscribeto:定义要发布的相机消息,
Thecoordinateframetheimageispublishedunderinthetftree. image在TF树中的情况
InRviz,adda''Camera''displayandunder''ImageTopic''setitto
YoushouldseeacameraviewofyourGazeboenvironment.Inthefollowingtwopictures,asodacanwasaddedtotheenvironmentforbettervisuals.
Thecokecanadded:
Thecorrespondingcameraviewafterthependulumhasfallen:
Multicamera 多目相机
Description:synchronizesmultiplecamera'sshutterssuchthattheypublishtheirimagestogether.Typicallyusedforstereocameras,usesaverysimilarinterfaceastheplain
Note:currentlyonlysupportsstereocameras.See
Githubissue.
DepthCamera深度相机
Description:simulatesasensorlikeaKinect,whichisduplicatedintheKinectplugin.Willprobablybemergedinthefuture.
OpenniKinect
'''Description:'''SimulatesanXbox-Kinect,publishesthesametopicsasthecorrespondingROSdriversfortheXboxkinectasdocumentedintheFuertedocumentationhere.
GPULaser 激光
Description:simulateslaserrangesensorbybroadcastingLaserScanmessageasdescribedinsensor_msgs.SeeHokuyoLaserScannersReference.
RRBotExample
SeetheRRBotExampleforaddingaCameratoRRBotbeforereviewingthisexample.Similartoaddingacamera,wewilladdanewlinkandjointtotheXacroURDFoftheRRBot.Thistime,insteadofusingjustarectangleforthevisualmodel,we'llusea
mesh: 添加模型文件
Nowwe'lladdtheplugininformationto
Mostofthepropertiesareself-explanatory,butwe'llreviewsomebelow:激光线是否可视。
Whentrue,asemi-translucentlaserrayisvisualizedwithinthescanningzoneofthegpulaser.Thiscanbeaninformativevisualization,orannuisance.
Moredocumentationonthe
SDFDocumentation. 消息名称 与TF关系
SetthesetotheROStopicnameyouwouldliketopublishthelaserscansto,andthetransformframeyouwouldlikeTFtouse.
InRviz,adda''LaserScan''displayandunder''Topic''setitto
YoushouldseeafaintlaserscanlineinyourGazeboenvironment.Whilethependulumisswinging,youshouldalsoseethelaserscanswing.Ifthescanistoofaint,youcanupthesizeofthelaserscaninthepropertiesoftheLaserScandisplayinRviz.
Asizeof1misveryeasytosee.Inthefollowingtwopictures,ahouseandconstructionbarrelwasaddedtotheenvironmentforbettervisuals.
ViewfromGazebo:
ThecorrespondinglaserviewfromRviz:
Laser 是否支持GPU
Description:thenon-GPUversionof
TorunwithRRBot,open
replace
with
andreplace
with
save,thenlaunchthesamelaunchfilesasforGPULaser.
BlockLaser 块激光(多线)
Description:providesgridstylelaserrangescannersimulation(e.g.Velodyne).
F3D(ForceFeedbackGroundTruth) 力反馈
Description:broadcastsexternalforcesonabodyinsimulationoverWrenchStampedmessageasdescribedingeometry_msgs.
Force 力
Description:ROSinterfaceforapplyingWrench(geometry_msgs)onabodyinsimulation.
IMU
Description:simulates
imu_node
JointPoseTrajectory 关节点跟踪
Description:listenstoajointtrajectoryactionandplaysbackthesetofjointpositions.Setsthesetofjointstoexactpositionswithoutregardstosimulatedphysicsandforces.
P3D(3DPositionInterfaceforGroundTruth) 运动位置捕捉
Description:broadcaststheinertialposeofanybodyinsimulationviaOdometrymessageasdescribedinnav_msgsviaROStopic.
Projector
Description:projectsastatictexturefromasourceoutwards,suchasusedwiththePR2'soriginalheadcamerasensor.SeeAPI
documentationformoreinformation.
ProsilicaCamera
Description:Simulatesinterfacesexposedbya
ROSProsilicaCamera.Here'san
exampleURDFXacromacro.
Bumper 保险杠减震器
Description:providescontactfeedbackvia
ContactsStatemessage.
DifferentialDrive 差速驱动
DescriptionmodelpluginthatprovidesabasiccontrollerfordifferentialdriverobotsinGazebo.Youneedawelldefineddifferentialdriverobottousethisplugin.
SkidSteeringDrive 滑动导向驱动
DescriptionmodelpluginthatprovidesabasiccontrollerforskidsteeringdriverobotsinGazebo(Pioneer3ATforinstance).
VideoPlugin 视频
DescriptionvisualpluginthatdisplaysaROSimagestreamonanOGRETextureinsidegazebo.Thisplugindoesnotmodifythetextureofoneoftheexistinglinksurfaces,butcreatesanewtextureontopofit.Thetexturewillbecreated
ontheXYplane,visiblefromthe+Zside.Thepluginrequiresapixelsizewhileconstructingthetexture,andwillresizeincomingROSimagemessagestomatchiftheyareadifferentsize.
PlanarMovePlugin 平面运动
Descriptionmodelpluginthatallowsarbitraryobjects(forinstancecubes,spheresandcylinders)tobemovedalongahorizontalplaneusingageometry_msgs/Twistmessage.Thepluginworksbyimpartingalinearvelocity(XY)andanangular
velocity(Z)totheobjecteverycycle.
HereisafullURDFexamplethatdemonstrateshowtocontrolafloatingboxinsidegazebousingthisplugin,usingdifferentvisualandcollisionelements.Note:Theobjectneedstohavesufficientinertiatopreventundesirablemotions-whichcanoccur
asareactiontothesuppliedvelocity.Youcantryincreasinginertiauntiltheobjectmovesasdesired.Itisalsogoodtohavethecenterofmassclosetotheground.
Template 自定义插件
Description:anexamplec++plugintemplateforanyonewhowantstowritetheirownplugin.
controllers,andros_control.
参考:http://gazebosim.org/tutorials?tut=ros_gzplugins
GazebopluginsgiveyourURDFmodelsgreaterfunctionalityandcantieinROSmessagesandservicecallsforsensoroutputandmotorinput.Inthistutorialweexplainbothhowtosetuppreexistingpluginsandhowtocreateyourowncustompluginsthatcan
workwithROS.
插件的作用就是使得可以利用仿真环境下的传感器输出消息,同时传递电机等一些输入消息。。相当于我可以获知仿真下激光与视觉才仿真环境下的感知,我也可以发送指令控制仿真环境下的机器人移动。在本教程中,我们将解释如何安装预先存在的插件和如何创建自己的自定义插件。
首先要建立传感器的urdf文件,再加入gazebo的文件描述好相应的传感器参数消息,同时加入插件。(理解好插件,相当于干驱动层之上的消息发布与接收。插件就是为了建立驱动层与消息层的连接).
Prerequisites
MakesureyouhavetheRRBotsetupasdescribedintheprevioustutorialonURDFs.
AddingPlugins
PluginscanbeaddedtoanyofthemainelementsofaURDF-a<robot>,
<link>,or
<joint>dependingonwhatthescopeandpurposeofthepluginis.ToaccomplishaddingaplugintoaparticularelementinyourURDF,youmustwrapyour
<plugin>tagwithina
<gazebo>element.
插件依据使用的目的可以添加在
<robot>,
<link>,or
<joint>标签下,
<plugin>都在
<gazebo>标签下。
Addingaplugintothe<robot>
element
Thefollowingisanexampleofapluginfora<robot>elementinaURDF: 无
reference(参考系) 表示整个robot
<gazebo> <pluginname="differential_drive_controller"filename="libdiffdrive_plugin.so"> ...pluginparameters... </plugin> </gazebo>
Intheaboveexamplethepluginwasaddedtothe
<robot>elementbecause,similartoother
<gazebo>elementsandproperties,ifno
reference="x"isspecifieditisassumesthereferenceistheentire
<robot>.In
<model>.
SDFNote:
Delvingalittledeeperintheconversionprocess,yourURDFisconvertedtoaSDFbeforebeingparsedbyGazebo.Anyelementsinsidethe
<gazebo>tagswhicharenotintheelementtabledescribedintheprevious
tutorialonURDFsaredirectlyinsertedintothe
<model>tagofthegeneratedSDF.Asanexample,thisfeaturecanbeusedtointroducemodelspecificplugins.ThefollowingistheconvertedSDFfromtheaboveURDFexample:
gazebo解析urdf-->sdf任何<gazebo>标签里的不在urdf元素表里的元素直接插入《model》标签内生成sdf文件。
<modelname="your_robot_model"> <pluginname="differential_drive_controller"filename="libdiffdrive_plugin.so"> ...pluginparameters... </plugin> </model>
RefertotheSDFdocumentationformoreinformationonhowthisfeaturecanbeused.
Addingaplugintothe<link>
element
Similarto<plugin>elementsfor
<robot>,youcanadda
<plugin>elementtoalinkbypassinga
reference="your_link_name"value.
<gazeboreference="your_link_name"> <pluginname="your_link_laser_controller"filename="libgazebo_ros_laser.so"> ...pluginparameters... </plugin> </gazebo>
Addingaplugintothe<joint>
element
Thisisaccomplishedinthesamewayasa<link>exceptthereferencenameisajointname.
Pluginsavailableingazebo_plugins 预先安装的可用插件
Thefollowingsectionsdocumentallofthepluginsavailableinthegazebo_plugins.Wesuggestyoureviewtheminorderbecausemoredetailiscoveredinthefirstcoupleofpluginsandyoucanlearnsomeoftheconceptsfromthevariousplugins'documentation.
Thenamesofeachsectionisderivedfromthepluginclassname.Forexample,"BlockLaser"isfromthe
GazeboRosBlockLaserclassandcanbefoundinthefile
gazebo_plugins/src/gazebo_ros_block_laser.cpp.
Iftherearesomesectionsblank,itmeansthatthisauthorgottiredofdocumentingeverypluginandyoushouldfillintheareawithyourexperienceshouldyouhaveknowledgeandexamplesofhowtousetheparticularplugin.
Camera
Description:providesROSinterfaceforsimulatingcamerassuchaswge100camerabypublishingtheCameraInfoandImageROSmessagesasdescribedinsensormsgs.
RRBotExample
Inthissection,wewillreviewasimpleRGBcameraattachedtotheendoftheRRBotpendulumarm.Youcanlookinsiderrbot.xacrotofollowtheexplanation.Thefirstelementsofthisblockareanextralinkandjointadded
totheURDFfilethatrepresentsthecamera.Wearejustusingasimpleredboxtorepresentthecamera,thoughtypicallyyoucoulduseameshfileforabetterrepresentation.
创建urdf文件表示一个红色盒子代表相机。
<jointname="camera_joint"type="fixed"> <axisxyz="010"/> <originxyz="${camera_link}0${height3-axel_offset*2}"rpy="000"/> <parentlink="link3"/> <childlink="camera_link"/> </joint> <!--Camera--> <linkname="camera_link"> <collision> <originxyz="000"rpy="000"/> <geometry> <boxsize="${camera_link}${camera_link}${camera_link}"/> </geometry> </collision> <visual> <originxyz="000"rpy="000"/> <geometry> <boxsize="${camera_link}${camera_link}${camera_link}"/> </geometry> <materialname="red"/> </visual> <inertial> <massvalue="1e-5"/> <originxyz="000"rpy="000"/> <inertiaixx="1e-6"ixy="0"ixz="0"iyy="1e-6"iyz="0"izz="1e-6"/> </inertial> </link>
AXacropropertyisalsodefined:
<xacro:propertyname="camera_link"value="0.05"/><!--Sizeofsquare'camera'box-->
YoushouldbeabletolaunchtheRRBotandseearedboxattachedtotheendofthearm.
NextwewillreviewtheGazebopluginthatgivesusthecamerafunctionalityandpublishestheimagetoaROSmessage.IntheRRBotwehavebeenfollowingtheconventionofputtingGazeboelementsinthe
rrbot.gazebofile:
在gazebo文件中添加插件相机的特征参数。参考系,传感器类型,更新速率,相机名称,水平镜头视角成像参数(尺寸格式),最近与最远有效视场,噪声。
相机控制插件(参数对应可调)libgazebo_ros_camera.so
<!--camera--> <gazeboreference="camera_link"> <sensortype="camera"name="camera1"> <update_rate>30.0</update_rate> <cameraname="head"> <horizontal_fov>1.3962634</horizontal_fov> <image> <width>800</width> <height>800</height> <format>R8G8B8</format> </image> <clip> <near>0.02</near> <far>300</far> </clip> <noise> <type>gaussian</type> <!--Noiseissampledindependentlyperpixeloneachframe. Thatpixel'snoisevalueisaddedtoeachofitscolor channels,whichatthatpointlieintherange[0,1].--> <mean>0.0</mean> <stddev>0.007</stddev> </noise> </camera> <pluginname="camera_controller"filename="libgazebo_ros_camera.so"> <alwaysOn>true</alwaysOn> <updateRate>0.0</updateRate> <cameraName>rrbot/camera1</cameraName> <imageTopicName>image_raw</imageTopicName> <cameraInfoTopicName>camera_info</cameraInfoTopicName> <frameName>camera_link</frameName> <hackBaseline>0.07</hackBaseline> <distortionK1>0.0</distortionK1> <distortionK2>0.0</distortionK2> <distortionK3>0.0</distortionK3> <distortionT1>0.0</distortionT1> <distortionT2>0.0</distortionT2> </plugin> </sensor> </gazebo>
Let'sdiscusssomeofthepropertiesofthisplugin...
<gazeboreference="camera_link">
Thelinkname"camera_link"mustmatchthenameofthelinkweaddedtotheXacroURDF. 需要与robot模型link名称对应
<sensortype="camera"name="camera1">
Thesensorname"camera1"mustbeuniquefromallothersensornames.ThenameisnotusedmanyplacesexceptforwithinGazebopluginsyoucanaccess 名字唯一
<update_rate>30.0</update_rate>
NumberoftimespersecondanewcameraimageistakenwithinGazebo.Thisisthemaximumupdateratethesensorwillattemptduringsimulationbutitcouldfallbehindthistargetrateifthephysicssimulationrunsfasterthanthesensorgenerationcan
keepup.
<horizontal_fov>1.3962634</horizontal_fov> <image> <width>800</width> <height>800</height> <format>R8G8B8</format> </image> <clip> <near>0.02</near> <far>300</far> </clip>
Fillinthesevaluestomatchthemanufacturer'sspecsonyourphysicalcamerahardware.Onethingtonoteisthatthepixelsareassumedtobesquare. 硬件相机参数,像素假定方块
Additionally,thenearandfarclipsaresimulation-specificparametersthatgiveanupperandlowerboundtothedistanceinwhichthecamerascanseeobjectsinthesimulation.Thisisspecifiedinthecamera'soptometryframe.
<pluginname="camera_controller"filename="libgazebo_ros_camera.so">
Thisiswheretheactual
gazebo_ros/gazebo_ros_camera.cppfileislinkedto,asasharedobject.
<cameraName>rrbot/camera1</cameraName> <imageTopicName>image_raw</imageTopicName> <cameraInfoTopicName>camera_info</cameraInfoTopicName>
Herewedefinetherostopicthecamerawillbepublishingto,forboththeimagetopicandthecamerainfotopic.ForRRBot,youshouldsubscribeto:定义要发布的相机消息,
/rrbot/camera1/image_raw /rrbot/camera1/camera_info
<frameName>camera_link</frameName>
Thecoordinateframetheimageispublishedunderinthetftree. image在TF树中的情况
RunningtheRRBotExample
Afteryouhavesavedbothrrbot.xacroand
rrbot.gazebo,youshouldbeabletolaunchbothRvizandGazeboinseparateterminals:
roslaunchrrbot_gazeborrbot_world.launch roslaunchrrbot_descriptionrrbot_rviz.launch
InRviz,adda''Camera''displayandunder''ImageTopic''setitto
/rrbot/camera1/image_raw.
YoushouldseeacameraviewofyourGazeboenvironment.Inthefollowingtwopictures,asodacanwasaddedtotheenvironmentforbettervisuals.
Thecokecanadded:
Thecorrespondingcameraviewafterthependulumhasfallen:
Multicamera 多目相机
Description:synchronizesmultiplecamera'sshutterssuchthattheypublishtheirimagestogether.Typicallyusedforstereocameras,usesaverysimilarinterfaceastheplainCameraplugin
Note:currentlyonlysupportsstereocameras.See
Githubissue.
AtlasCodeExample
Inthiscodeexamplethereisbothaleftandrightcamera:<gazeboreference="left_camera_frame">
<sensortype="multicamera"name="stereo_camera">
<update_rate>30.0</update_rate>
<cameraname="left">
<horizontal_fov>1.3962634</horizontal_fov>
<image>
<width>800</width>
<height>800</height>
<format>R8G8B8</format>
</image>
<clip>
<near>0.02</near>
<far>300</far>
</clip>
<noise>
<type>gaussian</type>
<mean>0.0</mean>
<stddev>0.007</stddev>
</noise>
</camera>
<cameraname="right">
<pose>0-0.070000</pose>
<horizontal_fov>1.3962634</horizontal_fov>
<image>
<width>800</width>
<height>800</height>
<format>R8G8B8</format>
</image>
<clip>
<near>0.02</near>
<far>300</far>
</clip>
<noise>
<type>gaussian</type>
<mean>0.0</mean>
<stddev>0.007</stddev>
</noise>
</camera>
<pluginname="stereo_camera_controller"filename="libgazebo_ros_multicamera.so">
<alwaysOn>true</alwaysOn>
<updateRate>0.0</updateRate>
<cameraName>multisense_sl/camera</cameraName>
<imageTopicName>image_raw</imageTopicName>
<cameraInfoTopicName>camera_info</cameraInfoTopicName>
<frameName>left_camera_optical_frame</frameName>
<!--<rightFrameName>right_camera_optical_frame</rightFrameName>-->
<hackBaseline>0.07</hackBaseline>
<distortionK1>0.0</distortionK1>
<distortionK2>0.0</distortionK2>
<distortionK3>0.0</distortionK3>
<distortionT1>0.0</distortionT1>
<distortionT2>0.0</distortionT2>
</plugin>
</sensor>
</gazebo>
DepthCamera深度相机
Description:simulatesasensorlikeaKinect,whichisduplicatedintheKinectplugin.Willprobablybemergedinthefuture.OpenniKinect
'''Description:'''SimulatesanXbox-Kinect,publishesthesametopicsasthecorrespondingROSdriversfortheXboxkinectasdocumentedintheFuertedocumentation<gazebo>
<pluginname="${link_name}_controller"filename="libgazebo_ros_openni_kinect.so">
<baseline>0.2</baseline>
<alwaysOn>true</alwaysOn>
<updateRate>1.0</updateRate>
<cameraName>${camera_name}_ir</cameraName>
<imageTopicName>/${camera_name}/depth/image_raw</imageTopicName>
<cameraInfoTopicName>/${camera_name}/depth/camera_info</cameraInfoTopicName>
<depthImageTopicName>/${camera_name}/depth/image_raw</depthImageTopicName>
<depthImageInfoTopicName>/${camera_name}/depth/camera_info</depthImageInfoTopicName>
<pointCloudTopicName>/${camera_name}/depth/points</pointCloudTopicName>
<frameName>${frame_name}</frameName>
<pointCloudCutoff>0.5</pointCloudCutoff>
<distortionK1>0.00000001</distortionK1>
<distortionK2>0.00000001</distortionK2>
<distortionK3>0.00000001</distortionK3>
<distortionT1>0.00000001</distortionT1>
<distortionT2>0.00000001</distortionT2>
<CxPrime>0</CxPrime>
<Cx>0</Cx>
<Cy>0</Cy>
<focalLength>0</focalLength>
<hackBaseline>0</hackBaseline>
</plugin>
</gazebo>
GPULaser 激光
Description:simulateslaserrangesensorbybroadcastingLaserScanmessageasdescribedinsensor_msgs.SeeRRBotExample
SeetheRRBotExampleforaddingaCameratoRRBotbeforereviewingthisexample.Similartoaddingacamera,wewilladdanewlinkandjointtotheXacroURDFoftheRRBot.Thistime,insteadofusingjustarectangleforthevisualmodel,we'lluseamesh: 添加模型文件
<jointname="hokuyo_joint"type="fixed">
<axisxyz="010"/>
<originxyz="00${height3-axel_offset/2}"rpy="000"/>
<parentlink="link3"/>
<childlink="hokuyo_link"/>
</joint>
<!--HokuyoLaser-->
<linkname="hokuyo_link">
<collision>
<originxyz="000"rpy="000"/>
<geometry>
<boxsize="0.10.10.1"/>
</geometry>
</collision>
<visual>
<originxyz="000"rpy="000"/>
<geometry>
<meshfilename="package://rrbot_description/meshes/hokuyo.dae"/>
</geometry>
</visual>
<inertial>
<massvalue="1e-5"/>
<originxyz="000"rpy="000"/>
<inertiaixx="1e-6"ixy="0"ixz="0"iyy="1e-6"iyz="0"izz="1e-6"/>
</inertial>
</link>
Nowwe'lladdtheplugininformationto
rrbot.gazebo,againaswedidforthecameraexample: 传感器与插件配置
<!--hokuyo-->
<gazeboreference="hokuyo_link">
<sensortype="gpu_ray"name="head_hokuyo_sensor">
<pose>000000</pose>
<visualize>false</visualize>
<update_rate>40</update_rate><ray>
<scan>
<horizontal>
<samples>720</samples>
<resolution>1</resolution>
<min_angle>-1.570796</min_angle>
<max_angle>1.570796</max_angle>
</horizontal>
</scan>
<range>
<min>0.10</min>
<max>30.0</max>
<resolution>0.01</resolution>
</range>
<noise>
<type>gaussian</type>
<!--NoiseparametersbasedonpublishedspecforHokuyolaser
achieving"+-30mm"accuracyatrange<10m.Ameanof0.0mand
stddevof0.01mwillput99.7%ofsampleswithin0.03mofthetrue
reading.-->
<mean>0.0</mean>
<stddev>0.01</stddev>
</noise>
</ray>
<pluginname="gazebo_ros_head_hokuyo_controller"filename="libgazebo_ros_gpu_laser.so">
<topicName>/rrbot/laser/scan</topicName> <frameName>hokuyo_link</frameName></plugin>
</sensor>
</gazebo>
Mostofthepropertiesareself-explanatory,butwe'llreviewsomebelow:激光线是否可视。
<visualize>false</visualize>
Whentrue,asemi-translucentlaserrayisvisualizedwithinthescanningzoneofthegpulaser.Thiscanbeaninformativevisualization,orannuisance.
Moredocumentationonthe
<sensor>and
<ray>elementscanbefoundinthe
SDFDocumentation. 消息名称 与TF关系
<topicName>/rrbot/laser/scan</topicName> <frameName>hokuyo_link</frameName>
SetthesetotheROStopicnameyouwouldliketopublishthelaserscansto,andthetransformframeyouwouldlikeTFtouse.
RunningtheRRBotExample
Afteryouhavesavedbothrrbot.xacroand
rrbot.gazebo,youshouldbeabletolaunchbothRvizandGazeboinseparateterminals:
roslaunchrrbot_gazeborrbot.launch
roslaunchrrbot_descriptionrrbot_rviz.launch
InRviz,adda''LaserScan''displayandunder''Topic''setitto
/rrbot/camera1/image_raw.
YoushouldseeafaintlaserscanlineinyourGazeboenvironment.Whilethependulumisswinging,youshouldalsoseethelaserscanswing.Ifthescanistoofaint,youcanupthesizeofthelaserscaninthepropertiesoftheLaserScandisplayinRviz.
Asizeof1misveryeasytosee.Inthefollowingtwopictures,ahouseandconstructionbarrelwasaddedtotheenvironmentforbettervisuals.
ViewfromGazebo:
ThecorrespondinglaserviewfromRviz:
Laser 是否支持GPU
Description:thenon-GPUversionof,butessentiallyusesthesamecode.SeeGPULaserfordocumentation.
GPULaser
TorunwithRRBot,open
rrbot.gazeboandchangethefollowingtwolines.
replace
<sensortype="gpu_ray"name="head_hokuyo_sensor">
with
<sensortype="ray"name="head_hokuyo_sensor">
andreplace
<pluginname="gazebo_ros_head_hokuyo_controller"filename="libgazebo_ros_gpu_laser.so">
with
<pluginname="gazebo_ros_head_hokuyo_controller"filename="libgazebo_ros_laser.so">
save,thenlaunchthesamelaunchfilesasforGPULaser.
BlockLaser 块激光(多线)
Description:providesgridstylelaserrangescannersimulation(e.g.Velodyne).F3D(ForceFeedbackGroundTruth) 力反馈
Description:broadcastsexternalforcesonabodyinsimulationoverWrenchStampedmessageasdescribedingeometry_msgs.Force 力
Description:ROSinterfaceforapplyingWrench(geometry_msgs)onabodyinsimulation.IMU
Description:simulatesimu_node
JointPoseTrajectory 关节点跟踪
Description:listenstoajointtrajectoryactionandplaysbackthesetofjointpositions.Setsthesetofjointstoexactpositionswithoutregardstosimulatedphysicsandforces.P3D(3DPositionInterfaceforGroundTruth) 运动位置捕捉
Description:broadcaststheinertialposeofanybodyinsimulationviaOdometrymessageasdescribedinnav_msgsviaROStopic.Projector
Description:projectsastatictexturefromasourceoutwards,suchasusedwiththePR2'soriginalheadcamerasensor.SeeAPIdocumentationformoreinformation.
ProsilicaCamera
Description:SimulatesinterfacesexposedbyaROSProsilicaCamera.Here'san
exampleURDFXacromacro.
Bumper 保险杠减震器
Description:providescontactfeedbackviaContactsStatemessage.
<gazebo>
<pluginname="${name}_gazebo_ros_bumper_controller"filename="libgazebo_ros_bumper.so">
<alwaysOn>true</alwaysOn>
<updateRate>${update_rate}</updateRate>
<bumperTopicName>${name}_bumper</bumperTopicName>
<frameName>world</frameName>
</plugin>
</gazebo>
DifferentialDrive 差速驱动
DescriptionmodelpluginthatprovidesabasiccontrollerfordifferentialdriverobotsinGazebo.Youneedawelldefineddifferentialdriverobottousethisplugin.<gazebo>
<pluginname="differential_drive_controller"filename="libgazebo_ros_diff_drive.so">
<alwaysOn>true</alwaysOn>
<updateRate>${update_rate}</updateRate>
<leftJoint>base_link_right_wheel_joint</leftJoint>
<rightJoint>base_link_left_wheel_joint</rightJoint>
<wheelSeparation>0.5380</wheelSeparation>
<wheelDiameter>0.2410</wheelDiameter>
<torque>20</torque>
<commandTopic>cmd_vel</commandTopic>
<odometryTopic>odom</odometryTopic>
<odometryFrame>odom</odometryFrame>
<robotBaseFrame>base_footprint</robotBaseFrame>
</plugin>
</gazebo>
SkidSteeringDrive 滑动导向驱动
DescriptionmodelpluginthatprovidesabasiccontrollerforskidsteeringdriverobotsinGazebo(Pioneer3ATforinstance).<gazebo>
<pluginname="skid_steer_drive_controller"filename="libgazebo_ros_skid_steer_drive.so">
<updateRate>100.0</updateRate>
<robotNamespace>/</robotNamespace>
<leftFrontJoint>front_left_wheel_joint</leftFrontJoint>
<rightFrontJoint>front_right_wheel_joint</rightFrontJoint>
<leftRearJoint>back_left_wheel_joint</leftRearJoint>
<rightRearJoint>back_right_wheel_joint</rightRearJoint>
<wheelSeparation>0.4</wheelSeparation>
<wheelDiameter>0.215</wheelDiameter>
<robotBaseFrame>base_link</robotBaseFrame>
<torque>20</torque>
<topicName>cmd_vel</topicName>
<broadcastTF>false</broadcastTF>
</plugin>
</gazebo>
VideoPlugin 视频
DescriptionvisualpluginthatdisplaysaROSimagestreamonanOGRETextureinsidegazebo.Thisplugindoesnotmodifythetextureofoneoftheexistinglinksurfaces,butcreatesanewtextureontopofit.ThetexturewillbecreatedontheXYplane,visiblefromthe+Zside.Thepluginrequiresapixelsizewhileconstructingthetexture,andwillresizeincomingROSimagemessagestomatchiftheyareadifferentsize.
<gazeboreference="display_screen_link">
<visual>
<pluginname="display_video_controller"filename="libgazebo_ros_video.so">
<topicName>image</topicName>
<height>120</height>
<width>160</width>
</plugin>
</visual>
</gazebo>
PlanarMovePlugin 平面运动
Descriptionmodelpluginthatallowsarbitraryobjects(forinstancecubes,spheresandcylinders)tobemovedalongahorizontalplaneusingageometry_msgs/Twistmessage.Thepluginworksbyimpartingalinearvelocity(XY)andanangularvelocity(Z)totheobjecteverycycle.
HereisafullURDFexamplethatdemonstrateshowtocontrolafloatingboxinsidegazebousingthisplugin,usingdifferentvisualandcollisionelements.Note:Theobjectneedstohavesufficientinertiatopreventundesirablemotions-whichcanoccur
asareactiontothesuppliedvelocity.Youcantryincreasinginertiauntiltheobjectmovesasdesired.Itisalsogoodtohavethecenterofmassclosetotheground.
<robotname="test_model">
<!--rootlink,onthegroundjustbelowthemodelorigin-->
<linkname="base_footprint">
<visual>
<originxyz="000"rpy="000"/>
<geometry>
<boxsize="0.0010.0010.001"/>
</geometry>
</visual>
</link>
<jointname="base_link_joint"type="fixed">
<originxyz="0.001.25"rpy="000"/>
<parentlink="base_footprint"/>
<childlink="base_link"/>
</joint>
<!--themodel-->
<linkname="base_link">
<inertial>
<massvalue="50"/>
<originxyz="00-1.25"/>
<inertiaixx="50.0"ixy="0.0"ixz="0.0"
iyy="50.0"iyz="0.0"
izz="50.0"/>
</inertial>
<visual>
<geometry>
<boxsize="0.50.51.0"/><!--doesnotneedtomatchcollision-->
</geometry>
</visual>
<collision>
<originxyz="00-1.0"/>
<geometry>
<cylinderlength="0.5"radius="0.25"/>
</geometry>
</collision>
</link>
<gazebo>
<pluginname="object_controller"filename="libgazebo_ros_planar_move.so">
<commandTopic>cmd_vel</commandTopic>
<odometryTopic>odom</odometryTopic>
<odometryFrame>odom</odometryFrame>
<odometryRate>20.0</odometryRate>
<robotBaseFrame>base_footprint</robotBaseFrame>
</plugin>
</gazebo>
</robot>
Template 自定义插件
Description:anexamplec++plugintemplateforanyonewhowantstowritetheirownplugin.NextSteps
Nextwewillanalyzetheros_controlpackagesintegratedwithGazebofortightcontroller/actuator/simulatorintegrationActuators,
controllers,andros_control.
相关文章推荐
- 素描绘画中体积和空间感问题探讨
- UVA208在一个图中,给定终点和起点,搜索路线,巧妙剪枝
- Mount VDI as logical drive on host
- MySql 使用递归函数时遇到的级联删除问题
- lua脚本的基本语法(二)
- torcs源码分析--(3)总览
- php 基于PDO下的exec()函数查询
- HDU 5495 LCS (置换)
- torcs源码分析--(2)关键文件及结构
- 航电 acm 2013
- torcs源码分析--(1)工程分析
- OpenGL 缺省视景体是中心在原点,边长为2的立方体
- 用CocoaPods做iOS程序的依赖管理
- 知名广告拦截插件 Adblock 出售 买家未公布
- Myeclipse提示失效?
- final关键字
- 《TCP/IP详解 卷一:协议》读书笔记--ARP:地址解析协议
- static关键字
- Android中Activity四种启动模式(LaunchMode)和taskAffinity属性
- 无名