ROS

[ROS2] 3. Work Space 만들기

Magin 2024. 2. 3. 15:19
728x90

1. ROS2 source 하기

이전 포스트에서 마지막에 ~/.bashrc에 "source /opt/ros/humble/setup.bash" 명령어를 등록해놨다면 생략하셔도 됩니다.

#터미널을 열고
source /opt/ros/humble/setup.bash

 

2. Directory 만들기

mkdir -p ~/catkin_ws/src #가운데 catkin_ws는 사용자가 원하는 이름 가능!
cd ~/catkin_ws/src

해당 공간이 이제 ros2 작업을 진행할 공간이다.

 

3. Sample repository 복사

#해당 작성자는 ros2 humble 버전 사용
git clone https://github.com/ros/ros_tutorials.git -b humble

해당 repository는 ros_tutorials로 구성되어 있고 turtlesim 패키지가 포함되어있다.

이외에도 다양하게 있지만 COLCON_IGNORE 파일이 포함되어 있어서 빌드시 무시된다는 점이 있다고 한다.

4. Dependency 확인하기

 Sample repository를 복사해왔지만 항상 Package를 빌드하기전에 확인을 해봐야한다.

이에 대해 확인하고 설치하는 명령어이다.

cd ..
sudo apt install python3-rosdep
sudo rosdep init
rosdep update
cd ~/catkin_ws

#humble
rosdep install -i --from-path src --rosdistro humble -y

#foxy
rosdep install -i --from-path src --rosdistro foxy -y

 

문제가 없거나 설치가 이미 되어있다면 다음 문구를 확인 할 수 있다.

"All required rosdeps installed successfully"

 

5. colcon으로 ws빌드

이제 문제가 없는걸 확인했으니 빌드를 진행한다.

cd ~/catkin_ws
colcon build

 

빌드가 완료가 되면 아래처럼 나오는걸 확인 할 수 있다.

cd ~/catkin_ws
ls

#build  install  log  src

 

이제 작업 시작!!

 

#참고

[1] 개발자와 함께하는 ROS2 Humble에서 작업공간 생성하기

[2] ROS2: 작업공간(workspace) 생성

 

728x90