瞬驰(Dash)D1开发手册--Raspberry Pi之ROS空间的创建

上一节,我们已经在Raspberry Pi上安装了ROS系统。这一节,我们来学习下如何构建ROS工作空间。

创建工作空间和ROS包

  • 创建工作空间目录
mkdir  ~/catkin_ws/src
  • 下载ros_arduino_bridge包,用于和下位机通讯,控制底盘的移动。
git clone https://github.com/hbrobotics/ros_arduino_bridge.git
cd ros_arduino_bridge
git checkout indigo-devel
  • 创建dashgo_bringup包
cd ~/catkin_ws/src
catkin_create_pkg dashgo_bringup std_msgs rospy roscpp
cd ~/catkin_ws/src/dashgo_bringup
mkdir  launch script config
  • 编译软件包
cd ~/catkin_ws
catkin_make

修改配置

  • 添加ros_arduino_python配置文件 ~/catkin_ws/src/rdashgo_bringup/config/my_arduino_params.yaml ,内容如下:
port: /dev/ttyACM0
baud: 115200
timeout: 0.1

rate: 50 sensorstate_rate: 10 use_base_controller: True base_controller_rate: 10 # For a robot that uses base_footprint, change base_frame to base_footprint base_frame: base_link # === Robot drivetrain parameters wheel_diameter: 0.12 wheel_track: 0.35 encoder_resolution: 900 gear_reduction: 1.0 motors_reversed: False # === PID parameters Kp: 100 Kd: 0 Ki: 0 Ko: 1000 accel_limit: 0.3 # === Sensor definitions. Examples only - edit for your robot. sensors: { }

创建dashgo的启动文件 ~/catkin_ws/src/dashgo_bringup/launch/minimal.launch,内容如下:

<launch>
   <node name="arduino" pkg="ros_arduino_python" type="arduino_node.py" output="screen> <rosparam file="$(find dashgo_bringup)/config/my_arduino_params.yaml" command="load" />
   </node>

  <arg name="node_name" value="velocity_smoother"/>
  <arg name="nodelet_manager_name" value="nodelet_manager"/>
  <arg name="config_file" value="$(find dashgo_bringup)/config/yocs_velocity_smoother.yaml"/>
  <arg name="raw_cmd_vel_topic" value="cmd_vel"/>
  <arg name="smooth_cmd_vel_topic" value="smooth_cmd_vel"/>
  <arg name="robot_cmd_vel_topic" value="robot_cmd_vel"/>
  <arg name="odom_topic" value="odom"/>

  <!-- nodelet manager -->
  <node pkg="nodelet" type="nodelet" name="$(arg nodelet_manager_name)" args="manager"/>

  <!-- velocity smoother -->
  <include file="$(find yocs_velocity_smoother)/launch/velocity_smoother.launch">
    <arg name="node_name" value="$(arg node_name)"/>
    <arg name="nodelet_manager_name" value="$(arg nodelet_manager_name)"/>
    <arg name="config_file" value="$(arg config_file)"/>
    <arg name="raw_cmd_vel_topic" value="$(arg raw_cmd_vel_topic)"/>
    <arg name="smooth_cmd_vel_topic" value="$(arg smooth_cmd_vel_topic)"/>
    <arg name="robot_cmd_vel_topic" value="$(arg robot_cmd_vel_topic)"/>
    <arg name="odom_topic" value="$(arg odom_topic)"/>
  </include>

</launch>
  • ros_arduino_python监听的速度由”cmd_vel”修改为“smooth_cmd_vel”

环境变量和权限

添加串口访问权限

sudo usermod -a -G dialout pi

时间同步

sudo ntpdate ntp.ubuntu.com

设置ROS环境变量,在~/.bashrc和 ~/.profile分别添加

alias vi='vim'
alias ll='ls -l
source /opt/ros/indigo/setup.bash
source /home/pi/catkin_ws/devel/setup.bash

另外需要安装下vim

sudo apt-get install vim

你可能感兴趣的:(瞬驰(Dash)D1开发手册--Raspberry Pi之ROS空间的创建)