The robot is controlled by a C program running in offline mode on the TX. It uses a 10ms cycle to:
read the I2C gyro and accelerometer sensors (it’s reading 6 bytes, and takes a couple miliseconds),
calculate the Kalman filter for the angle and gyro bias,
read the counter inputs, subtract them, and deal with counter overruns,
apply a Kalman filter to the counter values in order to get decent position and speed values,
read the remote control inputs and calculate how the robot is to be driven/steered,
calculate the PWM drive for the motors using the PID function
and do some housekeeping, such a putting some data on the TX display and send more data over bluetooth to a PC that monitors the robot.
Each of the above steps use 200-300 microsecond (some more, some less) of a ‘ProgTic’ call, so it all easily fits into a 10ms cycle.
The robot functions stand-alone, but can connect to an application running on a PC and send real-time data to the PC. The PC can also tell the robot to change the PID variables which was very useful for the manual tuning of the PID constants.