Spot Dog PROGRAMMING
This tutorial will guide you through starting up spot, using SPOT, and how to program SPOT using Python. Python is the backbone of this tutorial; it is best to prepare for this workshop by researching functions and classes prior to this tutorial.
Step 1: Prepare your working Directory
Go to this GitHub repo, click the green <> Code button, and then click "Download ZIP". Note that this repository will change with new updates and features, so it is best to either use Github Desktop to get the most recent updates, or manually check before using SPOT.
Once downloaded, unzip the ZIP file and note where you have it saved.
Step 2: open vs code & install requirements
To control SPOT, Boston Dynamics wrote a SDK which we use in our demonstrations. It is imperative that you not only download all requirements Boston Dynamics includes, but also what we include. To do this:
Open VS Code, and open the SPOT-Workshop folder that you downloaded from the GitHub repo.
Open a new Terminal, and check that Python is installed
python3 --version
and that pip is installed
pip --version
If either throws an error, make sure to install them with the links provided above.
With Python and pip installed, type the following commands
pip install -r requirements.txt
python3 -m pip install bosdyn-client==3.3.2 bosdyn-mission==3.3.2 bosdyn-choreography-client==3.3.2
If these throw errors, let one of the staff members know!
Step 3: Understanding the files
spot_helper.py functions
stand()
Makes SPOT stand
No parameters
sit()
Makes SPOT sit
No parameters
move_direction()
Moves SPOT in a certain direction for a certain amount of time
Parameters: direction, duration [seconds] (ignore self!)
example: ("left", 2)
rotate()
Rotates SPOT in a certain direction for a certain amount of time
Parameters: direction, duration [seconds] (ignore self!)
example: ("right", 3)
turn_body_pitch_yaw()
Turns SPOT in pitch and yaw direction
Parameters: pitch, yaw (ignore self)
code_here.py functions
listen_for_enter()
ESTOP is the override function to STOP SPOT whenever you need to
If you ever need to STOP SPOT, press enter when your code is running
main()
Main function where things are initialized and powered on
Where you will be writing your own code in the next step
STEP 4: WRITING YOUR OWN CODE
There are a few important things before you write in your file.
Make sure to call the controller object before each function
example:
controller.function()
Use time.sleep(#) in between each controller.function() line you write (this allows for SPOT to not die)
example:
controller.stand()
time.sleep(4)
controller.sit()
Always save your file!
Now you can code!
Add all of your desired functions and movements in between the
#ENTER SPOT ACTIONS HERE
(type here!)
#SPOT ACTIONS END HERE
EXAMPLE PROGRAM
controller.stand()
time.sleep(4)
controller.sit()
time.sleep(4)
controller.move_direction("forward", 1)
time.sleep(1.5)
controller.rotate("left",2)
time.sleep(2.5)
controller.move_direction("backward", 1)
time.sleep(1.5)
controller.turn_body_pitch_yaw(0.5, 0.5)
time.sleep(4)
NOW YOU CAN TEST/RUN YOUR CODE!
Connect to SPOT's WiFi
spot-BD-03420010
Make sure that SPOT is turned on (blue and red buttons are lit)
Ping SPOT in your terminal
ping 192.168.80.3
If you receive a message along the lines of "bytes returned" you have successfully connected to SPOT.
To get out of this menu, enter control C
In that same terminal. type
python3 code_here.py
or python code_here.py
Enter the username and password
username: workshop
password: SpotWorkshop
Watch SPOT do his thing!