newton.actuators.BatteryConstantResistance#

class newton.actuators.BatteryConstantResistance(nominal_voltage, resistance, min_voltage, actuator_start, actuators, *, world=None, world_count=0)[source]#

Bases: BatteryBase

Battery from BAM (Better Actuator Models): an ideal voltage source behind a constant internal resistance.

As in BAM, the voltage of a battery is

\[V = \max\big(V_{\text{nominal}} - R \max(0, \textstyle\sum I),\; V_{\min}\big)\]

over the currents \(I\) the actuators assigned to it draw, e.g. \(d\, I_{\text{motor}}\) for MotorDC. The sum is signed, so a regenerating actuator offsets a driving one, and regeneration does not raise the voltage above nominal. Each battery sums its actuators in a fixed order, so the voltage is deterministic.

The supply and the motors form an explicit feedback loop. For a MotorDC behind a DUTY-configured DrivePD and a ClampingCurrentDuty without an active current limit, it settles while resistance * sum(max_duty**2 / motor resistance) < 1 over the actuators sharing a battery; above that bound, or while a current limit is active, the voltage may oscillate instead of converging.

classmethod resolve_arguments(args)#

Resolve user-provided arguments with defaults.

Parameters:

args (dict[str, Any]) – User-provided arguments. nominal_voltage [V] is required; resistance [Ω] defaults to 0, and min_voltage [V] defaults to 0, with which the voltage only stays non-negative.

Returns:

Complete arguments with defaults filled in.

Raises:

ValueError – nominal_voltage is missing, min_voltage is negative or exceeds nominal_voltage, or resistance is negative.

Return type:

dict[str, Any]

__init__(nominal_voltage, resistance, min_voltage, actuator_start, actuators, *, world=None, world_count=0)#

Initialize the batteries.

Parameters:
  • nominal_voltage (wp.array[wp.float32]) – Voltage without load [V]. Shape (B,).

  • resistance (wp.array[wp.float32]) – Internal resistance [Ω]. Shape (B,).

  • min_voltage (wp.array[wp.float32]) – Lowest voltage under load [V]. Shape (B,).

  • actuator_start (wp.array[wp.int32]) – See BatteryBase.__init__().

  • actuators (wp.array[wp.int32]) – See BatteryBase.__init__().

  • world (wp.array[wp.int32] | None) – See BatteryBase.__init__().

  • world_count (int) – See BatteryBase.__init__().

Raises:

ValueError – An array does not have one entry per battery.

reset(sim_control, *, world_mask=None)#

Restore the nominal voltage of the reset batteries.

Raises:
  • AttributeError – sim_control has no actuator_supply_voltage.

  • ValueError – actuator_supply_voltage is None, or world_mask does not have shape (world_count + 1,).

See BatteryBase.reset() for the arguments.

step(sim_control, next_control=None)#

Drop each battery’s voltage with the current of its actuators.

Raises:
  • AttributeError – sim_control has no actuator_supply_current, or the written control no actuator_supply_voltage.

  • ValueError – One of these arrays is None.

See BatteryBase.step() for the arguments.

min_voltage#

Lowest voltage under load [V], shape (B,).

nominal_voltage#

Voltage without load [V], shape (B,).

resistance#

Internal resistance [Ω], shape (B,).