pyrcf.components.agents.ml_agent_base

Classes

MLAgentBase

An abstract base class machine-learned controller agents.

Module Contents

class pyrcf.components.agents.ml_agent_base.MLAgentBase

Bases: pyrcf.components.agents.agent_base.AgentBase, abc.ABC

An abstract base class machine-learned controller agents.

See docstrings for each method to be implemented.

abstract initialise_robot_cmd(joint_states: pyrcf.core.types.JointStates)

Override this method in child class if custom initilisation is required (e.g. joint name order). By default, this method sets the joint name and position values to be equal to the input joint states object, with kp and kd set to be the default (in constructor).

abstract update_input_to_model(robot_state: pyrcf.core.types.RobotState, global_plan: pyrcf.core.types.GlobalMotionPlan, t: float, dt: float) numpy.ndarray

Should update (self._input_ndarray) using appropriate values (input to model). This method has access to self._latest_ctrl_cmd (type RobotCmd) as well if needed. (NOTE: self._latest_ctrl_cmd is set to be the initial robot joint positions (zero velocities and efforts commands) with default_kp and default_kd at start).

abstract update_cmd_from_model_output(model_output: numpy.ndarray, robot_state: pyrcf.core.types.RobotState, global_plan: pyrcf.core.types.GlobalMotionPlan, t: float, dt: float) None

Should update self._latest_robot_cmd (type RobotCmd) using the output from the NN model.

Parameters:

model_output (np.ndarray) – the numpy array created from the output tensor from the model after the inference query was done. This is the output of the neural network. This method should use this object to update self._latest_robot_cmd to be sent to the robot.

abstract get_action(robot_state: pyrcf.core.types.RobotState, global_plan: pyrcf.core.types.GlobalMotionPlan, t: float = None, dt: float = None) pyrcf.core.types.RobotCmd

Should return the control command given the current robot state and global plan.

Parameters:
  • robot_state (RobotState) – The current state information from the robot.

  • global_plan (GlobalMotionPlan) – the latest global plan generated by the global planner used in the loop.

  • t (float, optional) – the current time signature of the control loop. Defaults to None (controllers may or may not need this).

  • dt (float, optional) – the time since the last control loop. Defaults to None (controllers may or may not need this).

Returns:

The output control command to be sent to the robot.

Return type:

RobotCmd