bam.mujoco#
Classes#
A MujocoController is a class allowing to apply the torque and update frictions |
Functions#
|
Loads a BAM configuration file and returns the list of controllers and the mapping dicts. |
Module Contents#
- class bam.mujoco.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.
- Parameters:
model (bam.Model) – Model to use (can be loaded using load_model)
actuator (str) – Actuator to control. The actuated joint properties will be updated. This can be a list of actuators
mujoco_model (mujoco.MjModel) – The mujoco model
mujoco_data (mujoco.MjData) – The mujoco data
vin_drop_gain (float | None) – 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
vin_min (float | None) – the minimum voltage, if not None the voltage will not go below this value
max_current (float | None) – 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.
- model#
- actuator#
- mujoco_model#
- mujoco_data#
- vin_drop_gain = None#
- vin_min = None#
- max_current = None#
- dofs = []#
- q_target#
- dof_to_q_target#
- last_ts#
- act_indexes#
- joint_indexes#
- qpos_indexes#
- dof_indexes#
- get_q_target(name: str) float#
Return the current target position for a named actuator [rad].
- Parameters:
name – Actuator name as passed to the constructor.
- set_q_target(name: str, q_target: float)#
Set the target position for a named actuator.
- Parameters:
name – Actuator name as passed to the constructor.
q_target – Desired joint angle [rad].
- reset(qpos)#
Reset the controller to a given joint position state.
Should be called after every
mujoco.mj_resetDatato clear the internal target and voltage-drop state.- Parameters:
qpos – Full
mj_data.qposarray. The controller extracts the positions of its controlled joints.
- update()#
Update the controlled actuator(s) data: - Torque to apply - Friction parameters - Damping
- bam.mujoco.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.
- Parameters:
path (str) – path to the configuration file
mujoco_model (mujoco.MjModel) – the mujoco model
mujoco_data (mujoco.MjData) – the mujoco data
kp (float) – the proportional gain
vin (float) – the input voltage
- Returns:
list of controllers, dofs to model mapping, dofs to id mapping
- Return type:
list