We have currently hard-coded certain parameters in the ESP32 code. For example:
The magnetometer scaling factors and offsets are hard-coded
The assignment of the tuning knobs is fixed (e.g., VRB, VRC, VRD are currently the attitude control gains, but later we will need to ressign them to other parameters)
and there might be other such hard-coded values. It would be better to be able to configure them from the Pi.
Proposed solution
The Pi will send via the Serial an initialisation sequence. In particular, it will send out the message in JSON format
{"command": "initialisation"}
in a while loop until the ESP32 reads it and acknowledges it by replying
{"status": "initialisation"}
Then, the Raspberry Pi will send to the ESP one the following messages
Proceed
if the ESP should just proceed with the default parameters, the following command should be issued
{"command": "proceed"}
The ESP should then acknowledge this by sending back the message
{"status": "proceeding"}
Calibrate
The Pi can send the command to the ESP for it to calibrate the magnetometer
{"command": "calibrate" }
The ESP will then acknowledge the message by saying {"status": "calibrating"} and once it has calibrated the magnetometer it will say {"status": "calibration complete"}.
Set gains
The following command can be sent to set certain (fixed) values to any of the controller gains or other parameters
The ESP32 will acknowledge the receipt of the command with {"status": "assigning trimmers"} and then {"status": "trimmers assigned"} (perhaps with additional information on the exact assignment).
Completion of initialisation sequence
The initialisation sequence ends when the Pi sends {"command": "proceed"} (see above).
The issue
We have currently hard-coded certain parameters in the ESP32 code. For example:
and there might be other such hard-coded values. It would be better to be able to configure them from the Pi.
Proposed solution
The Pi will send via the Serial an initialisation sequence. In particular, it will send out the message in JSON format
in a while loop until the ESP32 reads it and acknowledges it by replying
Then, the Raspberry Pi will send to the ESP one the following messages
Proceed
if the ESP should just proceed with the default parameters, the following command should be issued
The ESP should then acknowledge this by sending back the message
Calibrate
The Pi can send the command to the ESP for it to calibrate the magnetometer
The ESP will then acknowledge the message by saying
{"status": "calibrating"}
and once it has calibrated the magnetometer it will say{"status": "calibration complete"}
.Set gains
The following command can be sent to set certain (fixed) values to any of the controller gains or other parameters
Again, the ESP will acknowledge the receipt of the command with
{"status": "setting gains"}
andArming
When the ESP is ready to arm, it should return the message:
before it arms, it should inform the Pi by sayin
and when it arms, it should say
Assignment of trimmers
The Raspberry can assign the trimmers to any of the parameters of the ESP32. For example, this can look like this:
The ESP32 will acknowledge the receipt of the command with
{"status": "assigning trimmers"}
and then{"status": "trimmers assigned"}
(perhaps with additional information on the exact assignment).Completion of initialisation sequence
The initialisation sequence ends when the Pi sends
{"command": "proceed"}
(see above).Let me hear your thoughts on this.