Fix compass heading direction, add magnetic declination and heading offset
- Fix atan2 sign bug: atan2(-yHeading, xHeading) per Freescale AN4248 eq.22. The previous atan2(yHeading, xHeading) produced counter-clockwise angles, causing East/West to be swapped relative to compass convention. - Add imuSetMagneticDeclination() (T:146, field "decl") to correct the offset between magnetic north and true north (iPhone shows true north). Value is persisted in imuConfig.json across reboots. - Add imuSetHeadingOffset() (T:147, field "off") to compensate for sensor mounting orientation on the rover. Also persisted. - Persist decl and hOff in imuConfig.json (version 2, backwards compatible). - Fix calibration feedback for web interface: T:126 now includes calDone=1 (success) or calDone=0 (fail) once after calibration completes, plus decl and hOff fields. Calibration start message explains polling procedure. - Remove duplicate #include <nvs_flash.h> and unused Adafruit ICM20948 includes that caused build failures when libraries were not installed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
6f1391d1e9
commit
9b0a5a9926
+15
-7
@@ -112,12 +112,20 @@
|
||||
// set the echo mode of recving new cmd.
|
||||
// 0: [default]off
|
||||
// 1: on
|
||||
// {"T":143,"cmd":0}
|
||||
#define CMD_UART_ECHO_MODE 143
|
||||
|
||||
// start magnetometer calibration and save to flash after rotation
|
||||
// {"T":145}
|
||||
#define CMD_CALI_MAG_START 145
|
||||
// {"T":143,"cmd":0}
|
||||
#define CMD_UART_ECHO_MODE 143
|
||||
|
||||
// start magnetometer calibration and save to flash after rotation
|
||||
// {"T":145}
|
||||
#define CMD_CALI_MAG_START 145
|
||||
|
||||
// set magnetic declination in degrees (find at magnetic-declination.com)
|
||||
// {"T":146,"decl":4.5}
|
||||
#define CMD_SET_MAG_DECLINATION 146
|
||||
|
||||
// set fixed heading offset in degrees (compensates sensor mounting angle)
|
||||
// {"T":147,"off":90.0}
|
||||
#define CMD_SET_HEADING_OFFSET 147
|
||||
|
||||
|
||||
|
||||
@@ -576,4 +584,4 @@
|
||||
// === === === mainType & moduleType settings. === === ===
|
||||
// {"T":900,"main":1,"module":0}
|
||||
// main_type: 1-WAVE ROVER, 2-UGV02, 3-UGV01
|
||||
#define CMD_MM_TYPE_SET 900
|
||||
#define CMD_MM_TYPE_SET 900
|
||||
|
||||
Reference in New Issue
Block a user