1
0
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:
Andrey Pohilko 2017-12-24 11:32:42 +03:00
parent 6878cbeda7
commit 2e2e36d560

@ -172,11 +172,17 @@ class EncodedMotor(Peripheral):
if self.port == PORT_AB:
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._speed_abs(speed_primary))
params += pack("<b", abs_primary)
if self.port == PORT_AB:
params += pack("<b", self._speed_abs(speed_secondary))
params += pack("<b", abs_secondary)
params += self.TRAILER