bam.mujoco ========== .. py:module:: bam.mujoco Classes ------- .. autoapisummary:: bam.mujoco.MujocoController Functions --------- .. autoapisummary:: bam.mujoco.load_config Module Contents --------------- .. py:class:: MujocoController(model: bam.model.Model, actuator: str, mujoco_model: mujoco.MjModel, mujoco_data: mujoco.MjData, vin_drop_gain: float | None = None, vin_min: float | None = None, max_current: float | None = None) A MujocoController is a class allowing to apply the torque and update frictions from the computed model during a simulation. :param bam.Model model: Model to use (can be loaded using load_model) :param str actuator: Actuator to control. The actuated joint properties will be updated. This can be a list of actuators :param mujoco.MjModel mujoco_model: The mujoco model :param mujoco.MjData mujoco_data: The mujoco data :param float | None vin_drop_gain: The voltage drop gain, if not None the voltage will be reduced by vin_drop_gain * load, where load is the sum of the absolute value of the motor torques :param float | None vin_min: the minimum voltage, if not None the voltage will not go below this value :param float | None max_current: Firmware current limit [A]. If not None, the motor current is clipped to ``[-max_current, max_current]`` (equivalently the motor torque is clipped to ``±max_current * kt``), reproducing the firmware-side current saturation of the motor. .. py:attribute:: model .. py:attribute:: actuator .. py:attribute:: mujoco_model .. py:attribute:: mujoco_data .. py:attribute:: vin_drop_gain :value: None .. py:attribute:: vin_min :value: None .. py:attribute:: max_current :value: None .. py:attribute:: dofs :value: [] .. py:attribute:: q_target .. py:attribute:: dof_to_q_target .. py:attribute:: last_ts .. py:attribute:: act_indexes .. py:attribute:: joint_indexes .. py:attribute:: qpos_indexes .. py:attribute:: dof_indexes .. py:method:: get_q_target(name: str) -> float Return the current target position for a named actuator [rad]. :param name: Actuator name as passed to the constructor. .. py:method:: set_q_target(name: str, q_target: float) Set the target position for a named actuator. :param name: Actuator name as passed to the constructor. :param q_target: Desired joint angle [rad]. .. py:method:: reset(qpos) Reset the controller to a given joint position state. Should be called after every ``mujoco.mj_resetData`` to clear the internal target and voltage-drop state. :param qpos: Full ``mj_data.qpos`` array. The controller extracts the positions of its controlled joints. .. py:method:: update() Update the controlled actuator(s) data: - Torque to apply - Friction parameters - Damping .. py:function:: load_config(path: str, mujoco_model: mujoco.MjModel, mujoco_data: mujoco.MjData, kp: float, vin: float) -> tuple Loads a BAM configuration file and returns the list of controllers and the mapping dicts. :param path: path to the configuration file :type path: str :param mujoco_model: the mujoco model :type mujoco_model: mujoco.MjModel :param mujoco_data: the mujoco data :type mujoco_data: mujoco.MjData :param kp: the proportional gain :type kp: float :param vin: the input voltage :type vin: float :returns: list of controllers, dofs to model mapping, dofs to id mapping :rtype: list