개요
이번 글은 아두이노에서 ROS topic을 발행하여 값을 확인하는 과정을 기록한 글이다.
Version Dependencies
Arduino SAM Boards (32-bits ARM Cortex-M3) : 1.6.11
micro-ros-arduino : ros-humble 2.0.7
Ubuntu : 22.04
ROS 2 Version : Humble
1. 패키지 설치 및 git clone
#본인의 ROS2 워크스페이스에서 작업하면 됩니다.
cd ~/robot2_ws/src
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git
# rosdep으로 의존 패키지 업데이트
sudo apt update && rosdep update
rosdep install --from-paths . --ignore-src -y
# pip 설치
sudo apt-get install python3-pip
# micro-ROS tools 과 소스 빌드
cd ~/robot2_ws
colcon build --packages-select micro_ros_setup
source install/local_setup.bash
# micro-ROS agent 패키지 설치
cd ~/robot2_ws
ros2 run micro_ros_setup create_agent_ws.sh
ros2 run micro_ros_setup build_agent.sh
source install/local_setup.bash
아두이노 DUE를 연결 했을 때
연결 해제 했을 때
아두이노 Sketch를 열어준다. 아래와 같이 아두이노 듀에 관련 패키지를 설치하라고 하면 설치한다.
2. 아래 깃허브에 들어가서 자신의 ROS 버전에 맞게 micro ros 라이브러리 .zip 파일을 설치한다.
Releases · micro-ROS/micro_ros_arduino
micro-ROS library for Arduino. Contribute to micro-ROS/micro_ros_arduino development by creating an account on GitHub.
github.com
3. Arduino 환경 설정
Sketch -> Include library -> Add .ZIP Library로 들어가서 설치한 라이브러리를 추가한다.
업로드 시 아래와 같은 오류가 발생한다.
이 때 File -> Preference로 가서 아래에 있는 preference.txt 파일이 있는 디렉토리로 간다음,
Package -> arduino -> hardware -> sam -> 1.6.11 (버전) 에서 터미널을 열고 아래 명령어를 입력한다.
curl https://raw.githubusercontent.com/micro-ROS/micro_ros_arduino/main/extras/patching_boards/platform_arduinocore_sam.txt > platform.txt
혹시 몰라 paltform.txt 파일 첨부
4. 실행 방법 (중요)
1) 먼저 아두이노 코드를 업로드 한다. ( ros2 run 을 먼저해서 읽어오면 안됨)
2. 그 다음 터미널을 열어서 아래 명령어를 입력한다.
ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyACM0
그러면 아래와 사진과 같이 나온다. (다르게 나오면 듀에 보드 reset 버튼을 눌러준다)
3. 또 다른 터미널을 열어서 아래 명령어를 입력하여 듀에보드가 출력하는 토픽을 확인한다.
ros2 topic echo /micro_ros_arduino_node_publisher
not found 에러가 뜨면 아래 명령어를 입력 후 다시 실행한다.
source install/local_setup.bash
Reslut ( Success )
trobule shooting
ERROR 1)
sol 1)
sudo apt update
sudo apt -y install ament-cmake
result : ERROR 2)
ERROR 2)
sol 2)
주석 처리
result
후..너무 어려웠다
이렇게 해서 나중에 아두이노 보드에서 받는 센싱 데이터를 ROS 를 통해서 integration을 할 수 있다.
[참고 자료]
https://huroint.tistory.com/30
https://soulful-magenta-dog-467.medium.com/micro-ros-with-arduino-ros2-arduino-7e754ba5210
'Robotics 🤖 > Ubee' 카테고리의 다른 글
[Ubee] catkin_make에서 cakin build로 빌드 툴 변경하기(feat : em Error) (2) | 2023.11.24 |
---|---|
cmd_vel topic으로 로봇 액추에이터 구동하기 (0) | 2023.09.16 |
cmd_vel topic을 위한 파라미터 수정하기(ROS) (0) | 2023.09.16 |
아두이노 Rosserial 통신 (UNO, Noetic) (0) | 2023.09.16 |
아두이노 + ROS 2 튜토리얼 [2] (10) | 2023.08.29 |