Wifi Connection: First, connect to the WiFi router that we've set up specifically for communicating with the robots:
If you're using our Microsoft Surface laptops, they should connect automatically to the router. But make sure:
The router's SSID (signal name) is StuyRobots and its password is the same: StuyRobots.
On the Surface laptops, there is an icon on the bottom right that indicates which network connections are available, and which one you're connected to.
Once connected to StuyRobots, you won't be connected to the internet(!) So don't expect to use that laptop to find answers to your questions.
Connect to your robot: Then, use a browser (whichever's available on the laptop) to connect to your robot only!
The robots have names that look like "robot-204" and "robot-210" -- these numbers range from 201 to 210 (and possibly larger).
Let's say that your robot is "robot-205". In a browser, connect to the following address: "http://192.168.1.205". You should see this:
Use the large right-hand icon ">_" to connect to a terminal inside the robot, and the left-hand icon to bring up a GUI (if it works). You may noodle-around in the GUI, but you may make changes only in your own team directory. Note that the robot's username is: pi and the password is: robots1234.
The laptops also should have the VNC program on them. If you launch that program, and it asks you for a connection address (and your robot is "robot-205", say), use 192.168.1.205:1. Remember that trailing ":1" in the address. With VNC, you can use IDLE -- you'll find it when clicking on the Programming Menu on the upper-left.
Creating a directory for your team:
This is a one-time process. Connect to the directory: cd ~/Desktop/GoPiGo/Software/Python then make sure that you are there (use pwd)
Get the list of files/directories: ls -l and make sure that there is already a directory called Stuy
If not, create it using mkdir Stuy
Connect to the Stuy directory (and, as always, make sure that you're there using pwd), and check to see if your team directory is there. Your team's directory name is composed of your teacher's name (either skons for Mr. Konstantinovich, or pbrooks for Mr. Brooks), the year and your class period. So if you're in Mr. Brooks's 9th period class, your team's directory name would be pbrooks-2017-per9. Create your team's directory if it's not there.
Connecting to the Python directory and to your team's directory:
via Terminal: cd ~/Desktop/GoPiGo/Software/Python and then cd Stuy/pbrooks-2017-per9
via IDLE:
import os
os.chdir('/home/pi/Desktop/GoPiGo/Software/Python') and then os.chdir('Stuy/pbrooks-2017-per9')
check where you're connected using os.getcwd()
Testing the robot's Python functions:
Dexter Industries' Python Function page: https://www.dexterindustries.com/GoPiGo/programming/python-programming-for-the-raspberry-pi-gopigo/
fwd() | run the wheel motors forward |
stop() | stops the wheel motors |
enable_com_timeout(timeout-time) | Turn off robot's motors if no communication within timeout-time. timeout-time is in milliseconds enable_com_timeout(1500) will turn off the motors if you don't communicate with the robot within 1.5 seconds returns 1 on success, -1 on failure |
volt() | returns the voltage seen by the robot (12 volts with fresh batteries, lower after usage) |
bwd() | run the wheel motors backward |
left() | turn left |
right() | turn right |
set_speed(the_speed) | set wheel speeds (range: 0 - 255) |
set_left_speed(left_speed) | set left wheel speed (range: 0 - 255) |
set_right_speed(right_speed) | set right whell speed (range: 0 - 255) |
increase_speed() | increase speed by 10 |
decrease_speed() | decrease speed by 0 |
enable_encoders() | (enabled by default): the wheel encoders will be counting rotational steps (18 steps per complete revolution) |
enc_read(motor) | reads the current encoder number (how many steps the encoder has gone) since the last enc_tgt() (see below). Motor number is either 0 or 1. |
enc_tgt(motor1,motor2,target) | Move robot until one of the motors has turned a "target" number of
encoder steps (there are 18 steps per complete rotation). If m1==1 then motor1 will step after "target" number of steps. If m1==0, then motor1 will not be stopped by this command. The same with motor2. I think motor1 is the left motor, but you'll have to figure that out. The encoders for both motors will be set to 0. |
us_dist(15) | return the distance (in centimeters) from the ultrasonic sensors to the obstacle in front of it |
enabled_servo() | enables the servo (the rotatable platform that the ultrasonic sensor is on). |
servo(angle) | rotate the servo to the desired angle (range: 0 - 180). Suggestion from the manual: "This function moves the servo to the position that is given. You will have to manually add a very small delay when trying to do a servo sweep or when moving the servo because the servo moves much slower than the code so you will have to account for the delay." |
trim_write(amount) | Automatically drives one motor slightly faster than the other to
compensate for physical differences between the motors (otherwise the
robot will go slightly to the right or left). -100 <= amount <=
100. Set the trim through trial-and-error. Details from the manual:
|