操作系统:ubuntu16.04
ROS版本:kinetic
Gazebo版本:7.0.0
mkdir -p ~/racecar_ws/src
cd ~/racecar_ws/src
catkin_init_workspace
git clone https://github.com/xmy0916/racecar.git
cd ..
catkin_make
echo "source ~/racecar_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
roslaunch racecar_gazebo racecar_runway.launch
新建终端
cd racecar_ws/
roslaunch racecar_gazebo slam_gmapping.launch
保存地图的路径:/racecar_ws/src/racecar/racecar_gazebo/map
cd ~/racecar_ws/src/racecar/racecar_gazebo/map
rosrun map_server map_saver -f map_racecar
分析:在控制小车运动时,小车很容易翻车。不过最终能运行完地图。
新建终端
cd racecar_ws/
roslaunch racecar_gazebo racecar_runway_navigation.launch
新建终端:
cd racecar_ws/
roslaunch racecar_gazebo racecar_rviz.launch
新建终端
cd racecar_ws/
rosrun racecar_gazebo path_pursuit.py
gazebo
roslaunch racecar_gazebo racecar.launch
点击insert—>track,即可将跑道模型拖到小车模型中。注意:将小车放到适当的位置。
cd racecar_ws/src/racecar/racecar_gazebo/launch
touch mycar.launch
gedit mycar.launch
写入如下代码:
<?xml version="1.0"?>
<launch>
<!-- Launch the racecar -->
<include file="$(find racecar_gazebo)/launch/racecar.launch">
<arg name="world_name" value="mycar"/>
</include>
</launch>
roslaunch racecar_gazebo mycar.launch
roslaunch racecar_gazebo slam_gmapping.launch
控制小车跑一圈地图,建好的地图如下:
新建终端,保存gmapping创建的地图
cd racecar_ws/src/racecar/racecar_gazebo/map
rosrun map_server map_saver -f mycar_map
cd racecar_ws/src/racecar/racecar_gazebo/launch/
touch mycar1.launch
gedit mycar1.launch
并写入以下代码:
<?xml version="1.0"?>
<launch>
<!-- Launch the racecar -->
<include file="$(find racecar_gazebo)/launch/racecar.launch">
<arg name="world_name" value="mycar"/>
</include>
<!-- Launch the built-map -->
<node name="map_server" pkg="map_server" type="map_server" args="$(find racecar_gazebo)/map/mycar_map.yaml" />
<!--Launch the move base with time elastic band-->
<param name="/use_sim_time" value="true"/>
<node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen">
<rosparam file="$(find racecar_gazebo)/config/costmap_common_params.yaml" command="load" ns="global_costmap" />
<rosparam file="$(find racecar_gazebo)/config/costmap_common_params.yaml" command="load" ns="local_costmap" />
<rosparam file="$(find racecar_gazebo)/config/local_costmap_params.yaml" command="load" />
<rosparam file="$(find racecar_gazebo)/config/global_costmap_params.yaml" command="load" />
<rosparam file="$(find racecar_gazebo)/config/teb_local_planner_params.yaml" command="load" />
<param name="base_global_planner" value="global_planner/GlobalPlanner" />
<param name="planner_frequency" value="0.01" />
<param name="planner_patience" value="5.0" />
<!--param name="use_dijkstra" value="false" /-->
<param name="base_local_planner" value="teb_local_planner/TebLocalPlannerROS" />
<param name="controller_frequency" value="5.0" />
<param name="controller_patience" value="15.0" />
<param name="clearing_rotation_allowed" value="false" />
</node>
</launch>
roslaunch racecar_gazebo mycar1.launch
roslaunch racecar_gazebo racecar_rviz.launch
rosrun racecar_gazebo path_pursuit.py
通过这次实验很好的对ROS下智能车的仿真实验的完成,用仿真功能包自带的地图很好的能跑出来,而且能够用2D Nav Goal发布目标来实现智能车的自主定位,但在用自己所建的赛道时,用键盘确实能完成跑道,但在用2D Nav Goal发布目标实现智能车的自主定位,小车容易打滑,而且在遇到障碍物时,有时会发生侧翻现象。可能是相关代码还不够完善吧。不过最终还是跑出来了。注意事项:在构建地图时要注意地图尺寸大小,如果不合适,将会影响下车的导航,就会一直卡在某一个障碍物的前面。