This is a custom image from ros2 core humble used in our graduation project
185
Installation will be devided into two parts Docker Installation and ROS2 Humble Installation
To install Docker on your machine
sudo apt-get update
sudo apt install docker.io docker-compose docker-buildx
To run Docker without using sudo, you need to add your user to the docker group, which allows managing Docker as a non-root user. Here’s how you can do it:
Create the docker group (if it doesn't exist):
sudo groupadd docker
Add your user to the docker group:
Replace $(whoami) with your username, or just use the command as is to add the current user.
sudo usermod -aG docker $(whoami)
Apply the new group membership: Either log out and log back in, or run the following command to apply the group membership without logging out:
newgrp docker
Test if you can run Docker without sudo:
Try running a Docker command, like:
docker run hello-world
If everything is set up correctly, Docker will run without needing sudo.
Install the following image that has ROS2 Humble on an Ubuntu 22.04LTS machine
note that this is ros core if you want the full desktop Here
docker pull ros:humble-ros-core
Congratulations now you have ROS2 Image ready on your machine
Here you run any container for the first time
docker run -it --rm \
--net=host \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
""ImageName:TagName""
Note that if you want to run the offical image
ImageName:TagName -> ros:humble-ros-coreif you want to run your own customized image for example ros2_test:latest
ImageName:TagName -> ros2_test:latestFirst, you'll need to know the container ID or name
docker ps -a
docker ps
docker exec to Open a New TerminalOnce you have the container ID or name, use the docker exec command to open a new terminal session inside the running container:
docker exec -it <container_name_or_id> /bin/bash
For example, if the container is named ros2_test_container, you would run:
docker exec -it ros2_test_container /bin/bash
This will open a new terminal session inside the running container, and you can interact with it just like you did when you first started the container.
After each new (installation, update, upgrade) or any modification in the container's content its highly recommended to commit those changes to avoid repeating it again in the future
docker ps -a
docker ps
docker commit "Container's ID or name" "NewImageName:Tagname"
-it: Same as when you initially ran the container; -i for interactive mode and -t for allocating a terminal./bin/bash: Specifies the shell to run (you can also use /bin/sh if bash is not available).Now, you should have a new terminal session in the same container.
Use Docker Compose file
On our raspberrypi you can find docker installed and ros2_test:latest has:
You need to configure your raspi on your network Wherther by doing it manually using mouse keyboard and screen or modifying network-config file by changing the SSID to your Wifi name and password to you WiFi password
Then you can SSH on the raspi using putty, by writing pi.local into the host IP Address
write the following command raspi-config select the Interface option and enable VNC
Open VNC view and enter pi.local to connet to your raspi
It's recommended to run terminator for better terminal layout
terminal 1 run this command to start and run the custom image that we'll use:docker run -it --rm \
--net=host \
--env="DISPLAY" \
--env="QT_X11_NO_MITSHM=1" \
--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
--name=ros2_main\
ros2_test:latest
terminal 2 On Host machine (Raspi) and run this command to ensure that the container can access your host's X11 display server for OpenGL renderingxhost +local:docker
terminal 3 and know the current running containers and copy the IDdocker ps
terminal 3 on the same containerdocker exec -it "Container's ID" /bin/bash
Now terminal 1 and terminal 3 are on the same container try those demos
Run each command on a seperate terminal (terminal 1 or 3)
ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key
Congratulation now you can control turtle sim through your keyboard!
Run each command on a seperate terminal (terminal 1 or 3)
ros2 run demo_nodes_cpp talker
ros2 run demo_nodes_cpp talker
Congratulation now you've made 2 nodes communicate in that docker container!
Content type
Image
Digest
sha256:a451428c1…
Size
297 MB
Last updated
almost 2 years ago
docker pull omarbarakota/ros2_gp