This repository contains a Dockerfile and associated scripts for creating a Docker image that combines ROS2 (Robot Operating System 2) with Vicon motion capture system integration. The image includes this ros2-node to communicate with external Vicon system.
This Docker image is designed to provide a pre-configured environment for robotics research and development, particularly for projects that involve both ROS2 and Vicon motion capture systems. It's based on the official ROS2 Foxy desktop image and includes additional tools and libraries for working with Vicon systems.
Docker image is built using github-action
, and uploaded to Docker Hub.
docker pull hansonhschang/ros2-vicon:latest
The variable
<name>
in following sections will behansonhschang/ros2-vicon
.
To build the Docker image locally:
Clone this repostitory
git clone https://github.com/hanson-hschang/ros2-vicon.git
Change directory to your downloaded folder
cd ros2-vicon
Build the image from the Dockerfile
.
The .
after build
means to look for the Dockerfile
in the current directory.
The -t <name>
means to tag the image with a name <name>
.
Note that the tag name can be any of your choice but it can only be in lower cases.
docker build . -t <name>
A built image on Docker Hub may also be pulled directly.
To find more details on how to use Docker, please refer Docker's official documentation. Here, we list couple of CLI commands that can be useful to setup.
To create and start a new container from the image, run the following command
docker run -i -t --rm <name>
docker run -i -t --rm --entrypoint bash <name>
flag | value | function |
---|---|---|
-i |
keeps STDIN open even if not attached, allowing for interactive use |
|
-t |
allocates a pseudo-TTY, which provides an interactive shell in the container | |
-v |
<host_path>:<container_path> |
Mount the host volume to container |
--rm |
automatically removes the container when it exits. It's useful for creating temporary containers that clean up after themselves | |
--entrypoint |
bash |
overrides the default entrypoint of the container with bash. It means that instead of running whatever command was specified as the default in the Dockerfile , the container will start a bash shell. |
<name> |
name of the Docker image to use for creating the container. |
One may also combine two tags together, e.g.
-i -t
is the same as-it
.
Now you have entered the bash in the container just created. To exit, run the following command, and the container will be clean up because of the --rm
flag in the previous command.
exit
(Optional) If one would like to keep the container running in the background after exiting, remove the flag --rm
from the command in step 1.
(Optional) To check what containers are still running in the background, run
docker ps --all
Sample output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
163d0594b46d ros2-vicon "bash" 13 seconds ago Exited (0) 7 seconds ago nice_margulis
In this case, a container of name: nice_margulis
with container id: 163d0594b46d
is running.
(Optional) To re-start one container with name <container_id>
docker start -i -a <container_name>
flag | function |
---|---|
-i |
keeps STDIN open even if not attached, allowing for interactive use |
-a |
attaches the terminal to the container's STDOUT (standard output) and STDERR (standard error) streams. This means you'll see the output from the container's main process in your terminal. |
(Optional) To remove one container with name <container_id>
docker rm <container_id>
(Optional) To remove an image with name <name>
docker rmi <name>
All these commands have a GUI in the Docker Desktop app as well.
For GUI applications, you may need to set up X11 forwarding or use other methods to enable GUI support.
You can run ros2
commands as if you have ros2
installed on local machine. Just prepend docker run -it --rm <name> ros2
.
To use your own script or folder outside of the container, you have to create the container without
--rm
flag, and copy the contents inside. Take a look here.
The structure is similar to this.
Run the following ros2 nodes on each terminal:
docker run -it --rm <name> ros2 run demo_nodes_cpp talker
docker run -it --rm <name> ros2 run demo_nodes_cpp listener
The default host ip is
192.168.1.12
.
docker run -it --rm <name> ros2 launch vicon_receiver client.launch.py
To see the topics, you may use
docker run -it --rm <name> ros2 topic list
To see the message in the topic <topic>
, you can implement your own listener or use
docker run -it --rm <name> ros2 topic echo <topic>
Mock system can be launched when Vicon system is not available.
docker run -it --rm <name> ros2 launch vicon_receiver mock_client.launch.py
More documentation can be found here.
Using the docker -v
flag which mounts the host directory, data can be directly saved in host file system.
docker run -it --rm \
-v <host_directory_path>:/bag_files \
<name> \
ros2 bag record -o /bag_files/<record_name> /topic1 /topic2 /topic3
More commands are available in official ROS2 documentation. Here, I'm providing few that will be useful
to debug the docker
container.
docker run -it --rm <name> ros2 pkg list # list all available ros2 packages
docker run -it --rm <name> ros2 topic list # list all available ros2 topics
docker run -it --rm <name> ros2 topic echo <topic> # listen to a topic data
This repository uses GitHub Actions for continuous integration and delivery. On each pull request to the main branch, the workflow will:
The workflow can also be manually triggered from the GitHub Actions tab.
Contributions to improve this Docker image are welcome. Please submit issues and pull requests on this GitHub repository.