コード例 #1
0
Robot.log("BEGIN TEST")
"""
# Test bounceback
Robot.log("My_block.spin_turn");
Target_Angle = 120
for spins in range(0, 300):
	My_block.spin_turn(Target_Angle)
	Target_Angle = Target_Angle + random.randint(-180,180)
	sleep(1)

# Test simple turn
Robot.log("My_block.simple_turn");
Target_Angle = 120
for spins in range(0, 300):
	My_block.simple_turn(Target_Angle)
	Target_Angle = Target_Angle + random.randint(-180,180)
	sleep(1)
"""

# Test proportional turn
Robot.log("My_block.proportional_turn")
Target_Angle = 120
for spins in range(0, 300):
    My_block.proportional_turn(Target_Angle)
    Target_Angle = Target_Angle + random.randint(-180, 180)
    sleep(2)

Robot.log("TEST COMPLETE")
Robot.log_file.close()
コード例 #2
0
def swingset_mission():
    """
    Completes M-07 Swing, and M-08 Elevator.
    """

    Robot.right_attachment.on_for_seconds(50, 0.5)

    # Establishes the compass point the robot is facing

    Robot.gyro.compass_point = 90

    # Complete Swing and back away

    My_block.gyro_straight(40, 7.36)

    My_block.gyro_straight(30, -1)

    # Smush against wall

    My_block.spin_turn(0)
    My_block.wall_square(100)

    # Drive to elevator

    My_block.gyro_straight(35, 1.62)
    My_block.spin_turn(56)
    My_block.gyro_straight(35, 2.15)

    # qwhack elevator

    Robot.left_attachment.on_for_rotations(35, 1)
    sleep(0.5)
    Robot.tank_pair.on_for_rotations(55, 55, -1.05)
    Robot.left_attachment.on_for_rotations(-35, 0.95)

    # Do House Mission
    Robot.debug_print(Robot.gyro.compass_point)

    My_block.spin_turn(89)

    Robot.debug_print(Robot.gyro.compass_point)

    Robot.right_attachment.on_for_seconds(-50, 1.4)

    Robot.debug_print(Robot.gyro.compass_point)

    My_block.gyro_straight(30, 0.81)

    Robot.debug_print(Robot.gyro.compass_point)

    My_block.spin_turn(99)

    Robot.debug_print(Robot.gyro.compass_point)

    Robot.steer_pair.on_for_rotations(0, -20, 0.3)

    My_block.spin_turn(93)

    Robot.debug_print(Robot.gyro.compass_point)

    Robot.steer_pair.on_for_rotations(0, -20, 0.3)

    My_block.proportional_turn(86)

    # Go Home.

    My_block.gyro_straight(100, -6)
    My_block.wall_square(100)
    Robot.right_attachment.on_for_rotations(100, 2.2)
    sleep(0.4)
    My_block.proportional_turn(0)