PiFi – Getting code onto the robot

Back to docs

Description

Once you’ve written some code, you’ll want a way you can transfer it to

your robot so that you can run it. This is done via a WiFi connection to
the Raspberry Pi.

Connecting to your robot

Once you turn your robot on, it will boot up, and after a short amount
of time it will create a WiFi network, called robocon-TEAMXX, where XX
is a number specific to your team. Once this network is available, you
can connect to it in the same way you connect to any other WiFi network;
the password will have been provided to your team with the kit.

Uploading code to your robot

Once you’ve connected to your robot’s WiFi access point, visit
http://robot.sr in a web browser to access the robot management
interface.

This interface allows you to upload code to the robot, start and stop
the code, and view your code’s output. To access the code upload
facility, click the “upload” link on the homepage at http://robot.sr.

The way you upload code to your robot depends on whether you’re using
multiple files to split your code up. If your code is all in one file, you
can upload it to the robot as-is — the robot will automatically detect
that it’s a Python file and handle it without any extra effort.

If you’ve split your code up into multiple files, you’ll need to create
a zip file containing your code (there are many free utilities to create
zip files available online). The robot will look for a file called
main.py in the zip archive to run; if it can’t find one, you’ll get an
error message. If this happens, make sure that you’ve put your code into
the root of the zip archive, not within a folder.

Once you’ve uploaded some code, you’ll get a success message, and you’re
ready to run your code!

Running code on your robot

To start and stop your robot, visit http://robot.sr in a web browser
and click the “run” link. You’ll see a screen with the robot’s current
status; if the robot is ready to run, there will be some configuration
options visible, and a large “Start” button.

Once you’re ready to start the robot (you’ve uploaded your code and set
up the configuration options), press “Start”, and you’ll see various
information about your robot, including the time until the end of the
round, the configuration you chose when you pressed Start, and — most
importantly — anything your code has output (for example via using
print).

If you want to stop the robot early, press the big “Stop” button. You
may need to reload the page once the robot has stopped in order to
update the webpage with the robot’s final output.

Last Updated On November 24, 2017