motor_control¶
- class MotorControlBase(powertrain: Powertrain)¶
Bases:
ABCMotorControlBaseobject.Abstract base class for creating motor control objects.
See Also
- abstract apply_rules()¶
- class PWMControl(powertrain: Powertrain)¶
Bases:
MotorControlBasePWMControlobject.Attributes¶
Methods¶
add_rule()It adds a
ruletoruleslist.apply_rules()It applies all the
rulesin order to get a validpwmvalue to set to thepowertrain’s motor.
Raises
TypeErrorIf
powertrainis not an instance ofPowertrain,if the first element in
powertrainis not an instance ofMotorBase,if an element of
powertrainis not an instance ofRotatingObject.
ValueErrorIf
powertrain.elementsis an empty tuple.
See Also
- add_rule(rule: RuleBase) None¶
It adds a
ruletoruleslist.Parameters¶
Raises
TypeErrorIf
ruleis not an instance ofRuleBase.
See Also
rulesmodule
- apply_rules() None¶
It applies all the
rulesin order to get a validpwmvalue to set to thepowertrain’s motor.It loops over listed
rulesand applies all of them:if a single rule returns a valid
pwm, then this value is set aspowertrain’s motorpwm,if more than a single rule returns a valid
pwm, then it raises aValueError, since multiple rules are valid at the same time and it is not possible to identify whichpwmvalue to use,if no rule returns a valid
pwm, then it setspowertrain’s motorpwmto1.
Before settings the
pwm, its value is saturated in order to be within-1and1.Raises
ValueErrorIf two different rules are applicable at the same time. Only a single applicable rule is allowed to a specific simulation time.
- class RuleBase¶
Bases:
ABCRuleBaseobject.Abstract base class for creating rules objects.
- abstract apply()¶