Ubuntu 18.04 | Ros Melodic | Gazebo 9.0.0 |
---|
mkdir -p ~/racecar_ws/src
cd ~/racecar_ws/src
catkin_init_workspace
git clone https://github.com/xmy0916/racecar.git
(控件的安装是防止后面运行不正确,这里一步步安装就好。)
sudo apt-get install ros-melodic-driver-base
sudo apt-get install ros--melodic-gazebo-ros-control
sudo apt-get install ros--melodic-effort-controllers
sudo apt-get install ros--melodic-joint-state-controller
sudo apt-get install ros-melodic-ackermann-msgs
sudo apt-get install ros-melodic-global-planner
sudo apt-get install ros-melodic-teb-local-planner
cd ~/racecar_ws
catkin_make
编译成功如下图所示:
(出现100%,恭喜你很幸运,如果出现问题,本文后面有解决办法!)
echo "source ~/racecar_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
roslaunch racecar_gazebo racecar.launch
Gazebo
,点击Edit->Build Editor,创建模型,保存该模型~/.gazebo/models
,下载模型文件库gazebo_models的方法git clone https://bitbucket.org/osrf/gazebo_models/downloads/
~/.gazebo/models
应该是这样的~/racecar_ws/src/racecar/racecar_gazebo/launch
,并创建mango.launch文件cd ~/racecar_ws/src/racecar/racecar_gazebo/launch
sudo gedit mango.launch
在里面加入如下代码:
source ./devel/setup.bash
roslaunch racecar_gazebo mango.launch
WASD控制 | 运动情况 |
---|---|
W | 前进 |
S | 后退 |
D | 轮子右转,小车不动 |
A | 轮子左转,小车不动 |
A + W | 小车左向前移 |
A + S | 小车右向后移 |
D + W | 小车右向前移 |
D + S | 小车左向后移 |
上面运行的终端不关闭,继续gmapping建图运行
roslaunch racecar_gazebo slam_gmapping.launch
- 我把控制小车转完整圈的整个运行做成了GIF动图上传了上来,可以看见,它运行的很慢,大约8分钟,大家耐心等待!
cd ~/racecar_ws
rosrun map_server map_saver -f mango_car_map
cd ~/racecar_ws/src/racecar/racecar_gazebo/launch
sudo gedit mango_auto.launch
1.手工导航,运行自己创建的赛道
cd ~/racecar_ws
source ./devel/setup.bash
roslaunch racecar_gazebo mango_auto.launch
roslaunch racecar_gazebo racecar_rviz.launch
rosrun racecar_gazebo path_pursuit.py
(根据上面步骤做,不一定会遇见这些问题。)
问题一
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by “driver_base” with
any of the following names:
driver_baseConfig.cmake
driver_base-config.cmake
Add the installation prefix of “driver_base” to CMAKE_PREFIX_PATH or set
“driver_base_DIR” to a directory containing one of the above files. If
“driver_base” provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
racecar/system/hokuyo_node/CMakeLists.txt:13 (find_package)
– Configuring incomplete, errors occurred!
See also “/home/mango/racecar_ws/build/CMakeFiles/CMakeOutput.log”.
See also “/home/mango/racecar_ws/build/CMakeFiles/CMakeError.log”.
Invoking “cmake” failed
解决办法
原因是确少driver_base功能包,安上它就好了
sudo apt-get install ros-melodic-driver-base
然后执行catkin_make编译通过
问题二
CMake Error at /opt/ros/melodic/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
Add the installation prefix of “OpenCV” to CMAKE_PREFIX_PATH or set
“OpenCV_DIR” to a directory containing one of the above files. If “OpenCV”
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
racecar/racecar_gazebo/CMakeLists.txt:8 (find_package)
– Configuring incomplete, errors occurred!
See also “/home/mango/racecar_ws/build/CMakeFiles/CMakeOutput.log”.
See also “/home/mango/racecar_ws/build/CMakeFiles/CMakeError.log”.
Invoking “cmake” failed
解决办法
首先使用指令搜索OpenCVConfig.cmake文件的路径:
进入相关目录编辑catkinConfig.cmake文件
cd /opt/ros/melodic/share/catkin/cmake
sudo gedit catkinConfig.cmake
在find _package
前面添加如下内容
set(OpenCV_DIR /usr/share/OpenCV)
sudo apt-get install ros-melodic-ackermann-msgs
问题四
[gazebo_gui-3] process has died [pid 11595, exit code 137, cmd /opt/ros/melodic/lib/gazebo_ros/gzclient __name:=gazebo_gui __log:=/home/mango/.ros/log/465e242c-bad7-11ea-800b-000c2971498d/gazebo_gui-3.log].
log file: /home/mango/.ros/log/465e242c-bad7-11ea-800b-000c2971498d/gazebo_gui-3*.log
问题五
[gazebo-2] process has died [pid 12735, exit code 255, cmd /opt/ros/melodic/lib/gazebo_ros/gzserver -e ode /home/mango/racecar_ws/src/racecar/racecar_gazebo/worlds/racecar_runway.world __name:=gazebo __log:=/home/mango/.ros/log/1d633998-bad9-11ea-800b-000c2971498d/gazebo-2.log].
log file: /home/mango/.ros/log/1d633998-bad9-11ea-800b-000c2971498d/gazebo-2*.log
(这两个问题可以重启虚拟机试试。)
问题六
ERROR: cannot launch node of type [gmapping/slam_gmapping]: gmapping
ROS path [0]=/opt/ros/melodic/share/ros
ROS path [1]=/home/mango/racecar_ws/src
ROS path [2]=/home/mango/catkin_ws/src
ROS path [3]=/opt/ros/melodic/share
解决办法
也是缺少相关包导致的,执行如下命令安装
sudo apt-get install ros-melodic-gmapping
sudo apt-get install ros-melodic-map-server
sudo apt-get -y install ros-melodic-navigation
本次ROS机器人定位导航仿真结束了,作为物联网小白,肯定有很多不足,希望各位大佬指正,谢谢。