Control using Odroid SBC

Startup Session ๋งŒ๋“ค๊ธฐ

๋กœ๋ด‡์˜ ์ „์›์ธ๊ฐ€ํ›„ OS ์‹œ์ž‘์‹œ์— ์ž๋™์œผ๋กœ ํ”„๋กœ๊ทธ๋žจ์ด ๋™์ž‘๋˜๋„๋ก ์„ธํŒ…ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณธ๋‹ค.

~/.bashrc ์— ๋ช…๋ น์–ด๋ฅผ ๋‹จ์ถ•์–ด๋กœ ์‹คํ–‰์‹œํ‚ค๊ธฐ ์œ„ํ•œ alias ์„ค์ •์„ ํ•œ๋‹ค. ์ด๋Š” ์„ ํƒ์‚ฌํ•ญ์ด๋‚˜ ์ด๋ ‡๊ฒŒ ํ•ด๋†“์œผ๋ฉด ํŽธ๋ฆฌํ•˜๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์ด ๋‚ด์šฉ์„ .bashrc ํŒŒ์ผ ๋งˆ์ง€๋ง‰์— ๊ธฐ์ž…์„ ํ•ด ๋†“์œผ๋ฉด mr0๋ผ๋Š” ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ•ด๋‹นํ•˜๋Š” roslaunch ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค.

sr๊ณผ sr0 ๋‹จ์ถ• ๋ช…๋ น์–ด๋Š” ์•„๋ž˜์—์„œ ๋‹ค์‹œ ์„ค๋ช…ํ•˜๊ฒ ๋‹ค.

alias mr0='roslaunch mecanum_robot_ver1 mecanum_robot_ver1_teleop.launch'
alias sr='screen -r startupSess'
alias sr0='screen -r startupSess0'

์ด์   ~/ ํด๋”์— ํ˜น์€ ์›ํ•˜๋Š” ํด๋”์— screen์„ ์ด์šฉํ•˜์—ฌ ์‹œ์ž‘ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์„ค๋ช…ํ•œ๋‹ค. screen ์ด ์„ค์น˜๋˜์–ด ์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ์—๋Š” sudo apt-get install screen ๋ช…๋ น์–ด๋กœ ์„ค์น˜๋ฅผ ํ•˜๋ฉด๋œ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์€ bash script๋ฅผ ์ด์šฉํ•˜์—ฌ startupSess ์Šคํƒ€ํŠธ์—… ์„ธ์…˜์„ ๋งŒ๋“ค์ˆ˜ ์žˆ๋‹ค. cat ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•˜์—ฌ autorun_script.sh ํŒŒ์ผ์•ˆ์˜ ๋‚ด์šฉ์„ ๋“ค์—ฌ๋‹ค ๋ณด๋ฉด screen ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•˜์—ฌ ์‹œ์ž‘ ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰๋˜๋ฉฐ mr0 ๋ผ๋Š” ์•ž์— ์„ ์–ธํ•œ ๋‹จ์ถ•๋ช…๋ น์–ด๋กœ roslaunch ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.

odroid@odroid:~$ cat autorun_script.sh
# Run HuboQ Remastered Ver1 - hq0 in Startup
screen -S "startupSess" -d -m
screen -r "startupSess" -X stuff $'mr0\n'

autorun_script.sh๋Š” ์‹คํ–‰๊ฐ€๋Šฅ ๋ช…๋ น์–ด๋กœ ๋งŒ๋“ค์–ด์•ผํ•˜๊ธฐ chmod +x autorun_script.sh ๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ์‹คํ–‰๊ฐ€๋Šฅํ•˜๊ฒŒ ๋งŒ๋“ค์–ด๋†“๋Š”๋‹ค. ์—ฌ๊ธฐ๊นŒ์ง€ ํ•˜๋ฉด autorun_script.sh ํŒŒ์ผ์„ ์ด์šฉํ•˜์—ฌ screen ์„ธ์…˜์„ ์—ด๊ณ  ๊ทธ ์•ˆ์—์„œ rosํ”„๋กœ๊ทธ๋žจ์„ ๋Œ๋ฆฌ๊ฒŒ ๋œ๋‹ค.

screen์€ ์šฐ๋ฆฌ๊ฐ€ ssh๋ฅผ ์ด์šฉํ•ด์„œ ์›๊ฒฉ์ ‘์†์„ ํ•˜๋ฉด ํ„ฐ๋ฏธ๋„ ์ฐฝ์—์„œ ํ•˜๋‚˜์˜ ์„ธ์…˜์ด ์ƒ์„ฑ๋˜๋“ฏ์ด ์œ„์˜ screen์„ ์ด์šฉํ•˜์—ฌ ์„ธ์…˜์„ ๋งŒ๋“  ๊ฒƒ์ด๋ฏ€๋กœ ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ background์—์„œ ๋™์ž‘ํ•˜๊ฒŒ ๋˜๋ฉฐ ์ด๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ๋ช…๋ น์–ด๊ฐ€ ์•ž์—์„œ ๋ฏธ๋ฆฌ ๋งŒ๋“ค์–ด ๋†“์€ sr ์ด๋‹ค.

์ž, ์ด์ œ ์‹ค์งˆ์ ์œผ๋กœ ์ฒ˜์Œ OS๊ฐ€ ์‹คํ–‰๋˜๊ณ ๋‚˜์„œ ์ž๋™์ ์œผ๋กœ autorun_script.sh๊ฐ€ ๋™์ž‘๋˜๋„๋ก ํ•ด์•ผํ•œ๋‹ค. ์ด๊ฒƒ์€ /etc/rc.local ํŒŒ์ผ์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค.

odroid@odroid:~$ cat /etc/rc.local
#!/bin/bash

# autorun script
su odroid -c '/home/odroid/autorun_script_gpio.sh &'
su odroid -c '/home/odroid/autorun_script.sh &'

if [ -f /aafirstboot ]; then /aafirstboot start ; fi

if [ -f /aafirstboot ]; then /aafirstboot start ; fi

exit 0

์—ฌ๊ธฐ์„œ๋Š” autorun_script.sh์™€ autorun_script_gpio.sh ๋‘๊ฐœ์˜ bash script๊ฐ€ ๊ฐ๊ฐ ๋…๋ฆฝ์ ์ธ screen ์„ธ์…˜์œผ๋กœ ์‹คํ–‰๋˜๋„๋ก ํ•˜์˜€๋‹ค. ์ด๋Š” odroid์˜ gpio๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ๋ณ„๋„์˜ ํ”„๋กœ๊ทธ๋žจ๊ณผ roslauch๋ฅผ ํ†ตํ•ด ์‹คํ–‰ํ•˜๋Š” ๋‘๊ฐœ์˜ ํ”„๋กœ๊ทธ๋žจ์„ ๋ชจ๋‘ ์‹คํ–‰ํ•ด์•ผํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด์™€ ๊ฐ™์ด ๊ตฌ์„ฑํ•˜์˜€๋‹ค.

์ด๋ ‡๊ฒŒ ์„ธํŒ…์„ ํ•˜๋ฉด ์‹œ์ž‘์‹œ ์ž๋™์ ์œผ๋กœ mr0 ํ”„๋กœ๊ทธ๋žจ๊ณผ gpio ํ”„๋กœ๊ทธ๋žจ์ด ์‹คํ–‰๋˜๋Š”๋ฐ ์ด๋Š” background์—์„œ ์‹คํ–‰์ด ๋œ๋‹ค๊ณ  ํ•˜์˜€์œผ๋ฏ€๋กœ ์ด ์‹คํ–‰์ƒํƒœ๋ฅผ ์ง์ ‘ ํ™•์ธํ•˜๊ณ ์ž ํ• ๋•Œ๋Š” ssh๋กœ ํ„ฐ๋ฏธ๋„ ์ ‘์†์„ ํ•œ ์ƒํƒœ์—์„œ sr ๋˜๋Š” sr0๋ฅผ ํ†ตํ•ด ๊ฐ๊ฐ ์„ธ์…˜์œผ๋กœ ์ž…์žฅ์„ ํ•  ์ˆ˜ ์žˆ๊ณ  ๋‚˜์˜ฌ ๋•Œ๋Š” exit ๋ช…๋ น์–ด๋กœ ๋‚˜์˜ฌ ์ˆ˜ ์žˆ๋‹ค.

Last updated

Was this helpful?