So because the season is over, my 8th graders had the bright idea to issue a challenge to each other, Programmer has to drive and score a certain amount of points, Driver has to program to get a certain amount of points.
We made the stipulation we’ll stick with Python vs going into PROS just for simplicity of teaching, but we’re having an issue with turning on a 6 motor drive.
So we programmed using python a SuperDrive, and got all the numbers correct as best as I can remember, but the only way to get accurate turns is by going at 10% power so it hits, and then the turns are not accurate fully, we type 90 degrees and it overshoots, by like 45 degrees.
We’re using set_turn_constant and set_turn_threshold to no avail, we made sure the gearing was correct (at least I thought so). Driving forward is accurate, its all turns thats messing up.
Heres the code, I’ll upload the video in a minute
lfm = Motor(Ports.PORT3, GearSetting.RATIO_6_1, True)
lmm = Motor(Ports.PORT4, GearSetting.RATIO_6_1, True)
lbm = Motor(Ports.PORT5, GearSetting.RATIO_6_1, True)
rfm = Motor(Ports.PORT10,GearSetting.RATIO_6_1, False)
rmm = Motor(Ports.PORT9, GearSetting.RATIO_6_1, False)
rbm = Motor(Ports.PORT8, GearSetting.RATIO_6_1, False)
pre = Motor(Ports.PORT6, False)
hook = Motor(Ports.PORT7,GearSetting.RATIO_6_1, False)
lb = Motor(Ports.PORT1, True)
inert = Inertial(Ports.PORT20)
dnk = DigitalOut(brain.three_wire_port.e)
clp = DigitalOut(brain.three_wire_port.d)
# Motor groups
lmg = MotorGroup(lfm, lmm, lbm)
rmg = MotorGroup(rfm, rmm, rbm)
intake = MotorGroup(pre, hook)
# drivetrain and Controller
SupaDrive = SmartDrive(lmg, rmg, inert, 300, 320, 320, INCHES, 1) #Motor Groups, Circumfrence, Track Width, Wheel base, Units(MM or Inches) Gear Ratio
#Functions
def Drivee (direction, distance, speed):
SupaDrive.set_drive_velocity(speed, PERCENT)
SupaDrive.drive_for(direction, distance, INCHES)
def Turnn (direction, angle, speed):
SupaDrive.set_turn_velocity(speed, PERCENT)
SupaDrive.turn_for(direction, angle, DEGREES)
def LadyBrown (direction, angle, speed):
lb.spin_for(direction, angle, DEGREES, speed, PERCENT)
def Intakee (direction, angle, speed):
intake.spin_for(direction, angle, DEGREES, speed, PERCENT)
def Donkerr (dare):
dnk.set(dare)
def Clamp (dare):
clp.set(dare)
#Competition Code
def pre_autonomous():
count = 0
brain.screen.clear_screen()
while True:
brain.screen.print_at("Pre_Auton.... %6d" %(count), x=10, y=40)
count = count + 1
inert.calibrate()
SupaDrive.set_stopping(HOLD)
SupaDrive.set_turn_constant(3.5)
SupaDrive.set_turn_threshold(3.5)
def autonomous():
count = 0
brain.screen.clear_screen()
while True:
Drivee(FORWARD, 16, 80)
Turnn(RIGHT, 70, 8)
Drivee(REVERSE, 10, 80)
wait(500)
Clamp(True)
wait(500)
Turnn(LEFT, 140, 8)
Intakee(LEFT, 4000, 100)
brain.screen.print_at("Auton.... %6d" %(count), x=10, y=40)
count = count + 1
def usercontrol():
count = 0
brain.screen.clear_screen()
while True:
brain.screen.print_at("User Control.... %6d" %(count), x=10, y=40)
# controller with joy sticks
#Buttons
comp = Competition(usercontrol, autonomous) #do not touch this