mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Protect motor from going nuts in angled mode
This commit is contained in:
parent
6878cbeda7
commit
2e2e36d560
@ -172,11 +172,17 @@ class EncodedMotor(Peripheral):
|
|||||||
if self.port == PORT_AB:
|
if self.port == PORT_AB:
|
||||||
mtype += 1 # de-facto rule
|
mtype += 1 # de-facto rule
|
||||||
|
|
||||||
|
abs_primary = self._speed_abs(speed_primary)
|
||||||
|
abs_secondary = self._speed_abs(speed_secondary)
|
||||||
|
|
||||||
|
if mtype == self.ANGLED_GROUP and (not abs_secondary or not abs_primary):
|
||||||
|
raise ValueError("Cannot have zero speed in double angled mode") # otherwise it gets nuts
|
||||||
|
|
||||||
params = pack("<B", self.MOVEMENT_TYPE) + pack("<B", mtype) + params
|
params = pack("<B", self.MOVEMENT_TYPE) + pack("<B", mtype) + params
|
||||||
|
|
||||||
params += pack("<b", self._speed_abs(speed_primary))
|
params += pack("<b", abs_primary)
|
||||||
if self.port == PORT_AB:
|
if self.port == PORT_AB:
|
||||||
params += pack("<b", self._speed_abs(speed_secondary))
|
params += pack("<b", abs_secondary)
|
||||||
|
|
||||||
params += self.TRAILER
|
params += self.TRAILER
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user