Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ros_launch.sh and example #45

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/navigation2/scripts/Navigation_ROS2_R1_SIM.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

<!-- modules -->

<module>
<name>ros2_launch.sh</name>
<parameters>/usr/local/src/hsp/tour-guide-robot/app/navigation2/launch/robot_state_publisher.launch.py use_sim_time:=true</parameters>
<workdir>/home/user1/tour-guide-robot/app/navigation2/scripts/</workdir>
<node>console</node>
</module>

<module>
<name>ros2</name>
<parameters>launch robot_state_publisher.launch.py use_sim_time:=true</parameters>
Expand Down
27 changes: 27 additions & 0 deletions app/navigation2/scripts/ros2_launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# This scripts wraps ros2 launch handling the SIGTERM signal - currently bugged in ros2 (https://github.com/ros2/launch/issues/666)
# In particular, the user can substitute the ros2 launch command in yarpmanager with this script.
# The syntax is the same but the full path to the launch_file is needed.
# Stopping the script via yarpmanager will correctly stop the nodes. Killing the script will leave the nodes dangling.


_term() {
echo "Got SIGTERM"
kill -2 -${group}
}

if [ "$#" -lt 2 ]
then
echo "Usage ros2_launch.sh <package> <launch_file> <args>"
exit -1
fi

trap _term SIGTERM

setsid ros2 launch $@ --noninteractive &

group=$!
echo "Group pid: $group"
child=$!
wait "$child"