5.3 Error correction

Where does the error correction code fit?

First of all, the error correction code should not execute any more frequently than the length values update. Otherwise, the logic will still be glaring at the same values, making the same correction. As a result, the error correction can be either coupled with the ADC-to-length conversion logic, or in a thread that gets triggered by the ADC-to-length conversion logic.

Note that there are different kinds of error correction code that should become active at different times. As a result, each kind of error correction code must be guarded by appropriate conditions:

This means that the program must somehow keep track of the state of the robot in addition to the DiffSteer structure.

Note that the frequency of error correction should also match the physical capabilities of the robot. For example, if a skew correction motion cannot complete in 100ms, it doesn’t make any sense to check for error again before 100ms. The amount of time to perform a correctional action should be predictable because all the coefficients are known.

As a result, it is best to make slight corrections more often than to make lengthy/big corrections less frequently. If a correction can complete in 40ms to 100ms, it should be okay.

Note that the amount of correction should depend on the severity of the error. This is why it is useful to convert ADC values to distance units.