1》准备导航所需要的包。
a.ros-indigo-gampping :我们不需要修改包内的东西,所以直接安装可执行文件就好了。
sudo apt-get install ros-indigo-slam-gmapping
b.安装雷达的驱动(我的是robopack),直接将提供的ros驱动包拷贝到工作空间中,
c.安装导航定位包,navigation 进入git:https://github.com/ros-planning/navigation/tree/indigo-devel,下载和自己ros版本匹配的包,解压到自己的工作空间中,
cd ~/catkin_ws
catkin_make
indigo的navigation包会出现一个依赖问题,:Orocos-bfl not found while installing navigation stack ROS indigo + Ubuntu 14.04
解决方法:
rosdep install --from-paths src --ignore-src --rosdistro indigo -y
d.由于导航包在/cmd_val下发布的移动数据加速度会过于不友好,所以我们需要对速度做平滑处理,其实就是控制加速,一般通过滤波即可实现,在此我们采用turtlebot的平滑包即可,
安装平滑包yocs_velocity_smoother,具体的平滑算法和输入切换请自己阅读源码。
apt-get install ros-indigo-yocs-velocity-smoother
所有的包准包好后,我们去准备启动所需的launch文件,首先是机器人地盘的启动文件base_controller.launch:
"use_sim_time" value="false" /> "link_laser" pkg="tf" type="static_transform_publisher" args="0.15 0 0.15 0 0 0 base_link laser 50"/> "link_footprint" pkg="tf" type="static_transform_publisher" args="0 0 0 0 0 0 base_link base_footprint 50"/> "odom_tf_package" type="tf_broadcaster_node" name="serial_send_recevice" output="screen"/> "$(find odom_tf_package)/launch/include/rplidar_ros.launch.xml">
"node_name" value="velocity_smoother"/> "nodelet_manager_name" value="nodelet_manager"/> "config_file" value="$(find odom_tf_package)/config/yocs_velocity_smoother.yaml"/> "raw_cmd_vel_topic" value="cmd_vel"/> "smooth_cmd_vel_topic" value="smoother_cmd_vel"/> "robot_cmd_vel_topic" value="robot_cmd_vel"/> "odom_topic" value="odom"/> "nodelet" type="nodelet" name="$(arg nodelet_manager_name)" args="manager"/> "$(find yocs_velocity_smoother)/launch/velocity_smoother.launch"> "node_name" value="$(arg node_name)"/> "nodelet_manager_name" value="$(arg nodelet_manager_name)"/> "config_file" value="$(arg config_file)"/> "raw_cmd_vel_topic" value="$(arg raw_cmd_vel_topic)"/> "smooth_cmd_vel_topic" value="$(arg smooth_cmd_vel_topic)"/> "robot_cmd_vel_topic" value="$(arg robot_cmd_vel_topic)"/> "odom_topic" value="$(arg odom_topic)"/>
2.然后去准备建图包的启动文件gmapping.launch
"scan_topic" default="scan" /> "gmapping" type="slam_gmapping" name="slam_gmapping" output="screen" clear_params="true"> "odom_frame" value="/odom""/> "map_update_interval" value="30.0"/> "maxRange" value="5.0"/> "maxUrange" value="4.5"/> "sigma" value="0.05"/> "kernelSize" value="1"/> "lstep" value="0.05"/> "astep" value="0.05"/> "iterations" value="5"/> "lsigma" value="0.075"/> "ogain" value="3.0"/> "lskip" value="0"/> "srr" value="0.01"/> "srt" value="0.02"/> "str" value="0.01"/> "stt" value="0.02"/> "linearUpdate" value="0.5"/> "angularUpdate" value="0.436"/> "temporalUpdate" value="-1.0"/> "resampleThreshold" value="0.5"/> "particles" value="80"/> "xmin" value="-1.0"/> "ymin" value="-1.0"/> "xmax" value="1.0"/>
3,导航包(move_base)和定位(amcl)的启动文件:savvy_amcl.launch
"use_sim_time" value="false" /> "map" default="map.yaml" /> "map_server" pkg="map_server" type="map_server" args="$(find savvy)/maps/$(arg map)"/> "$(find savvy)/launch/move_base_amcl.launch" /> "$(find savvy)/launch/tb_amcl.launch" />
move_base_amcl.launch:
"move_base" type="move_base" respawn="false" name="move_base" output="screen" clear_params="true"> "$(find savvy)/config/savvyconfig/costmap_common_params.yaml" command="load" ns="global_costmap" /> "$(find savvy)/config/savvyconfig/costmap_common_params.yaml" command="load" ns="local_costmap" /> "$(find savvy)/config/savvyconfig/local_costmap_params.yaml" command="load" /> "$(find savvy)/config/savvyconfig/global_costmap_params.yaml" command="load" /> "$(find savvy)/config/savvyconfig/base_local_planner_params.yaml" command="load" /> "$(find savvy)/config/nav_obstacles_params.yaml" command="load" />
tb_amcl.launch:
"use_map_topic" default="false"/> "scan_topic" default="scan"/> "amcl" type="amcl" name="amcl" clear_params="true"> "use_map_topic" value="$(arg use_map_topic)"/> "odom_model_type" value="diff"/> "odom_alpha5" value="0.1"/> "gui_publish_rate" value="10.0"/> "laser_max_beams" value="60"/> "laser_max_range" value="12.0"/> "min_particles" value="500"/> "max_particles" value="2000"/> "kld_err" value="0.05"/> "kld_z" value="0.99"/> "odom_alpha1" value="0.2"/> "odom_alpha2" value="0.2"/> "odom_alpha3" value="0.2"/> "odom_alpha4" value="0.2"/> "laser_z_hit" value="0.5"/> "laser_z_short" value="0.05"/> "laser_z_max" value="0.05"/> "laser_z_rand" value="0.5"/> "laser_sigma_hit" value="0.2"/> "laser_lambda_short" value="0.1"/> "laser_model_type" value="likelihood_field"/> "laser_likelihood_max_dist" value="2.0"/> "update_min_d" value="0.25"/> "update_min_a" value="0.2"/> "odom_frame_id" value="odom"/> "resample_interval" value="1"/> "transform_tolerance" value="1.0"/> "recovery_alpha_slow" value="0.0"/>
4.导航的配置参数如下:
base_local_planner_params.yaml
controller_frequency: 2.0
recovery_behavior_enabled: false
clearing_rotation_allowed: false TrajectoryPlannerROS: max_vel_x: 0.3 min_vel_x: 0.05 max_vel_y: 0.0 # zero for a differential drive robot min_vel_y: 0.0 min_in_place_vel_theta: 0.5 escape_vel: -0.1 acc_lim_x: 2.5 acc_lim_y: 0.0 # zero for a differential drive robot acc_lim_theta: 3.2 holonomic_robot: false yaw_goal_tolerance: 0.1 # about 6 degrees xy_goal_tolerance: 0.15 # 10 cm latch_xy_goal_tolerance: false pdist_scale: 0.8 gdist_scale: 0.6 meter_scoring: true heading_lookahead: 0.325 heading_scoring: false heading_scoring_timestep: 0.8 occdist_scale: 0.1 oscillation_reset_dist: 0.05 publish_cost_grid_pc: false prune_plan: true sim_time: 2.5 sim_granularity: 0.025 angular_sim_granularity: 0.025 vx_samples: 8 vy_samples: 0 # zero for a differential drive robot vtheta_samples: 20 dwa: true simple_attractor: false
costmap_common_params.yaml
obstacle_range: 2.5
raytrace_range: 3.0
robot_radius: 0.30 inflation_radius: 0.15 max_obstacle_height: 0.6 min_obstacle_height: 0.0 observation_sources: scan scan: {data_type: LaserScan, topic: /scan, marking: true, clearing: true, expected_update_rate: 0}
global_costmap_params.yaml
global_costmap:
global_frame: /map
robot_base_frame: /base_link
update_frequency: 1.0
publish_frequency: 0 static_map: true rolling_window: false resolution: 0.01 transform_tolerance: 0.5 map_type: costmap
local_costmap_params.yaml
local_costmap:
global_frame: /odom
robot_base_frame: /base_link
update_frequency: 1.0
publish_frequency: 1.0 static_map: false rolling_window: true width: 6.0 height: 6.0 resolution: 0.01 transform_tolerance: 0.5 map_type: costmap
四,准备好以上所有的启动文件和配置参数后,我们开始创建地图和导航,
1.创建地图:
roslaunch savvy base_controller.launch //启动地盘控制器
roslaunch savvy gmapping.launch
roscd savvy/maps/
rosrun map_server map_saver -f mymap
然后会产生以下地图文件
mymap.pgm mymap.yaml
2.开始导航
roslaunch savvy base_controller.launch //启动地盘控制器
roslaunch savvy savvy_amcl.launch map:=mymap.yaml
rosrun rviz rviz -d `rospack find savvy`/nav_test.rviz
然后指定导航目标,开始自己慢慢玩吧,不过因为我的TF变换主要是里程计更新的,车体打滑或者地盘电机震荡都会积累误差,所以我们必须添加视觉里成计或者闭环检测。