Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- KOALA_BEAR = "6_1"
- LINE_FOLLOWER = "2_3"
- LIMIT_SWITCH = "limit_switch"
- ARM_MOTOR = "6_801"
-
- def autonomous_setup():
- print("Autonomous mode has started!")
- la = Robot.get_value(LINE_FOLLOWER, "right")
- lb = Robot.get_value(LINE_FOLLOWER, "left")
- lc = Robot.get_value(LINE_FOLLOWER, "center")
- # in case of any needed motor inversions
- Robot.set_value(KOALA_BEAR, "invert_b", False)
- Robot.set_value(KOALA_BEAR, "invert_a", True)
-
- def autonomous_main():
- right_motor_speed = 1
- left_motor_speed = 1
- la = Robot.get_value(LINE_FOLLOWER, "right")
- lb = Robot.get_value(LINE_FOLLOWER, "left")
- lc = Robot.get_value(LINE_FOLLOWER, "center")
- # Robot following tape in a straight line
- if (lb > lc and lb > la):
- # print("left")
- right_motor_speed = 0.45
- left_motor_speed = 0.2
- Robot.set_value(KOALA_BEAR, "velocity_a", right_motor_speed)
- Robot.set_value(KOALA_BEAR, "velocity_b", left_motor_speed)
- # Robot following tape that starts to go to the right, diagonally not a 90 degree turn
- elif (la > lc and la > lb):
- # print("right")
- right_motor_speed = 0.2
- left_motor_speed = 0.45
- Robot.set_value(KOALA_BEAR, "velocity_a", right_motor_speed)
- Robot.set_value(KOALA_BEAR, "velocity_b", left_motor_speed)
- elif (lc > la and lc > lb):
- # print("straight")
- right_motor_speed = .55
- left_motor_speed = .55
- Robot.set_value(KOALA_BEAR, "velocity_a", right_motor_speed)
- Robot.set_value(KOALA_BEAR, "velocity_b", left_motor_speed)
- # Robot following tape that starts to go to the left, diagonally not a 90 degree turn
- else:
- pass
- #print("broken, sad, and confused robot :(")
-
- def teleop_setup():
- print("Teleop mode has started!")
- # in case of any needed motor inversions
- Robot.set_value(KOALA_BEAR, "invert_b", False)
- Robot.set_value(KOALA_BEAR, "invert_a", True)
-
- def teleop_main():
- right_motor_speed = 0
- left_motor_speed = 0
- arm_speed = 0
- if Keyboard.get_value("w"):
- right_motor_speed = 0.5
- left_motor_speed = 0.5
- elif Keyboard.get_value("s"):
- right_motor_speed = -0.5
- left_motor_speed = -0.5
- if Keyboard.get_value("d"):
- right_motor_speed = 0.075
- left_motor_speed = 0.5
- elif Keyboard.get_value("a"):
- right_motor_speed = 0.5
- left_motor_speed = 0.075
- if Keyboard.get_value("t"):
- right_motor_speed = 1
- left_motor_speed = 1
- elif Keyboard.get_value("g"):
- right_motor_speed = -1
- left_motor_speed = -1
- if Keyboard.get_value("h"):
- right_motor_speed = 0.3
- left_motor_speed = 1
- elif Keyboard.get_value("f"):
- right_motor_speed = 1
- left_motor_speed = 0.3
- if Keyboard.get_value("up_arrow"):
- arm_speed = 0.1
- elif Keyboard.get_value("down_arrow"):
- arm_speed = -0.1
- Robot.set_value(KOALA_BEAR, "velocity_b", left_motor_speed)
- Robot.set_value(KOALA_BEAR, "velocity_a", right_motor_speed)
- # KOALA_BEAR below is the second motor controller for the arm specifically !!! CHANGE THE IDS WHEN DRIVING
- Robot.set_value(ARM_MOTOR, "velocity_b", arm_speed)
Advertisement
Add Comment
Please, Sign In to add comment