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)))
#test steps=10 with VRep.connect("127.0.0.1", 19997) as api: r = LegoEV3(api) while steps: r.move_forward() time.sleep(0.1) r.rotate_right() time.sleep(0.1) steps=steps-1