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

Set roslaunch namespace #109

Open
wants to merge 2 commits into
base: melodic-devel
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions src/robot_upstart/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def __init__(self, name="ros", interface=None, user=None, workspace_setup=None,
# This will be desired if the nodes spawned by this job are intended to
# connect to an existing master.
self.roslaunch_wait = False

# Set the roslaunch namespace
self.roslaunch_ns = ""

# Set the string of the "After=" section
# of the generated Systemd service file
Expand Down
19 changes: 18 additions & 1 deletion templates/job-start.em
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@
#!/bin/bash
# THIS IS A GENERATED FILE, NOT RECOMMENDED TO EDIT.

roslaunch_log_opt="--log"

while getopts ":s" opt; do
case $opt in
s)
roslaunch_log_opt="--screen"
;;
:)
echo "Option -$OPTARG requires an argument."
exit 1
;;
?)
echo "Invalid option: -$OPTARG index:$OPTIND"
;;
esac
done

function log() {
logger -s -p user.$1 ${@@:2}
}
Expand Down Expand Up @@ -104,7 +121,7 @@ if [ "$?" != "0" ]; then
fi

# Punch it.
setpriv --reuid @(user) --regid @(user) --init-groups roslaunch $LAUNCH_FILENAME @(roslaunch_wait?'--wait ')&
setpriv --reuid @(user) --regid @(user) --init-groups roslaunch $LAUNCH_FILENAME __ns:=@(roslaunch_ns) @(roslaunch_wait?'--wait ') $roslaunch_log_opt&
PID=$!

log info "@(name): Started roslaunch as background process, PID $PID, ROS_LOG_DIR=$ROS_LOG_DIR"
Expand Down