기술 성공, 실패 기록소

ros kinetic installation 본문

프로그래밍언어/ROS

ros kinetic installation

sunlab 2019. 9. 23. 18:08
728x90

ubuntu 16.04 LTS에선 ros kinetic을 설치한다.

 

1. 재설치를 한다면 먼저는 기존에 설치 되어있는 ros를 깔끔하게 삭제한다음 재설치 해야한다.

 

https://answers.ros.org/question/57213/how-i-completely-remove-all-ros-from-my-system/

 

sudo apt-get purge ros-*

+ https://gintrie.tistory.com/23

purge와 remove의 차이점

$ apt remove <패키지명>

패키지를 삭제한다. 하지만 설정파일은 남겨둔다.

$ apt purge <패키지명>

패키지를 삭제한다. 설정파일도 함께 삭제한다.

 

sudo apt-get autoremove

+ https://kldp.org/node/74906

의존성이 있어 설치되었던 패키지들 중 필요없는것들을 삭제한다.

 

If you've created a workspace, you'll have to also remove that...

and if you added the setup scripts to your .bashrc, you'd have to remove them too.

 

 

 

2. kinetic 설치

http://wiki.ros.org/kinetic/Installation/Ubuntu

 

(1) Setup your sources.list

Setup your computer to accept software from packages.ros.org.

 

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

 

(2) set up your keys

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

+키는 계속 바뀌므로 http://wiki.ros.org/kinetic/Installation/Ubuntu 여기에서 확인할 것.

 

(3) installation

 

sudo apt-get update

 

Desktop-Full Install: (Recommended) : ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception

 

sudo apt-get install ros-kinetic-desktop-full

 

+ 위의 설치만으로 기본적인 rqt는 포함되지만 추가로 rqt 관련 모든 패키지를 설치하자.

rqt 관련 모든 패키지를 설치하면 여로모로 편리하고 다양한 rqt 플러그인을 사용할 수 있다.

sudo apt-get install ros-kinetic-rqt*

 

(4) initialize rosdep

Before you can use ROS, you will need to initialize rosdep. rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS.

 

sudo rosdep init

rosdep update

 

(5) Environment setup

It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:

 

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc

source ~/.bashrc

+ /opt/ros/kinetic/setup.bash 는 ros의 환경설정 파일이다.

ROS_ROOT, ROS_PACKAGE_PATH 등의 환경변수들이 정의되어 있다.

 

 

(6) Dependencies for building packages

To create and manage your own ROS workspaces, there are various tools and requirements that are distributed separately. For example, rosinstall is a frequently used command-line tool that enables you to easily download many source trees for ROS packages with one command.

 

To install this tool and other dependencies for building ROS packages, run:

 

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

 

 

3. 작업폴더 생성 및 초기화

ros에서는 catkin이라는  ros 전용 빌드 시스템을 사용하고 있다.

이를 사용하려면 다음처럼 catkin 작업 폴더를 생성하고 초기화해야 한다.

이 설정은 작업 폴더를 새롭게 생성하지 않는 한 처음 한 번만 설정해주면 된다.

 

$ mkdir -p ~/catkin_ws/src

$ cd ~/catkin_ws/src

$ catkin_init_workspace 

 

catkin 작업폴더 빌드하기

$ cd ~/catkin_ws/

$ catkin_make

catkin 빌드 시스템의 빌드 관련 파일은 build 폴더에 저장되고

빌드 후 실행 관련 파일은 devel 폴더에 저장된다.

 

마지막으로 catkin 빌드 시스템과 관련된 환경 파일을 불러오자.

$ source ~/catkin_ws/devel/setup.bash

+ catkin_make 빌드 후에는  source ~/catkin_ws/devel/setup.bash 를 실행시켜야 하는 것 같다.

 

 

 

4. 테스트

 

$ roscore

+ 에러없이 동작하면 제대로 설치된 것.

 

 

 

5. ROS 환경설정

 

gedit ~/.bashrc

 

# Set ROS Kinetic
source /opt/ros/kinetic/setup.bash
source ~/catkin_ws/devel/setup.bash

# Set ROS Network
export ROS_HOSTNAME=xxx.xxx.xxx.xxx
export ROS_MASTER_URI=http://${ROS_HOSTNAME}:11311

# Set ROS alias command
alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'

 

source /opt/ros/kinetic/setup.bash

ㄴ ros의 환경설정 파일.

source ~/catkin_ws/devel/setup.bash

ㄴ catkin 빌드 시스템과 관련된 환경 파일.

 

$ source ~/.bashrc

ㄴ 수정한 bashrc 파일의 설정을 반영

 

 

 

 

 

 

 

 

 

 

 

'프로그래밍언어 > ROS' 카테고리의 다른 글

Where is the source code of installed packages?  (0) 2019.11.12
roslib  (0) 2019.11.09
Introduction to tf  (0) 2019.11.09
ros individual package download  (0) 2019.10.26
ROS 환경설정 설명  (0) 2019.10.02