bam.model#
Attributes#
Classes#
Friction model for a servo actuator. |
|
Friction model for a servo actuator. |
Functions#
|
Load a BAM friction model from a parameter file. |
|
Load a BAM friction model from a parameter dictionary. |
Module Contents#
- class bam.model.Model(load_dependent: bool = False, directional: bool = False, stribeck: bool = False, quadratic: bool = False, name: str = None, title: str = '')#
Friction model for a servo actuator.
Combines a motor model (set via
set_actuator()) with a friction budget that maps joint state and torques to a maximum resistive torque \(\tau_{fm}\). The friction applied by the simulator is the stopping torque clipped in \([-\tau_{fm}, \tau_{fm}]\).Use
load_model()to instantiate from a parameter file rather than constructing directly.- Parameters:
load_dependent – Enable load-dependent friction terms.
directional – Enable directional (motor-side vs external-side) load friction. Requires
load_dependent=True.stribeck – Enable Stribeck effect (higher friction near zero velocity).
quadratic – Enable quadratic load-friction coupling term. Requires
directional=Trueandstribeck=True.name – Model variant identifier, e.g.
"m6".title – Human-readable title used in plots.
- actuator_name = None#
- name = None#
- title = ''#
- load_dependent: bool = False#
- directional: bool = False#
- stribeck: bool = False#
- quadratic: bool = False#
- max_friction_base = 0.2#
- max_load_friction = 0.5#
- max_viscous_friction = 1.0#
- reset() None#
Resets the model internal state
- set_actuator(actuator: bam.actuator.Actuator) None#
Attach an actuator to this model and initialize its parameters.
- Parameters:
actuator – Actuator instance to attach. Determines the motor model (kt, R, kp, vin) and the set of friction parameters that are created on this model.
- compute_frictions(motor_torque: float, external_torque: float, dtheta: float) tuple#
Compute the friction budget for the current state.
Returns the two MuJoCo friction parameters that implement the BAM friction-budget formulation:
frictionloss(Coulomb-like constant term) anddamping(viscous term). The simulator applies friction by clipping the stopping torque in \([-\text{frictionloss} - \text{damping}\cdot|\dot{\theta}|,\ +\ldots]\).- Parameters:
motor_torque – Torque produced by the motor [Nm].
external_torque – External (gravity/load) torque seen at the joint [Nm].
dtheta – Joint velocity [rad/s].
- Returns:
Tuple
(frictionloss, damping)ready to be written intomj_model.dof_frictionlossandmj_model.dof_damping.
- get_parameters() dict#
This returns the list of parameters that can be optimized.
- get_parameter_values() dict#
Return a dict containing parameter values
- load_parameters(json_file: str) list#
Load parameters from a given filename
- load_parameters_from_dict(data: dict) list#
Load parameters from a given dict
- class bam.model.DummyModel#
Bases:
ModelFriction model for a servo actuator.
Combines a motor model (set via
set_actuator()) with a friction budget that maps joint state and torques to a maximum resistive torque \(\tau_{fm}\). The friction applied by the simulator is the stopping torque clipped in \([-\tau_{fm}, \tau_{fm}]\).Use
load_model()to instantiate from a parameter file rather than constructing directly.- Parameters:
load_dependent – Enable load-dependent friction terms.
directional – Enable directional (motor-side vs external-side) load friction. Requires
load_dependent=True.stribeck – Enable Stribeck effect (higher friction near zero velocity).
quadratic – Enable quadratic load-friction coupling term. Requires
directional=Trueandstribeck=True.name – Model variant identifier, e.g.
"m6".title – Human-readable title used in plots.
- bam.model.models#
- bam.model.load_model(json_file: str = None, *, motor_name: str = None, model: str = None) Model#
Load a BAM friction model from a parameter file.
Specify the source with one of two mutually exclusive approaches:
Bundled motor — pass
motor_nameandmodel:model = load_model(motor_name="xl330", model="m6")
Custom JSON — pass
json_file(output ofbam.fit):model = load_model("params/my_motor/m6.json")
- Parameters:
json_file – Path to a BAM params JSON file.
motor_name – Name of a bundled motor (e.g.
"xl330","mx106"). Must be combined withmodel.model – Model variant for a bundled motor (
"m1"–"m6"). Must be combined withmotor_name.
- Returns:
A
Modelinstance with all parameters loaded.- Raises:
FileNotFoundError – If the requested bundled motor or model does not exist.
- bam.model.load_model_from_dict(data: dict) Model#
Load a BAM friction model from a parameter dictionary.
This is the low-level counterpart of
load_model(), used when the JSON data has already been parsed.- Parameters:
data – Dictionary produced by
json.loadon a BAM params file. Must contain at least"model"and"actuator"keys.- Returns:
A
Modelinstance with all parameters loaded.