【嵌入式应用13】ROS智能车定位导航仿真

【嵌入式应用13】ROS智能车定位导航仿真

(原赛道自主导航,构建地图再导航)

1.初始化
mkdir -p ~/zjp/racecar_ws/src
cd zjp/racecar_ws/src
catkin_init_workspace

image-20200705212110274

2.克隆 racecar 源代码包并编译
git clone https://github.com/xmy0916/racecar.git
cd ..

修改racecar_gazebo/CMakeLists.txt的opencv路径为自己的opencv build文件夹路径。

image-20200705213030084

catkin_make

【嵌入式应用13】ROS智能车定位导航仿真_第1张图片

加入环境变量:

image-20200705213539939

3.自己绘制模型
gazebo

绘制如下图:

【嵌入式应用13】ROS智能车定位导航仿真_第2张图片

4.构建world

运行小车模型,加入自己的模型,保存为world。

roslaunch racecar_gazebo racecar.launch 

构建如下图:
【嵌入式应用13】ROS智能车定位导航仿真_第3张图片

保存在racecar_ws/src/racecar_gazebo/worlds:

【嵌入式应用13】ROS智能车定位导航仿真_第4张图片

5.绘制地图

新建myworld.launch

cd racecar/racecar_gazebo/launch
sudo touch myworld.launch

添加以下代码:


<launch>
  
  <include file="$(find racecar_gazebo)/launch/racecar.launch">
    <arg name="world_name" value="zjp"/>
  include>
launch>

【嵌入式应用13】ROS智能车定位导航仿真_第5张图片

roslaunch racecar_gazebo myWorld.launch
roslaunch racecar_gazebo slam_gmapping.launch 

速度不宜过快,小心翻车重来~~~

下面是绘制好地图:

6.保存地图
cd racecar/racecar_gazebo/map
rosrun map_server map_saver -f zjpmap_map

【嵌入式应用13】ROS智能车定位导航仿真_第6张图片

7.自主导航

修改racecar/racecar_gazebo/launch/autocar.launch:


<launch>
  
  <include file="$(find racecar_gazebo)/launch/racecar.launch">
 <arg name="world_name" value="zjp3"/>
  include>
  
  
  <node name="map_server" pkg="map_server" type="map_server" args="$(find racecar_gazebo)/map/mycar_map.yaml" />

  
  <param name="/use_sim_time" value="true"/>
<node name="map_server" pkg="map_server" type="map_server" args="$(find racecar_gazebo)/map/zjpmap_map.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="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 autocar.launch 
roslaunch racecar_gazebo racecar_rviz.launch

【嵌入式应用13】ROS智能车定位导航仿真_第7张图片

开启自主导航:

rosrun racecar_gazebo path_pursuit.py

【嵌入式应用13】ROS智能车定位导航仿真_第8张图片

小车自动行驶到指定位置,实验结束。

你可能感兴趣的:(嵌入式应用)