2017-05-18 Robot Lab!

posted May 18, 2017, 6:33 AM by Samuel Konstantinovich
Goal: Write some programs to test the robot.

Tools:
1. You will need to build delays into your program. To do this we use the time
import time
#now you can use the sleep(seconds command)
time.sleep(1)

2. Loading functions from a package:
from package import *

#if you do this:
from time import *
#you can just say:
sleep(1)

The robots have a package gopigo. You do NOT have to copy this file to your directory, however you can look at its contents in order to see how the functions work.

#to use the robot commands you need to:
from gopigo import *

3. Setup your home directory:
a. Connect to your robot (use VNC)
b. Open a terminal on your robot.
c. Increase the terminal font size (edit -> preferences -> style -> terminal font size)
c. Make your home directory: (replace per04 with per05 if you are period 5)

Type the following in the terminal to make your home directory, and make it easy to write to. 
[The sudo command gives an error about resolving host, this is not a problem at all!]

cd ~/Desktop/GoPiGo/Software/Python/Stuy/
sudo mkdir skon-2017-per04  
sudo chown pi skon-2017-per4

4. Make a new python file   robotTest1.py  and try to do the following:
a. Import the gopigo, and time functions.
b. Try to make the robot turn right , wait 1 second, then turn left.
c. Do the same thing with forward and back.
d. Try to move the robot. Wait, adjust the speed, then move again. 
e. Use the speed adjustments to help you with the following:
    Turn 90 degrees, slow the robot down until it actually is close to 90 degrees. 
    Turn 90 degrees 4 times. Does the robot end up where it started?
    Try to make the robot move in a square (not too large) How accurate is it?
    Try to increase the accuracy of your square!
f. Make a function leg(n,a) that makes the robot move n centimeters, and turn a degrees.
   Use this to try to draw a triangle, and a square. 



Comments