ROS模拟环境导航源码搭建(一) 安装组件
建立项目
tzy@ubuntu:~/ROS_Navigation$ mkdir -p catkin_ws/src tzy@ubuntu:~/ROS_Navigation$ cd catkin_ws/ tzy@ubuntu:~/ROS_Navigation/catkin_ws$ catkin_make
导航组件
下载
tzy@ubuntu:~/ROS_Navigation/catkin_ws$ cd src/ tzy@ubuntu:~/ROS_Navigation/catkin_ws/src$ git clone https://github.com/ros-planning/navigation.git --branch=kinetic-devel
编译
tzy@ubuntu:~/ROS_Navigation/catkin_ws$ cd ../ tzy@ubuntu:~/ROS_Navigation/catkin_ws$ catkin_make ...... [ 96%] Built target carrot_planner [ 96%] Built target rotate_recovery Scanning dependencies of target move_base [ 97%] Building CXX object navigation/move_base/CMakeFiles/move_base.dir/src/move_base.cpp.o [ 98%] Linking CXX shared library /home/tzy/ROS_Navigation/catkin_ws/devel/lib/libdwa_local_planner.so [ 98%] Built target dwa_local_planner [ 98%] Linking CXX shared library /home/tzy/ROS_Navigation/catkin_ws/devel/lib/libmove_base.so [ 98%] Built target move_base Scanning dependencies of target move_base_node [ 98%] Building CXX object navigation/move_base/CMakeFiles/move_base_node.dir/src/move_base_node.cpp.o [100%] Linking CXX executable /home/tzy/ROS_Navigation/catkin_ws/devel/lib/move_base/move_base [100%] Built target move_base_node
Stage模拟环境组件
安装
tzy@ubuntu:~/ROS_Navigation/catkin_ws$ sudo apt-get install ros-kinetic-stage ros-kinetic-stage-ros
下图显示已经安装好了
tzy@ubuntu:~/ROS_Navigation/catkin_ws$ rospack list | grep stage stage /opt/ros/kinetic/share/stage stage_ros /opt/ros/kinetic/share/stage_ros
环境配置
tzy@ubuntu:~/ROS_Navigation/catkin_ws/src$ catkin_create_pkg simbot std_msgs rospy roscpp tzy@ubuntu:~/ROS_Navigation/catkin_ws/src$ catkin_make tzy@ubuntu:~/ROS_Navigation/catkin_ws/src$ source devel/setup.bash tzy@ubuntu:~/ROS_Navigation/catkin_ws/src$ roscd simbot tzy@ubuntu:~/ROS_Navigation/catkin_ws/src/simbot $ mkdir launch param rviz urdf maps
模拟环境配置文件
tzy@ubuntu:~/ROS_Navigation/catkin_ws/src/simbot/maps$ cat simbot.inc define mylaser ranger ( sensor ( range [ 0.1 30.0 ] fov 270 # 激光视野 samples 541 # 激光数量 ) # generic model properties color "blue" size [ 0.06 0.15 0.03 ] ) define mybot position ( pose [ 0.0 0.0 0.0 0.0 ] localization "gps" size [ 0.4 0.4 0.3 ] # 机器人大小 origin [ 0.0 0.0 0.0 0.0 ] gui_nose 1 drive "diff" # 差分 color "red" mylaser(pose [ 0.1 0.0 0.0 0.0 ]) # 激光安装位置,机器人顶部x方向0.1m处 ) tzy@ubuntu:~/ROS_Navigation/catkin_ws/src/simbot/maps$ cat simbot.world include "simbot.inc" define floorplan model ( # sombre, sensible, artistic color "gray30" # most maps will need a bounding box boundary 1 gui_nose 0 gui_grid 0 gui_outline 0 gripper_return 0 fiducial_return 0 laser_return 1 ) resolution 0.05 # 分辨率 interval_sim 100 # simulation timestep in milliseconds window ( size [ 874 1077 ] # pgm像素宽高 center [ 0 0 ] rotate [ 0.000 0.000 ] scale 50 ) floorplan ( name "home" bitmap "./home.pgm" size [ 43.700 53.850 1.000 ] # pgm实际宽高,像素宽高*分辨率 pose [ 21.85 26.925 0.000 0.000 ] # size/2,相当于将地图左下角移到动0 0点 ) # throw in a robot mybot ( pose [ 1 1 0.0 0.0 ] # 机器人摆放位置 name "bot1" )
运行测试
tzy@ubuntu:~/ROS_Navigation/catkin_ws/src/simbot/maps$ rosrun stage_ros stageros simbot.world [Loading simbot.world][Include simbot.inc] warn: worldfile simbot.world:19 : property [laser_return] is defined but not used (/tmp/binarydeb/ros-kinetic-stage-4.1.1/libstage/worldfile.cc WarnUnused) [ INFO] [1638354195.714265559]: Found 1 laser devices and 0 cameras in robot 0
显示如下
tzy@ubuntu:~/ROS_Navigation/catkin_ws$ rostopic list /base_pose_ground_truth /base_scan /clock /cmd_vel /odom /rosout /rosout_agg /tf tzy@ubuntu:~/ROS_Navigation/catkin_ws$ rostopic hz /base_pose_ground_truth subscribed to [/base_pose_ground_truth] WARNING: may be using simulated time average rate: 11.250 min: 0.000s max: 0.200s std dev: 0.07370s window: 10 average rate: 10.000 min: 0.000s max: 0.200s std dev: 0.07255s window: 20 ^Caverage rate: 10.476 min: 0.000s max: 0.200s std dev: 0.07056s window: 23
参考链接
Player Project (sourceforge.net)