Priceless

Ubuntu 22.04에서 Docker를 통해 ROS Noetic 실행하기 + Hydra 예제 수행 본문

ROS1 & ROS2

Ubuntu 22.04에서 Docker를 통해 ROS Noetic 실행하기 + Hydra 예제 수행

Hyun__ 2025. 1. 23. 17:32

ROS Noetic using Docker

Ubuntu 22.04 환경에서 ROS1 환경의 작업물을 사용해야 할 때가 있다
이 때 간단하게 사용하기 좋은 방법을 정리했다

# terminal 1
docker pull osrf/ros:noetic-desktop-full

xhost +local:docker # X11 디스플레이 접근 허용

# open container for roscore
docker run --gpus all -it \
  --name my_ros_container \
  --env="DISPLAY" \
  --env="QT_X11_NO_MITSHM=1" \
  --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
  --volume="$HOME:/root/HostHome" \
  osrf/ros:noetic-desktop-full
  
source /opt/ros/noetic/setup.bash
roscore
  
# terminal 2
docker exec -it my_ros_container bash
source /opt/ros/noetic/setup.bash
rviz

# terminal 3
docker exec -it my_ros_container bash
source /opt/ros/noetic/setup.bash
rosbag play <bag file>

 

위와 같이 ros noetic을 도커 상에서 실행할 수 있다

기능을 확인하기 위해 hydra 를 수행해본다

 

Hydra in container

아래는 컨테이너 내에서 hydra를 수행하는 과정이다
https://github.com/MIT-SPARK/Hydra?tab=readme-ov-file

 

GitHub - MIT-SPARK/Hydra

Contribute to MIT-SPARK/Hydra development by creating an account on GitHub.

github.com

 

# General Requirements
sudo apt update
sudo apt install python3-rosdep python3-catkin-tools python3-vcstool
rosdep init
rosdep update

# Building Hydra
mkdir -p catkin_ws/src
cd catkin_ws
catkin init
catkin config -DCMAKE_BUILD_TYPE=Release

cd src
sudo apt install git
git clone https://github.com/MIT-SPARK/Hydra.git hydra
vcs import . < hydra/install/hydra.rosinstall
rosdep install --from-paths . --ignore-src -r -y

cd ..
catkin build

# terminal 2,3
source /catkin_ws/devel/setup.bash

# Quickstart
# terminal 2
rosbag decompress uHumans2_office_s1_00h.bag

# terminal 3
roslaunch hydra_ros uhumans2.launch

# terminal 2
cd <path to bag file>
rosbag play uHumans2_office_s1_00h.orig.bag --clock

 

orig.bag 파일에서 나오는 토픽은 아래와 같다

# rostopic list
/clock
/rosout
/rosout_agg
/tesse/depth_cam/camera_info
/tesse/depth_cam/mono/image_raw
/tesse/front_lidar/scan
/tesse/imu/clean/imu
/tesse/imu/noisy/biases/accel
/tesse/imu/noisy/biases/gyro
/tesse/imu/noisy/imu
/tesse/left_cam/camera_info
/tesse/left_cam/mono/image_raw
/tesse/left_cam/rgb/image_raw
/tesse/odom
/tesse/rear_lidar/scan
/tesse/right_cam/camera_info
/tesse/right_cam/mono/image_raw
/tesse/right_cam/rgb/image_raw
/tesse/seg_cam/camera_info
/tesse/seg_cam/rgb/image_raw
/tf
/tf_static

 

 
컨테이너 내에서 git ssh 오류 발생 시 아래 사이트 참고
https://junyoeng.tistory.com/entry/Git-%EA%B3%B5%EA%B0%9C%ED%82%A4-%EB%93%B1%EB%A1%9D%ED%95%98%EA%B8%B0-gitgithubcom-Permission-denied-publickey

 

Git 공개키 등록하기 git@github.com: Permission denied (publickey)

Permission denied (publickey)GitHub에 올라간 Repository를 아무나 pull 또는 push를 하게 되면 큰 문제가 생길 수 있다. 때문에 해당 기능을 사용하기 위해선 유저에게 권한이 있는지 확인이 필요한데, 이때

junyoeng.tistory.com

 

https://docs.github.com/ko/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

 

새 SSH 키 생성 및 ssh-agent에 추가 - GitHub Docs

SSH(Secure Shell Protocol)를 사용하여 GitHub의 리포지토리에서 데이터에 액세스하고 쓸 수 있습니다. SSH를 통해 연결할 때 로컬 머신에서 프라이빗 키 파일을 사용하여 인증합니다. 자세한 내용은 SSH

docs.github.com

 

 

ssh-keygen -t ed25519 -C <github email>
<enter>
<enter>
<enter>
eval "$(ssh-agent -s)"
ssh-add /root/.ssh/id_ed25519
cat /root/.ssh/id_ed25519.pub
# add git SSH on github.com

 

결과

docker 내에서 hydra 테스트 완료