Creating a controller

A controller represents a specific robotic behavior. Its main method is execute(), that accepts the state of the robot and the elapsed time as arguments and returns a structure suitable for controlling the robot. For example, the controllers implemented in pySimiam so far return a (v, ω) tuple - the linear and angular speeds in the unicycle model.

The controller can also have a set of parameters, set with set_parameters(). Again, the structure of the parameters is up to the controller implementation. The supervisor using this controller should provide suitable arguments to the controller’s constructor.

Additionally, the controller should provide the means to reset its internal state by implementing restart(). This method is called every time the supervisor switches from one controller to the next, and it might be necessary to reset the accumulated error, for example, as in a PID controller.

API

class controller.Controller(params)[source]

The controller class defines a behavior for the supervisor class. Any implemention must inherit from this class and implement the Controller,execute() method to return a unicycle model output.

Parameters:params (Struct) – A structure containing the internal controller parameters, such as PID constants.
Controller.execute(state, dt)[source]

Given a state and elapsed time, calculate and return robot motion parameters

Parameters:
  • state (Struct) – Output from the supervisor process() method
  • dt (float) – Time elapsed since last call to execute()

To be implemented in subclasses.

Controller.restart()[source]

Reset the controller to the initial state.

Controller.set_parameters(params)[source]

Set the internal parameters of the controller.

Parameters:params (Struct) – A structure containing the internal controller parameters, such as PID constants.

To be implemented in subclasses,

Table Of Contents

Previous topic

Writing a supervisor

Next topic

Useful User API

This Page