分享

ROS探索总结(四)

 openlog 2016-02-02

三、实现分析

       按照上面的仿真过程,我们详细分析每一步的代码实现。   

       1、TurtleBot机器人运行

       机器人运行使用的是launch文件,首先打开fake_turtlebot.launch文件。 
[plain] view plain copy
  1. <launch>  
  2.   <param name="/use_sim_time" value="false" />  
  3.   
  4.   <!-- Load the URDF/Xacro model of our robot -->  
  5.   <arg name="urdf_file" default="$(find xacro)/xacro.py '$(find turtlebot_description)/urdf/turtlebot.urdf.xacro'" />  
  6.      
  7.   <param name="robot_description" command="$(arg urdf_file)" />  
  8.       
  9.   <node name="arbotix" pkg="arbotix_python" type="driver.py" output="screen">  
  10.       <rosparam file="$(find rbx1_bringup)/config/fake_turtlebot_arbotix.yaml" command="load" />  
  11.       <param name="sim" value="true"/>  
  12.   </node>  
  13.     
  14.   <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher">  
  15.       <param name="publish_frequency" type="double" value="20.0" />  
  16.   </node>  
  17.     
  18.   <!-- We need a static transforms for the wheels -->  
  19.   <node pkg="tf" type="static_transform_publisher" name="odom_left_wheel_broadcaster" args="0 0 0 0 0 0 /base_link /left_wheel_link 100" />  
  20.   <node pkg="tf" type="static_transform_publisher" name="odom_right_wheel_broadcaster" args="0 0 0 0 0 0 /base_link /right_wheel_link 100" />  
  21.   
  22. </launch>  

        文件可以大概分为四个部分:
        (1) 从指定的包中加载urdf文件
        (2) 启动arbotix模拟器
        (3) 启动状态发布节点
        (4) tf坐标系配置

2、rviz配置文件

       在打开rviz的时候需要加载一个.vcg的配置文件,主要对rviz中的插件选项进行默认的配置。这里打开的是sim_fuerte.vcg文件,由于文件比较长,这里只列举重点的部分。
[plain] view plain copy
  1. Background\ ColorB=0.12549  
  2. Background\ ColorG=0.12549  
  3. Background\ ColorR=0.12549  
  4. Camera\ Config=158.108 0.814789 0.619682 -1.57034  
  5. Camera\ Type=rviz::FixedOrientationOrthoViewController  
  6. Fixed\ Frame=/odom  
  7. Grid.Alpha=0.5  
  8. Grid.Cell\ Size=0.5  
  9. Grid.ColorB=0.941176  
  10. Grid.ColorG=0.941176  
  11. Grid.ColorR=0.941176  
  12. Grid.Enabled=1  
  13. Grid.Line\ Style=0  
  14. Grid.Line\ Width=0.03  
  15. Grid.Normal\ Cell\ Count=0  
  16. Grid.OffsetX=0  
  17. Grid.OffsetY=0  
  18. Grid.OffsetZ=0  
  19. Grid.Plane=0  



        上面的代码是配置背景颜色和网格属性的,对应rviz中的选项如下图所示。
        
        其中比较重要的一个选项是Camera的type,这个选项是控制开发者的观察角度的,书中用的是FixedOrientationOrthoViewController的方式,就是上面图中的俯视角度,无法看到机器人的三维全景,所以可以改为OrbitViewController方式,如下图所示:

3、发布topic

        要让机器人动起来,还需要给他一些运动需要的信息,这些信息都是通过topic的方式发布的。
        这里的topic就是速度命令,针对这个topic,我们需要发布速度的信息,在ROS中已经为我们写好了一些可用的数据结构,这里用的是Twist信息的数据结构。在终端中可以看到Twist的结构如下:
              
        用下面的命令进行消息的发布,其中主要包括力的大小和方向。
[plain] view plain copy
  1. Background\ ColorB=0.12549  
  2. Background\ ColorG=0.12549  
  3. Background\ ColorR=0.12549  
  4. Camera\ Config=158.108 0.814789 0.619682 -1.57034  
  5. Camera\ Type=rviz::FixedOrientationOrthoViewController  
  6. Fixed\ Frame=/odom  
  7. Grid.Alpha=0.5  
  8. Grid.Cell\ Size=0.5  
  9. Grid.ColorB=0.941176  
  10. Grid.ColorG=0.941176  
  11. Grid.ColorR=0.941176  
  12. Grid.Enabled=1  
  13. Grid.Line\ Style=0  
  14. Grid.Line\ Width=0.03  
  15. Grid.Normal\ Cell\ Count=0  
  16. Grid.OffsetX=0  
  17. Grid.OffsetY=0  
  18. Grid.OffsetZ=0  
  19. Grid.Plane=0  



4、节点关系图


----------------------------------------------------------------

欢迎大家转载我的文章。

转载请注明:转自古-月

http://blog.csdn.net/hcx25909

欢迎继续关注我的博客


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多