Jobs

This file defines the Job class, which is the primary code API to robot_upstart.

class robot_upstart.job.Job(name='ros', interface=None, user=None, workspace_setup=None, rosdistro=None, master_uri=None, log_path=None)[source]

Represents a ROS configuration to launch on machine startup.

Construct a new Job definition.

Parameters:
  • name (str) – Name of job to create. Defaults to “ros”, but you might prefer to use the name of your platform.
  • interface (str) – Network interface to bring ROS up with. If specified, the job will come up with that network interface, and ROS_IP will be set to that interface’s IP address. If unspecified, the job will come up on system startup, and ROS_HOSTNAME will be set to the system’s hostname.
  • user (str) – Unprivileged user to launch the job as. Defaults to the user creating the job.
  • workspace_setup (str) – Location of the workspace setup file to source for the job’s ROS context. Defaults to the current workspace.
  • rosdistro (str) – rosdistro to use for the /etc/ros/DISTRO path. Defaults to $ROS_DISTRO from the current environment.
  • master_uri (str) – For systems with multiple computers, you may want this job to launch with ROS_MASTER_URI pointing to another machine.
  • log_path (str) – The location to set ROS_LOG_DIR to. If changed from the default of using /tmp, it is the user’s responsibility to manage log rotation.
add(package=None, filename=None, glob=None)[source]

Add launch or other configuration files to Job.

Files may be specified using relative, absolute, or package-relative paths. Files may also be specified using shell globs.

Parameters:
  • package (str) – Optionally specify a package to search for the file or glob relative-to.
  • filename (str) – Name of a file to add to the job. Relative to the package path, if specified.
  • glob (str) – Shell glob of files to add to the job. Relative to the package path, if specified.
install(root='/', sudo='/usr/bin/sudo', Provider=<class 'robot_upstart.providers.Upstart'>)[source]

Install the job definition to the system.

Parameters:
  • root (str) – Override the root to install to, useful for testing.
  • sudo (str) – Override which sudo is used, useful for testing or for making it use gksudo instead.
  • provider (Provider) – Override to use your own generator function for the system file preparation.
uninstall(root='/', sudo='/usr/bin/sudo', Provider=<class 'robot_upstart.providers.Upstart'>)[source]

Uninstall the job definition from the system.

Parameters:
  • root (str) – Override the root to uninstall from, useful for testing.
  • sudo (str) – Override which sudo is used, useful for testing or for making it use gksudo instead.
  • provider (Provider) – Override to use your own generator function for the system file preparation.

Example

A minimal example of creating an upstart job using this API:

import robot_upstart

j = robot_upstart.Job()
j.add(package="myrobot_bringup", filename="launch/base.launch")
j.install()

The Job.add() method may be called multiple times, of course, and you may alternatively specify a glob, if you’re like to create a job which launches all of the launchfiles from a package, eg:

import robot_upstart

j = robot_upstart.Job()
j.add(package="myrobot_bringup", glob="launch/*.launch")
j.install()

Finally, if the package parameter is not specified, then the glob or filename is relative to the current directory, rather than a package.

Table Of Contents

Previous topic

The uninstall script

Next topic

Providers

This Page