Hardware‎ > ‎The Critterbot Robot‎ > ‎



Critterdriver has 4 threads:

1. Main loop:
    while (true) {
        const CritterControlDrop* lastAction = actionBuffer.getLastAction();
        if (lastAction) {
            bool actionSend = serialLink.sendActionIfPossible(*lastAction);
            if (!actionSend)
                std::cerr << "Warning: action skipped" << std::endl;
        CritterStateDrop* stateDrop = serialLink.readStateDrop();
        if (!stateDrop)

2. Listening to connected clients (code in C++ but java-like syntax here):
    while (true) {
        for (Client client: clients) {
            if (client.hasDataAvailable()) {
                CritterControlDrop action = client.receiveControlDrop();

3. Writing on the serial port when the main loop asks for it
4. Accepting new clients


Main loop (run every 10ms):
  • event UART: communication on the serial port (between Walter and the ARM). First, read the information sent by Walter, then write the current observation to Walter)
  • event SSC: manage the SSC bus
  • event SPI: manage the SPI bus
  • event LED drive: high level control of the LED (for instance: compute the colors to display the current charge)
  • event LED control: low level control of the LED. Use the SSC bus.
  • event accelerometer: receive the information from the accelerometer. Use the SPI bus.
  • event boot: allow to reflash the ARM. Use the serial port (via event UI).
  • event error: error monitoring on the ARM
  • event motor: communication with the AVRs (motors and power). Send a command at each time steps (10ms) and receive the current status of the AVRs. Use the SPI bus.
  • event ADC: driver for the internal ADC of the ARM. Receive the information from the magnetometer.
  • event ADC-SPI: driver for the external ADCs. Use the SPI bus. Receive information from the gyroscope, the IR sensors, the light sensors and the beacon sensors (IR light)
  • event thermo: driver controlling the bus TWI. Receive the information from the thermal sensors.
  • event UI: user interface driver. Handle the communication when the ARM and Walter are using user interface mode (as opposed to machine mode)
  • event recharge: high level control of the robot to direct it to the docking station when batteries are low (is it enabled?)
  • event monitor: high level monitoring of the robot: disable motor command if their temperature are too high