Skip to content

Supervisors

Sebastian Buck edited this page May 14, 2017 · 3 revisions

What is a Supervisor?

Supervisors are called before the robot controller in the execution loop. They watch over the robot while it drives along the path and fire an alert, if there is something wrong (e.g. some timeout expired). Such an alert will cause immediate abortion of the current path and send an stop command to the robot.

Currently implemented Supervisors:

  • WaypointTimeout: Stops the robot, if the time needed to reach the next waypoint on the path exceeds a defined limit. This is only applicable with robot controllers that go stepwise from waypoint to waypoint!
  • DistanceToPath: Stops the robot, if it moves too far away from the desired path (e.g. due to bad controlling)
  • PathLookout: Stops the robot, if there is an obstacle on the path somewhere ahead of the robot. This gives the opportunity to early discard the current path and replan.

Supervisors are not allowed to change the state of the robot and have no access to other modules. All information the need is passed to them in a Supervisor::State object.

Supervisor Chain

Supervisors are not called directly but via the SupervisorChain. This allows the use of multiple supervisors at once. The supervisors in the chain are called in the order they were added. To stop the robot it is sufficient if one supervisor in the chain fires an alert. The process is aborted immediately in this case, so remaining supervisors are not called anymore.

Add Supervisor to Chain

To add a new supervisor to the chain simply use the method addSupervisor of SupervisorChain. It is good practice to add an use_xy-parameter for the supervisor so it can easily be activated or deactivated as needed:

if (opt_s.use_path_lookout()) {
    supervisors_.addSupervisor( Supervisor::Ptr(new PathLookout(*pose_tracker_)) );
}

Implement new Supervisors

It is easy to implement new supervisors. One simply has to create a new class that inherits from Supervisor. There are only two methods that need to be implemented:

  • getName(): Returns a string with the name of the supervisor. This name is printed automatically to stdout, if the supervisor is added to the chain, giving the user an overview of which supervisors are active.
  • supervise(): This method decides if the robot can go on or not. It has two parameters State and Result which are described in the following.

Supervisor::State

The state contains all information that is required by the supervisors to make their decision. In case the contained information is not sufficient for a new supervisor, the State struct can be extended as long as the following rules are kept:

  • Avoid copies, use pointers of references instead.
  • Supervisors must not change the robots state, so make sure that all data is declared as const, if passed as reference or pointer

There is one exception of the const rule: the feedback field is used as an output parameter that can be changed by all supervisors and is therefore not const.

Supervisor::Result

This is the output of the Supervisor. If the supervisor detected a problem and the robot has to stop, set can_continue to false and set a appropriate status code to status. In case all is fine and the robot can go one, nothing has to be set, as this is the default.