This rep based on Linux System: Ubuntu18.04 & ROS melodic version.
This rep stores the source code for Smart Car simulation.
-
More information please check at '赛道和无人车三维模型.zip' file.
-
Click Preparation for details about preparatory work.
-
Click Beginner Tutorial for framework of this project and some guidence.
-
Simple Project is the source code of Beginner Tutorial.
More tutorials are as follow:
[注意!] 有问题建议先查ROS wiki, 国内博客「古月居」也是个很好的参考
友链
- Racecar References:Hypha-ROS/hypharos_racecar
- AMCL:amcl - ROS Wiki amcl - CSDN
- Global planner: global_planner - ROS Wiki
- TEB local planner:teb_local_planner - ROS Wiki Reference1 and Reference2
- DWA local planner:dwa_local_planner - ROS Wiki Reference
- TF:TF transfrom - CSDN
[注意!]
以下四步涉及的功能包为racecar_using_gazebo_odom压缩包,非racecar!!
(以下步骤为基本测试流程,使用gazebo_linkstate直接获取odometry信息,可以跑下全程时间在1分钟左右)
gedit ~/.bashrc
编辑后source
source ~/.bashrc
roslaunch racecar_gazebo racecar.launch
roslaunch racecar_gazebo racecar_rviz.launch
载入move_base相关配置,启动map_server
roslaunch racecar_gazebo racecar_runway_navigation.launch
启动 rviz+gazbo+navigation
roslaunch racecar_gazebo racecar_rviz_navigation.launch
启动纯追踪算法
rosrun racecar_gazebo path_pursuit.py
-
由于赛方要求不能直接使用gazebo_linkstate得到的odometry信息,因此此方案添加由rf2o包中laser生成的odometry进行/odom信息发布
-
需要将rf2o_laser_odometry放在racecar同目录下(自己工作路径的/src下)
(1)在终端中使用如下代码一键安装相关依赖
rosdep install --from-paths src --ignore-src -r -y
(2)转到工作空间下进行catkin_make
catkin_make
-
添加robot_pose_ekf-master放在racecar同目录下(自己工作路径的/src下)
已写入相关launch文件中,直接启动下面两个launch文件即可
roslaunch racecar_gazebo racecar_runway_navigation.launch
roslaunch racecar_gazebo racecar_rviz_navigation.launch
-
为方便比赛时一键启动,统一添加至run_all.launch
roslaunch racecar_gazebo run_all.launch
检查是否缺少相关组件,模型需要通过joint-state-publisher-gui获取当前车轮位置信息
安装gui模块:
sudo apt-get install ros-melodic-joint-state-publisher-gui
CMake Error at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:83 (find_package): Could not find a package configuration file provided by “OpenCV” with any of the following names:
OpenCVConfig.cmake
opencv-config.cmake
解决方法:
-
定位OpenCV安装位置(melodic默认在/usr/share/OpenCV/)得到你的opencv的路径
(尽量选择ROS自带的OpenCV,一般是放在/usr/share/OpenCV/文件目录下)
locate OpenCVConfig.cmake
- 修改racecar_gazebo下的CMakeLists.txt文件
gedit ~/racecar_ws/src/racecar_gazebo/CMakeLists.txt
set(OpenCV_DIR /usr/share/OpenCV/)
- /odom节点需要在amcl中进行配置(odom->base_footprint的tf变换)
- racecar.urdf.xacro文件中小车模型基准是base_footprint而非base_link,需要在对应文件中更改
grep -r base_link
在对应工作空间/src下用上述终端命令可查找和base_link相关文件及其路径(system中对应base_frame中的base_link也需要改为base_footprint,不要改tf树!!!不要改urdf!!!)
将/pf/pose/odom改为/vesc/odom暂时可行(供测试使用)
自己使用时需要将odom话题改为自己需要使用的odom话题
参考博客内容进行amcl配置
(1)map 和 odom 与 base_footprint 之间tf树均连通,但呈并列关系
修改 gazebo_odometry.py 文件中 cmd.header.frame_id 信息,使map - odom - base_footprint连通
错误如下:
正确tf树:
-
[注意!]
遇到rf2o无法编译问题的解决方法:
将laser_pose = laser_pose + pose_aux_2D改为
laser_pose = laser_pose + poses::CPose3D(pose_aux_2D)
### 说明
- 本包采用的小车模型为阿卡曼汽车模型,若采用差速小车模型需要自行更改
- 本包控制器为自行编写的解算控制过程,可能会有点乱😂有需要自行调整