Select Git revision
-
Montaño Sarria, Andres Felipe authoredMontaño Sarria, Andres Felipe authored
ros.bash 1.68 KiB
###################################################################
# ROS aliases and functions
###################################################################
# Define ROS_DISTRO before source ROS
if [ -z $ROS_DISTRO ]; then export ROS_DISTRO=noetic; fi
# Determine shell extension
if [ -z $SHELL ]; then echo "SHELL not set"; else ext=$(basename ${SHELL}); fi
# Source rosmon
function smon(){
source /opt/ros/${ROS_DISTRO}/etc/catkin/profile.d/50-rosmon.${ext}
}
# cd to the root of the workspace
function roshome(){
roscd && cd ..
}
# Source the current workspace
function sourcews(){
source ./devel/setup.${ext} && smon
}
# Source the current workspace
function sourceros(){
source /opt/ros/${ROS_DISTRO}/setup.${ext} && smon
}
# Source the current workspace
function sourcethis(){
pwd_st=${PWD}
roshome && source ./devel/setup.${ext} && smon
cd ${pwd_st}
}
# Automatic catkin build
function cb() {
pwd_cb=${PWD}
roshome
catkin build --summarize "$@"
sourcethis
cd ${pwd_cb}
}
# Clean workspace (delete the generated folders, then catkin build)
function cbclean(){
roshome && rm -rf build devel install && catkin build --summarize
}
# Initialize catkin workspace, configure and build it
function cib(){
catkin init && catkin config --extend /opt/ros/${ROS_DISTRO} && catkin build --summarize
}
# If terminal starts in a ws, auto source it (useful for vscode)
pwd_init=${PWD}
cropped=${PWD#${HOME}/ros/${ROS_DISTRO}/}
WS_name=${cropped%%/*}
WS_path=${HOME}/ros/${ROS_DISTRO}/${WS_name}
FILE=${WS_path}/devel/setup.${ext}
if [[ -f $FILE ]]; then
cd ${WS_path}
source $FILE
cd ${pwd_init}
else
source /opt/ros/${ROS_DISTRO}/setup.${ext}
fi