В момента ресурсът е наличен само на английски

Teacher's Notes Pro Preview

For today’s lesson, the motor should be in its default 0-degree position during construction. You can verify this using the marker on the motor.

At the end of the lesson, the students will take part in a small competition. To prepare for it, they will need a race track.

Place two objects on the floor (these can be LEGO models or any other suitable items) that the students will use as markers while programming their robots to drive in a figure-eight pattern around them. Mark a starting line at the beginning of a straight section of the track.

content picture

Необходимо е да се абонирате за FLLCasts.com, за да достъпите това видео

Абонирай се

  • #2605
  • 24 Mar 2026

"Program the robot to move forward by rotating its wheels two full turns. "

from hub import port
import motor
import runloop

async def main():
    motor.run_for_degrees(port.A, 720, 1000)

runloop.run(main())

"Program the robot to turn its front wheels to the left. "

from hub import port
import motor
import runloop

async def main():
    motor.run_for_degrees(port.B, 30, 1000)

runloop.run(main())

"Program the robot to turn its front wheels to the left, then move forward by two wheel rotations. "

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.B, 30, 1000)
    motor.run_for_degrees(port.A, 720, 1000)

runloop.run(main())

"At the end of your program, add a right turn, then move forward by two more wheel rotations. "

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.B, 30, 1000)
    await motor.run_for_degrees(port.A, 720, 1000)
    await motor.run_for_degrees(port.B, -60, 1000)
    motor.run_for_degrees(port.A, 720, 1000)

runloop.run(main())

"Modify your program to perform the same sequence of actions, but use the run_to_absolute_position() command to control the steering."

from hub import port
import motor
import runloop

async def main():
    await motor.run_to_absolute_position(port.B, 30, 1000)
    await motor.run_for_degrees(port.A, 720, 1000)
    await motor.run_to_absolute_position(port.B, 330, 1000)
    motor.run_for_degrees(port.A, 720, 1000)

runloop.run(main())

"Program the car to park perpendicular to the starting position while moving only forward."

from hub import port
import motor
import runloop

async def main():
    await motor.run_to_absolute_position(port.B, 30, 1000)
    motor.run_for_degrees(port.A, 1100, 1000)

runloop.run(main())

"Program the car to park perpendicular to the starting position while moving only backward. "

from hub import port
import motor
import runloop

async def main():
    await motor.run_to_absolute_position(port.B, 30, 1000)
    motor.run_for_degrees(port.A, -1100, 1000)

runloop.run(main())

"Place the robot behind the starting line and program it to move forward using the run_for_degrees() command. It should pass between the two beams marking the track and stop where you want the first turn to begin."

from hub import port
import motor
import runloop

async def main():
    motor.run_for_degrees(port.A, this number depends on the field, 1000)

runloop.run(main())

"Program the robot to drive around the first beam using the run_to_absolute_position() and run_for_degrees() commands. The robot should stop in a position where it can drive in a straight line between the two beams, heading in the opposite direction. "

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 30, 1000)
    motor.run_for_degrees(port.A, this number depends on the field, 1000)

runloop.run(main())

"Program the robot to move forward using the run_for_degrees() command, passing between the two beams that mark the track. The robot should stop where you want the second turn to begin. "

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 30, 1000)
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 0, 1000)
    motor.run_for_degrees(port.A, this number depends on the field, 1000)

runloop.run(main())

"Program the robot to drive around the second beam marking the track and stop behind the starting line using the run_to_absolute_position() and run_for_degrees() commands. "

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 30, 1000)
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 0, 1000)
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 330, 1000)
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    motor.run_to_absolute_position(port.B, 0, 1000)

runloop.run(main())

"Program the robot to complete three full laps of the track."

There are several ways to solve this task, and none of them are considered wrong. Repeating the lines of code is also an acceptable solution.

Курсове и занятия включващи този Урок

Този Урок е използван в следните курсове и занятия.

Image for Level A: Python Foundations – Robotics with LEGO SPIKE Prime
  • 46
  • 4:32
  • 78
Image for Lesson 6 - Steering an Unmanned Vehicle
  • 2
  • 7
  • 15
  • 3d_rotation 1