From db0caad282efa082482a22036828cb53508d53ed Mon Sep 17 00:00:00 2001 From: Antoni Luong Pham Date: Mon, 15 Feb 2021 14:47:07 -0800 Subject: [PATCH] sets/inventor: Add MVP basic program. rename MVP Basic program fix MVP Basic program --- sets/inventor/mvp/README.md | 7 +++++++ sets/inventor/mvp/mvp_basic.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 sets/inventor/mvp/README.md create mode 100644 sets/inventor/mvp/mvp_basic.py diff --git a/sets/inventor/mvp/README.md b/sets/inventor/mvp/README.md new file mode 100644 index 0000000..8fe5112 --- /dev/null +++ b/sets/inventor/mvp/README.md @@ -0,0 +1,7 @@ +# Example LEGO® MINDSTORMS® Robot Inventor programs for M.V.P. + +This program requires PyBricks v3.0 firmware installed on the Inventor Hub. + +Building instructions can be found at https://www.lego.com/en-us/service/buildinginstructions/51515. + +The playing instructions for each robot variant are in the docstrings of the corresponding file. diff --git a/sets/inventor/mvp/mvp_basic.py b/sets/inventor/mvp/mvp_basic.py new file mode 100644 index 0000000..7598928 --- /dev/null +++ b/sets/inventor/mvp/mvp_basic.py @@ -0,0 +1,28 @@ +""" +This program is for MVP's basic "Buggy" mode. + +Follow the corresponding building instructions in the LEGO® MINDSTORMS® +Robot Inventor App. +""" + +from pybricks.pupdevices import Motor +from pybricks.parameters import Direction, Port + + +class MVP: + def __init__(self): + self.steer_motor = Motor(Port.A) + self.drive_motor = Motor(Port.B, + positive_direction=Direction.COUNTERCLOCKWISE) + + def calibrate(self): + self.steer_motor.run_target(speed=1000, target_angle=0) + + +# Initialize mvp and straighten its steering. +mvp = MVP() +mvp.calibrate() + +# Make mvp drive in a circle. +mvp.steer_motor.run_angle(speed=350, rotation_angle=50) +mvp.drive_motor.run_angle(speed=800, rotation_angle=16 * 360)