ConstantPWM

class ConstantPWM(timer: Timer, powertrain: Powertrain, target_pwm_value: float | int)

Bases: RuleBase

ConstantPWM object.

It can be used to make a gradual start of the powertrain’s motion, in order to avoid a peak in the powertrain’s DC motor absorbed electric current.

It checks whether the timer is active and, if so, it sets the pwm of powertrain motor to the constant target_pwm_value.

Methods

apply()

It checks if timer is active and, if so, it returns the pwm to apply to the powertrain motor, equal to target_pwm_value.

Raises

TypeError
  • If timer is not an instance of Timer,

  • if powertrain is not an instance of Powertrain,

  • if target_pwm_value is not a float or an int.

ValueError

If target_pwm_value is not within -1 and 1.

See Also

DCMotor.pwm

apply() None | float | int

It checks if timer is active and, if so, it returns the pwm to apply to the powertrain motor, equal to target_pwm_value.

Returns

float or int or None

PWM value to apply to the motor, equal to target_pwm_value.