赞
踩
ROS中阶笔记(八):机器人SLAM与自主导航—机器人自主导航
其中白色框内的是ROS已经为我们准备好的必须使用的组件,灰色框内的是ROS中可选的组件,蓝色的是用户需要提供的机器人平台上的组件。
$ sudo apt-get install ros-kinetic-navigation
1、全局路径规划(global planner)
2、本地实时规划(local planner)
参数含义请参考:http://wiki.ros.org/move_base
mbot_navigation/launch/move_base.launch来启动move_base 节点。
<launch>
<node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen" clear_params="true">
<rosparam file="$(find mbot_navigation)/config/mbot/costmap_common_params.yaml" command="load" ns="global_costmap" />
<rosparam file="$(find mbot_navigation)/config/mbot/costmap_common_params.yaml" command="load" ns="local_costmap" />
<rosparam file="$(find mbot_navigation)/config/mbot/local_costmap_params.yaml" command="load" />
<rosparam file="$(find mbot_navigation)/config/mbot/global_costmap_params.yaml" command="load" />
<rosparam file="$(find mbot_navigation)/config/mbot/base_local_planner_params.yaml" command="load" />
</node>
</launch>
http://wiki.ros.org/amcl
蓝色点是根据概率算法来估算机器人的位置,蓝色点越密集的地方,说明机器人在这个位置概率越高
具体算法可参考:《概率机器人》
mbot_navigation/launch/amcl.launch来启动amcl功能包
<launch> <arg name="use_map_topic" default="false"/> <arg name="scan_topic" default="scan"/> <node pkg="amcl" type="amcl" name="amcl" clear_params="true"> <param name="use_map_topic" value="$(arg use_map_topic)"/> <!-- Publish scans from best pose at a max of 10 Hz --> <param name="odom_model_type" value="diff"/> <param name="odom_alpha5" value="0.1"/> <param name="gui_publish_rate" value="10.0"/> <param name="laser_max_beams" value="60"/> <param name="laser_max_range" value="12.0"/> <param name="min_particles" value="500"/> <param name="max_particles" value="2000"/> <param name="kld_err" value="0.05"/> <param name="kld_z" value="0.99"/> <param name="odom_alpha1" value="0.2"/> <param name="odom_alpha2" value="0.2"/> <!-- translation std dev, m --> <param name="odom_alpha3" value="0.2"/> <param name="odom_alpha4" value="0.2"/> <param name="laser_z_hit" value="0.5"/> <param name="laser_z_short" value="0.05"/> <param name="laser_z_max" value="0.05"/> <param name="laser_z_rand" value="0.5"/> <param name="laser_sigma_hit" value="0.2"/> <param name="laser_lambda_short" value="0.1"/> <param name="laser_model_type" value="likelihood_field"/> <!-- <param name="laser_model_type" value="beam"/> --> <param name="laser_likelihood_max_dist" value="2.0"/> <param name="update_min_d" value="0.25"/> <param name="update_min_a" value="0.2"/> <param name="odom_frame_id" value="odom"/> <param name="resample_interval" value="1"/> <!-- Increase tolerance because the computer can get quite busy --> <param name="transform_tolerance" value="1.0"/> <param name="recovery_alpha_slow" value="0.0"/> <param name="recovery_alpha_fast" value="0.0"/> <remap from="scan" to="$(arg scan_topic)"/> </node> </launch>
执行以下命令:
$ cd ~/catkin_ws/src
$ git clone https://github.com/pirobot/rbx1.git
$ cd rbx1 # ~/catkin_ws/src/rbx1
$ git checkout indigo-devel
$ cd ~/catkin_ws
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash
$ rospack profile # 加入ROS package路径
如果这个package的代码后来更新了,需要执行以下代码:
$ cd ~/catkin_ws/src/rbx1
$ git pull
$ cd ~/catkin_ws
$ catkin_make
$ source ~/catkin_ws/devel/setup.bash
rviz+arbotix来进行仿真,实现ROS功能包算法的功能。
分别在四个终端下面运行这四个命令:
roslaunch rbx1_bringup fake_turtlebot.launch #启动机器人,ArbotiX节点,加载机器人的URDF文件
roslaunch rbx1_nav fake_move_base_map_with_obstacles.launch # 启动导航节点
rosrun rviz rviz -d 'rospack find rbx1_nav'/nav_obstacles.rviz # 启动rviz
rosrun rbx1_nav move_base_square.py # 启动历程
ERROR: cannot launch node of type [arbotix_python/arbotix_driver]: arbotix_python
ROS path [0]=/opt/ros/kinetic/share/ros
ROS path [1]=/home/ggk/ORB_SLAM2/Examples/ROS/ORB_SLAM2
ROS path [2]=/home/ggk/catkin_ws/src
ROS path [3]=/opt/ros/kinetic/share
解决方法:https://answers.ros.org/question/243919/cannot-launch-node-of-type-arbotix_pythonarbotix_driver-arbotix_python/
1、检查是否安装 arbotix_python package
roscd arbotix_python
2、安装 arbotix_python
方法一:不推荐
sudo apt-get install ros-kinetic-arbotix-*
方法二:推荐
cd ~/catkin_ws/src
git clone https://github.com/vanadiumlabs/arbotix_ros.git
cd ~/catkin_ws
catkin_make
source ~/catkin_ws/devel/setup.bash
ERROR: cannot launch node of type [arbotix_python/arbotix_driver]: can't locate node [arbotix_driver] in package [arbotix_python]
说明:
安装 arbotix_python,用方法一不行,无法启动节点,因此应该用方法二
roslaunch mbot_gazebo mbot_laser_nav_gazebo.launch # 启动仿真环境
roslaunch mbot_navigation nav_cloister_demo.launch # 启动导航节点
2D Nav Goal来选择目标点,点击左键,来选择一个目标姿态。
2D Pose Estimate调整机器人的位姿,
绿色线:全局规划
红色线:局部规划
前面通过各种功能包来完成SLAM功能,通过导航机器人到达目标点的路径规划;
接下来,把SLAM和导航结合起来:
在导航的过程当中,不断的自主的去探索未知的环境,最终来完成地图的构建;
roslaunch mbot_gazebo mbot_laser_nav_gazebo.launch # 启动仿真环境
roslaunch mbot_navigation exploring_slam_demo.launch # 启动SLAM+导航的节点
# 机器人一边导航,一变建图
完全自主在环境当中做运动,去把整个地图构建起来;
roslaunch mbot_gazebo mbot_laser_nav_gazebo.launch
roslaunch mbot_navigation exploring_slam_demo.launch
rosrun mbot_navigation exploring_slam.py # 控制机器人运动,完成地图构建
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。