์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

2. ROS ์„ค์น˜(๋ฐ์Šคํฌํƒ‘), ๊ฐœ๋ฐœ์„ ํŽธ๋ฆฌํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” ๋„๊ตฌ๋“ค ์•ˆ๋‚ด

Swimming_Kim 2021. 1. 29. 17:50
๐Ÿ’ป

2. ROS ์„ค์น˜(๋ฐ์Šคํฌํƒ‘), ๊ฐœ๋ฐœ์„ ํŽธ๋ฆฌํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” ๋„๊ตฌ๋“ค ์•ˆ๋‚ด

 

Ubuntu Linux 18.04๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๋Š” ๋ฐ์Šคํฌํƒ‘์„ ๊ธฐ์ค€์œผ๋กœ ROS๋ฅผ ์„ค์น˜ํ•ด ๋ด…์‹œ๋‹ค

 

์ค€๋น„๋ฌผ


  • ์šฐ๋ถ„ํˆฌ ๋ฆฌ๋ˆ…์Šค๊ฐ€ ์„ค์น˜๋œ ๋ฐ์Šคํฌํƒ‘ (ํ˜น์€ ์™ธ์žฅ ๊ทธ๋ž˜ํ”ฝ์„ ํฌํ•จํ•œ ๋…ธํŠธ๋ถ) 1๋Œ€
  • ๋ฆฌ๋ˆ…์Šค ์ปค๋งจ๋“œ ๋ผ์ธ์— ๋Œ€ํ•œ ์•ฝ๊ฐ„์˜ ์ง€์‹
  • ์พŒ์ ํ•œ ์ธํ„ฐ๋„ท ํ™˜๊ฒฝ

 

๐Ÿ’ก
๋กœ๋ด‡์— ๋ฆฌ๋ˆ…์Šค๊ฐ€ ๋„๋Š” ๊ฒƒ์€ ์ดํ•ดํ•˜๋Š”๋ฐ... ์šฐ๋ถ„ํˆฌ ๋ฐ์Šคํฌํƒ‘์ด ์™œ ํ•„์š”ํ•œ๊ฐ€์š”?

 

๋ฐ”๋กœ ์‹ค์ œ ํ•˜๋“œ์›จ์–ด๋กœ ๋„˜์–ด๊ฐ€๊ธฐ ์ „์—, ROS์˜ ์ฃผ์š” ๊ฐœ๋…๋“ค์„ ์‹œ๋ฎฌ๋ ˆ์ด์…˜์„ ํ†ตํ•ด ์ตํ˜€๋ณผ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

 

๋งˆ์น˜ ์šฐ๋ฆฌ๊ฐ€ ๊ฒŒ์ž„์„ ํ•  ๋•Œ ์ข‹์€ ๊ทธ๋ž˜ํ”ฝ ์นด๋“œ๊ฐ€ ์žˆ์œผ๋ฉด ๋†’์€ ํ•ด์ƒ๋„์—์„œ ๋ฉˆ์ถค ์—†์ด ํ”Œ๋ ˆ์ด๋ฅผ ํ•  ์ˆ˜ ์žˆ๋“ฏ์ด, ์‹œ๋ฎฌ๋ ˆ์ด์…˜์„ ๋กœ๋“œํ•˜๊ณ  ์‹คํ–‰์‹œํ‚ฌ ๋•Œ์—๋„ ๋…ธํŠธ๋ถ๋ณด๋‹ค๋Š” ๋ฐ์Šคํฌํƒ‘์ด ํผํฌ๋จผ์Šค ์ธก๋ฉด์—์„œ ์œ ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

 

  • ์šฐ๋ถ„ํˆฌ ๋ถ€ํŒ… USB ๋งŒ๋“ค๊ธฐ
Create a bootable USB stick on Windows | Ubuntu
With a bootable Ubuntu USB stick, you can: Install or upgrade Ubuntu Test out the Ubuntu desktop experience without touching your PC configuration Boot into Ubuntu on a borrowed machine or from an internet cafe Use tools installed by default on the USB stick to repair or fix a broken configuration Creating a bootable Ubuntu USB stick from Microsoft Windows is very simple and we're going to cover the process in the next few steps.
https://ubuntu.com/tutorials/create-a-usb-stick-on-windows#10-installation-complete
๐Ÿ’ก
rufus ๋Œ€์‹ , BalenaEtcher๋ฅผ ์‚ฌ์šฉํ•ด๋„ ์ข‹์Šต๋‹ˆ๋‹ค. ํ›„์— ์ ฏ์Šจ๋‚˜๋…ธ์— ์šฐ๋ถ„ํˆฌ ์„ค์น˜ ์‹œ์—๋„ ๋‹ค์‹œ ์‚ฌ์šฉํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

  • ์šฐ๋ถ„ํˆฌ & ์œˆ๋„์šฐ ๋“€์–ผ ๋ถ€ํŒ… ํ™˜๊ฒฝ ๋งŒ๋“ค๊ธฐ (GRUB)

image from : IT'S FOSS

 

๐Ÿ› ๏ธ ์šฐ๋ถ„ํˆฌ ์„ค์น˜๋ฅผ ์›์น˜ ์•Š์œผ์‹œ๋‹ค๋ฉด, WSL์„ ์‚ฌ์šฉํ•œ ์œˆ๋„์šฐ ์„ค์น˜ ๋ฐฉ๋ฒ•๋„ ๋งํฌํ•ด๋‘๋‹ˆ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

 

Install Windows Subsystem for Linux (WSL) on Windows 10
There are two options available for installing Windows Subsystem for Linux (WSL): Simplified install (preview release): wsl --install The wsl --install simplified install command requires that you join the Windows Insiders Program and install a preview build of Windows 10 (OS build 20262 or higher), but eliminates the need to follow the manual install steps.
https://docs.microsoft.com/en-us/windows/wsl/install-win10
Running ROS on Windows 10
The Windows Subsystem for Linux (WSL) is a compatibility layer which allows to run a whole bunch of linux binaries natively on Windows 10. With the advent of the Windows 10 Creators Update in March 2017, the WSL was heavily updated and now is able to run ROS lunar and melodic.
https://janbernloehr.de/2017/06/10/ros-windows

 

Terminator ์„ค์น˜


๋‹ค์ค‘ ๋ถ„ํ•  ํ„ฐ๋ฏธ๋„์„ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค

# ppa ๋“ฑ๋ก
$ sudo add-apt-repository ppa:gnome-terminator
Enter

# ์„ค์น˜ ์ „ ์—…๋ฐ์ดํŠธ
$ sudo apt-get update

# terminator ์„ค์น˜
$ sudo apt-get install terminator -y

๐Ÿ’ป14๊ฐ• - Jetson Nano ๊ฐœ๋ฐœํ™˜๊ฒฝ๊ณผ Python ๊ฐ€์ƒํ™˜๊ฒฝ ๊ตฌ์„ฑ

 

vscode ์„ค์น˜


Visual Studio Code - Code Editing. Redefined
Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
https://code.visualstudio.com/
  • Visual Studio IntelliCode
  • Project Manager
  • URDF
  • C/C++
  • Python
  • CMake Tools
  • Material Theme
  • Code runner
  • etc...

 

Additional Setup


$ sudo apt-get purge modemmanager

$ sudo adduser [์‚ฌ์šฉ์ž ๊ณ„์ • ์ด๋ฆ„]
$ sudo usermod -aG sudo [์‚ฌ์šฉ์ž ๊ณ„์ • ์ด๋ฆ„]

reference : How to create sudo user on Ubuntu 18.04 Bionic Beaver Linux

 

Ubuntu ROS Melodic ์„ค์น˜


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

$ sudo apkey adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
# ์˜ค๋ฅ˜ ๋ฐœ์ƒ์‹œ
$ curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -

$ sudo apt update
$ sudo apt install ros-melodic-desktop-full

$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
$ source ~/.bashrc
$ sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
$ sudo rosdep init
$ rosdep update

์ฐธ๊ณ  ์ž๋ฃŒ : ROS Wiki

Wiki
A ROS distribution is a versioned set of ROS packages. These are akin to Linux distributions (e.g. Ubuntu). The purpose of the ROS distributions is to let developers work against a relatively stable codebase until they are ready to roll everything forward.
http://wiki.ros.org/Distributions
๐Ÿ’ก
์œ„ ์„ค์น˜๋Š” ์ ฏ์Šจ ๋‚˜๋…ธ์— ์„ค์น˜ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ!! ๋ฐ์Šคํฌํƒ‘(๋…ธํŠธ๋ถ)์šฉ ์„ค์น˜์ž…๋‹ˆ๋‹ค!!

 

์•ž์œผ๋กœ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฐฐ๋ณดํŒ ROS ํŒจํ‚ค์ง€๋“ค์„ ์ถ”๊ฐ€ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

$ sudo apt-get install ros-melodic-<package name>

์ž๋™์™„์„ฑ tabํ‚ค๋ฅผ ์ ๊ทน ์‚ฌ์šฉํ•˜์„ธ์š”!!

 

์„ค์น˜ ํ™•์ธ


  • ์ƒˆ๋กœ ํ„ฐ๋ฏธ๋„์„ ์—ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
$ roscore
... logging to /home/kimsooyoung/.ros/log/5b440a74-4cda-11eb-a263-9cb6d08bf543/roslaunch-kimsooyoung-XPS-13-9370-10527.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://localhost:38251/
ros_comm version 1.14.10


SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.10

NODES

auto-starting new master
process[master]: started with pid [10537]
ROS_MASTER_URI=http://localhost:11311/

setting /run_id to 5b440a74-4cda-11eb-a263-9cb6d08bf543
process[rosout-1]: started with pid [10559]
started core service [/rosout]

๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ปค๋งจ๋“œ๋ผ์ธ์ด ๋ณด์˜€๋‹ค๋ฉด ์™„๋ฃŒ๋œ ๊ฒƒ์ž…๋‹ˆ๋‹ค!! ๐Ÿ˜‰

 

์‹œํ—˜์‚ผ์•„ ROS ํ”„๋กœ๊ทธ๋žจ์„ ํ•˜๋‚˜ ์‹คํ–‰์‹œ์ผœ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

$ rosrun turtlesim turtlesim_node

# ์ƒˆ ํ„ฐ๋ฏธ๋„ ์‹คํ–‰
$ rosrun turtlesim turtle_teleop_key

์œ„ ์ปค๋งจ๋“œ ๋ผ์ธ๋“ค๋„ ๋ชจ๋‘ ์‹คํ–‰๋˜์…จ๋‹ค๋ฉด, ๋ฌธ์ œ์—†์ด ์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

~/.bashrc ์ˆ˜์ •


$ gedit ~/.bashrc

# ํŒŒ์ผ ์ œ์ผ ์•„๋ž˜์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‚ด์šฉ ์ž…๋ ฅ
alias eb='gedit ~/.bashrc'
alias sb='source ~/.bashrc'
alias gs='git status'
alias gp='git pull'
alias cw='cd ~'
alias cs='cd ~/src'
alias cm='cd ~ && catkin_make'

alias cma='catkin_make -DCATKIN_WHITELIST_PACKAGES=""'
alias cop='catkin_make --only-pkg-with-deps'
alias sds='source devel/setup.bash'
alias axclient='rosrun actionlib axclient.py'

# ์ข…๋ฃŒ ํ›„ ํ„ฐ๋ฏธ๋„ ์—…๋ฐ์ดํŠธ
$ source ~/.bashrc

๊ฐ๊ฐ์˜ ๋ช…๋ น์ด ์–ด๋–ค ์˜๋ฏธ๋ฅผ ๊ฐ€์ง€๋Š”์ง€๋Š” ์•ž์œผ๋กœ ๊ณ„์†ํ•ด์„œ ๋‹ค๋ค„๋ด…๋‹ˆ๋‹ค.

๋‹ค๋งŒ, alias๊ฐ€ ์–ด๋–ค ๊ฒƒ์ธ์ง€๋งŒ ์‚ด์ง ์งš์–ด๋ณด๊ณ  ๋„˜์–ด๊ฐ€๊ฒ ์Šต๋‹ˆ๋‹ค.