Model via: https://github.com/albmardom/EV-R3P
In [ ]:
rclass='LegoEV3'
print('Loading class: {}'.format(rclass))
class LegoEV3:
def __init__(self, api: VRep):
self._api = api
self._left_motor = api.joint.with_velocity_control("Motor_B")
self._right_motor = api.joint.with_velocity_control("Motor_C")
#self._left_sensor = api.sensor.proximity("Pioneer_p3dx_ultrasonicSensor3")
#self._right_sensor = api.sensor.proximity("Pioneer_p3dx_ultrasonicSensor6")
def rotate_right(self, speed=2.0):
self._set_two_motor(speed, -speed)
def rotate_left(self, speed=2.0):
self._set_two_motor(-speed, speed)
def move_forward(self, speed=2.0):
self._set_two_motor(speed, speed)
def move_backward(self, speed=2.0):
self._set_two_motor(-speed, -speed)
def _set_two_motor(self, left: float, right: float):
self._left_motor.set_target_velocity(left)
self._right_motor.set_target_velocity(right)
methods = [method for method in dir(eval(rclass)) if not method.startswith('_')]
print('Methods available in {}:\n\t{}\n'.format(eval(rclass).__name__ , '\n\t'.join(methods)))