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

Added model parameter to the install script #102

Open
wants to merge 2 commits into
base: noetic-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
7 changes: 5 additions & 2 deletions src/robot_upstart/install_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def get_argument_parser():
p.add_argument("--systemd-after", type=str, metavar="After=",
help="Set the string of the After= section"
"of the generated Systemd service file")
p.add_argument("--model", type=str, metavar="MODEL",
help="Specify the model of your robot if not specified under ROBOT_MODEL")
p.add_argument("--map_name", type=str, metavar="MODEL",
help="Specify the map name for your robot")

return p

Expand All @@ -88,8 +92,7 @@ def main():
j = robot_upstart.Job(
name=job_name, interface=args.interface, user=args.user,
workspace_setup=args.setup, rosdistro=args.rosdistro,
master_uri=args.master, log_path=args.logdir,
systemd_after=args.systemd_after)
master_uri=args.master, log_path=args.logdir, model=args.model, systemd_after=args.systemd_after)

for this_pkgpath in args.pkgpath:
pkg, pkgpath = this_pkgpath.split('/', 1)
Expand Down
23 changes: 21 additions & 2 deletions src/robot_upstart/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class Job(object):
""" Represents a ROS configuration to launch on machine startup. """

def __init__(self, name="ros", interface=None, user=None, workspace_setup=None,
rosdistro=None, master_uri=None, log_path=None,
systemd_after=None):
rosdistro=None, master_uri=None, log_path=None, model=None, map_name=None, systemd_after=None):
"""Construct a new Job definition.

:param name: Name of job to create. Defaults to "ros", but you might
Expand All @@ -68,6 +67,8 @@ def __init__(self, name="ros", interface=None, user=None, workspace_setup=None,
default of using /tmp, it is the user's responsibility to manage log
rotation.
:type log_path: str
:param model: Your robot model if not specified under ROBOT_MODEL.
:type model: str
"""

self.name = name
Expand Down Expand Up @@ -110,6 +111,24 @@ def __init__(self, name="ros", interface=None, user=None, workspace_setup=None,
# startup job itself. List of strs.
self.files = []

# Sets the model environment variable if provided, else results in
# ROBOT_MODEL=ROBOT
if model:
self.model = name.upper() + '_MODEL=' + model
else:
try:
self.model = name.upper() + '_MODEL=' + os.environ[name.upper() + '_MODEL']
except KeyError:
self.model = name.upper() + '_MODEL=ROBOT'

if map_name:
self.map_name = name.upper() + '_MAP=' + map_name
else:
try:
self.map_name = name.upper() + '_MAP=' + os.environ[name.upper() + '_MAP']
except KeyError:
self.map_name = name.upper() + '_MAP=ROBOT'

def add(self, package=None, filename=None, glob=None):
""" Add launch or other configuration files to Job.

Expand Down
6 changes: 6 additions & 0 deletions templates/job-start.em
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export ROS_MASTER_URI=@(master_uri)
@[else]@
export ROS_MASTER_URI=http://127.0.0.1:11311
@[end if]@
@[if model]@
export @(model)
@[end if]@
@[if map_name]@
export @(map_name)
@[end if]@
export ROS_HOME=${ROS_HOME:=$(echo ~@(user))/.ros}
export ROS_LOG_DIR=$log_path

Expand Down