Managing robot modes

We can manage modes by starting and stopping our behavior scripts as subprocesses. The mode manager will have a configuration for our known modes.

Let's start a file called robot_modes.py. This will contain a class called RobotModes that will handle robot processes and return a list of known scripts. Let's start with some imports and the top of the class definition:

import subprocessclass RobotModes(object):    """Our robot behaviors and tests as running modes"""    ...

The first thing we will provide is a configuration. The configuration comes in two sections; one maps a mode name to a file—a Python file. Note that we are specifying a list of files, and not inferring it. Although we could take our mode/path section and add ...

Get Learn Robotics Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.