-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added make target/recipe to test the ros2 installation with 'make tes…
…t_ros2_installation'
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
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,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
echoerr() { printf "%b" "$*\n" >&2;} | ||
exiterr (){ printf "%s\n" "$@" >&2; exit 1;} | ||
|
||
SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
|
||
|
||
if ! command -v ros2 &> /dev/null; then | ||
exiterr "ERROR: ROS 2 is not installed or not in PATH" | ||
fi | ||
|
||
ros_version=$(ros2 pkg prefix ros2cli) | ||
echo "ROS 2 Version: $ros_version" | ||
if [[ -z "$ros_version" ]]; then | ||
exiterr "ERROR: Failed to get ROS 2 version" | ||
fi | ||
|
||
if [[ -z "$ROS_DISTRO" ]]; then | ||
exiterr "ERROR ROS_DISTRO environment variable is not set" | ||
fi | ||
echo "ROS_DISTRO is set to: $ROS_DISTRO" | ||
|
||
echo "Testing 'ros2 topic list' command..." | ||
if ! ros2 topic list; then | ||
exiterr "ERROR: Failed to run 'ros2 topic list'" | ||
else | ||
echo "'ros2 topic list' command succeeded" | ||
fi | ||
|
||
echo "ROS 2 is installed correctly" | ||
|