Skip to content

Instantly share code, notes, and snippets.

@lukicdarkoo
Last active April 22, 2020 19:38
Show Gist options
  • Save lukicdarkoo/d03196b15367b804b27c142dad8644e9 to your computer and use it in GitHub Desktop.
Save lukicdarkoo/d03196b15367b804b27c142dad8644e9 to your computer and use it in GitHub Desktop.
Simple ROS Package Helper
# Quick start
# Install dependencies: pip3 install rosinstall_generator vcstool colcon-common-extensions; sudo -H pip3 install rosdep
# Install the script: curl https://gist.githubusercontent.com/lukicdarkoo/d03196b15367b804b27c142dad8644e9/raw/503201cc3b2a86c61dfb4f3cf1cc761cbc096bff/rospm.sh >> $HOME/.bashrc; exec bash
rospm-install() {
# This tool combines `rosinstall_generator`, `vcs` and `colcon` to
# easily install package in a custom ROS workspace
# Set default parameters
PACKAGE_NAME=$1
if [ -z "$PACKAGE_NAME" ]; then
echo "No package chosen"
return 1
fi
if [ -z "$ROS_DISTRO" ]; then
ROS_DISTRO="eloquent"
echo "No ROS_DISTRO set, setting it to ${ROS_DISTRO}"
fi
if [ -z "$ROS_WS" ]; then
ROS_WS=$(pwd)
echo "No ROS_WS set, setting it to ${ROS_WS}"
fi
# Prepare the workspace
export ROS_PACKAGE_PATH=${ROS_WS}/src
source ${ROS_WS}/install/local_setup.bash
# Download list of dependencies, download dependencies and build needed packages
rosinstall_generator ${PACKAGE_NAME} --deps --exclude RPP --rosdistro ${ROS_DISTRO} > /tmp/rospkgs.repos
vcs import ${ROS_WS}/src < /tmp/rospkgs.repos
# rosdep install --from-paths src --ignore-src -r -y
colcon build --packages-up-to ${PACKAGE_NAME} --packages-skip $(ls build)
# Source the workspace
source ${ROS_WS}/install/local_setup.bash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment