Communication Protocol: Mission Control to and from Jetson

Protocol Overview
The "base station" refers to any computer that is running our Mission Control software []. This software runs a standard TCP server which the rover connects to. The rover automatically chooses which IP address to connect to based on the SSH_CLIENT environment variable. That is, it is assumed that whichever computer was used to SSH into the Jetson is also the base station.

Once the TCP socket is connected, the packet format is a four-byte header followed by a variable-length body. The header is a four-byte little-endian integer specifying the length of the body (in bytes). The body is a JSON object (a string encoded in UTF-8, I think?). The Mission Control side of the implementation is here [] and the rover side is here [].

As of this writing, this protocol is implemented only for the base-station-to-rover direction. We sometimes send JSON packets the other direction (from the rover to the base station) but this doesn't use the length headers, is probably super buggy, and isn't yet used for anything in Mission Control.

Mission Control to Rover JSON Message Formats
The base-station-to-rover JSON objects are formatted as follows. There is always a "type" field which indicates what the other fields of the object should be.

Engage the e-stop:

Drive clockwise in a wide-radius circle (must re-send at least once per second, or the rover will time out and stop moving): The numbers must be within the bounds [-1, 1].

Turn arm base clockwise using PWM control: The target must be in the range [-1, 1]. The motor names are listed here: [] but this has only been tested with the arm motors. (The science station interface is not implemented and I don't know what will happen if you try to use "motor_broadcast".)

Turn arm base clockwise using PID control: DO NOT USE THIS unless you've verified that the that motor joint has a working encoder and calibrated PID coefficients. Otherwise the motor might go crazy and damage things (or damage you). You must re-send the message at least once per 300ms or the arm will time out and stop moving.

Move the hand forward in the X direction with respect to the rover base [NOT IMPLEMENTED YET]: The X axis is the one that the rover follows when it drives straight forward. The Y axis points out to the left (when facing the X axis) and the Z axis points straight up.

Toggle autonomous navigation mode: