bam.simulate#
Classes#
Single-axis pendulum simulator used during identification. |
Module Contents#
- class bam.simulate.Simulator(model: bam.model.Model)#
Single-axis pendulum simulator used during identification.
Implements the BAM simulation loop: firmware control law → motor torque → friction budget → stopping-torque clipping → Euler integration. Used by
bam.fitto roll out a model against recorded logs and compute the identification loss.- Parameters:
model – BAM friction model to simulate.
- screen = None#
- model#
- reset(q: float = 0.0, dq: float = 0.0)#
Resets the simulation to a given state
- step(control: None | float, torque_enable: bool, dt: float)#
Advance the simulation by one timestep.
- Parameters:
control – Control signal sent to the actuator (voltage, current, or torque depending on the actuator type).
Noneis treated as zero.torque_enable – Whether the actuator is powered. When
Falsethe motor torque is zero and only gravity and friction act.dt – Timestep [s].
- rollout_log(log: dict, reset_period: float = None, simulate_control: bool = False)#
Roll out the model against a recorded log and return predicted trajectories.
- Parameters:
log – Processed log dict as returned by
bam.logs.Logs.make_batch()or loaded directly from a processed JSON file.reset_period – If set, re-synchronize the simulator state to the log at this interval [s]. Useful when error accumulation destabilizes long rollouts.
simulate_control – If
True, recompute the control signal from the simulated state using the firmware control law. IfFalse, use the control values recorded in the log.
- Returns:
Tuple
(positions, velocities, controls)— lists of values at each timestep.