Update V1 – Camera Overhaul , Bug Fixes and More!


Note: we’ve released a second update to fix a problem with the camera caused by the first update. Have a look at it here

Our team has been working diligently to push an update to the brain box. It contains the much-needed camera and stability improvements. Huge thanks to the entire RoboCon team for testing the update. Special mentions to Josh for writing the patch and Brendan for working on calibration.

Updating The Brainbox

1) Download the update file
2) Turn on the brain box
3) Upload the update file to the brain box via the web interface (the same way you upload your code)
4) Go to the Run page to check that the update uploaded successfully
5) Turn off the brain box
6) Turn on the brain box
7) Go to the Run page to check that the update completed successfully (you may have to scroll down to see the output) 
– if you get any message apart from "upload complete", record _the entire log_ and 
send it to us (take pictures with your phone if you have to)
and send it to us (take pictures with your phone if you have to)

Changelog v1

This is a list of the changes that have been made to the software running on the brain box . The update to version 1 is currently optional, but will be required in order to participate in the competition.

General
-------

- Changed robot behaviour when the round ends.

When the round ends, any attached motors will be turned off, and the
GPIO pins will all be configured as inputs. In addition, all servos
attached to the PWM outputs will be set to 0%, so you should make sure
that this is a safe position for your servos to be in.

If your code depends on the servos being in a particular position when
the start button is pressed, you will need to use the extended
initialisation pattern described in the documentation::

r = Robot.setup()
r.init()

# Here you can move the servos to the correct position.
# For example:
r.servos[0] = 42

# Then you must call this before you do anything else:
r.wait_start()

- Fixed the physical start button.

Previously, the start button was nonfunctional. It now starts the
robot in competition mode, meaning that the round will be stopped
after three minutes. The web interface can still be used, and is the
recommended method for developing and testing code.

- Added mitigation for hardware bug related to PWM/servo outputs.

As detailed in a recent blog post, there is an issue with the PWM
outputs on the brain box (used to control servos) that causes them to
be driven past 100% when the brain box boots; this means that any
attached servos will be driven into their physical stops when the
brain box is turned on, which could lead to damage if left in this
state. This update includes a mitigation for this issue: all attached
servos will unfortunately still be driven past 100% when the brain box
receives power, but as soon as the Raspberry Pi boots, they will be
set to 100% only.

Shepherd
--------

Shepherd is the web interface for the brain box, visible in a web
browser at robot.sr.

- Corrected several issues to do with uploading and running code.

We've had several reports of strange behaviour when uploading code
after other code has been run, including random code crashes and a
lack of visible output. These bugs should now be fixed.

- Fixed code upload via zip file.

- Added the last image taken by the camera to the web interface.

The last image from the camera is now displayed on the run page, to
help you determine what your robot can see. It is updated each time
your code calls `sr.robot.Robot().see`.

- Increased output refresh rate.

Your code's output will now be refreshed once every second.

- Simplified and reorganised the run page.

The development/competition mode selection now determines whether the
round will automatically end or not (there is no separate setting any
more).

- Corrected various incorrect and misleading error messages.

sr.robot
--------

sr.robot is the Python library you use to control the robot.

- Improved camera performance and accuracy.

The camera now uses its video port when `sr.robot.Robot().see` is
called, which is significantly faster than taking a still image, and
several steps have been removed from the image processing pipeline.
The focal lengths used to calculate the size of markers have also been
recalibrated, which should improve the accuracy of measurements
returned by the vision code.

- Added `save` argument to `sr.robot.Robot().see`.

This controls whether the image from the camera is written to the
filesystem. It is enabled by default, but can be disabled to provide a
small performance boost. Note that disabling it will prevent the image
on the run page on the web interface from being updated.

- Added functionality to save logs to attached USB stick.

If a USB stick is plugged in before the robot boots, the logs will be
saved to a file called `logs.txt`. This is primarily intended for use
in the competition, where you will not be able to interact with your
robot via the web interface.

- Added support for saving images from the camera to attached USB stick.

To enable this, create a file called `collect_images.txt` at the root
of the USB stick. Images will be saved even if the `save` argument to
`sr.robot.Robot().see` is false. The USB stick must be plugged in
before the brain box receives power.

- Added support for logging visible markers to attached USB stick.

To enable this, create a file called `log_markers.txt` at the root of
the USB stick. Each time `sr.robot.Robot().see` is called, a new file
will be created on the USB stick, containing details of each marker
that's visible, including the code, distance, and polar coordinates of
the marker (`rot_x` and `rot_y`). The USB stick must be plugged in
before the brain box receives power.

- Made access to non-existent ThunderBorgs raise an error.

- Removed various debugging statements and corrected an error message.

You will no longer see error messages about missing ThunderBorgs, and
debugging messages that were printed when interacting with the motors
have been removed. In addition, the error displayed when GPIO pin 3 is
configured as an analog input has been changed to refer to the correct
pin.