Add value-setter for Robot class

Fixes #305
This commit is contained in:
Andrew Scheller
2016-05-28 13:50:47 +01:00
parent 42f9d4f3b8
commit b3035d306e
2 changed files with 28 additions and 0 deletions

View File

@@ -776,6 +776,20 @@ class Robot(SourceMixin, CompositeDevice):
right_motor=Motor(*right),
_order=('left_motor', 'right_motor'))
@property
def value(self):
"""
Represents the motion of the robot as a tuple of (left_motor_speed,
right_motor_speed) with ``(-1, -1)`` representing full speed backwards,
``(1, 1)`` representing full speed forwards, and ``(0, 0)``
representing stopped.
"""
return super(Robot, self).value
@value.setter
def value(self, value):
self.left_motor.value, self.right_motor.value = value
def forward(self, speed=1):
"""
Drive the robot forward by running both motors forward.