关闭

ROS 学习系列 -- 执行turtlebot navigation的方法

5685人阅读 评论(2) 收藏 举报
分类:
我们讲一下如何使用现有的turtlebot launch文件来启动navigation,并在PC上使用rviz指挥。

1. 网络环境布置

turtlebot单片机我们使用的是firefly,rviz运行在PC上,它们使用wifi通讯。master ros运行在firefly上,PC需要指向firefly。在PC修改IP到firefly主机的映射,修改/etc/hosts 文件,如

sudo nano /etc/hosts

打开hosts后,我们从前面几行开始插入firefly单片机的ip地址和hostname,形式如下:

127.0.0.1       localhost
127.0.1.1       pc_hostname
192.168.1.16    firefly

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
完毕后保存并确认可以在PC上ping通firefly名字本身。


在firefly单片机上source下面的脚本内容,设定turtlebot为master ROS节点:

export TURTLEBOT_BASE=roomba
export TURTLEBOT_STACKS=circles
export TURTLEBOT_3D_SENSOR=asus_xtion_pro
export TURTLEBOT_SIMULATION=false
export TURTLEBOT_SERIAL_PORT=/dev/ttyUSB0
export ROS_IP=192.168.1.16
export TURTLEBOT_MAP_FILE=/home/firefly/room323.yaml

在PC上source下面的脚本内容,指向turtlebot为master ROS节点:

export ROS_MASTER_URI=http://firefly:11311
export ROS_HOSTNAME=<span style="font-family:SimSun;">pc_hostname</span>

2. 安装必要软件包 

在firefly单片机上执行下面的脚本安装:

sudo apt-get install ros-indigo-turtlebot ros-indigo-rocon-app-platform ros-indigo-rocon-multimaster ros-indigo-rocon-msgs ros-indigo-rocon-qt-gui ros-indigo-rocon-tools ros-indigo-std-capabilities ros-indigo-rqt-capabilities ros-indigo-rocon-remocon ros-indigo-rocon-apps ros-indigo-turtlebot-rapps

在PC上执行下面的脚本安装:

sudo apt-get install ros-indigo-turtlebot-rviz-launchers
当然RVIZ 是必须已经安装完了


3. 启动turtlebot和rviz 
在firefly单片机上打开一个终端执行下面脚本:

roslaunch turtlebot_bringup minimal.launch


在firefly单片机上打开第二个终端执行下面脚本:

roslaunch  turtlebot_app nav_map.launch

注意这里一定要设置环境变量 TURTLEBOT_MAP_FILE 注明地图yaml文件的位置。这个时候,turtlebot已经可以使用了,准备接受命令移动。


执行下面脚本在PC上执行脚本:

roslaunch turtlebot_rviz_launchers view_navigation.launch --screen
这时候就可以看到rviz上显示如下画面,点击按钮'2D Pose Estimate' '2D Nav Goal'就可以导航了:



4. 简化后的turtlebot启动脚本

在firefly单片机上只执行一个简化后的launch脚本也可以,脚本内容如下:

<!--
  Right now, the android app is hard coded to look for /cmd_vel as the input
  topic.
 -->
<launch>  
  
<!-- Turtlebot -->
  <arg name="base"              default="$(env TURTLEBOT_BASE)"         doc="mobile base type [create, roomba]"/>
  <arg name="battery"           default="$(env TURTLEBOT_BATTERY)"      doc="kernel provided locatio for battery info, use /proc/acpi/battery/BAT0 in 2.6 or earlier kernels." />
  <arg name="stacks"            default="$(env TURTLEBOT_STACKS)"       doc="stack type displayed in visualisation/simulation [circles, hexagons]"/>
  <arg name="3d_sensor"         default="$(env TURTLEBOT_3D_SENSOR)"    doc="3d sensor types [kinect, asux_xtion_pro]"/>
  <arg name="simulation"        default="$(env TURTLEBOT_SIMULATION)"   doc="set flags to indicate this turtle is run in simulation mode."/>
  <arg name="serialport"        default="$(env TURTLEBOT_SERIAL_PORT)"  doc="used by create to configure the port it is connected on [/dev/ttyUSB0, /dev/ttyS0]"/>
  <arg name="robot_name"        default="$(env TURTLEBOT_NAME)"         doc="used as a unique identifier and occasionally to preconfigure root namespaces, gateway/zeroconf ids etc."/>
  <arg name="robot_type"        default="$(env TURTLEBOT_TYPE)"         doc="just in case you are considering a 'variant' and want to make use of this."/>

  <param name="/use_sim_time" value="$(arg simulation)"/>

  <include file="$(find turtlebot_bringup)/launch/includes/robot.launch.xml">
    <arg name="base" value="$(arg base)" />
    <arg name="stacks" value="$(arg stacks)" />
    <arg name="3d_sensor" value="$(arg 3d_sensor)" />
  </include>
  <include file="$(find turtlebot_bringup)/launch/includes/mobile_base.launch.xml">
    <arg name="base" value="$(arg base)" />
    <arg name="serialport" value="$(arg serialport)" />
  </include>  
  
  <arg name="scan_topic"              default="scan"/>
  <arg name="cmd_vel_topic"           default="/teleop/cmd_vel"/>
  <arg name="compressed_image_topic"  default="/teleop/compressed_image"/>
  
  <include file="$(find turtlebot_bringup)/launch/3dsensor.launch">
    <arg name="rgb_processing" value="false" />
    <arg name="depth_registration" value="false" />
    <arg name="depth_processing" value="false" />
  </include>

  <!-- Make a slower camera feed available. -->
  <!-- *********************** Teleoperation ********************** -->
  <param name="camera/rgb/image_color/compressed/jpeg_quality" value="22"/>
  <!-- 
  <node pkg="topic_tools" type="throttle" name="camera_throttle" args="messages camera/rgb/image_rect_color/compressed 5"/>
  -->
  
  <node pkg="nodelet" type="nodelet" name="teleop_velocity_smoother"
        args="load yocs_velocity_smoother/VelocitySmootherNodelet /mobile_base_nodelet_manager">
    <rosparam file="$(find turtlebot_bringup)/param/defaults/smoother.yaml" command="load"/>
    <remap from="teleop_velocity_smoother/raw_cmd_vel" to="$(arg cmd_vel_topic)"/>
    <remap from="teleop_velocity_smoother/smooth_cmd_vel" to="/cmd_vel_mux/input/teleop"/>

    <!-- Robot velocity feedbacks; use the one configured as base default -->
    <remap from="teleop_velocity_smoother/odometry"       to="/odom"/>
    <remap from="teleop_velocity_smoother/robot_cmd_vel"  to="/mobile_base/commands/velocity"/>
  </node>

  <!-- *********************** Optimisation *********************** -->
  <node pkg="tf" type="tf_change_notifier" name="tf_throttle_for_android_gui">
    <param name="polling_frequency"             value="5"/>
    <param name="translational_update_distance" value="-1"/>
    <param name="angular_update_distance"       value="-1"/>
    <rosparam param="frame_pairs">
      - {source_frame: base_footprint, target_frame: map}
      - {source_frame: camera_depth_frame, target_frame: map}
    </rosparam>
  </node>


  <!-- *************************** Navi *************************** -->
  <include file="$(find turtlebot_navigation)/launch/includes/move_base.launch.xml">
    <arg name="odom_topic" value ="/odom" />
  </include>
  <include file="$(find turtlebot_navigation)/launch/includes/amcl.launch.xml">
    <arg name="use_map_topic" value ="true"/>
  </include>
  
  <!--
  <node pkg="topic_tools" type="throttle" name="relay_compressed_throttle_image" args="messages camera/rgb/image_rect_color/compressed_throttle 5 $(arg compressed_image_topic)" required="true">
    <param name="lazy" value="false"/>
  </node>
  -->
  
  <node pkg="topic_tools" type="throttle" name="relay_scan" args="messages scan 5 $(arg scan_topic)" required="true">
    <param name="lazy" value="false"/>
  </node>

  <!-- Maps -->
  <arg name="map_file" default=" $(env TURTLEBOT_MAP_FILE)" />
  <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />


<!--  <node pkg="map_store" type="map_manager" name="map_manager" output="screen"/>-->

  <!-- World Canvas -->
  <arg name="debug" default="false"/>
  <node pkg="world_canvas_server" type="world_canvas_server" name="world_canvas_server" args="$(arg debug)" output="screen">
    <param name="start_map_manager" value="true"/>
    <param name="auto_save_map" value="false"/>
  </node> 
</launch>


2
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:160698次
    • 积分:1741
    • 等级:
    • 排名:千里之外
    • 原创:28篇
    • 转载:1篇
    • 译文:0篇
    • 评论:62条