23.10.04 ์งํ
24.02.25 1์ฐจ ์์
25.07.15 2์ฐจ ์์
--- INDEX ---
0. ์ก ์๋ก
1. .bashrcํ์ผ
2. alias ์ค์
3. ROS2 ๊ธฐ๋ณธ .bashrc
--- --- ---
0. ์ก ์๋ก
.bashrc ํ์ผ
์ด๊ฒ ๋ญ๊น? ๋ญ๋ฐ ROS๋ฅผ ๋ง์ง๋๋ฐ ๊ฐ์๊ธฐ ๋ฌ๊ธ์์ด ๊ฑด๋ค์ผ๊น..?
์ฌ์ค ROS๋์ ํฐ ์๊ด์ ์๋๋ฐ, ROS๋ฅผ ์กฐ๋ชฐ๋ฑ ๊ฑฐ๋ฆฌ๋๋ฐ์ ์์ด์ bashrc๋ฅผ ๊ฑด๋๋๊ฒ ํธ๋ฆฌํ๊ธฐ๋๋ฌธ์ ๋ง์ง์ ๊ฑฐ๋ ค๋ดค๋ค.
1. .bashrc ํ์ผ?
bashrc๋ ์ฌ์ฉ์๋ง๋ค run command๋ค์ ๋ชจ์๋๋ ํ์ผ์ธ๋ฐ, ์ฌ๊ธฐ์ ๋ค์ํ ๋จ์ถํค(alias)๊ฐ์๊ฒ ๋ฑ๋ก๋์ด์๋ค.
bash๊ฐ ์ผ์ง ๋ ๋ง๋ค ์ด ํ์ผ์ ํ๋ฒ ์ฝ๊ณ ์ผ์ง๋ฏ๋ก, ์คํํ ํ์ผ์ด ๋ง์ ROS์์๋, bashrc์ ๊ธฐ๋ณธ์ ์ผ๋ก ์คํ ๋ช ๋ น์ด๋ค์ ๋ฃ์ด๋๋ฉด, bash๋ฅผ ์๋ก ์ฌ๋ ๊ฒ ๋ง์ผ๋ก๋ ์คํ ๋ช ๋ น์ด๋ค์ ๋ชจ์กฐ๋ฆฌ ํ๋ฒ์ฉ ์ฝ๊ณ ์์ํ๋ ๊ฒ๊ณผ ๊ฐ๋ค.
๊ทธ๋ฌ๋๊น, ์งง๊ฒ ๋งํ๋ฉด.. RPG๊ฒ์์์ ๊ธฐ๋ณธ๋ฅ๋ ฅ์น ๊ฐํํ๋ ์คํฌ์ด ์์๋๋ฐ, ์ด๋ฅผ ํจ์๋ธ๋ก ๋ฐ๊พผ ๋๋์ด๋ค.
๋ค์ํ ํธ์ง๊ธฐ๋ค์ ์ด์ฉํด ์ฌ๊ธฐ์ ์ ์ํ ์ ์์ผ๋(vi, gefit, vim ๋ฑ), ํ์๋ vscode๋ฅผ ๊น์๋์ผ๋ฏ๋ก vscode๋ฅผ ์ด์ฉํด๋ณด์.
$ cd
$ code .
ํ์์ vscode๋ฅผ ์ด๋ฉด
์จ์ด์๋ ํ์ผ๋ค์ด ๋ณด์ธ๋ค. Linux๊ธฐ๋ฐ์ OS์์ " . "(๋ง์นจํ)๋ก ์์ํ๋ ํ์ผ์ ์จ๊นํ์ผ์ด๊ธฐ ๋๋ฌธ์ ls๋ช ๋ น์ผ๋ก ๋ณด์ด์ง ์์์ ๊ฒ์ด๋ค.
์ด์, .bashrc๋ฅผ ํด๋ฆญํด์ฃผ๋ฉด,
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
์ด๋ฐ ์ฝ๋๊ฐ ์์ํ ๋ฐ, ์ ์ผ ๋ง์ง๋ง์ ์๋์ ๊ฐ์ ์ฝ๋๋ฅผ ์ถ๊ฐํ๋ค.
echo "ROS2 humble has been activated"
source /opt/ros/humble/setup.bash
setup.bash๋ ros2๋ฅผ ์ฐ๋ฉด์ ํญ์ ๋๋ ค์ผ๋๋ ์ฝ๋์ด๊ธฐ์, ์์ ๊ฐ์ ์ฝ๋๋ฅผ ์ถ๊ฐํ๋ค.
.bashrcํ์ผ์ด ๋ณ๊ฒฝ๋์์ผ๋ฏ๋ก,
source ~/.bashrc
์ ์ ๋ ฅํ์ฌ bashrc๋ฅผ ๋ค์ ์ฝํ์ค์ผ ํ๋ค.
์ด์ , ํฐ๋ฏธ๋์ ์ผค ๋ ๋ง๋ค "ROS2 humble has been activated"๋ผ๋ ๋ฌธ๊ตฌ๊ฐ ๊ณ์ ๋จ๊ฒ ๋๋ค.
2. alias ์ค์
bashrcํ์ผ์ souce๋ก ์ง์ ์ ์ผ๋ก ๋ฃ์ด๋๋ฉด, ํฐ๋ฏธ๋์ด ์ผ์ง๋๋ง๋ค ์๋์ผ๋ก ros์ setupํ์ผ์ด ์ผ์ง์ง๋ง,
๋ด๊ฐ ๋ฐ๋ก ๋ช ๋ น์ด๋ฅผ ๋ง๋ค์ด์ ์คํํ๊ณ ์ถ์๋๋ง ๊ฐํธํ๊ฒ ์คํํ ์ ์๋ค.
์์ 1๋ฒ์์ ์ถ๊ฐํ๋ ์ฝ๋ ์์ด ์๋์ ์ฝ๋๋ง ๋ฃ์ด๋ณด์.
alias qwe="source /opt/ros/humble/setup.bash; echo \" activbated \""
๊ทธ๋ฌ๊ณ ๋์ ์๋์ ์ฝ๋๋ฅผ ๋๋ฏธ๋์ฐฝ์ ์ ๋ ฅํด์ผ ์ ์ฉ๋๋ค.
source ~/.bashrc
์ด์ qwe๋ผ๋ ๋์ถฉ๋ง๋ "๋ช ๋ น์ด"๊ฐ ์๊ธด๊ฑฐ๋ค.
์ผ์ผ ๋๋ค.
3. ROS ๊ธฐ๋ณธ .bashrc
๋ค์ด๋ฒ ์นดํ "์ค๋ก์นด"์ ํ์ค์๋ฐ์ฌ๋ bashrc๋ด์ฉ์ ๊ฐ์ ธ์๋ค.
์ผ๋จ ์ถ์ฒ๊ณ ๋ญ๊ณ ๋ค ์ ์ด๋๊ฒ ์ง๋ง ๋ด๊ฐ ๋ณผ๋ ค๊ณ ๊ฐ์ ธ์จ๊ฑฐ๋ผ... ๋ฌธ์ ์ ์ญ์ ํจ ใ
https://cafe.naver.com/openrt/25288
001 ROS 2 ๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ถ
Created Date: 2020.07.13 Modified Date: 2022.02.03 revision 34 * ๋ก๋ด ์ด์์ฒด์ ROS ๊ฐ์ข ๋ชฉ์ฐจ: https://cafe...
cafe.naver.com
source /opt/ros/humble/setup.bash
source ~/robot_ws/install/local_setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
source /usr/share/vcstool-completion/vcs.bash
source /usr/share/colcon_cd/function/colcon_cd.sh
export _colcon_cd_root=~/robot_ws
export ROS_DOMAIN_ID=7
export ROS_NAMESPACE=robot1
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
# export RMW_IMPLEMENTATION=rmw_connext_cpp
# export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
# export RMW_IMPLEMENTATION=rmw_gurumdds_cpp
# export RCUTILS_CONSOLE_OUTPUT_FORMAT='[{severity} {time}] [{name}]: {message} ({function_name}() at {file_name}:{line_number})'
export RCUTILS_CONSOLE_OUTPUT_FORMAT='[{severity}]: {message}'
export RCUTILS_COLORIZED_OUTPUT=1
export RCUTILS_LOGGING_USE_STDOUT=0
export RCUTILS_LOGGING_BUFFERED_STREAM=1
alias cw='cd ~/robot_ws'
alias cs='cd ~/robot_ws/src'
alias ccd='colcon_cd'
alias cb='cd ~/robot_ws && colcon build --symlink-install'
alias cbs='colcon build --symlink-install'
alias cbp='colcon build --symlink-install --packages-select'
alias cbu='colcon build --symlink-install --packages-up-to'
alias ct='colcon test'
alias ctp='colcon test --packages-select'
alias ctr='colcon test-result'
alias rt='ros2 topic list'
alias re='ros2 topic echo'
alias rn='ros2 node list'
alias killgazebo='killall -9 gazebo & killall -9 gzserver & killall -9 gzclient'
alias af='ament_flake8'
alias ac='ament_cpplint'
alias testpub='ros2 run demo_nodes_cpp talker'
alias testsub='ros2 run demo_nodes_cpp listener'
alias testpubimg='ros2 run image_tools cam2image'
alias testsubimg='ros2 run image_tools showimage'
[์ถ์ฒ] 001 ROS 2 ๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ถ (์คํ์์ค ์ํํธ์จ์ด & ํ๋์จ์ด: ๋ก๋ด ๊ธฐ์ ๊ณต์ ์นดํ (์ค๋ก์นด)) | ์์ฑ์ ํ์ค์
4. ์ฃผ์์ฌํญ
๊ธฐ์กด์ .bashrc์ ๋ด์ฉ์ ์ง์ฐ๊ณ ์ฎ๊ธฐ์ง ์๋๊ฒ์ ๋งค์ฐ ๊ฐ๋ ฅํ ๊ถ๊ณ ํ๋ค.
๊ธฐ์กด์ ์ฐ๋ฆฌ๊ฐ CLIํ๊ฒฝ์์ ์ปค๋ฉ๋๋ฅผ ์ ๋ ฅํ๋ฉด์ ์๊น์ด ๋ณํ๋ ๊ฒ๋ค๋ ๋ค .bashrc์ ๋ฑ๋ก๋์ด์๋ ๊ฒ์ด๊ธฐ์,,,
๊ธฐ์กด์ ๋ด์ฉ์ ์ง์ฐ๋ฉด "๊ต์ฅํ ๋ถํธํ", ํฐ์๊ณผ ๊ฒ์์๋ฐ์ ๋ณผ ์ ์๋ ์๊ธฐ์๋๋ก ๋์๊ฐ ์ ์๋ค.
ํ์๋ ์ฌ์ค ์๊ณ ์ถ์ง ์์๋ค.. ํนํ WSLํ๊ฒฝ์์ ์ด๊ฑธ ์ง์ ๋ค๋ฉด, ์๊ทธ๋๋ ์ชผ๋๋ง ํ๊ฒฝ์์ ๋ณด์ด์ง๋ ์๋ ๊ฒํฐํ๋ฉด์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํด์ผํ๋ค.
'SW > ROS2 & Linux' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
apt update ์ค ์ค๋ฅ, ํด์ ํฉ์ด ๋ง์ง ์์ต๋๋ค. (apt update hash sum mismatch) (1) | 2024.06.02 |
---|---|
ROS2) ROS2 Humble ์ค์นํ๊ธฐ (Ubuntu 22.04 LTS) ! (0) | 2023.09.30 |
ROS2) VMware installing & Ubuntu 22.04 (3) | 2023.09.29 |
Linux Basic (0) | 2022.08.09 |