Raspberry Pi 설정 - ROS2

STELLA N5 로봇에는 SBC(Single Board Computer)로 Raspberry Pi 5가 탑재됩니다. 초기 설정이 완료된 이미지가 구워진 SD 카드가 기본으로 제공됩니다.

Raspberry Pi 관련 확인 사항

  • 기본 제공되는 SD카드는 Raspberry Pi OS Bookworm, ROS2 Jazzy 그리고 STELLA 관련 패키지가 모두 설치된 이미지가 구워진 SD카드입니다.

  • SD카드에 IMG를 다시 설치하려면 다음 링크에서 .img 형식 이미지 파일을 다운로드하여 재설치하시면 됩니다.

  • 제공되는 Raspberry Pi OS의 초기 비밀번호는 1 입니다.

  • 다음 링크에서 stella_n5_bookworm_ros2.img 파일을 다운로드할 수 있습니다.

Raspberry Pi OS 설치

  • STELLA N5의 Raspberry Pi에 Raspberry Pi OS를 설치합니다.

  • 설치 방법은 다음 링크를 참고하십시오.

ROS2 한 줄 설치

wget https://raw.githubusercontent.com/ntrexlab/ROS_INSTALL_SCRIPT/main/install_ros2_jazzy_pios.sh && chmod 755 ./install_ros2_jazzy_pios.sh && bash ./install_ros2_jazzy_pios.sh 

OS 최신 업데이트

  • Raspberry Pi OS를 설치한 후, 다음 명령어를 사용하여 최신 버전으로 업데이트합니다.

sudo apt-get update && sudo apt-get upgrade -y

ROS2 설치

  • Raspberry Pi OS에 ROS2를 설치합니다.

wget https://s3.ap-northeast-1.wasabisys.com/download-raw/dpkg/ros2-desktop/debian/bookworm/ros-jazzy-desktop-0.3.2_20240525_arm64.deb
  • 실행 권한 부여

sudo chmod 644 ./ros-jazzy-desktop-0.3.2_20240525_arm64.deb
sudo apt install ./ros-jazzy-desktop-0.3.2_20240525_arm64.deb
  • 환경 설정

sudo nano ~/.bashrc

사진처럼 .bashrc에 다음 내용을 추가하고 저장합니다.

source /opt/ros/jazzy/setup.bash
source ~/jazzy_ws/install/local_setup.bash
source ~/colcon_ws/install/local_setup.bash
  • 환경 설정 적용

source ~/.bashrc

STELLA N5 패키지 설치

  • 관련 패키지 설치

sudo apt install python3-rosinstall-generator
sudo apt install -y build-essential cmake python3-argcomplete python3-rosinstall-generator python3-rosinstall python3-pip
sudo pip3 install --break-system-packages colcon-common-extensions colcon-ros
pip3 install empy==3.3.4
  • librealsense 라이브러리 설치

cd ~/
git clone https://github.com/IntelRealSense/librealsense.git
cd librealsense
mkdir build && cd build
cmake .. -DBUILD_EXAMPLES=true -DFORCE_LIBUVC=true -DBUILD_WITH_CUDA=false -DBUILD_PYTHON_BINDINGS=false
make -j$(nproc)
sudo make install
  • ROS2 패키지 설치

mkdir -p ~/jazzy_ws/src
cd ~/jazzy_ws/src
git clone https://github.com/ros/joint_state_publisher.git -b ros2
git clone https://github.com/ros/filters.git -b ros2
git clone https://github.com/ros/angles.git -b ros2
git clone https://github.com/ros/diagnostics.git -b ros2-jazzy
git clone https://github.com/ros-perception/laser_filters.git -b ros2
git clone https://github.com/ros-perception/image_common.git -b jazzy
git clone https://github.com/ros-perception/image_transport_plugins.git -b jazzy
git clone https://github.com/ros-perception/vision_opencv.git -b humble
git clone https://github.com/ros-perception/perception_pcl.git -b jazzy
git clone https://github.com/ros-perception/pcl_msgs.git -b ros2
git clone -b jazzy https://gitlab.com/boldhearts/ros2_v4l2_camera.git

cd ~/jazzy_ws
colcon build
source ~/.bashrc
  • SELLA N5 패키지 설치

mkdir -p colcon_ws/src
cd ~/colcon_ws/src/
git clone https://github.com/ntrexlab/STELLA_N5_ROS2.git
cd ~/colcon_ws/src/STELLA_N5_ROS2/stella_teleop_bluetooth/stella_teleop_bluetooth/
chmod +x stella_teleop_bluetooth.py
  • Hailo AI HAT+ 관련 라이브러리 설치

sudo apt update
sudo apt full-upgrade
sudo apt-get install libgstreamer1.0-dev gir1.2-gst-plugins-base-1.0 -y
sudo apt install hailo-all -y
sudo reboot
cd ~/
git clone https://github.com/hailo-ai/hailo-rpi5-examples.git
cp /home/pi/colcon_ws/src/STELLA_N5_ROS2/stella_hailo_rpi5_ros2_examples/install_ros2.sh /home/pi/hailo-rpi5-examples
cd /home/pi/hailo-rpi5-examples
chmod +x install_ros2.sh
./install_ros2.sh
  • Serial 통신설정

cd ~/colcon_ws/src/STELLA_N5_ROS2/stella_bringup
sh create_udev_rules.sh
ls -al /dev/A* /dev/R* /dev/M*
  • Device 목록에 RPLIDAR, RPLIDAR2, AHRS, MW, BT 항목이 생성된 것을 확인할 수 있습니다.

패키지 컴파일

  • 다음 명령어를 사용하여 패키지를 컴파일합니다.

source ~/.bashrc
cd ~/colcon_ws
colcon build --symlink-install

Raspberry Pi SD 카드 설정

  • Raspberry Pi에 장착된 SD카드의 모든 용량을 활용할 수 있도록 다음의 과정을 진행합니다.

sudo raspi-config
    -> 6 Advanced Options를 선택
    -> A1 Expand Filesystem을 선택

PCIe 3.0 속도 설정

  • AI HAT+ 의 Hailo 칩이 최고 성능을 발휘할 수 있도록 다음 과정을 진행합니다.

sudo raspi-config
    -> 6 Advanced Options를 선택
    -> A8 PCIe Speed을 선택
    -> Yes 선택

NTP(Network Time Protocol) 서버를 이용한 시간 설정

sudo ntpdate ntp.ubuntu.com

설정 파일 수정을 통한 USB 전류 제한 해제

sudo nano /boot/firmware/config.txt

아래의 사진처럼 파일에 다음 줄을 추가하고 저장합니다.

usb_max_current_enable=1
sudo reboot

SSH를 이용하여 원격 접속 확인

  • Raspberry Pi에 원격으로 접속할 수 있도록 다음 과정을 진행합니다.

sudo raspi-config
    -> 3  Interface Options를 선택
    -> P2 SSH를 선택하여 SSH를 Enable 함

Last updated