Example 5 Time To Turn

Simulation

not found

Real Life

not found

What does the code do?

In this code the robot moves forward for 1200 ms using mav at 1500 velocity, then curve right for 1500ms(1000 and 1500 velocity) then curve left for 2000ms(1500 and 500 velocity)

Functions Used

mav( motor port, velocity)

msleep(distance in ms)

Function Implementation

 1#!/usr/bin/python3
 2import os, sys
 3sys.path.append("/usr/lib")
 4from kipr import*
 5
 6def main():
 7   mav(0, 1500)
 8   mav(3, 1500)
 9   msleep(1200)
10
11   mav(0, 1000)
12   mav(3, 1500)
13   msleep(1500)
14
15   mav(0, 1500)
16   mav(3, 500)
17   msleep(2000)
18
19if __name__ == "__main__":
20   main()

Rookie Tips

By having one motor move at a slower speed, the robot will start to curve! This will let your robot move in different directions! If you want your robot to turn without curving, try having one motor be positive and the other negative.