-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Makefiles with shell scripts for building and running the demos
Related to space-ros/space-ros#178 - Remove makefiles for canadarm2 and curiosity rover demo - Add build.sh for building canadarm2 and curiosity rover demo - Add run.sh for running the demos - Update README.md of demos to the new process
- Loading branch information
1 parent
f64c755
commit 7c5dbc6
Showing
9 changed files
with
364 additions
and
142 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Define variables | ||
DOCKER_IMAGE="osrf/space-ros:canadarm_demo" | ||
LOCAL_WORKSPACE=$(pwd) | ||
SHELL="/bin/bash" | ||
|
||
# Define packages | ||
SIM_PACKAGES="canadarm_description canadarm_gazebo" | ||
CONTROL_PACKAGE="canadarm_moveit_config canadarm_demo" | ||
DEMO_PACKAGES="$CONTROL_PACKAGE $SIM_PACKAGES" | ||
|
||
#################################################################################################### | ||
# High-level functions | ||
#################################################################################################### | ||
# Help function to describe each target | ||
help() { | ||
echo "CanadArm2 Build Script" | ||
echo "Usage: ./build.sh [subcommand] [demo]" | ||
echo "Available subcommands:" | ||
echo " ./build.sh help - Show this help message" | ||
echo " ./build.sh clean - Clean the local workspace" | ||
echo " ./build.sh - Build the demos" | ||
exit 0 | ||
} | ||
|
||
# Build all | ||
build() { | ||
build-control-demo | ||
} | ||
|
||
# Clean the local workspace | ||
clean() { | ||
rm -rf "$LOCAL_WORKSPACE"/install "$LOCAL_WORKSPACE"/log "$LOCAL_WORKSPACE"/build | ||
} | ||
|
||
check_docker() { | ||
if ! command -v docker &>/dev/null; then | ||
echo "Docker is not installed. Please install Docker to continue." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_xterm() { | ||
if ! command -v xterm &>/dev/null; then | ||
echo "xterm is not installed. Please install xterm to continue." | ||
echo "On Ubuntu, you can install xterm with 'sudo apt install xterm'." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_ros2() { | ||
if ! command -v ros2 &>/dev/null; then | ||
echo "ROS 2 is not installed. Please install ROS 2 to continue." | ||
exit 1 | ||
fi | ||
} | ||
|
||
#################################################################################################### | ||
# Low-level functions | ||
#################################################################################################### | ||
# Build the Docker image | ||
build-docker() { | ||
docker build -t "$DOCKER_IMAGE" . | ||
} | ||
|
||
# Build the Gazebo workspace locally | ||
build-gazebo() { | ||
# shellcheck source=/opt/ros/${ROS_DISTRO}/setup.bash | ||
# shellcheck disable=SC1091 | ||
source /opt/ros/"${ROS_DISTRO}"/setup.bash && | ||
rosdep install --from-paths . -r -y --skip-keys "$DEMO_PACKAGES" && | ||
colcon build --symlink-install --base-paths "$LOCAL_WORKSPACE" --install-base "$LOCAL_WORKSPACE"/install \ | ||
--cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | ||
--packages-select $SIM_PACKAGES | ||
} | ||
|
||
#################################################################################################### | ||
# Control demo | ||
#################################################################################################### | ||
build-control-demo() { | ||
build-docker | ||
build-gazebo | ||
} | ||
|
||
#################################################################################################### | ||
# Main script logic to call the appropriate function | ||
#################################################################################################### | ||
case "$1" in | ||
help) | ||
help | ||
;; | ||
clean) | ||
clean | ||
;; | ||
*) | ||
check_docker | ||
check_ros2 | ||
|
||
build | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC2089 | ||
XTERM_CONFIG="-bg black -fg white -fa 'Monospace' -fs 11" | ||
DOCKER_IMAGE="osrf/space-ros:canadarm_demo" | ||
LOCAL_WORKSPACE=$(pwd) | ||
|
||
# Run the CanadArm Gazebo simulation locally | ||
run-gazebo() { | ||
# shellcheck disable=SC2090 | ||
# shellcheck disable=SC2086 | ||
xterm $XTERM_CONFIG -T 'CanadArm2 Gazebo' -e "source /opt/ros/\${ROS_DISTRO}/setup.bash \ | ||
&& source $LOCAL_WORKSPACE/install/setup.bash \ | ||
&& ros2 launch canadarm_gazebo canadarm.launch.py" & | ||
} | ||
|
||
run-control-demo() { | ||
# shellcheck disable=SC2090 | ||
# shellcheck disable=SC2086 | ||
xterm $XTERM_CONFIG -T 'CanadArm2 Demo' -e "docker run -it --rm \ | ||
-e RMW_IMPLEMENTATION=rmw_cyclonedds_cpp \ | ||
$DOCKER_IMAGE \ | ||
bash -c 'source ~/.bashrc && ros2 launch canadarm_demo canadarm.launch.py'" & | ||
} | ||
|
||
check_docker() { | ||
if ! command -v docker &>/dev/null; then | ||
echo "Docker is not installed. Please install Docker to continue." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_xterm() { | ||
if ! command -v xterm &>/dev/null; then | ||
echo "xterm is not installed. Please install xterm to continue." | ||
echo "On Ubuntu, you can install xterm with 'sudo apt install xterm'." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_ros2() { | ||
if ! command -v ros2 &>/dev/null; then | ||
echo "ROS 2 is not installed. Please install ROS 2 to continue." | ||
exit 1 | ||
fi | ||
} | ||
|
||
run() { | ||
|
||
check_docker | ||
check_xterm | ||
check_ros2 | ||
|
||
run-gazebo | ||
run-control-demo | ||
} | ||
|
||
run |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.