본문 바로가기
프로젝트 모음/HRI ROS Project

[Robotics][Proj 11] 라즈베리파이3에 ROS 설치 (Kinetic)

by 하람 Haram 2023. 5. 10.
728x90

사용하는 어플이

https://appinventor.mit.edu/

 

MIT App Inventor

An Overview of the App Inventor Sources -- Components Read about how the App Inventor sources are structured in this series of blog posts. This week we discuss the App Inventor components module. More

appinventor.mit.edu

여기를 통해 만든 블루투스 어플이기 때문에

어쩔 수 없이 블루투스를 이용하여서 정보를 받고 받은 정보를 ROS를 통해서 Publish를 하고자 한다

(어플단을 건드리기 싫어서)

 

 

하지만 여기서 검색을 해보니

PC는 socket을 통한 블루투스를 지원하지 않으므로 PyBluez를 이용한 블루투스 통신도 할 수 없다. 다만 Bluetooth 드라이버를 설치하면 COM 포트가 할당되므로 시리얼 통신을 통한 연결은 가능하다. 그러나 Bluetooth BLE는 시리얼 프로파일을 제공하지 않으므로 COM 포트가 할당되지 않는다. 이 경우 별도의 프로파일을 작성해서 사용해야 한다.

그냥 요약하자면  PC와 핸드폰 블루투스 통신이 안된다

 

그래서 라즈베리 파이를 사용하기로 하였다

 

라즈베리 파이 세팅

 

사용한 라즈베리 : Rasberrypi 3

ROS 버전 : Kinetic

(noetic도 가능하지만 제약이 좀 있다고 한다)

 

먼저 기본적인 부팅을 끝낸 후 Ros 부터 깔아주자

http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Kinetic%20on%20the%20Raspberry%20Pi

 

ROSberryPi/Installing ROS Kinetic on the Raspberry Pi - ROS Wiki

Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. Installing ROS Kinetic on the Raspberry Pi Des

wiki.ros.org

 

 

1. 메모리 늘리기

ROS가 용량이 크기 때문에 메모리 부족할 수 도 있어서 SWAP 메모리의 크기를 늘려준다

100M -> 1024MB

sudo nano /etc/dphys–swapfile

여기에서 다음과 같이 바꿔주자

# set size to absolute value, leaving empty (default) then uses computed value
# you most likely don't want this, unless you have an special disk situation
# CONF_SWAPSIZE=100
CONF_SWAPSIZE=1024

그 다음 적용을 위해 아래의 명령어 실행

sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start

 

2. ROS 레포지토리 setup

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

근데 본인은 2번째 코드를 돌릴 때

gpg: keyserver receive failed: No name

다음과 같은 오류가 나와서 

일단 찝찝하긴 하지만 다음 명령어로 넘어가도 큰 영향이 없어서 패스했다

 

조금 찾아본 결과

sudo apt install curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

이런 식으로 해결한 사람도 있다고 한다 (나는 패스)

 

3. ROS 패키피 설치

먼저 dirmngr을 설치 (dirmngr : Certificate Revocation List(CRLs) 쉽게 파일을 관리해주는 패키지)

sudo apt-get install dirmngr
sudo apt-get update
sudo apt-get upgrade

 

 

4. ROS 의존성 패키지 다운

sudo apt install -y python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential cmake
sudo rosdep init
rosdep update

 

5. 워크스페이스 만들기

문서에서는 ros_catkin_ws로 만들었지만 나는 catkin_ws가 편해서 이대로 진행하려다 이건 ros의 catkin이다

mkdir -p ~/ros_catkin_ws
cd ~/ros_catkin_ws

6. ROS 패키지 다운로드

문서는 아래의 ROS-Comm을 받는 것을 추천하지만 rqt, rviz가 없다 ? 절대 안되지 Desktop으로 다운로드 진행!

 

- ROS-Comm

 ROS package, build, and communication libraries. No GUI tools.
rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall
wstool init src kinetic-ros_comm-wet.rosinstall

 

- ROS-DESKTOP

ROS, rqt, rviz, and robot-generic libraries
This will add all of the catkin or wet packages in the given variant and then fetch the sources into the 
~/ros_catkin_ws/src directory. The command will take a few minutes to download all of the core ROS packages into the src folder. The -j8 option downloads 8 packages in parallel.
rosinstall_generator desktop --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-wet.rosinstall
wstool init src kinetic-desktop-wet.rosinstall

 

이 명령어로 종속 프로그램들을 확인할 수 있다는데

rosdep install --from-paths src --ignore-src --rosdistro kinetic -y

귀찮게 그런거 말고 그냥

src 폴더와 kinetic-desktop-wet.rosinstall 있으면 성공인듯

src 들어가서 ls 쳐보면 package엄청 많이 나온다

 

그러면 성공인듯

 

7. Building the catkin Workspace

 

sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic

를 하면 다음과 같은 에러가 난다

 

The packages or cmake arguments have changed, forcing cmake invocation

==> Processing catkin package: 'catkin'
==> cmake /home/kist/catkin_ws/src/catkin -DCATKIN_DEVEL_PREFIX=/home/kist/catkin_ws/devel_isolated/catkin -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release -G Unix Makefiles in '/home/kist/catkin_ws/build_isolated/catkin'
-- Using CATKIN_DEVEL_PREFIX: /home/kist/catkin_ws/devel_isolated/catkin
-- Using CMAKE_PREFIX_PATH:
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Could NOT find PY_em (missing: PY_EM)
CMake Error at cmake/empy.cmake:30 (message): Unable to find either executable 'empy' or Python module 'em'... try installing the package 'python-empy' Call Stack (most recent call first): cmake/all.cmake:164 (include) CMakeLists.txt:8 (include)

-- Configuring incomplete, errors occurred! See also "/home/kist/catkin_ws/build_isolated/catkin/CMakeFiles/CMakeOutput.log".
<== Failed to process package 'catkin':
Command '['cmake', '/home/kist/catkin_ws/src/catkin', '-DCATKIN_DEVEL_PREFIX=/home/kist/catkin_ws/devel_isolated/catkin', '-DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic', '-DCMAKE_BUILD_TYPE=Release', '-G', 'Unix Makefiles']' returned non-zero exit status 1.

Reproduce this error by running:
==> cd /home/kist/catkin_ws/build_isolated/catkin && cmake /home/kist/catkin_ws/src/catkin -DCATKIN_DEVEL_PREFIX=/home/kist/catkin_ws/devel_isolated/catkin -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles' Command failed, exiting.

 

사실 잘 읽어보면 방법을 제시해주고 있다 밑에 명령어 돌리란다

cd /home/kist/catkin_ws/build_isolated/catkin
cmake /home/kist/catkin_ws/src/catkin -DCATKIN_DEVEL_PREFIX=/home/kist/catkin_ws/devel_isolated/catkin -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles'

근데 이거 해보면 또 오류가 난다

-- Configuring incomplete, errors occurred! See also "/home/kist/catkin_ws/build_isolated/catkin/CMakeFiles/CMakeOutput.log".
CMake Error: Cannot open file for write: /home/kist/catkin_ws/build_isolated/catkin/CMakeCache.txt.tmp
CMake Error: : System Error: Permission denied CMake Error: Unable to open cache file for save. /home/kist/catkin_ws/build_isolated/catkin/CMakeCache.txt
CMake Error: : System Error: Permission denied

딱 봐도 권한문제이니 sudo 로 해결하자

sudo cmake /home/kist/catkin_ws/src/catkin -DCATKIN_DEVEL_PREFIX=/home/kist/catkin_ws/devel_isolated/catkin -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles'

이러면 될줄 알았는데 또 오류가 난다

LL_PREFIX=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles'
-- Using CATKIN_DEVEL_PREFIX: /home/kist/catkin_ws/devel_isolated/catkin
-- Using CMAKE_PREFIX_PATH:
-- Using PYTHON_EXECUTABLE: /usr/bin/python -- Using Debian Python package layout
-- Could NOT find PY_em (missing: PY_EM) CMake Error at cmake/empy.cmake:30 (message):
Unable to find either executable 'empy' or Python module 'em'... try installing the package 'python-empy'
Call Stack (most recent call first): cmake/all.cmake:164 (include) CMakeLists.txt:8 (include)
-- Configuring incomplete, errors occurred!
See also "/home/kist/catkin_ws/build_isolated/catkin/CMakeFiles/CMakeOutput.log".

로그를 보던가 python-empy를 깔아달라고 한다 조금 찾아보니 생각보다 단순했다

https://answers.ros.org/question/353111/following-installation-instructions-catkin_make-generates-a-cmake-error/

 

Following installation instructions: catkin_make generates a cmake error - ROS Answers: Open Source Q&A Forum

Following installation instructions: catkin_make generates a cmake error edit I am new to ROS and try to install it for the first time. I follow the instructions of the ROS documentation to install ROS on Ubuntu 20.04. Things get wrong when creating a ROS

answers.ros.org

 

https://github.com/ysl208/iRoPro/issues/59

 

Unable to find either executable 'empy' or Python module 'em'... try installing the package 'python-empy' · Issue #59 · ysl

When running catkin build I get the following error CMake Error at /opt/ros/melodic/share/catkin/cmake/empy.cmake:29 (message): Unable to find either executable 'empy' or Python module 'em'... try ...

github.com

 

그냥 밑에 명령어

sudo apt install python3-empy

돌려주고 다시

sudo cmake /home/kist/catkin_ws/src/catkin -DCATKIN_DEVEL_PREFIX=/home/kist/catkin_ws/devel_isolated/catkin -DCMAKE_INSTALL_PREFIX=/opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles'

하면

깔끔히 해결된다

728x90