Maneuvers with Distance Control

Distance in Ticks

The cyber:bot board’s Feedback 360° servo driver measures distance in 64ths of a turn.  That’s equivalent to half way between two of the smallest spokes in the cyber:bot wheel.  For simplicity, we’ll call 1/64th of a rotation a ‘tick’.  Since the diameter of the cyber:bot wheel is 66.2 mm, we can use Ω x diameter to calculate that the circumference is 208 mm.  Then, 1/64th of that is 3.25 mm, the distance the wheel travels when it rotates one tick.

The feedback360 module has a method named drive.goto(), which you supply with two distances in ticks, one for each wheel.  In this example, drive.goto(64, 64) results in both wheels turning forward 64 ticks x 3.25 mm/tick = 208 mm, the circumference of the wheel.  Converting to inches, that would be 208 mm x 1 in/ 25.4 mm ≈ 8.2 in.  Using 32 ticks would get the cyber:bot about half that far, about 4.1 in.     


In this activity, you will use drive.goto to make the cyber:bot travel certain distances, and incorporate calculations into your script to make the cyber:bot travel a specified distance in inches.  You will use distance values that will make the cyber:bot turn in place, pivot, and arc.

Distance Maneuver Script

This script will perform the forward, left, right, left, backward pattern, and the cyber:bot should return much closer to its starting point.  In fact, with drive.goto, you can mark the spoke on each wheel that’s pointing straight up when the script starts, and it should be pointing up again when the script completes.

  • Make sure there are five AA batteries to your cyber:bot robot’s battery pack and that it’s plugged into your cyber:bot board.
  • Connect the micro:bit in the cyber:bot to your computer with a USB cable.
  • Set the PWR switch to 1.
  • Right-click the distances_forward_left_right_left_backward.hex link below, and select Save link as…

distances_forward_left_right_left_backward.hex

 

  • Open distances_forward_left_right_left_backward.hex it with the python.microbit.org/v/2 editor.
  • Click Connect.
  • Click Flash.
  • Set the PWR switch to 0.

Distance Maneuver Tests

  • Disconnect the USB cable from the cyber:bot robot’s micro:bit module.
  • Set it on the floor
  • Set the PWR switch to 2.
  • Verify that the cyber:bot
    • Rolls forward for 3 wheel turns
    • Rotates left for by about 90°
    • Rotates right by about 180°
    • Rotates left by about 90°
    • Rolls backward for 3 wheel turns