Table of contents
1. Installation, configuration and running environment
2. Create a working area and download the source code package
2. Download Gazebo build track function package racecar
3. Install the software packages required for this operation
4. Racecar function package compilation
5. Start the simulation compilation
Start gazebo, run and open the car model
1. Installation, configuration and running environment
Refer to the previous article:
2. Create a working area and download the source code package
1. Create a workspace
First create the ros work area racecar_ws
mkdir -p ~/racecar_ws/src
Change to the working area directory
cd ~/racecar_ws/src
Initialize the current directory as a ROS workspace
catkin_init_workspace
It will create a directory named under the current directory src
and create a CMakeLists.txt file inside it along with an empty package.xml file:
src
The directory is used to store each ROS software package,- The CMakeLists.txt file is used to configure the build system of the workspace
- The package.xml file is used to describe the metadata information of the ROS package.
After executing catkin_init_workspace
the command, you can src
start creating ROS packages in the directory, and then use the Catkin build tool to build and manage these packages.
2. Download Gazebo build track function package racecar
(The code used here is open source on other people's github)
git clone https://github.com/xmy0916/racecar.git
The git access is unstable, the effect is as follows, you need to try a few more times
Cloning into 'racecar'...
fatal: unable to access 'https://github.com/xmy0916/racecar.git/': Failed to connect to github.com port 443: Connection refused
Successfully downloaded:
remote: Enumerating objects: 701, done.
remote: Counting objects: 100% (701/701), done.
remote: Compressing objects: 100% (426/426), done.
remote: Total 701 (delta 252), reused 638 (delta 193), pack-reused 0
Receiving objects: 100% (701/701), 28.23 MiB | 962.00 KiB/s, done.
Resolving deltas: 100% (252/252), done.
After the download is complete, the racecar function package looks like this
3. Install the software packages required for this operation
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
(It is recommended to install in sequence, do not copy all at once)
-
Install the driver-base package in ROS Melodic: Provides some driver interfaces and functions for communication with hardware devices.
sudo apt-get install ros-melodic-driver-base
-
Install the gazebo-ros-control package: Provides an interface and controller to the Gazebo simulation environment to control a robot or robot model in simulation.
sudo apt-get install ros-melodic-gazebo-ros-control
-
Install the effort-controllers package: a number of controllers are provided to control the force or torque of the robot joints.
sudo apt-get install ros-melodic-effort-controllers
-
Install the joint-state-controller package: Provides a controller that publishes messages about the state of the robot's joints.
sudo apt-get install ros-melodic-joint-state-controller
-
Install the ackermann-msgs package: defines the ROS message type for the Ackermann car model.
sudo apt-get install ros-melodic-ackermann-msgs
-
Install the global-planner package: Provides a global path planning algorithm.
sudo apt-get install ros-melodic-global-planner
-
Install the teb-local-planner package: Provides the local path planning function using the Teb local path planner.
sudo apt-get install ros-melodic-teb-local-planner
error 1
run
sudo apt-get install ros--melodic-gazebo-ros-control
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ros—melodic-gazebo-ros-control
correct mistakes
sudo apt update
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
-
Add the APT repository address of the ROS package to
/etc/apt/sources.list.d/ros-latest.list
the file. Specifically, this command will write a line to the file specifying the address of the APT repository for the ROS package. -
Import the key of the ROS package from the specified keyserver. This command will import the key of the ROS package to the system to ensure that the package is officially released by ROS.
-
Update the system's package index.
error 2
E: The repository 'http://ppa.launchpad.net/fkrull/deadsnakes/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
correct mistakes
This error means that this warehouse is not maintained. So we can delete it.
sudo apt-add-repository -r ppa:jonathonf/vim
i.e. remove the PPA repository named "jonathonf/vim" from your system.
4. Racecar function package compilation
cd ~/racecar_ws
catkin_make
report error
solve
Path to search for OpenCVConfig.cmake file
locate OpenCVConfig.cmake
Enter the relevant directory to edit the catkinConfig.cmake file
sudo dedit catkinConfig.cmake
Add the following content in front of find _package
set(OpenCV_DIR /usr/share/OpenCV)
after change
mango@mango-virtual-machine:~/racecar_ws$ catkin_make
Base path: /home/hjx/racecar_ws
Source space: /home/hjx/racecar_ws/src
Build space: /home/hjx/racecar_ws/build
Devel space: /home/hjx/racecar_ws/devel
Install space: /home/hjx/racecar_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/hjx/racecar_ws/build"
####
####
#### Running command: "make -j1 -l1" in "/home/hjx/racecar_ws/build"
####
[ 5%] Built target serial
[ 8%] Built target serial_example
[ 8%] Built target _ackermann_msgs_generate_messages_check_deps_AckermannDriveStamped
[ 8%] Built target std_msgs_generate_messages_py
[ 8%] Built target _ackermann_msgs_generate_messages_check_deps_AckermannDrive
[ 12%] Built target ackermann_msgs_generate_messages_py
[ 12%] Built target std_msgs_generate_messages_lisp
5. Start the simulation compilation
echo "source ~/racecar_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
-
Append this
source ~/racecar_ws/devel/setup.bash
line of command to~/.bashrc
the file.setup.bash
The file is the configuration file of the ROS workspace, this command will ensure that the ROS workspace is loaded every time the terminal is started. -
Reload
~/.bashrc
the file so that the terminal session can access the configuration of the ROS workspace.
Start gazebo, run and open the car model
roslaunch racecar_gazebo racecar.launch