The supervisor class oversees the control of a single robot. The supervisor does not move the robot directly. Instead, the supervisor selects a controller to do the work and uses the controller outputs to generate the robot inputs.
Parameters: |
|
---|
Any extension of pysimiam will require inheriting from this superclass. The important methods that have to be implemented to control a robot are estimate_pose(), process(), init_default_parameters() and get_ui_description().
The base class implements a state machine for switching between different controllers. See add_controller() for more information.
Type : | Pose |
---|
The initial pose of the robot, as supplied to the constructor. This parameter can be used in the user implementation
Type : | Pose |
---|
The estimated pose of the robot. This variable is updated automatically in the beginning of the calculation cycle using estimate_pose()
Type : | Struct |
---|
Current parameter structure of the supervisor. Updated in set_parameters()
Type : | Controller |
---|
The current controller to be executed in execute(). The subclass can set this value in process() or in the constructor. In case the state machine is used, the current controller will be switched automatically.
Type : | {Controller: [(condition()->bool,:class:~controller.Controller)]} |
---|
The transition table of the state machine. The keys of the dictionary are the state. The conditions are executed one after another until one returns True or the list is through. If one of the conditions evaluates to True, its corresponding controller is made current.
Type : | int |
---|
The color of the robot in the view (useful for drawing).
Add a transition table for a state with controller
The arguments are (function, controller) tuples. The functions cannot take any arguments. Each step, the functions are executed in the order they were supplied to this function. If a function evaluates to True, the current controller switches to the one specified with this function. The target controller is restarted using controller.Controller.restart().
The functions are guaranteed to be called after process(). Thus, robot should contain actual information about the robot.
Create and return a controller instance for a given controller class.
Parameters: |
|
---|
Draw anything in the view before anything else is drawn (except the grid)
Parameters: | renderer (Renderer) – A renderer to draw with |
---|
Draw anything in the view after everything else is drawn
Parameters: | renderer (Renderer) – A renderer to draw with |
---|
Updates the pose using odometry calculations.
Returns: | The estimated robot pose |
---|---|
Return type: | Pose |
The result of the evaluation of this function will be used to set self.pose_est
Must be implemented in subclasses.
Based on robot state and elapsed time, return the parameters for robot motion.
Parameters: |
|
---|---|
Returns: | An object (normally a tuple) that will be passed to the robot’s set_inputs() method. |
The default implementation proceeds as follows:
Check if the controller has to be switched
Get controller state from get_controller_state()
Execute currently selected controller with the parameters from previous step
Return unicycle model parameters as an output (velocity, omega)
Get the parameters that the current controller needs for operation
Returns: | A parameter structure in the format appropriate for the current controller. |
---|---|
Return type: | Struct |
The result of this function will be used to run the controller.
Must be implemented in subclasses
Get the parameter structure of the supervisor. A call to supervisor.set_parameters(supervisor.get_parameters()) should not change the supervisor’s state
Returns: | A supervisor-specific parameter structure. |
---|---|
Return type: | Struct |
Return a list describing the parameters available to the user.
Parameters: | params (Struct) – An instance of the paramaters structure as returned from get_parameters. If not specified, this method should use parameters |
---|---|
Returns: | A list describing the interface |
The structure returned by this function is used in the interface to show a window where the user can adjust the supervisor parameters. When the user confirms the changed parameters, this structure is used to create the structure that will be passed to set_parameters().
The format of the returned object is as follows:
Must be implemented in subclasses.
Populate parameters with default values
Must be implemented in subclasses.
Evaluate the information about the robot and set state variables.
Update this supervisor parameters. The params will have the same structure as specified by get_ui_description()
Parameters: | params (Struct) – An instance of the paramaters structure as can be returned from get_parameters(). |
---|
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. |
---|