地址链接
智能车自主导航
mkdir -p ~/ qianRuShi/racecar_ws/src
cd qianRuShi/racecar_ws/src
catkin_init_workspace
git clone https://github.com/xmy0916/racecar.git
cd ..
catkin_make
sudo apt-get update
sudo apt-get install ros-melodic-driver-base
locate OpenCVConfig.cmake
更改 racecar_gazebo/CMakeLists.txt如下:(截图的最后一行)
set(OpenCV_DIR /home/wangyang/opencv-3.4.1/build)
gedit ~/.bashrc
根据自己的路径,在末尾添加工作空间的环境变量,并保存:
source ~/qianRuShi/racecar_ws/devel/setup.bash
再次运行
source ~/.bashrc
roslaunch racecar_gazebo racecar.launch
roslaunch racecar_gazebo racecar_runway.launch
新建终端
roslaunch racecar_gazebo slam_gmapping.launch
解决方案:镜像下载就行
pip install msg -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
好吧,后来发现不是在python安装,如下安装:
sudo apt-get install ros-melodic-ackermann-msgs
在racecar_ws/src/racecar/racecar_gazebo/scripts的keyboard_teleop.py可以看见
这里还容易翻车,大家注意了,开慢点,翻车了就重新来过
roslaunch racecar_gazebo racecar_runway.launch
roslaunch racecar_gazebo slam_gmapping.launch
你要是顺利完成地图,可以保存起来,后面自主导航用自己的(我尝试过用他的地图,但是莫名其妙的,图出来不了):
保存到racecar_gazebo/map吧,就不用了在移动了
cd racecar/racecar_gazebo/map
rosrun map_server map_saver -f map_racecar
可关闭上面的rviz进程了,然后
修改racecar_runway_navigation.launch文件,更改地图:
roslaunch racecar_gazebo racecar_runway_navigation.launch
sudo apt-get install ros-melodic-teb-local-planner
roslaunch racecar_gazebo racecar_rviz.launch
rosrun racecar_gazebo path_pursuit.py
我原本准备使用的我以前构建的模型,如何创建,请自行百度------gazebo构建模型
发现被我删了,于是自己又搞了一个。
之前的终端都可以ctrl+c了。
roslaunch racecar_gazebo racecar.launch
然后点击左侧的insert,将自己的模型拖进
再加入一些障碍物 Construction Cone(这里以前导入的模型库,没有自行百度,或者不要障碍物就是)
选择File->Save World As,保存到racecar/racecar_gazebo/worlds下:
cd racecar/racecar_gazebo/launch
sudo gedit myWorld.launch
添加下列代码
<?xml version="1.0"?>
<launch>
<!-- Launch the racecar -->
<include file="$(find racecar_gazebo)/launch/racecar.launch">
<arg name="world_name" value="myWorld"/>
</include>
</launch>
重复上面的步骤,终端运行
roslaunch racecar_gazebo myWorld.launch
新建终端运行
roslaunch racecar_gazebo slam_gmapping.launch
cd racecar_ws/src/racecar/racecar_gazebo/map
rosrun map_server map_saver -f mycar_map
在racecar/racecar_gazebo/launch/下
gedit autocar.launch
添加:
<?xml version="1.0"?>
<launch>
<!-- Launch the racecar -->
<include file="$(find racecar_gazebo)/launch/racecar.launch">
<arg name="world_name" value="myworld2"/>
</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 autocar.launch
roslaunch racecar_gazebo racecar_rviz.launch
rosrun racecar_gazebo path_pursuit.py
过程中,遇到了不少问题,但是好在github的源码地址有解决方案,在过程中,可能会有许多网络问题,如github资源下载慢,请参考我的另外一篇文章三步解决github下载慢的问题,另外,apt-get下载慢的话,也自己更换源,阿里,清华的都可以,参考这里。运行中途,小车容易翻车,开车慢点所以,不然要搞很久。更换地图,更换launch文件,一定记得修改相关的文件设置。