diff --git a/src/robot_upstart/install_script.py b/src/robot_upstart/install_script.py index 626e633..f55af97 100644 --- a/src/robot_upstart/install_script.py +++ b/src/robot_upstart/install_script.py @@ -68,6 +68,8 @@ def get_argument_parser(): help="Create symbolic link to job launch files instead of copying them.") p.add_argument("--wait", action='store_true', help="Pass a wait flag to roslaunch.") + p.add_argument("--model", type=str, metavar="MODEL", + help="Specify the model of your robot if not specified under ROBOT_MODEL") return p @@ -85,7 +87,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) + master_uri=args.master, log_path=args.logdir, model=args.model) for this_pkgpath in args.pkgpath: pkg, pkgpath = this_pkgpath.split('/', 1) diff --git a/src/robot_upstart/job.py b/src/robot_upstart/job.py index 36a7d55..6286ef2 100644 --- a/src/robot_upstart/job.py +++ b/src/robot_upstart/job.py @@ -40,7 +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): + rosdistro=None, master_uri=None, log_path=None, model=None): """Construct a new Job definition. :param name: Name of job to create. Defaults to "ros", but you might @@ -67,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 @@ -105,6 +107,16 @@ 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' + def add(self, package=None, filename=None, glob=None): """ Add launch or other configuration files to Job. diff --git a/templates/job-start.em b/templates/job-start.em index bdf9f1a..4b38679 100644 --- a/templates/job-start.em +++ b/templates/job-start.em @@ -67,6 +67,9 @@ 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]@ export ROS_HOME=${ROS_HOME:=$(echo ~@(user))/.ros} export ROS_LOG_DIR=$log_path