Setup Quick Source for ROS
Create .ros2rc or .ros1rc under your HOME
folder for quick sourcing instead of source /opt/ros/.../setup.bash
. Now you can just do:
source ~/.ros2rc
.ros2rc
#!/bin/sh
# ROS2 stuff
export ROS_DISTRO=humble
# Set your Domain ID if you are in a network with multiple computers,
# but do not turn this on if you want to use VScode to debug.
export ROS_DOMAIN_ID=7
source /opt/ros/$ROS_DISTRO/setup.bash
# Setup colcon_cd
source /usr/share/colcon_cd/function/colcon_cd.sh
export _colcon_cd_root=/opt/ros/$ROS_DISTRO
# Colcon Auto-completion
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
# For quick debug use --symlink-install
alias ros2build="colcon build --symlink-install;source install/setup.bash"
- See:
- How to Setup
colcon_cd
- How to Setup
If you are using Gazebo Simulator, add the following:
# Set Gazebo Version (If Installed), and source the setup
export GZ_VERSION="garden"
source /home/$USER/gazebo/install/setup.bash
If you have RosTeamWS, a framework for boosting team collaboration for robots using ROS, add the following:
# RosTeamWS setup
source <PATH TO ros_team_workspace>/setup.bash
# Add auto-sourcing
if [ -f ~/.ros_team_ws_rc ]; then
. ~/.ros_team_ws_rc
fi
.ros1rc
The following example is for sourcing ROS1:
#!/bin/sh
export ROS_DISTRO=noetic
source /opt/ros/$ROS_DISTRO/setup.bash
Add the following if you are using AMBF Simulator.
# AMBF
source ~/ambf/build/devel/setup.bash
alias ambf=~/ambf/bin/lin-x86_64/ambf_simulator
Working with CONDA
If you you want to run ROS with your configured Conda environment, you need to create/edit ./etc/conda/activate.d/env_vars.sh
of your current $CONDA_PREFIX
as follows:
#!/bin/sh
source ~/.ros2rc
export PYTHONPATH=~/miniconda3/envs/ros2/lib/python3.8/site-packages:/opt/ros/galactic/lib/python3.8/site-packages