print("Configuring motors...")
motor_steer = Motor('A')  # Front wheels (for steering)
motor_power = Motor('B')  # Back wheels (for moving)
print("DONE!")

# %% [markdown]
# # Set steering motor to starting position

# %%
print("Setting steering motor to position 0...")
motor_steer.run_to_position(45, speed=100)
motor_steer.run_to_position(0, speed=100)
print("DONE!")

# %% [markdown]
# # Move MVP

# %%
print("Steering...")
motor_steer.run_to_position(50, speed=35)
print("DONE!")

# %%
print("Moving...")
motor_power.set_default_speed(80)
motor_power.run_for_rotations(-16)
print("DONE!")

# %%
print("-" * 15 + " Execution ended " + "-" * 15 + "\n")
Esempio n. 2
0
# %%
hub.status_light.on('black')

# %% [markdown]
# # Configure motors

# %%
print("Configuring motors...")
motors_wheels = MotorPair('A', 'E')
motors_wheels.set_default_speed(70)

motor_left_arm = Motor('B') # Left arm
motor_right_arm = Motor('F') # Right arm

motor_left_arm.set_default_speed(40)
motor_right_arm.set_default_speed(-40)

motors_arms = MotorPair('B', 'F')
print("DONE!")

# %% [markdown]
# # Set arm motors to starting position
# This isn't part of the original program, but I think it is good practice to make sure motors always start in the same state.
#

# %%
print("Setting arm motors to position 0...")
motor_left_arm.run_to_position(0)
motor_right_arm.run_to_position(0)
print("DONE!")
hub = MSHub()
app = App()

# %%
hub.status_light.on('black')

# %% [markdown]
# # Configure motors

# %%
print("Configuring motors...")
motor_left_arm = Motor('B')  # Left arm
motor_right_arm = Motor('F')  # Right arm
motors_arms = MotorPair('B', 'F')

motor_left_arm.set_default_speed(-100)
motor_right_arm.set_default_speed(100)
print("DONE!")

# %% [markdown]
# # Set arm motors to starting position

# %%
print("Setting arm motors to position 0...")
motor_left_arm.run_to_position(0)
motor_right_arm.run_to_position(0)
print("DONE!")

# %% [markdown]
# # Make Charlie push himself around
# If Charlie doesn't move properly, try:
Esempio n. 4
0
        next(turret_generator)
        turret_generator.send(TURRET_ANGLE)

        wait_for_seconds(0.01)  # Small pause between steps.

    return None


# %% [markdown]
# After we have defined the turret movement, we can now make the AAT MS5 patrol until it finds those pesky Republic supporters!

# %%
TURRET_ANGLE = 40

print("Initializing turret with angle " + str(TURRET_ANGLE) + "...")
motor_turret.set_default_speed(10)
motor_turret.run_for_degrees(-TURRET_ANGLE)
print("DONE!")

print("Starting patrolling...")
move_turret()
print("DONE!")

# %% [markdown]
# Once it finds an enemy (i.e, it detects an obstacle), it will stop and center the turret.

# %%
print("Enemy detected! Attack!")
motor_power.stop()  # Stop the movement
motor_turret.run_to_position(0, speed=75)  # Center the turret
Esempio n. 5
0
print("DONE!")

# %% [markdown]
# # Configure motors

# %%
print("Configuring motors...")
motors_wheels = MotorPair('A', 'E')
print("DONE!")

# %% [markdown]
# # Rise arms

# %%
print("Rising arms...")
motor_f.set_default_speed(-75)
motors_arms = MotorPair('B', 'F')
motors_arms.move(-90, unit='degrees')  # Negative angle is clockwise movement
motors_arms.move(90,
                 unit='degrees')  # Positive angle is counterclockwise movement
print("DONE!")

# %% [markdown]
# # Customizing Charlie
# ## Defining functions
# I think that the main point of the original program is to show how Scratch's `My Block`s work.
# This is the equivalent of Python functions. Thus, first we will define them.
#
# It is important to note how the objects `hue`, `app`, and all the motors are defined globally
# (and don't need to be passed as arguments to the functions). It is also worth mentioning that
# it is good practice that functions always return something, even if it is a `None`.
Esempio n. 6
0
# %%
hub = MSHub()
app = App()

# %%
hub.status_light.on('black')

# %% [markdown]
# # Configure motors

# %%
print("Configuring motors...")
motor_wheel = Motor('E')  # Wheel (for turning around)
motor_left_arm = Motor('B')  # Left arm
motor_left_arm.set_default_speed(-80)
print("DONE!")

# %%
print("Setting arm motor to initial position...")
motor_left_arm.run_for_seconds(1)
print("DONE!")

# %% [markdown]
# # Configure sensor

# %%
print("Configuring color sensor...")
color_sensor = ColorSensor('C')
print("DONE!")
Esempio n. 7
0
hub.status_light.on('black')
hub.light_matrix.show_image('SILLY')


# %% [markdown]
# # Configure motors

# %%
print("Configuring motors...")
motors_wheels = MotorPair('A', 'E')
motors_wheels.set_default_speed(80)

motor_left_arm = Motor('B') # Left arm
motor_right_arm = Motor('F') # Right arm

motor_left_arm.set_default_speed(75)
motor_right_arm.set_default_speed(-75)

motors_arms = MotorPair('B', 'F')
print("DONE!")

# %% [markdown]
# # Set arm motors to starting position

# %%
print("Setting arm motors to position 0...")
motor_left_arm.run_to_position(0)
motor_right_arm.run_to_position(0)
print("DONE!")

# %% [markdown]