This is a simple tutorial walking through how to start a Gazebo simulation of Marvin, controlled via the keyboard.
It assumes that marvin_gazebo, marvin_control, marvin_description
are in your catkin workspace
It works on Windows via WSL 2 (Ubuntu) or on Pop!_OS and MacOS.
The repository is divided into the following parts:
- Docker: Dockerfile and automation scripts related to it are located in the root of the directory
- source: This directory is mounted as a catkin workspace to the Docker container, inside of it are the files required for running the robot.
In the source
folder the structure is the following:
- marvin_description: Contains different models of the robot and launch files for showing them in rviz
- marvin_gazebo: Used for launching the gazebo simulation environment and storage of Gazebo worlds
- marvin_control: Different types of steering and their launch files. Simulation is launched in Gazebo
- marvin_plan: Functionalities related to planning
Each directory has its own README file that explains how it works.
If you are new to Docker, there is a simple tutorial available here or here. In the case of wanting to run GUI programs, follow this tutorial.
The Dockerfile contains everything that is required for running a ROS environment inside a container. We have provided convenience scripts for launching a container and building the images. The container my_ros
is launched with 2 volumes attached to it: config, source
. The config
volume contains very bare-bones configuration files for using tmux inside the ROS container, another thing it contains is a bashrc
file that source the catkin workspace and ros functionalities.
Furthermode, there are these convenience scripts:
- build.sh: builds the Docker container with image name
my_ros
- run.sh: launches the container with required arguments, main important detail is support for display output. This allows for running graphical programs such as
rviz, Gazebo, rqt
. In the case of there being another container with namemy_ros
, it deletes the old one and launches a new one. - connect.sh: in case there is a need to use a second terminal screen, you can use this script to join to the container. As mentioned above, tmux is installed in the container.
- Erik: Worked on the docker container and ensured that all required packages are present in Dockerfile. Helped with debugging issues around GUI support.
- Jonas: Automation scripts for the Dockerfile and for downloading Docker. Ensured that GUIs work on Windows.
- Milan: Used a virtual machine.
- Kirill: Used a virtual machine.
-
Build the docker image by running
./build.sh
-
To create and run the
my_ros
container, run the script:./run.sh
Note: This will stop and recreate the container, if it already exists.
-
Initialize and build the project by running the following commands:
cd ~/catkin_ws/ sudo catkin build source ./devel/setup.bash
-
Run gazebo, rviz and topic publisher using
roslaunch marvin_control marvin_skid_teleop.launch
or
roslaunch marvin_ackermann_gazebo_control marvin_ackermann_gazebo_control.launch
This will start...
- rviz which will show the positions of the robot in real time
- gazebo which will be running the simulation
- publishing to topic
marvin/cmd_vel
-
Now you need a second terminal instance for running teleop control, either via a TMUX session or by opening a new terminal and running:
./connect.sh
-
To initialize the second terminal, you don't need to rebuild, just run:
cd ~/catkin_ws/ source ./devel/setup.bash
-
To start the teleop control, run:
rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:=/marvin/cmd_vel
You will know this is successfull if you see small table with explanations for control of the vehicle.
or
-
For starting the movement planner, run:
# Uses topics from skid steering rosrun marvin_plan hermit_curves_movement.py
-
Open a new terminal, and navigate to the source folder, and run.
catkin build source devel/setup.bash
-
Start publishing commands for movement.
# Stop the robot. rostopic pub /cmd_vel geometry_msgs/Twist "{linear: {x: 0.0, y: 0.0}, angular: {z: 0.0}}" -1
# Move straight rostopic pub /cmd_vel geometry_msgs/Twist "{linear: {x: 0.1}}"
# Move straight while turning right rostopic pub /cmd_vel geometry_msgs/Twist "{linear: {x: 0.1}, angular: {z: 0.02}}"
# Move straight while turning left rostopic pub /cmd_vel geometry_msgs/Twist "{linear: {x: 0.1}, angular: {z: -0.02}}"