mani_skill.agents.controllers.base_controller ============================================= .. py:module:: mani_skill.agents.controllers.base_controller Classes ------- .. autoapisummary:: mani_skill.agents.controllers.base_controller.BaseController mani_skill.agents.controllers.base_controller.CombinedController mani_skill.agents.controllers.base_controller.ControllerConfig mani_skill.agents.controllers.base_controller.DictController Module Contents --------------- .. py:class:: BaseController(config, articulation, control_freq, sim_freq = None, scene = None) Base class for controllers. The controller is an interface for the robot to interact with the environment. .. py:method:: __repr__() .. py:method:: _clip_and_scale_action(action) .. py:method:: _clip_and_scale_action_space() .. py:method:: _initialize_action_space() :abstractmethod: .. py:method:: _initialize_joints() .. py:method:: _preprocess_action(action) .. py:method:: before_simulation_step() Called before each simulation step in one control step. .. py:method:: get_state() Get the controller state. .. py:method:: reset() Resets the controller to an initial state. This is called upon environment creation and each environment reset .. py:method:: set_action(action) :abstractmethod: Set the action to execute. The action can be low-level control signals or high-level abstract commands. .. py:method:: set_drive_property() :abstractmethod: Set the joint drive property according to the config. .. py:method:: set_state(state) .. py:attribute:: _control_freq .. py:attribute:: _normalize_action .. py:attribute:: _original_single_action_space :type: gymnasium.spaces.Space The unbatched, original action space without any additional processing like normalization .. py:attribute:: _sim_steps Number of simulation steps per control step .. py:attribute:: action_space :type: gymnasium.spaces.Space the action space of the controller, which by default has a batch dimension. This is typically already normalized as well. .. py:attribute:: active_joint_indices :type: torch.Tensor indices of active joints controlled. Equivalent to [x.active_index for x in self.joints] .. py:attribute:: articulation .. py:attribute:: config .. py:property:: control_freq .. py:property:: device .. py:attribute:: joints :type: list[mani_skill.utils.structs.ArticulationJoint] active joints controlled .. py:property:: qpos Get current joint positions. .. py:property:: qvel Get current joint velocities. .. py:attribute:: scene :value: None .. py:attribute:: sets_target_qpos :type: bool Whether the controller sets the target qpos of the articulation .. py:attribute:: sets_target_qvel :type: bool Whether the controller sets the target qvel of the articulation .. py:attribute:: single_action_space :type: gymnasium.spaces.Space The unbatched version of the action space which is also typically already normalized by this class .. py:class:: CombinedController(configs, articulation, control_freq, sim_freq = None, scene = None) Bases: :py:obj:`DictController` A flat/combined view of multiple controllers. .. py:method:: _initialize_action_space() .. py:method:: from_action_dict(action_dict) Convert a dict of actions to a flat action. .. py:method:: set_action(action) Set the action to execute. The action can be low-level control signals or high-level abstract commands. .. py:method:: to_action_dict(action) Convert a flat action to a dict of actions. .. py:class:: ControllerConfig .. py:attribute:: controller_cls .. py:attribute:: joint_names :type: list[str] the names of the joints to control. Note that some controller configurations might not actually let you directly control all the given joints and will instead have some other implicit control (e.g. Passive controllers or mimic controllers). .. py:class:: DictController(configs, articulation, control_freq, sim_freq = None, scene = None) Bases: :py:obj:`BaseController` Base class for controllers. The controller is an interface for the robot to interact with the environment. .. py:method:: __repr__() .. py:method:: _initialize_action_space() .. py:method:: _initialize_joints() .. py:method:: before_simulation_step() Called before each simulation step in one control step. .. py:method:: from_qpos(qpos) Tries to generate the corresponding action given a full robot qpos. This can be useful for joint position control when setting a desired qposition even if some controllers merge some joints together like the mimic controller .. py:method:: get_state() Get the controller state. .. py:method:: reset() Resets the controller to an initial state. This is called upon environment creation and each environment reset .. py:method:: set_action(action) Set the action to execute. The action can be low-level control signals or high-level abstract commands. .. py:method:: set_drive_property() Set the joint drive property according to the config. .. py:method:: set_state(state) .. py:attribute:: _control_freq .. py:attribute:: action_space the action space of the controller, which by default has a batch dimension. This is typically already normalized as well. .. py:attribute:: articulation .. py:attribute:: configs .. py:attribute:: controllers :type: dict[str, BaseController] .. py:attribute:: scene :value: None .. py:attribute:: sets_target_qpos :value: False Whether the controller sets the target qpos of the articulation .. py:attribute:: sets_target_qvel :value: False Whether the controller sets the target qvel of the articulation