Commit Graph
38 Commits
Author SHA1 Message Date
Peter BarkerandClaude Opus 5 4ea77b7b2d AP_Compass: move the compass field simulation into the SITL library
AP_Compass_SITL held the compass sensor model -- the noise, the delay
buffer, the elliptical correction and the failure injection -- inline.
Move it to SITL::CompassSim so it sits alongside the rest of the sensor
simulation and beside the transformation it shares with
get_mag_offsets().

The consumer owns its own instance, so sampling stays where it was and
the 100Hz rate at which the sensor is simulated is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 09:29:27 +10:00
Peter BarkerandClaude Opus 5 fa2d3391b4 AP_Compass: share the compass sensor transformation
AP_Compass_SITL applied the orientations, board trim and scale factor to
the field inline.  Move it into SITL::SIM so that the several things
which want these numbers can share one copy, and add get_mag_offsets()
alongside it: SIM_MAGn_OFS is subtracted from the field before that
transformation is applied, so the offset a perfectly-calibrated compass
would end up with is the same transformation applied to SIM_MAGn_OFS.

That depends only on parameters, so it costs nothing to evaluate on
demand -- no field, noise or delay-buffer work is involved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 09:29:27 +10:00
Peter BarkerandClaude Opus 4.8 5b66034e0c AP_Compass: rotate the simulated compass by SIM_BRD_TRIM
Keep the compass consistent with the IMU under a board mounting offset; rotating only the IMU leaves a spurious yaw estimate error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 09:48:11 +10:00
Peter Barker 1bd05a9ea3 AP_Compass: provide base class implementation for AP_Compass_Backend::read
... and use it for those that are currently identical
2026-03-17 13:06:50 +13:00
Peter Barker dabcf0e91c AP_Compass: make compass instance number part of AP_Compass_Backend
rather than each backend storing this itself.

This allows many methods to assume that they are working on the current instance number rather than being passed the instance number

registering the compass via the compass backend method now infers setting the device ID
2025-10-14 14:48:58 +11:00
Peter Barker a657744a2f AP_Compass: rework SITL backend to be a single-instance
rather than this odd thing which acts as multiple backends
2025-10-08 13:23:49 +11:00
Andrew Tridgell aaeee2e7dc AP_Compass: implement SIM_MAG_SAVE_IDS 2023-10-31 10:14:42 +11:00
Mykhailo Kuznietsov 633bb159bf AP_Compass: Fix some typos
Fixed some typos found in the code.
2023-10-12 18:30:42 +11:00
Peter Barker 3adbaddab0 AP_Compass: regularise compass defines
start to make compass backends look like backends from our other libraries
2022-11-15 16:44:38 +11:00
Iampete1 209ad965be AP_Compass: remove custom rotations 2022-03-02 18:16:42 +11:00
Peter Barker ed608d37f6 AP_Compass: add and use AP_SIM_COMPASS_ENABLED 2022-01-17 15:24:02 +11:00
Andrew Tridgell 8eb40bafc5 AP_Compass: revert compass parameter changes 2021-12-04 16:51:53 +11:00
Iampete1 2fa2e70e7e AP_Compass: SITL: use new scale param 2021-11-30 08:14:43 +09:00
Peter Barker 9791fdeb11 AP_Compass: remove unused setup_earth_field 2021-06-15 09:47:31 +10:00
Andrew Tridgell 8920362212 AP_Compass: default SITL compass to having scale factor set 2020-09-20 09:25:57 +10:00
Andrew Tridgell c2feebea13 AP_Compass: allow simulation of compass sensor failure 2020-09-08 11:01:14 +10:00
Peter Barker 0f2bcea647 AP_Compass: remove use of Vector3 as function 2020-06-16 11:06:47 +10:00
bugobliterator c914a91be9 AP_Compass: add support for per mag calibration 2020-06-05 09:38:40 +10:00
Andy Piper f5320e8816 AP_Compass: make sure SITL rotation gets initialized like all the others
don't remove a custom rotation that has already been set
2020-05-21 16:28:27 +10:00
Mark Whitehorn 570aa929ca AP_Compass: handle ROTATION_CUSTOM in SITL 2020-04-28 10:57:26 +10:00
Siddharth Purohit 8d227d401a AP_Compass: modify compass driver to support consistent ordering and hotplugging 2020-02-19 13:59:53 +09:00
Andrew Tridgell 6fd0ca36aa AP_Compass: added estimation of compass scale factor
this adds new COMPASS_SCALE, COMPASS_SCALE2 and COMPASS_SCALE3
parameters, which give the sensor scaling factor. It is used to
compensate for an incorrect scaling in a compass.

The 3D compass calibration process will set the correct value
automatically, otherwise users can set the value to a known value for
an existing compass
2019-12-03 20:48:23 +11:00
Andrew Tridgell 71ad90819e AP_Compass: don't reset SITL compass offsets if set by user
makes for easier EKF compass bias learning testing
2019-09-11 14:22:18 +10:00
Andrew Tridgell 9e7929adf6 AP_Compass: removed unusued AP_Common/Semaphore.h 2019-05-15 15:33:48 +10:00
Andrew Tridgell 55e4b64755 AP_Compass: don't apply offsets twice in SITL 2018-10-19 16:03:45 +11:00
Andrew Tridgell 83065d5e88 AP_Compass: convert SITL to new accumulate approach 2018-10-17 12:54:22 +11:00
Andrew Tridgell a260792e9e AP_Compass: use WITH_SEMAPHORE()
and removed usage of hal.util->new_semaphore()
2018-10-17 12:54:22 +11:00
Lucas De Marchi de535dc573 AP_Compass: remove unused external and name arguments
Aka "fix copy and pasta".
2018-09-06 08:23:02 +10:00
Lucas De Marchi 4039b51810 AP_Compass: stop passing frontend pointer
Let AP_Compass_Backend call AP::compass() *once* instead of passing
the frontend pointer over and over.
2018-09-06 08:23:02 +10:00
Andrew Tridgell cbd6f4cc21 AP_Compass: fixed compass for tailsitters in SITL 2018-07-20 14:21:06 +10:00
Andrew Tridgell b4c7d1925e AP_Compass: allow for runtime changes to SIM_MAG_DIA_?
this makes for easier testing
2018-07-18 16:07:19 +10:00
Andrew Tridgell 4acc06df87 AP_Compass: support diagonal, off-diagonal and rotation in SITL
compass
2018-07-18 16:07:19 +10:00
Andrew Tridgell 7ec6522b9d AP_Compass: default to right mag offsets for SITL 2018-07-13 10:19:01 +10:00
Andrew Tridgell 2fe2c8fbda AP_Compass: initialise compass IDs saved in SITL
this ensures we don't get uncalibrates compasses in SITL
2018-07-13 10:19:01 +10:00
Andrew Tridgell 823c4523b3 AP_Compass: added SITL device IDs 2018-07-13 10:19:01 +10:00
Patrick José Pereira e456655932 AP_Compass: Use SITL singleton
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2018-06-26 00:02:01 +01:00
Michael du Breuil fb77d0739e AP_Compass: Remove unused time calls, stash the time in the read loop 2017-09-07 19:53:14 +01:00
Miguel Arroyo ee328c9683 AP_Compass: move SITL Compass to standard sensor backend model 2017-06-29 09:22:08 +10:00