Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
cgeller committed Feb 2, 2024
1 parent e9063d9 commit 28a5741
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push, pull_request]
# on: [push, pull_request]

jobs:
check:
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker

on: [push, pull_request]

jobs:

clean-up:
name: Clean up
runs-on: ubuntu-latest
steps:

- name: Clean up
run: rm -rf *

docker-ros:
runs-on: ubuntu-latest
needs: clean-up
steps:
- uses: actions/checkout@v4
name: Checkout repository
with:
submodules: true

- uses: robinraju/[email protected]
name: Download PythonAPI
with:
repository: carla-compose/carla-simulator
latest: true
fileName: PythonAPI.tar.gz
extract: true
out-file-path: docker/additional-files

- name: Remove PythonAPI.tar.gz
run: rm docker/additional-files/PythonAPI.tar.gz

- uses: ika-rwth-aachen/[email protected]
name: Run docker-ros pipeline
with:
base-image: rwthika/ros2:humble
command: ros2 launch carla_ros_bridge carla_ros_bridge.launch.py
target: run
platform: amd64
registry: docker.io
registry-user: ${{ secrets.DOCKER_USERNAME }}
registry-password: ${{ secrets.DOCKER_PASSWORD }}
image-name: rwthika/carla-ros-bridge
image-tag: ros2
enable-push-as-latest: true
enable-checkout: false
14 changes: 14 additions & 0 deletions CARLOS_CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Latest : 1.0.0

## 1.0.0 - Initial Release

### Major changes

* Created GitHub workflow to automatically build Docker images using [docker-ros](https://github.com/ika-rwth-aachen/docker-ros) (supports ROS 2 Humble distribution)
* Update to [CARLA 0.9.15](https://carla.org/2023/11/10/release-0.9.15/)
* Update to Ubuntu 22.04 and Python 3.10 including corresponding pip versions

### Minor changes

* Small fixes related to version updates
* Move original Docker related content to `docker_original_folder/`
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
# ROS/ROS2 bridge for CARLA simulator
# Communication Actor: *carla-ros-bridge*

<p align="left">
<img src="https://img.shields.io/github/v/release/ika-rwth-aachen/carla-ros-bridge"/>
<img src="https://img.shields.io/github/license/ika-rwth-aachen/carla-ros-bridge"/>
<a href="https://github.com/ika-rwth-aachen/carla-ros-bridge/actions/workflows/docker.yml">
<img src="https://github.com/ika-rwth-aachen/carla-ros-bridge/actions/workflows/docker.yml/badge.svg"/></a>
<img src="https://img.shields.io/badge/Ubuntu-22.04-E95420"/>
<img src="https://img.shields.io/badge/ROS 2-humble-blueviolet"/>
<img src="https://img.shields.io/badge/Python-3.10-blueviolet"/>
<img src="https://img.shields.io/github/stars/ika-rwth-aachen/carla-ros-bridge?style=social"/>
</p>

> [!IMPORTANT]
> This repository is a minimal fork of the official [ros-bridge](https://github.com/carla-simulator/ros-bridge)! All initial and following modifications to the original repository are documented in [CARLOS_CHANGELOG.md](./CARLOS_CHANGELOG.md).
> [!TIP]
> We recommend to use the *carla-ros-bridge* as **communication actor** in our open, modular and scalable simulation framework <a href="https://github.com/ika-rwth-aachen/carlos">**CARLOS**. <img src="https://img.shields.io/github/stars/ika-rwth-aachen/carlos?style=social"/></a>
>
> Here, it is the component that facilitates the powerful combination of CARLA and ROS. The component retrieves data from the simulation to publish it over ROS topics while simultaneously listening on different topics for requested actions, which are translated to commands to be executed in CARLA. It does this by using both the ROS communication standard DDS, as well as RPC via the CARLA Python API, in tandem, effectively bridging the two.
> [!TIP]
> Please also have look to the ROS specific [README](./docker/README.md) giving detailed insights about available ROS nodes, topics and services but also useful information about the containerization. Here, [docker-ros](https://github.com/ika-rwth-aachen/docker-ros) enables a continual building of container images with recent versions of ROS, Python, and Ubuntu.
> [!NOTE]
> We set up a Continous Integration (CI) pipeline as [GitHub workflow](./github/workflows/docker.yml) to continously build Docker images for the `carla-ros-bridge`, publicly available on [Docker Hub](https://hub.docker.com/r/rwthika/carla-ros-bridge).
---
---
## Original README

[![Actions Status](https://github.com/carla-simulator/ros-bridge/workflows/CI/badge.svg)](https://github.com/carla-simulator/ros-bridge)
[![Documentation](https://readthedocs.org/projects/carla/badge/?version=latest)](http://carla.readthedocs.io)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self):
# To prevent "float division by zero" within PID controller initialize it with
# a previous point in time (the error happens because the time doesn't
# change between initialization and first call, therefore dt is 0)
sys.modules['simple_pid.PID']._current_time = ( # pylint: disable=protected-access
sys.modules['simple_pid.pid']._current_time = ( # pylint: disable=protected-access
lambda: self.get_time() - 0.1)

# we might want to use a PID controller to reach the final target speed
Expand All @@ -71,7 +71,7 @@ def __init__(self):
output_limits=(-1, 1))

# use the correct time for further calculations
sys.modules['simple_pid.PID']._current_time = ( # pylint: disable=protected-access
sys.modules['simple_pid.pid']._current_time = ( # pylint: disable=protected-access
lambda: self.get_time())

if ROS_VERSION == 1:
Expand Down
2 changes: 1 addition & 1 deletion carla_ros_bridge/src/carla_ros_bridge/CARLA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.13
0.9.15
7 changes: 3 additions & 4 deletions carla_ros_bridge/src/carla_ros_bridge/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
except ImportError:
import Queue as queue
import sys
from distutils.version import LooseVersion
from threading import Thread, Lock, Event

import carla
Expand Down Expand Up @@ -413,13 +412,13 @@ def main(args=None):

# check carla version
dist = pkg_resources.get_distribution("carla")
if LooseVersion(dist.version) != LooseVersion(CarlaRosBridge.CARLA_VERSION):
if dist.version != CarlaRosBridge.CARLA_VERSION:
carla_bridge.logfatal("CARLA python module version {} required. Found: {}".format(
CarlaRosBridge.CARLA_VERSION, dist.version))
sys.exit(1)

if LooseVersion(carla_client.get_server_version()) != \
LooseVersion(carla_client.get_client_version()):
if carla_client.get_server_version() != \
carla_client.get_client_version():
carla_bridge.logwarn(
"Version mismatch detected: You are trying to connect to a simulator that might be incompatible with this API. Client API version: {}. Simulator API version: {}"
.format(carla_client.get_client_version(),
Expand Down
75 changes: 75 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Containerization of the carla-ros-bridge

- [ROS-Bridge](#ros-bridge)
- [Nodes](#nodes)
- [carla\_ros\_bridge/bridge.py](#carla_ros_bridgebridgepy)
- [Subscribed Topics](#subscribed-topics)
- [Published Topics](#published-topics)
- [Services](#services)
- [Usage of docker-ros Images](#usage-of-docker-ros-images)
- [Available Images](#available-images)
- [Default Command](#default-command)
- [Launch Files](#launch-files)
- [Official Documentation](#official-documentation)

## Nodes

| Package | Node | Description |
| --- | --- | --- |
| `carla_ros_bridge` | `bridge.py` | Enables two-way communication between ROS and CARLA via ROS topics and commands applied to the CARLA server |

### carla_ros_bridge/bridge.py

Also see the [official documentation](https://carla.readthedocs.io/projects/ros-bridge/en/latest/)

#### Subscribed Topics

| Topic | Type | Description |
| --- | --- | --- |
| `/carla/debug_marker` | `visualization_msgs/MarkerArray` | Draws markers in the CARLA world. |
| `/carla/weather_control` | `carla_msgs/CarlaWeatherParameters` | Set the CARLA weather parameters |
| `/clock` | `rosgraph_msgs/Clock` | Publishes simulated time in ROS. |

#### Published Topics

| Topic | Type | Description |
| --- | --- | --- |
| `/carla/status` | `carla_msgs/CarlaStatus` | Read the current status of CARLA |
| `/carla/world_info` | `carla_msgs/CarlaWorldInfo` | Information about the current CARLA map. |
| `/clock` | `rosgraph_msgs/Clock` | Publishes simulated time in ROS. |
| `/rosout` | `rosgraph_msgs/Log` | ROS logging. |

#### Services

| Service | Type | Description |
| --- | --- | --- |
| `/carla/destroy_object` | `carla_msgs/DestroyObject.srv` | Destroys an object |
| `/carla/get_blueprints` | `carla_msgs/GetBlueprints.srv` | Gets blueprints |
| `/carla/spawn_object` | `carla_msgs/SpawnObject.srv` | Spawn an object |


## Usage of docker-ros Images

### Available Images

| Tag | Description |
| --- | --- |
| `latest-dev_main_ci-amd64 ` | latest dev version |
| `latest_main_ci-amd64 ` | latest run version |

### Default Command

```bash
bash -ic "roslaunch carla_ros_bridge carla_ros_bridge.launch"
```
**Note:** The `-i` flag is used to invoke an interactive shell so any additions/changes to the `.bashrc` are effective when running the command.

### Launch Files

| Package | File | Path | Description |
| --- | --- | --- | --- |
| `carla_ros_bridge` | `carla_ros_bridge(launch/py)` | `/docker-ros/ws/install/share/carla_ros_bridge` | Creates ROS bridge node and connects it to the CARLA server |

## Official Documentation

- [ROS Bridge](https://carla.readthedocs.io/projects/ros-bridge/en/latest/)
15 changes: 15 additions & 0 deletions docker/additional-debs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
python3-pip
python3-osrf-pycommon
python3-rosdep
python3-wstool
python3-opencv
ros-$ROS_DISTRO-ackermann-msgs
ros-$ROS_DISTRO-cv-bridge
ros-$ROS_DISTRO-vision-opencv
ros-$ROS_DISTRO-rqt-image-view
ros-$ROS_DISTRO-rqt-gui-py
ros-$ROS_DISTRO-derived-object-msgs
ros-$ROS_DISTRO-pcl-conversions
wget
qtbase5-dev
qt5-qmake
10 changes: 10 additions & 0 deletions docker/additional-pip-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pep8==1.7.1
autopep8==2.0.4
cmake_format==0.6.11
pylint==3.0.3
transforms3d==0.4.1
pygame==2.5.2
pexpect==4.9.0
simple-pid==2.0.0
networkx==3.2.1
pyproj==3.6.1
27 changes: 27 additions & 0 deletions docker/custom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export DOCKER_ROS_FILES_PATH=/docker-ros/additional-files
# Install ROS version dependent apt packages
if [ "$ROS_DISTRO" = "noetic" ]; then
ADDITIONAL_PACKAGES="ros-$ROS_DISTRO-rviz
ros-$ROS_DISTRO-opencv-apps
ros-$ROS_DISTRO-rospy
ros-$ROS_DISTRO-rospy-message-converter
ros-$ROS_DISTRO-pcl-ros
python3-catkin-tools
python3-catkin-pkg
python3-catkin-pkg-modules"
else
ADDITIONAL_PACKAGES="ros-$ROS_DISTRO-rviz2"
fi
apt-get install --no-install-recommends -y $ADDITIONAL_PACKAGES
# Check if user provided CARLA PythonAPI. If not, exit
mkdir -p /opt/carla
if [ -d "$DOCKER_ROS_FILES_PATH/artifacts/PythonAPI" ]; then
mv $DOCKER_ROS_FILES_PATH/artifacts/PythonAPI /opt/carla/PythonAPI
else
echo "CARLA PythonAPI not found in $DOCKER_ROS_FILES_PATH/artifacts/PythonAPI ...Exiting"
exit 1
fi
# Create a script to append necessary paths to PYTHONPATH and make .bashrc source it
echo "export PYTHONPATH=\$PYTHONPATH:/opt/carla/PythonAPI/carla/dist/$(ls /opt/carla/PythonAPI/carla/dist | grep py$PYTHON_VERSION_SHORT.)" >> /opt/carla/setup.bash
echo "export PYTHONPATH=\$PYTHONPATH:/opt/carla/PythonAPI/carla" >> /opt/carla/setup.bash
echo "source /opt/carla/setup.bash" >> /root/.bashrc
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pcl_recorder/include/PclRecorderROS2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#include "rclcpp/rclcpp.hpp"
#include <pcl_conversions/pcl_conversions.h>
#include <rclcpp/time_source.hpp>
#include <tf2_eigen/tf2_eigen/tf2_eigen.hpp>
#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_listener.h>
#include <tf2_eigen/tf2_eigen.h>
#include <rclcpp/time_source.hpp>

class PclRecorderROS2 : public rclcpp::Node
{
Expand Down
1 change: 1 addition & 0 deletions rviz_carla_plugin/src/carla_control_panel_ROS2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <iomanip>

#include <tf2/utils.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>

#include <OgreCamera.h>
#include <OgreVector3.h>
Expand Down

0 comments on commit 28a5741

Please sign in to comment.