Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/u22 0.9.15 #726

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
## Getting started and documentation

Installation instructions and further documentation of the ROS bridge and additional packages are found [__here__](https://carla.readthedocs.io/projects/ros-bridge/en/latest/).

## Run with Docker

See [Docker](./docs/run_docker.md).
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
2 changes: 2 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ RUN /bin/bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
echo "export PYTHONPATH=\$PYTHONPATH:/opt/carla/PythonAPI/carla" >> /opt/carla/setup.bash'

COPY . /opt/carla-ros-bridge/src/
RUN /bin/bash -c 'apt install ros-$ROS_DISTRO-rviz2 python3-pip -y'
RUN /bin/bash -c 'rosdep install --from-paths src --ignore-src -r -y'
RUN /bin/bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
if [ "$ROS_VERSION" == "2" ]; then colcon build; else catkin_make install; fi'

Expand Down
36 changes: 36 additions & 0 deletions docker/Dockerfile_humble
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ARG CARLA_VERSION
ARG ROS_DISTRO

FROM ros:$ROS_DISTRO-ros-base

ARG CARLA_VERSION
ARG ROS_DISTRO

ENV CARLA_VERSION=$CARLA_VERSION
ENV DEBIAN_FRONTEND=noninteractive

SHELL ["/bin/bash", "-c"]

RUN apt update && apt upgrade -y
RUN apt install sudo -y
RUN sudo apt install --no-install-recommends wget -y
RUN apt install sudo -y

RUN mkdir -p /opt/carla-ros-bridge/src
WORKDIR /opt/carla-ros-bridge

COPY . /opt/carla-ros-bridge/src/

RUN sudo apt install python3-pip -y
RUN /bin/bash -c 'sudo apt-get install ros-$ROS_DISTRO-rviz2 -y'
RUN /bin/bash -c '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'
RUN /bin/bash -c 'rosdep update'
RUN /bin/bash -c 'rosdep install --from-paths src --ignore-src -r -y'
RUN /bin/bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
colcon build --symlink-install'

# replace entrypoint
COPY ./docker/content/ros_entrypoint_humble.sh /
50 changes: 50 additions & 0 deletions docker/Dockerfile_humble_user
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
ARG CARLA_VERSION
ARG ROS_DISTRO

FROM ros:$ROS_DISTRO-ros-base

ARG CARLA_VERSION
ARG ROS_DISTRO

ENV CARLA_VERSION=$CARLA_VERSION
ENV DEBIAN_FRONTEND=noninteractive

ARG USERNAME=devuser
ARG UID=${UID}
ARG GID=${GID}

SHELL ["/bin/bash", "-c"]

RUN apt update && apt upgrade -y
RUN apt install sudo -y
RUN sudo apt install --no-install-recommends wget -y
RUN apt install sudo -y

# Create new user and home directory
RUN groupadd --gid $GID $USERNAME \
&& useradd --uid ${UID} --gid ${GID} --create-home ${USERNAME} \
&& echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME} \
&& mkdir -p /home/${USERNAME} \
&& chown -R ${UID}:${GID} /home/${USERNAME}

USER ${USERNAME}
WORKDIR "/home/${USERNAME}"
RUN mkdir -p /home/${USERNAME}/carla-ros-bridge/src

COPY . /home/${USERNAME}/carla-ros-bridge/src

RUN sudo apt install python3-pip -y
RUN /bin/bash -c 'sudo apt-get install ros-$ROS_DISTRO-rviz2 -y'
RUN /bin/bash -c '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'
RUN /bin/bash -c 'rosdep update'
WORKDIR "/home/${USERNAME}/carla-ros-bridge"
RUN /bin/bash -c 'rosdep install --from-paths src --ignore-src -r -y'
RUN /bin/bash -c 'source /opt/ros/$ROS_DISTRO/setup.bash; \
colcon build --symlink-install'

# replace entrypoint
COPY ./docker/content/ros_entrypoint_humble.sh /
13 changes: 11 additions & 2 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh
#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

ROS_DISTRO="foxy"
ROS_DISTRO="humble"
CARLA_VERSION=$(cat ${SCRIPT_DIR}/../carla_ros_bridge/src/carla_ros_bridge/CARLA_VERSION)

while getopts r:c: flag
Expand All @@ -14,8 +14,17 @@ do
esac
done

if [[ "$ROS_DISTRO" == "humble" ]]
then
docker build \
-t carla-ros-bridge:$ROS_DISTRO \
-f Dockerfile_humble ${SCRIPT_DIR}/.. \
--build-arg ROS_DISTRO=$ROS_DISTRO \
--build-arg CARLA_VERSION=$CARLA_VERSION
else
docker build \
-t carla-ros-bridge:$ROS_DISTRO \
-f Dockerfile ${SCRIPT_DIR}/.. \
--build-arg ROS_DISTRO=$ROS_DISTRO \
--build-arg CARLA_VERSION=$CARLA_VERSION
fi
36 changes: 36 additions & 0 deletions docker/build_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

ROS_DISTRO="humble"
CARLA_VERSION=$(cat ${SCRIPT_DIR}/../carla_ros_bridge/src/carla_ros_bridge/CARLA_VERSION)
USERNAME=${USER}
UID=$(id -u)
GID=$(id -g)

while getopts r:c: flag
do
case "${flag}" in
r) ROS_DISTRO=${OPTARG};;
c) CARLA_VERSION=${OPTARG};;
*) error "Unexpected option ${flag}" ;;
esac
done

if [[ "$ROS_DISTRO" == "humble" ]]
then
docker build \
-t carla-ros-bridge:$ROS_DISTRO \
-f Dockerfile_humble_user ${SCRIPT_DIR}/.. \
--build-arg ROS_DISTRO=$ROS_DISTRO \
--build-arg CARLA_VERSION=$CARLA_VERSION \
--build-arg USERNAME=$USERNAME \
--build-arg UID=$UID \
--build-arg GID=$GID
else
docker build \
-t carla-ros-bridge:$ROS_DISTRO \
-f Dockerfile ${SCRIPT_DIR}/.. \
--build-arg ROS_DISTRO=$ROS_DISTRO \
--build-arg CARLA_VERSION=$CARLA_VERSION
fi
8 changes: 8 additions & 0 deletions docker/content/ros_entrypoint_humble.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

# setup ros environment
source "/opt/ros/humble/setup.bash"
source "/opt/carla-ros-bridge/install/setup.bash"

exec "$@"
12 changes: 11 additions & 1 deletion docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ usage() { echo "Usage: $0 [-t <tag>] [-i <image>]" 1>&2; exit 1; }

# Defaults
DOCKER_IMAGE_NAME="carla-ros-bridge"
TAG="foxy"
TAG="humble"

while getopts ":ht:i:" opt; do
case $opt in
Expand Down Expand Up @@ -35,4 +35,14 @@ echo "Using $DOCKER_IMAGE_NAME:$TAG"
docker run \
-it --rm \
--net=host \
-e DISPLAY=$DISPLAY \
--env=NVIDIA_VISIBLE_DEVICES=all \
--env=NVIDIA_DRIVER_CAPABILITIES=all \
--env=QT_X11_NO_MITSHM=1 \
--runtime=nvidia \
--privileged \
--shm-size=16gb \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /dev:/dev \
--gpus all \
"$DOCKER_IMAGE_NAME:$TAG" "$@"
35 changes: 35 additions & 0 deletions docs/run_docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Run Docker

Running docker is as easy as running two scripts and sending one command. One script to build the container, one to run the container and one ros launch command.

This page is speficially designated for ROS 2 Humble.

# Requirements

Docker has to be installed in the system. This is the only requirements.

# Building the Container

It is recommended for ROS 2 Humble to use the `build_user.sh` script:

```
cd <ros-bridge folder>
./build_user.sh
```

# Running the Container

```
./run.sh
```

Now the window is inside the ros-bridge container.

# Launching ROS 2

Make sure the carla server is running before launching ros:

```
source install/setup.bash
ros2 launch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch
```
2 changes: 2 additions & 0 deletions install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROS_PYTHON_VERSION="${ROS_PYTHON_VERSION:=3}"
ROS_VERSION="${ROS_VERSION:=2}"
PYTHON_SUFFIX=""
if [ "$ROS_PYTHON_VERSION" = "3" ]; then
PYTHON_SUFFIX=3
Expand Down
2 changes: 1 addition & 1 deletion pcl_recorder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ elseif(${ROS_VERSION} EQUAL 2)
add_executable(${PROJECT_NAME}_node src/PclRecorderROS2.cpp src/mainROS2.cpp)

ament_target_dependencies(${PROJECT_NAME}_node rclcpp sensor_msgs
pcl_conversions tf2 tf2_ros)
pcl_conversions tf2 tf2_ros tf2_eigen)

target_link_libraries(${PROJECT_NAME}_node ${Boost_SYSTEM_LIBRARY}
${PCL_LIBRARIES})
Expand Down