diff --git a/src/robot_upstart/job.py b/src/robot_upstart/job.py index 54fea50..a5dbb21 100644 --- a/src/robot_upstart/job.py +++ b/src/robot_upstart/job.py @@ -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 diff --git a/templates/job-start.em b/templates/job-start.em index d69fd03..691913d 100644 --- a/templates/job-start.em +++ b/templates/job-start.em @@ -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} } @@ -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"