https://www.youtube.com/watch?v=E8XPqDjof4U
ROBOTIS에서 제공한 영상 (옛날꺼라 잘 되지 않는다 ㅠㅠ
ROS2 예제따라해보기
예제를 이용하여 ROS2로 AX12 이용하기 입니다. 하지만. 옛날 버전이라 잘 되지 않네요.
트러블 슈팅이랑 같이 하여 올려보게씁니다.
$ mkdir -p ~/robotis_ws/src
$ cd ~/robotis_ws/src
위 명령어로 폴더를 만들고 안으로 들어가 로보티즈 깃허브의 다이나믹셀 SDK를 받아준다.
영상에서 git clone -b $ ROS_DISTRO-devel https://github.com/ROBOTIS-GIT/DynamixelSDK
를 쳐라고 하지만, 뭘해도 안된다.
왜냐?
devel 앞에 dashing 즉 ROS 버전을 입력하고 devel 을 적어야 한다. $도 없애야 한다고 한다..
위 명령어에서 <DISTRO>는 ROS 버전(예: melodic, noetic)을 나타냅니다. ros버전입력이라고 좀 친절히 알려주면 좋으련만 ㅠㅠ 초보자는 그저 웁니다.
$ git clone -b dashing-devel https://github.com/ROBOTIS-GIT/DynamixelSDK
젯슨나노 2GB버전이라 18.04 에 설치될 수 있는 ROS2는 dashing 버전이기에 설치한 버전에 맞춰서 입력하니 설치가 되었다.
깃허브에서 SDK에 대한 내용을 받아오는 내용으로 보인다
위에 내용을 터미널에 입력하니 다운로드가 되었다.
$cd ~/robotis_ws && colcon build --symlink-install
위의 명령어를 입력하여 내부 전체 파일을 빌드하고 symlink를 Install 한다.
여기서 symlink란??
Symlink는 Symbolic link의 줄임말로, 리눅스나 유닉스 기반 운영체제에서 사용되는 파일 시스템의 개념 중 하나입니다. Symlink는 다른 파일이나 디렉토리를 가리키는 파일이며, 이를 통해 해당 파일이나 디렉토리를 가리키는 모든 명령은 실제 파일이나 디렉토리에 적용됩니다.
즉, Symlink는 원본 파일이나 디렉토리에 대한 포인터나 별칭 같은 역할을 합니다. 이는 유용한 기능으로, 예를 들어 원본 파일이나 디렉토리를 다른 디렉토리에 복사하지 않고도 다른 디렉토리에서 접근할 수 있게 해주는 등의 작업에서 유용하게 사용됩니다.
하지만 다음과 같은 Error가 뜬다.
jetson@jetson-desktop:~/robotis_ws$ cd ~/robotis_ws && colcon build --symlink-install Starting >>> dynamixel_sdk Starting >>> dynamixel_sdk_custom_interfaces --- stderr: dynamixel_sdk CMake Error at CMakeLists.txt:18 (find_package): By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "ament_cmake", but CMake did not find one. Could not find a package configuration file provided by "ament_cmake" with any of the following names: ament_cmakeConfig.cmake ament_cmake-config.cmake Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set "ament_cmake_DIR" to a directory containing one of the above files. If "ament_cmake" provides a separate development package or SDK, be sure it has been installed. --- Failed <<< dynamixel_sdk [0.76s, exited with code 1] --- stderr: dynamixel_sdk_custom_interfaces CMake Error at CMakeLists.txt:19 (find_package): By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "ament_cmake", but CMake did not find one. Could not find a package configuration file provided by "ament_cmake" with any of the following names: ament_cmakeConfig.cmake ament_cmake-config.cmake Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set "ament_cmake_DIR" to a directory containing one of the above files. If "ament_cmake" provides a separate development package or SDK, be sure it has been installed. --- Failed <<< dynamixel_sdk_custom_interfaces [0.81s, exited with code 1] Summary: 0 packages finished [2.65s] 2 packages failed: dynamixel_sdk dynamixel_sdk_custom_interfaces 2 packages had stderr output: dynamixel_sdk dynamixel_sdk_custom_interfaces 1 package not processed |
아 ament관련 찾지 못한다고 뭔가가 문제가 있는것 같다.
이 에러는 CMakeLists.txt 파일에서 "ament_cmake" 패키지를 찾을 수 없다는 것을 알려주는 에러입니다. 이러한 경우에는 ament_cmake 패키지가 설치되어 있지 않은 것으로 생각할 수 있습니다.
$ sudo apt-get install ros-dashing-ament-cmake
1. 설치 해준다
2. ament_cmake_DIR 환경 변수를 설정하는 방법
export ament_cmake_DIR=/opt/ros/dashing/share/ament_cmake/cmake
- 여기서 /path/to/ament_cmakeConfig.cmake은 ament_cmakeConfig.cmake 파일이 위치한 디렉토리의 경로입니다.
3. CMAKE_PREFIX_PATH 환경 변수를 설정하는 방법
export CMAKE_PREFIX_PATH=/opt/ros/dashing:/opt/ros/dashing/share/ament_cmake/cmake:$CMAKE_PREFIX_PATH
여기서 /path/to/ament_cmake은 ament_cmake 패키지가 설치된 디렉토리의 경로입니다. $CMAKE_PREFIX_PATH는 이미 설정된 CMAKE_PREFIX_PATH 환경 변수의 값을 유지하며, 뒤에 추가적인 경로를 붙이는 역할을 합니다.
jetson@jetson-desktop:~/robotis_ws$ cd ~/robotis_ws && colcon build --symlink-install [4.404s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/path/to/ament_cmake' in the environment variable CMAKE_PREFIX_PATH doesn't exist Starting >>> dynamixel_sdk Starting >>> dynamixel_sdk_custom_interfaces --- stderr: dynamixel_sdk_custom_interfaces Traceback (most recent call last): File "/opt/ros/dashing/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", line 21, in <module> from ament_package.templates import get_environment_hook_template_path ModuleNotFoundError: No module named 'ament_package' CMake Error at /opt/ros/dashing/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message): execute_process(/usr/bin/python3 /opt/ros/dashing/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py /home/jetson/robotis_ws/build/dynamixel_sdk_custom_interfaces/ament_cmake_package_templates/templates.cmake) returned error code 1 Call Stack (most recent call first): /opt/ros/dashing/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:38 (include) /opt/ros/dashing/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package) /opt/ros/dashing/share/ament_cmake/cmake/ament_cmakeConfig.cmake:38 (include) CMakeLists.txt:19 (find_package) --- Failed <<< dynamixel_sdk_custom_interfaces [1.31s, exited with code 1] --- stderr: dynamixel_sdk Traceback (most recent call last): File "/opt/ros/dashing/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", line 21, in <module> from ament_package.templates import get_environment_hook_template_path ModuleNotFoundError: No module named 'ament_package' CMake Error at /opt/ros/dashing/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message): execute_process(/usr/bin/python3 /opt/ros/dashing/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py /home/jetson/robotis_ws/build/dynamixel_sdk/ament_cmake_package_templates/templates.cmake) returned error code 1 Call Stack (most recent call first): /opt/ros/dashing/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:38 (include) /opt/ros/dashing/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package) /opt/ros/dashing/share/ament_cmake/cmake/ament_cmakeConfig.cmake:38 (include) CMakeLists.txt:18 (find_package) --- Failed <<< dynamixel_sdk [1.50s, exited with code 1] Summary: 0 packages finished [3.32s] 2 packages failed: dynamixel_sdk dynamixel_sdk_custom_interfaces 2 packages had stderr output: dynamixel_sdk dynamixel_sdk_custom_interfaces 1 package not processed |
Error가 바뀌긴 했는데 여전히 되지 않는다.
만약 이미 ament_cmake 패키지가 설치되어 있다면, 아마도 ROS 2 Dashing 버전의 python 패키지를 찾지 못했을 가능성이 있습니다. 이 경우에는 python 패키지를 설치하면 됩니다.
sudo apt-get install python3-dashing-ros-ament
sudo apt-get install python3-rosdep
설치가 완료되면 다시 빌드를 시도해보세요.
rosdep은 ROS 패키지를 빌드하기 위해 필요한 의존성 패키지를 설치하는 도구입니다. rosdep은 ROS 공식 지원 패키지 중 하나이며, 패키지 의존성 해결 및 패키지 설치를 자동화하기 위한 도구입니다. python3-rosdep 패키지는 rosdep을 Python 3 버전에서 사용하기 위한 패키지입니다. 이 패키지를 설치하면 ROS 패키지를 더 쉽게 빌드하고 실행할 수 있습니다. 또한, 패키지의 의존성을 쉽게 해결할 수 있습니다. |
저걸 해도 설치가 죽어도 안된다.
dpkg -l | grep ament_cmake
를 검색하여 ament_cmake가 설치되어있는지를 확인한다. (설치가 되어있지 않다면 아무것도 뜨지 않는다.)
역시나 아무것도 뜨지 않는데 알수가 없다.
cmake version 3.10
CMake suite maintained and supported by Kitware (kitware.com/cmake).
이런.. 18.04버전에는 3.10 버전이 최신이라 3.12버전 이상이 설치가 불가능하다고 한다.
Ubuntu 18.04의 공식 패키지 저장소에는 CMake 3.12 이상 버전이 없다...
그래서 무슨 PPA 방식으로 설치해야한다고 해서 했지만 여전히 같았고 깃허브 주소가 없어진듯 하다.
그래서 소스코드를 받아서 사용할 수 있는 방법을 보았다.
CMake 3.12 버전 소스 코드는 아래 링크에서 다운로드 받을 수 있습니다.
https://cmake.org/files/v3.12/cmake-3.12.0.tar.gz
해당 링크에서 다운로드 받은 파일을 압축 해제한 뒤, 소스 코드를 빌드하면 됩니다. 다음은 빌드 방법입니다.
- 압축 해제한 폴더로 이동합니다.
- ./bootstrap 명령어를 실행합니다.
- make 명령어를 실행합니다.
- sudo make install 명령어를 실행합니다.
위 과정을 모두 완료하면 CMake 3.12 버전이 시스템에 설치됩니다.
해당 cmake를 설치해준다 ㅠㅠㅠ
대략 아래와 같은 PATH를 설정해주고
https://tttsss77.tistory.com/77
리눅스에 CMake 설치하기
리눅스에 CMake 설치하기 본 글에서는 리눅스에 CMake를 설치하는 방법을 소개한다. Ubuntu 리눅스에서 CMake를 설치하는 방법은 다음과 같은 두가지 방법이 있으며, 본 글에서는 아래 두가지 방법을
tttsss77.tistory.com
"cmake --version" 으로 버전 확인을한다.
'라즈베리파이 실습' 카테고리의 다른 글
Chat GPT를 활용하여 다이나믹셀 구동하는 예제살펴보기 (0) | 2023.03.17 |
---|---|
face detect (0) | 2020.11.18 |
Object Detect - R.P Python With Tensorflow Lite (0) | 2020.11.18 |
파이 카메라를 활용 5초동안 자동 영상 촬영 프로그램 (0) | 2020.11.18 |
라즈베리파이 마우스 클릭으로 사진 촬영 하기 (0) | 2020.11.18 |