Module API

rocon_launch

This is the top-level namespace of the rocon_launch ROS package. It provides machinery for spawning multiple roslaunch environments.

rocon_launch.exceptions

This module defines exceptions raised by the rocon_launch package.


exception rocon_launch.exceptions.InvalidRoconLauncher[source]

Bases: exceptions.Exception

Raised when an error occurs in parsing a rocon launcher

exception rocon_launch.exceptions.UnsupportedTerminal[source]

Bases: exceptions.Exception

Raised when an unsupported terminal is requested or auto-detected.

rocon_launch.launch

This module contains the machinery for spawning and managing multiple terminals that execute a pre-configured roslaunch inside each.


class rocon_launch.launch.RoconLaunch(terminal_name, hold=False)[source]

Bases: object

The rocon launcher. Responsible for all the pieces of the puzzle that go into spawning roslaunches inside terminals (startup, shutdown and signal handling).

__init__(terminal_name, hold=False)[source]

Initialise empty of processes, but configure a terminal so we’re ready to go when we start spawning.

Parameters:
  • terminal_name (str) – string name (or None) for the terminal to use.
  • hold (bool) – whether or not to hold windows open or not.
processes

List of spawned subprocess.Popen terminal processes.

signal_handler(sig, frame)[source]

Special handler that gets triggered if someone hits CTRL-C in the original terminal that executed ‘rocon_launch’. We catch the interrupt here, search and eliminate all child roslaunch processes first (give them time to gracefully quit) and then finally close the terminals themselves. closing down the terminals themselves.

Parameters:
  • sig (str) – signal id (usually looking for SIGINT - 2 here)
  • frame – frame
spawn_roslaunch_window(launch_configuration)[source]
Parameters:launch_configuration

:type launch_configuration RosLaunchConfiguration

temporary_files

List of temporary files used to construct launches that we must unlink before finishing.

rocon_launch.launch.main()[source]

Main function for the rocon_launch script.

rocon_launch.launch.parse_arguments()[source]

Argument parser for the rocon_launch script.

rocon_launch.roslaunch_configuration

This module provides the context for a roslaunch configuration.


class rocon_launch.roslaunch_configuration.RosLaunchConfiguration(name, package=None, port=None, title=None, namespace=None, args=[], options='')[source]

Bases: object

Configuration for a roslaunch (to be later spawned inside a terminal). This is typically generated by reading from a rocon_launch xml file but is also usable by other sources wishing to spawn roslaunched terminals.

__init__(name, package=None, port=None, title=None, namespace=None, args=[], options='')[source]
Parameters:
  • name (str) – filename (must be absolute path if package is set to None)
  • package (str) – name of the catkin package to find the launcher in (can be None)
  • port (int) – port to launch on (defaults to ROS_MASTER_URI’s or 11311 if None)
  • title (str) – title to use for the launch window (provides a sensible default if None)
  • args (str[]) – any args contained in the launcher
  • options (str) – command line options to pass to roslaunch (string form, not list)

:raises InvalidRoconLauncher

append_option(option)[source]

Appends a roslaunch command line option to the configuration.

Parameters:option (str) –
args

A list of (name, value) tuples representing roslaunch args.

name

Name of the roslauncher (must be absolute if there is no package specified).

namespace

Push the roslaunch down into this namespace.

options

A string of options to pass to roslaunch (not a list!), e.g. ‘–screen –local’

package

Package name in which to find the roslaunch (optional).

path

The absolute path to this launcher (automatically derived from package/name).

port

Port to start this configuration on (defaults to env. ROS_MASTER_URI or 11311 if not set).

screen()[source]
Returns:true or false depending on whether –screen is applied or not.
Return type:bool
title

The string to display on a spawned terminal window (easy for tabbing).

rocon_launch.terminals

This module provides a list of supported terminals and methods to handle them.


class rocon_launch.terminals.Active[source]

Bases: rocon_launch.terminals.Terminal

A pseudo representation of the currently open terminal.

prepare_command(title, cmd)[source]

Prepare a regular command to run inside the terminal window.

Parameters:
  • title (str) – label to put above on the terminal window
  • cmd (str[]) – command to run
prepare_roslaunch_command(roslaunch_configuration, meta_roslauncher_filename)[source]

Prepare the custom command for a roslaunch window.

Parameters:
  • roslaunch_configuration (RosLaunchConfiguration) – required roslaunch info
  • meta_roslauncher_filename (str) – temporary roslauncher file
class rocon_launch.terminals.GnomeTerminal[source]

Bases: rocon_launch.terminals.Terminal

Responsible for handling of gnome-terminal terminals.

prepare_command(title, cmd)[source]

Prepare a regular command to run inside the terminal window.

Parameters:
  • title (str) – label to put above on the terminal window
  • cmd (str[]) – command to run
prepare_roslaunch_command(roslaunch_configuration, meta_roslauncher_filename)[source]

Prepare the custom command for a roslaunch window.

Parameters:
  • roslaunch_configuration (RosLaunchConfiguration) – required roslaunch info
  • meta_roslauncher_filename (str) – temporary roslauncher file
class rocon_launch.terminals.Konsole[source]

Bases: rocon_launch.terminals.Terminal

Responsible for handling of kde konsole terminals.

prepare_command(title, cmd)[source]

Prepare a regular command to run inside the terminal window.

Parameters:
  • title (str) – label to put above on the terminal window
  • cmd (str[]) – command to run
prepare_roslaunch_command(roslaunch_configuration, meta_roslauncher_filename)[source]

Prepare the custom command for a roslaunch window.

Parameters:
  • roslaunch_configuration (RosLaunchConfiguration) – required roslaunch info
  • meta_roslauncher_filename (str) – temporary roslauncher file
rocon_launch.terminals.active = 'active'

String identifier for the currently open (active) terminal

rocon_launch.terminals.create_terminal(name=None)[source]

Creates a manager for the terminal with supporting methods and variables.

If name is None, it will try to auto-detect the user’s terminal. We’re currently using ubuntu’s x-terminal-emulator to choose the shell.

Parameters:name (str) – name of the terminal manager to create (None to auto-detect).
Returns:one of the suported terminal classes
Return type:one of the children of :class:.`.Terminal`

:raises UnsupportedTerminal if the name is not in the supported terminals list. :raises rocon_python_comms.NotFoundException if the specified/auto-detected terminal is not found on the system.

rocon_launch.terminals.gnome_terminal = 'gnome-terminal'

String identifier for Gnome’s terminal.

rocon_launch.terminals.gnome_terminal_wrapper = 'gnome-terminal.wrapper'

String identifier for an oft used representation of gnome’s terminal on desktops like KDE.

rocon_launch.terminals.konsole = 'konsole'

String identifier for KDE’s konsole terminal

rocon_launch.utils

This module provides some supporting utilities for rocon launches.


rocon_launch.utils.get_roslaunch_pids(parent_pid)[source]

Search the pstree of the specified pid for roslaunch processes. We use this to aid in gracefully terminating any roslaunch processes running in terminals before closing down the terminals themselves.

Parameters:parent_pid (str) – the pid of the parent process.
Returns:list of pids
Return type:str[]
rocon_launch.utils.parse_rocon_launcher(rocon_launcher, default_roslaunch_options, args_mappings={})[source]

Parses an rocon multi-launcher (xml file).

Parameters:
  • rocon_launcher (str) – xml string in rocon_launch format
  • default_roslaunch_options – options to pass to roslaunch (usually “–screen”)
  • args_mappings (dict) – command line mapping overrides, { arg_name : arg_value }
Returns:

list of launch configurations

Return type:

:class:`.RosLaunchConfiguration`[]

:raises InvalidRoconLauncher : if any roslaunch configuration failed