ros alias

# Description: Alias for ROS2
# Author: Tang Guofang
# Date: 2023-07-09

##############  ROS2 ################
if [ -d "/opt/ros/rolling" ]; then
  source /opt/ros/rolling/setup.bash
fi

##############  ROS2 WORKSPACE ################
ros2_ws="/home/sczone/01_workspace/06_zone"
if [ -d "$ros2_ws/install" ]; then
  source "$ros2_ws/install/setup.bash"
fi

##############  ROS2 BAG ################
alias rbpl='ros2 bag play -l -s sqlite3 '
alias rpplo='rbpl --start-offset '
##############  COLCON BUILD ################
cbpu() {
  if ( [ -d "$COLCON_PREFIX_PATH" ] && [ -d "$COLCON_PREFIX_PATH/.." ] ); then
    colcon build --packages-up-to "$1" --cmake-args " -DCMAKE_C_COMPILER_LAUNCHER=ccache" --cmake-args " -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" --build-base "$COLCON_PREFIX_PATH/../build" --install-base "$COLCON_PREFIX_PATH/../install" --event-handlers console_direct+
    echo -e "\033[1;33m-- Cross-folder compilation\n-- Output path: $(readlink -f $COLCON_PREFIX_PATH/..)/install\n-- Build path: $(readlink -f $COLCON_PREFIX_PATH/..)/build\n-- Please source the install/setup.bash then run the program\033[0m"
  else
    colcon build --packages-up-to "$1" --cmake-args " -DCMAKE_C_COMPILER_LAUNCHER=ccache" --cmake-args " -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" --event-handlers console_direct+
    echo -e "\033[1;33m-- Current-folder compilation\n-- Output path: current_path/install\n-- Build path: current_path/build\n-- Please source the install/setup.bash then run the program\033[0m"
  fi
}
_cbpu() {
  if ( [ -d "$COLCON_PREFIX_PATH" ] && [ -d "$COLCON_PREFIX_PATH/.." ] ); then
    COMPREPLY=()
    local cur=${COMP_WORDS[COMP_CWORD]}
    local prev=${COMP_WORDS[COMP_CWORD-1]}
    local opts=$(find $COLCON_PREFIX_PATH/.. -name "package.xml" -exec grep -oPm1 "(?<=<name>)[^<]+" {} \;)
    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  else
    return
  fi
}
complete -F _cbpu cbpu

##############  ROS2 RUN ################
rr() {
  if [[ "$1" == */ ]]; then
    local len=${#1}
    local len=$((len-1))
    local pkg=${1:0:$len}
  else
    local pkg=$1
  fi
  ros2 run "$pkg" "$pkg"
}
_rr() {
  COMPREPLY=()
  local cur=${COMP_WORDS[COMP_CWORD]}
  local prev=${COMP_WORDS[COMP_CWORD-1]}
  local opts=$(find $COLCON_PREFIX_PATH -mindepth 3 -maxdepth 3 -executable ! \( -path "*msg*" -o -path "*ament*" -o -path "*message*" -o -path "*share*" -o -path "*include*" -o -name "*.*" \) -printf "%f\n")
  COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}
complete -F _rr rr

alias rrpj='rr plotjuggler'

Including rclcpp/rclcpp.hpp Elapsed time: 26 s. (time), 0.00041 s. (clock)

Excluding rclcpp::rclcpp Elapsed time: 28 s. (time), 0.000434 s. (clock)

Using release mode Elapsed time: 25 s. (time), 0.000435 s. (clock)

First time using ccache Elapsed time: 26 s. (time), 0.00038 s. (clock)

Second time using ccache Elapsed time: 0 s. (time), 0.000341 s. (clock)

colcon build –cmake-args -DCMAKE_C_COMPILER_LAUNCHER=ccache –cmake_args -DCMAKE_CXX_COMPILER_LAUNCHER=ccache


已发布

分类

来自

标签:

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注