|
3 | 3 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) |
4 | 4 | # for examples |
5 | 5 |
|
| 6 | +# --- ROS2 workspace setup --- |
| 7 | + |
| 8 | +# Define the ROS2 workspace directory |
| 9 | +ROS2_WS_DIR="$HOME/AirStack/gcs/ros_ws" |
| 10 | +# needed for communication with Isaac Sim ROS2 # https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_ros.html#enabling-the-ros-bridge-extension |
| 11 | +export FASTRTPS_DEFAULT_PROFILES_FILE="$ROS2_WS_DIR/fastdds.xml" |
| 12 | +# for local development, prevent conflict with other desktops |
| 13 | +export ROS_LOCALHOST_ONLY=1 |
| 14 | + |
| 15 | +# fix ROS2 humble setuptools deprecation warning https://robotics.stackexchange.com/questions/24230/setuptoolsdeprecationwarning-in-ros2-humble/24349#24349 |
| 16 | +PYTHONWARNINGS="ignore:easy_install command is deprecated,ignore:setup.py install is deprecated" |
| 17 | +export PYTHONWARNINGS |
| 18 | + |
| 19 | +# Convenience functions for ROS2 workspace |
| 20 | + |
| 21 | +function bws(){ |
| 22 | + echo "Running \`colcon build $@\` in $ROS2_WS_DIR" |
| 23 | + COLCON_LOG_PATH="$ROS2_WS_DIR"/log colcon build --symlink-install --base-paths "$ROS2_WS_DIR"/ --build-base "$ROS2_WS_DIR"/build/ --install-base "$ROS2_WS_DIR"/install/ "$@" |
| 24 | +} |
| 25 | +function sws(){ |
| 26 | + echo "Sourcing "$ROS2_WS_DIR"/install/local_setup.bash" |
| 27 | + source "$ROS2_WS_DIR"/install/local_setup.bash || echo "Please make sure to build first with 'bws'" |
| 28 | +} |
| 29 | + |
| 30 | +# Function to prompt user for confirmation |
| 31 | +confirm_cws() { |
| 32 | + while true; do |
| 33 | + read -p "Are you sure you want to clean the ROS2 workspace under $ROS2_WS_DIR? (y/N): " yn |
| 34 | + yn=${yn:-no} # Default to 'no' if no answer is given |
| 35 | + case $yn in |
| 36 | + [Yy] | [Yy][Ee][Ss] ) return 0;; |
| 37 | + [Nn] | [Nn][Oo] ) return 1;; |
| 38 | + * ) echo "Please answer yes or no.";; |
| 39 | + esac |
| 40 | + done |
| 41 | +} |
| 42 | +function cws(){ |
| 43 | + # Call the confirmation function |
| 44 | + if confirm_cws; then |
| 45 | + echo "Cleaning ROS2 workspace..." |
| 46 | + set -x |
| 47 | + # Remove build, install, and log directories |
| 48 | + if ! rm -rf "$ROS2_WS_DIR"/build/ "$ROS2_WS_DIR"/install/ "$ROS2_WS_DIR"/log/; then |
| 49 | + { set +x; } 2>/dev/null |
| 50 | + echo "Error: Failed to remove ROS2 workspace directories." |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | + |
| 54 | + # Set environment variables |
| 55 | + export AMENT_PREFIX_PATH="/opt/ros/humble" |
| 56 | + export CMAKE_PREFIX_PATH="" |
| 57 | + |
| 58 | + { set +x; } 2>/dev/null # set +x w/out it being printed |
| 59 | + echo "ROS2 workspace has been cleaned successfully." |
| 60 | + else |
| 61 | + echo "Operation cancelled." |
| 62 | + fi |
| 63 | +} |
| 64 | + |
| 65 | +source /opt/ros/humble/setup.bash |
| 66 | +sws # source the ROS2 workspace by default |
| 67 | + |
6 | 68 | # If not running interactively, don't do anything |
7 | 69 | [ -z "$PS1" ] && return |
8 | 70 |
|
|
102 | 164 | # . /etc/bash_completion |
103 | 165 | #fi |
104 | 166 |
|
105 | | -# --- ROS2 workspace setup --- |
106 | | - |
107 | | -# Define the ROS2 workspace directory |
108 | | -ROS2_WS_DIR="$HOME/AirStack/gcs/ros_ws" |
109 | | -# needed for communication with Isaac Sim ROS2 # https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_ros.html#enabling-the-ros-bridge-extension |
110 | | -export FASTRTPS_DEFAULT_PROFILES_FILE="$ROS2_WS_DIR/fastdds.xml" |
111 | | -# for local development, prevent conflict with other desktops |
112 | | -export ROS_LOCALHOST_ONLY=1 |
113 | | - |
114 | | -# fix ROS2 humble setuptools deprecation warning https://robotics.stackexchange.com/questions/24230/setuptoolsdeprecationwarning-in-ros2-humble/24349#24349 |
115 | | -PYTHONWARNINGS="ignore:easy_install command is deprecated,ignore:setup.py install is deprecated" |
116 | | -export PYTHONWARNINGS |
117 | | - |
118 | | -# Convenience functions for ROS2 workspace |
119 | | - |
120 | | -function bws(){ |
121 | | - echo "Running \`colcon build $@\` in $ROS2_WS_DIR" |
122 | | - COLCON_LOG_PATH="$ROS2_WS_DIR"/log colcon build --symlink-install --base-paths "$ROS2_WS_DIR"/ --build-base "$ROS2_WS_DIR"/build/ --install-base "$ROS2_WS_DIR"/install/ "$@" |
123 | | -} |
124 | | -function sws(){ |
125 | | - echo "Sourcing "$ROS2_WS_DIR"/install/local_setup.bash" |
126 | | - source "$ROS2_WS_DIR"/install/local_setup.bash || echo "Please make sure to build first with 'bws'" |
127 | | -} |
128 | | - |
129 | | -# Function to prompt user for confirmation |
130 | | -confirm_cws() { |
131 | | - while true; do |
132 | | - read -p "Are you sure you want to clean the ROS2 workspace under $ROS2_WS_DIR? (y/N): " yn |
133 | | - yn=${yn:-no} # Default to 'no' if no answer is given |
134 | | - case $yn in |
135 | | - [Yy] | [Yy][Ee][Ss] ) return 0;; |
136 | | - [Nn] | [Nn][Oo] ) return 1;; |
137 | | - * ) echo "Please answer yes or no.";; |
138 | | - esac |
139 | | - done |
140 | | -} |
141 | | -function cws(){ |
142 | | - # Call the confirmation function |
143 | | - if confirm_cws; then |
144 | | - echo "Cleaning ROS2 workspace..." |
145 | | - set -x |
146 | | - # Remove build, install, and log directories |
147 | | - if ! rm -rf "$ROS2_WS_DIR"/build/ "$ROS2_WS_DIR"/install/ "$ROS2_WS_DIR"/log/; then |
148 | | - { set +x; } 2>/dev/null |
149 | | - echo "Error: Failed to remove ROS2 workspace directories." |
150 | | - exit 1 |
151 | | - fi |
152 | | - |
153 | | - # Set environment variables |
154 | | - export AMENT_PREFIX_PATH="/opt/ros/humble" |
155 | | - export CMAKE_PREFIX_PATH="" |
156 | | - |
157 | | - { set +x; } 2>/dev/null # set +x w/out it being printed |
158 | | - echo "ROS2 workspace has been cleaned successfully." |
159 | | - else |
160 | | - echo "Operation cancelled." |
161 | | - fi |
162 | | -} |
163 | | - |
164 | | -source /opt/ros/humble/setup.bash |
165 | | -sws # source the ROS2 workspace by default |
166 | | - |
167 | 167 | export RCUTILS_COLORIZED_OUTPUT=1 |
168 | 168 |
|
169 | 169 | export ROS_DOMAIN_ID=0 |
0 commit comments