Introduction
This article documents the steps taken to upgrade Carla ROS Bridge to be compabible with Carla Simulator v0.9.15.2 and with Ubuntu 22.04. The changes are very simple and no functional improvements are applied. See ROS Humble to get started with ROS 2. For installation an a simple introduction to docker see Easy Guide to Installing Docker.
Patch and work
The patch work is very (very) simple. In the Carla ROS Bridge simply make this change in pcl_recorder/CMakeLists.txt
in Line 69
.
ament_target_dependencies(${PROJECT_NAME}_node rclcpp sensor_msgs
pcl_conversions tf2 tf2_ros tf2_eigen)
That’s it really. The tf2_eigen
must be additionally specified as a dependency to build pcl_recorder
and we are good to go for the package to be built on Ubuntu 22.04 with ROS Humble. This was first applied in Carla ROS - Tf Eigen.
Also don’t for get to change the CARLA_VERSION
in carla_ros_bridge/src/carla_ros_bridge/CARLA_VERSION
.
0.9.15
Update the Dockerfile
Updating the Dockerfile was more challenging than originally thought. The entire commit is in Commit Dockerfile Humble. The solution however was very simple. Basically use rosdep to install and update dependencies. This way all the dependencies are automatically checked and updated. The usage is the same as the original instructions which we will delve into next.
Sample usage with the new Dockerfile
Run Carla Simulator
First thing we have to do is run the carla simulator in a separate docker container as the carla server. See Carla Server for more details.
xhost +local:docker
docker run --privileged --gpus all \
--net=host -e DISPLAY=$DISPLAY carlasim/carla:0.9.15 /bin/bash ./CarlaUE4.sh
The important thing here is to run the container with priviliges of accessing the GPUs and allow the carla port to be shared with the entire network.
Build Carla ROS Bridge
There is already a script available to build the bridge. First download the updated version of Carla ROS Bridge - Humble into your folder of choice.
As we will be installing the package inside a Docker Container, we do not need to build the ROS package itself.
# Navigate to your ROS Workspace or another folder
# mkdir -p ~/ros_ws/src
# cd ~/ros_ws/src
git clone --recurse-submodules https://github.com/pradhanshrijal/ros-bridge -b feature/u22-0.9.15
cd ros-bridge/docker
We can only build the docker image:
./build.sh
An additional script is available to build the docker container with the user priviliges of the current user. The difference is that it builds with a tag with the name of the user.
./build_user.sh
Run Carla ROS Bridge
There is also a script available for running the now built image:
./run.sh
It run the script with the user based image:
./run.sh -t humble-$USER
the PHA Way
Now we will integrate this bridge into the PHA Project and use it as an example for how to use this project. What we will do is install this package as an addition to the available image, in the SSI.
Folder Setup
First we setup the project as documented in SSI Space.
cd /home/${USER}
mkdir schreibtisch
cd schreibtisch
git clone https://github.com/pradhanshrijal/pha_docker_files
cd pha_docker_files
Run Sample Container
We will use the PHA 22 Mini image to show a sample installation. This image does not contain all the dependencies required by the ros-bridge so there will be some installations of dependencies associated with the container, the package itself will be installed in the SSI. The storage of this space is associated with the host and not the container itself. First setup the Container
./docker_scripts/run-compose.sh -b docker_scripts/docker-compose-user-mini.yaml \
-e docker_scripts/compose-file-user.env
Exec PHA Container
Enter the container with:
./docker_scripts/exec-cont.sh -c pha-22-mini-${USER}
NOTE: Use tmux for easy development inside docker.
Install Carla ROS Bridge
Now we can install the package in the SSI which in this case is located in /home/${USER}/docker_share
inside the docker container. First install the dependencies. Then navigate to the folder, download and install.
python3 -m pip install carla==0.9.15
python3 -m pip install pygame
sudo apt install ros-humble-derived-object-msgs -y
python3 -m pip install numpy==1.23.1
cd /home/${USER}/docker_share/git_pkgs
mkdir -p test_ws/src
cd test_ws/src
git clone --recurse-submodules https://github.com/pradhanshrijal/ros-bridge -b feature/u22-0.9.15
cd ..
source /opt/ros/humble/setup.bash
rosdep install -y --from-paths src --ignore-src --rosdistro humble # $ROS_DISTRO
colcon build --symlink-install
The installations can also be done with a script:
source /home/${USER}/docker_share/scripts/install/install_carla_bridge.sh ${USER} humble 0.9.15
All that is left is to source the ROS packages so the system can find them. Write it into the .bashrc
to automate it.
echo "source /opt/ros/humble/setup.bash" >> /home/${USER}/.bashrc
echo "source /home/${USER}/docker_share/git_pkgs/test_ws/install/setup.bash" >> /home/${USER}/.bashrc
That’s it folks, the installations are done. With this method it is possible to install other additions with relative ease and not much extra storage space compromise. It is also possible to use several ROS workspaces in a multitude of docker containers with relative ease. The combinations are expansive and still easy. All you have to do is source the right workspace into the right container. This can be done even easier with containers, link will be provided here when it is available in the future.
Launch Carla Bridge
Make sure Carla Simulator Server is running in another container. See Run Carla Simulator.
Now to launch as stated in Carla ROS 2 Install:
ros2 launch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch.py
Conclusion
This article creates a base simulation platform for the PHA Project using Carla with Ubuntu 22.04. It also provides an example on how to install ROS packages into a ready-made container without bloating it’s size.
Bibliography
- Carla ROS Bridge
- Carla Simulator v0.9.15.2
- Carla Server
- Carla ROS 2 Install
- Carla ROS - Tf Eigen
- ROS Humble
- PHA 22 Mini
- PHA Docker
- Commit Dockerfile Humble
- rosdep