docker로 carla, carla ROS bridge, RTabmap 돌려보기

haeryong·2023년 3월 10일
2

Carla with ROS bridge

nvidia-docker 설치

sudo apt install -y nvidia-docker2
sudo systemctl daemon-reload
sudo systemctl restart docker

X11 포워딩

xhost +local:root

carlaserver

docker run --rm --privileged --gpus all --runtime=nvidia  --net=host -e DISPLAY=$DISPLAY carlasim/carla:0.9.13 /bin/bash ./CarlaUE4.sh

-RenderOffScreen 옵션을 추가해 off screen mode로 실행할 수 있다.

docker run --rm --privileged --gpus all --runtime=nvidia  --net=host -e DISPLAY=$DISPLAY carlasim/carla:0.9.13 /bin/bash ./CarlaUE4.sh -RenderOffScreen

-quality-level=Low 옵션을 추가해 Low quality로 실행할 수 있다.

carla ROS bridge

docker run

docker run -it --privileged --gpus all --runtime=nvidia --net=host -e DISPLAY=$DISPLAY introlab3it/rtabmap_ros:melodic-latest

rtabmap_ros를 사용하지 않는 경우 ros가 설치된 다른 이미지를 사용해도 무방하다.

install carla-ros-bridge

ROS가 설치된 container 내부에서

apt update && apt install python-pip python-catkin-tools 
python -m pip install --upgrade pip
source /ros_entrypoint.sh
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1AF1527DE64CB8D9
add-apt-repository "deb [arch=amd64] http://dist.carla.org/carla $(lsb_release -sc) main"
mkdir -p ~/carla-ros-bridge/catkin_ws/src
cd ~/carla-ros-bridge/
git clone --recurse-submodules https://github.com/carla-simulator/ros-bridge.git catkin_ws/src/ros-bridge
cd catkin_ws/
rosdep update && rosdep install --from-paths src --ignore-src -r
catkin build
pip install carla==0.9.13
pip install pygame

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
echo "source /root/carla-ros-bridge/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

실행

carlaserver를 실행한(docker run) 상태에서

roslaunch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch

B키를 누르면 manual control이 가능하고, P키를 누르면 autopilot모드로 실행가능하다.


Rtabmap

/root/carla-ros-bridge/catkin_ws/src/ros-bridge/carla_spawn_objects/config/objects.json
에서

                    "type": "sensor.camera.depth",
                    "id": "depth_front",
                    "spawn_point": {"x": 2.0, "y": 0.0, "z": 2.0, "roll": 0.0, "pitch": 0.0, "yaw": 0.0},
                    "fov": 90.0,
                    "image_size_x": 800,
                    "image_size_y": 600

로 image size (800, 600)으로 변경.

roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start --Optimizer/GravitySigma 0.3" depth_topic:=/carla/ego_vehicle/depth_front/image rgb_topic:=/carla/ego_vehicle/rgb_front/image camera_info_topic:=/carla/ego_vehicle/rgb_front/camera_info depth_camera_info_topic:=/carla/ego_vehicle/depth_front/camera_info approx_sync:=false frame_id:=ego_vehicle/rgb_front

0개의 댓글