Hey
So my driver wants to make it so that our angler can move to a specific angle to score with our conveyer. I know you can set positions with a rotational sensor but I don’t know how, I have never worked with rotationals. Can anyone help.
Here is the code
def conveyer_forward():
CONVEYER.spin(FORWARD)
def conveyer_reverse():
CONVEYER.spin(REVERSE)
def conveyer_stop():
CONVEYER.stop()
def angler_up():
ANGLER.spin(FORWARD)
def angler_down():
ANGLER.spin(REVERSE)
def angler_stop():
ANGLER.stop()
def fourbar_up():
FOURBAR.spin(FORWARD)
def fourbar_down():
FOURBAR.spin(REVERSE)
def fourbar_stop():
FOURBAR.stop()
def clamp_close():
CLAMP.spin(FORWARD)
def clamp_open():
CLAMP.spin(REVERSE)
def clamp_stop():
CLAMP.stop()
controller_1.buttonL1.pressed(fourbar_up)
controller_1.buttonL1.released(fourbar_stop)
controller_1.buttonL2.pressed(fourbar_down)
controller_1.buttonL2.released(fourbar_stop)
controller_1.buttonR1.pressed(angler_up)
controller_1.buttonR1.released(angler_stop)
controller_1.buttonR2.pressed(angler_down)
controller_1.buttonR2.released(angler_stop)
controller_1.buttonB.pressed(clamp_open)
controller_1.buttonB.released(clamp_stop)
controller_1.buttonA.pressed(clamp_close)
controller_1.buttonA.released(clamp_stop)
controller_1.buttonUp.pressed(conveyer_forward)
controller_1.buttonUp.released(conveyer_stop)
controller_1.buttonLeft.pressed(conveyer_reverse)
controller_1.buttonLeft.released(conveyer_stop)
drivetrain.set_drive_velocity(100,PERCENT)
drivetrain.set_stopping(COAST)
CONVEYER.set_velocity(100,PERCENT)
CONVEYER.set_stopping(COAST)
ANGLER.set_velocity(100,PERCENT)
ANGLER.set_stopping(HOLD)
FOURBAR.set_velocity(100,PERCENT)
FOURBAR.set_stopping(HOLD)
CLAMP.set_velocity(100,PERCENT)
CLAMP.set_stopping(HOLD)
def pre_auton():
brain.screen.clear_screen()
brain.screen.print("pre auton code")
wait(1, SECONDS)
def autonomous():
count=0
brain.screen.clear_screen()
ANGLER.spin_for(REVERSE,645,DEGREES)
drivetrain.drive_for(FORWARD,57, INCHES)
wait(.25,SECONDS)
ANGLER.spin_for(FORWARD, 200, DEGREES)
wait(3,SECONDS)
drivetrain.drive_for(REVERSE, 50, INCHES)
while True:
brain.screen.print_at("Running Auton... %6d" %(count), x=10, y=60)
count = count + 1
wait(100, MSEC)
def usercontrol():
count = 0
brain.screen.clear_screen()
while True:
brain.screen.print_at("Running driver... %6d" %(count), x=10, y=40)
count = count + 1
wait(100, MSEC)
comp = Competition(usercontrol, autonomous)