pyrcf.control_loop.simple_managed_ctrl_loop
Classes
A minimal control loop that takes in a controller manager instead of a single controller and |
Module Contents
- class pyrcf.control_loop.simple_managed_ctrl_loop.SimpleManagedCtrlLoop(robot_interface: pyrcf.components.robot_interfaces.robot_interface_base.RobotInterface, state_estimator: pyrcf.components.state_estimators.state_estimator_base.StateEstimatorBase, controller_manager: pyrcf.components.controller_manager.controller_manager_base.ControllerManagerBase, global_planner: pyrcf.components.global_planners.global_planner_base.GlobalMotionPlannerBase, verbose: bool = True)
A minimal control loop that takes in a controller manager instead of a single controller and local planner.
The run method runs the following in a loop of specified frequency.
read robot state from robot interface
update robot state with state estimates from state estimator
get global plan message from global planner / user interface
- for agent in controller_manager.agents:
- compute control command to track the global plan (agent may be a Planner+Controller
agent)
accumulate commands from accumulation policy used by controller manager
write control command to robot
- robot
- state_estimator
- controller_manager
- global_planner
- _true_dt_getter
- _true_dt = 0.0
- _loop_count = 0
- run(loop_rate: float, clock: pyrcf.utils.time_utils.ClockBase = PythonPerfClock(), debuggers: List[pyrcf.components.ctrl_loop_debuggers.ctrl_loop_debugger_base.CtrlLoopDebuggerBase] = None, prestep_callbacks: List[pyrcf.components.callback_handlers.base_callbacks.CustomCallbackBase] = None, poststep_callbacks: List[pyrcf.components.callback_handlers.base_callbacks.CustomCallbackBase] = None)
The main control loop.
- Parameters:
loop_rate (float) – loop rate in hz. This will always use the system clock to try and maintain the desired control loop rate.
clock (ClockBase, optional) – Defines the clock to use for querying time for the components in the control loop. Time will be queried once per loop and the same t and dt will be passed to all components in that iteration. The option to select the clock is so that sim time can be used if required.
debuggers (CtrlLoopDebuggerBase, optional) – List of CtrlLoopDebuggerBase objects that are to be run in the control loop.
prestep_callbacks (List[CustomCallbackBase], optional) – List of CustomCallbackBase objects to be run in the control loop. Not recommended to do this except for debugging. Defaults to None.
poststep_callbacks (List[CustomCallbackBase]. optional) – List of additional CustomCallbackBase objects to be run in the control loop. Not recommended to do this except for debugging. Defaults to None.
- get_actual_loop_rate() Tuple[float, float]
Get the true loop rate and dt (using system clock).
- Returns:
True dt (s), true loop rate (hz)
- Return type:
Tuple[float, float]
- get_loop_count() int
Get the current number of iterations of the control loop.
- Returns:
current number of iterations of the control loop
- Return type:
int
- shutdown()
Cleanly shutdown all components in the control loop. Sequence of shutdown:
robot interface
controller manager
global planner
- send_shutdown_signal()
Request clean shutdown of control loop and components.