Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ladislas/feature/ahrs fusion #1245

Merged
merged 3 commits into from
Feb 7, 2023
Merged

Conversation

ladislas
Copy link
Member

  • ♻️ (CoreIMU): Return g intead of mg
  • ✨ (spikes): Add spike imu_kit_fusion

@ladislas ladislas self-assigned this Jan 10, 2023
@ladislas ladislas requested a review from HPezz January 10, 2023 16:49
@ladislas ladislas added the 01 - type: task Something to do label Jan 10, 2023
@ladislas ladislas added this to the v1.4.0 milestone Jan 10, 2023
@github-actions
Copy link

github-actions bot commented Jan 10, 2023

File comparision analysis report

🔖 Info

  • base: develop / 533502c + mbed-os@master+fixes+gcc-11-support + -std=c++20
  • head: ladislas/feature/ahrs-fusion / 574ee02 + mbed-os@master+fixes+gcc-11-support + -std=c++20
  • toolchain: GNU Arm Embedded Toolchain 10.3-2021.10 - 10.3.1 20210824
  • enable_log_debug: ON
Target Flash Used (base/head) Fash Used Δ Flash Available (base/head) Static RAM (base/head) Static RAM Δ
bootloader 183068 (69%) ø 79076 (30%)
79076 (30%)
41664 (7%) ø
os 500620 (31%) ø 1064052 (68%)
1064052 (68%)
94976 (18%) ø
Click to show memory sections
| -          |      Hex |     Bytes |  KiB |
|------------|---------:|----------:|-----:|
| Flash      | 0x200000 | 2 097 152 | 2048 |
| SRAM       |  0x80000 |   524 288 |  512 |
| Bootloader |  0x40000 |   262 144 |  256 |
| Header     |   0x1000 |     4 096 |    4 |
| OS         | 0x17E000 | 1 564 672 | 1528 |
| Tail       |   0x1000 |     4 096 |    4 |
| Scratch    |  0x40000 |   262 144 |  256 |

📝 Summary

Click to show summary
  • ✔️ - existing target
  • ✨ - new target
  • ⚰️ - deleted target
  • ✅ - files are the same
  • ❌ - files are different
Target Status .bin .map Total Flash (base/head) Total Flash Δ Static RAM (base/head) Static RAM Δ
LekaOS ✔️ 500620 (23%) ø 94976 (18%) ø
bootloader ✔️ 183068 (8%) ø 41664 (7%) ø
functional_ut_boost_ut ✔️ 409276 (19%) ø 30608 (5%) ø
functional_ut_core_imu ✔️ 385076 (18%) ø 31120 (5%) ø
functional_ut_deep_sleep_core_buffered_serial ✔️ 368332 (17%) ø 30560 (5%) ø
functional_ut_deep_sleep_core_motor ✔️ 376140 (17%) ø 30632 (5%) ø
functional_ut_deep_sleep_core_pwm ✔️ 378356 (18%) ø 30632 (5%) ø
functional_ut_deep_sleep_log_kit ✔️ 365268 (17%) ø 30976 (5%) ø
functional_ut_deep_sleep_mbed_hal ✔️ 366712 (17%) ø 30560 (5%) ø
functional_ut_file_manager ✔️ 386812 (18%) ø 30856 (5%) ø
functional_ut_firmware_kit ✔️ 378420 (18%) ø 30840 (5%) ø
functional_ut_imu_kit ✔️ 380704 (18%) ø 31120 (5%) ø
functional_ut_io_expander ✔️ 371176 (17%) ø 30576 (5%) ø
functional_ut_qdac ✔️ 372344 (17%) ø 30576 (5%) ø
spike_lk_accel_gyro ⚰️ - - - - - -
spike_lk_audio ✔️ 137172 (6%) ø 25176 (4%) ø
spike_lk_behavior_kit ✔️ 198012 (9%) ø 58680 (11%) ø
spike_lk_ble ✔️ 237980 (11%) ø 39416 (7%) ø
spike_lk_bluetooth ✔️ 92364 (4%) ø 22224 (4%) ø
spike_lk_cg_animations ✔️ 153672 (7%) ø 57224 (10%) ø
spike_lk_color_kit ✔️ 88544 (4%) ø 24376 (4%) ø
spike_lk_command_kit ✔️ 223140 (10%) ø 63832 (12%) ø
spike_lk_config_kit ✔️ 139228 (6%) ø 25192 (4%) ø
spike_lk_coreled ✔️ 88108 (4%) ø 24264 (4%) ø
spike_lk_core_touch_sensor ✔️ 93164 (4%) ø 22824 (4%) ø
spike_lk_event_queue ✔️ 84152 (4%) ø 22904 (4%) ø
spike_lk_file_manager_kit ✔️ 154432 (7%) ø 25520 (4%) ø
spike_lk_file_reception ✔️ 339964 (16%) ø 38448 (7%) ø
spike_lk_flash_memory ✔️ 86776 (4%) ø 22216 (4%) ø
spike_lk_fs ✔️ 174964 (8%) ø 48016 (9%) ø
spike_lk_imu_kit ✔️ 100944 (4%) ø 23592 (4%) ø
spike_lk_lcd ✔️ 173004 (8%) ø 57520 (10%) ø
spike_lk_led_kit ✔️ 115204 (5%) ø 25104 (4%) ø
spike_lk_log_kit ✔️ 84776 (4%) ø 23408 (4%) ø
spike_lk_motion_kit ✔️ 110736 (5%) ø 25824 (4%) ø
spike_lk_motors ✔️ 86336 (4%) ø 22248 (4%) ø
spike_lk_qdac ✔️ 91796 (4%) ø 22768 (4%) ø
spike_lk_reinforcer ✔️ 218660 (10%) ø 60512 (11%) ø
spike_lk_rfid ✔️ 84216 (4%) ø 22184 (4%) ø
spike_lk_sensors_battery ✔️ 87376 (4%) ø 23312 (4%) ø
spike_lk_sensors_imu_lsm6dsox - - 98480 (4%) - 23520 (4%) -
spike_lk_sensors_imu_lsm6dsox_fusion_calibration - - 104936 (5%) - 23096 (4%) -
spike_lk_sensors_light ✔️ 84072 (4%) ø 22216 (4%) ø
spike_lk_sensors_microphone ✔️ 84824 (4%) ø 22216 (4%) ø
spike_lk_sensors_temperature_humidity ✔️ 90616 (4%) ø 22192 (4%) ø
spike_lk_serial_number ✔️ 145028 (6%) ø 25256 (4%) ø
spike_lk_ticker_timeout ✔️ 82712 (3%) ø 22232 (4%) ø
spike_lk_touch_sensor_kit ✔️ 96668 (4%) ø 23392 (4%) ø
spike_lk_update_process_app_base ✔️ 157244 (7%) ø 26288 (5%) ø
spike_lk_update_process_app_update ✔️ 100456 (4%) ø 23240 (4%) ø
spike_lk_watchdog_isr ✔️ 87520 (4%) ø 24136 (4%) ø
spike_lk_wifi ✔️ 130984 (6%) ø 25528 (4%) ø
spike_mbed_blinky ✔️ 57616 (2%) ø 11496 (2%) ø
spike_mbed_watchdog_ticker_vs_thread ✔️ 84176 (4%) ø 23080 (4%) ø
spike_stl_cxxsupport ✔️ 83488 (3%) ø 22304 (4%) ø

🗺️ Map files diff output

Click to show diff list
spike_lk_sensors_imu_lsm6dsox (click to expand)

Flash used: 98480 (4%) / total: 2097152
SRAM used: 23520 (4%) / total: 524288
spike_lk_sensors_imu_lsm6dsox_fusion_calibration (click to expand)

Flash used: 104936 (5%) / total: 2097152
SRAM used: 23096 (4%) / total: 524288

@github-actions
Copy link

github-actions bot commented Jan 10, 2023

File comparision analysis report

🔖 Info

  • base: develop / 533502c + mbed-os@master+fixes+gcc-11-support + -std=c++20
  • head: ladislas/feature/ahrs-fusion / 574ee02 + mbed-os@master+fixes+gcc-11-support + -std=c++20
  • toolchain: GNU Arm Embedded Toolchain 10.3-2021.10 - 10.3.1 20210824
  • enable_log_debug: OFF
Target Flash Used (base/head) Fash Used Δ Flash Available (base/head) Static RAM (base/head) Static RAM Δ
bootloader 170784 (65%) ø 91360 (34%)
91360 (34%)
30968 (5%) ø
os 439584 (28%) ø 1125088 (71%)
1125088 (71%)
83760 (15%) ø
Click to show memory sections
| -          |      Hex |     Bytes |  KiB |
|------------|---------:|----------:|-----:|
| Flash      | 0x200000 | 2 097 152 | 2048 |
| SRAM       |  0x80000 |   524 288 |  512 |
| Bootloader |  0x40000 |   262 144 |  256 |
| Header     |   0x1000 |     4 096 |    4 |
| OS         | 0x17E000 | 1 564 672 | 1528 |
| Tail       |   0x1000 |     4 096 |    4 |
| Scratch    |  0x40000 |   262 144 |  256 |

📝 Summary

Click to show summary
  • ✔️ - existing target
  • ✨ - new target
  • ⚰️ - deleted target
  • ✅ - files are the same
  • ❌ - files are different
Target Status .bin .map Total Flash (base/head) Total Flash Δ Static RAM (base/head) Static RAM Δ
LekaOS ✔️ 439584 (20%) ø 83760 (15%) ø
bootloader ✔️ 170784 (8%) ø 30968 (5%) ø
functional_ut_boost_ut ✔️ 394140 (18%) ø 20456 (3%) ø
functional_ut_core_imu ✔️ 377528 (18%) ø 20968 (3%) ø
functional_ut_deep_sleep_core_buffered_serial ✔️ 360600 (17%) ø 20440 (3%) ø
functional_ut_deep_sleep_core_motor ✔️ 364540 (17%) ø 20480 (3%) ø
functional_ut_deep_sleep_core_pwm ✔️ 366676 (17%) ø 20480 (3%) ø
functional_ut_deep_sleep_log_kit ✔️ 352568 (16%) ø 20408 (3%) ø
functional_ut_deep_sleep_mbed_hal ✔️ 354344 (16%) ø 20408 (3%) ø
functional_ut_file_manager ✔️ 374928 (17%) ø 20696 (3%) ø
functional_ut_firmware_kit ✔️ 366972 (17%) ø 20688 (3%) ø
functional_ut_imu_kit ✔️ 373156 (17%) ø 20968 (3%) ø
functional_ut_io_expander ✔️ 359576 (17%) ø 20424 (3%) ø
functional_ut_qdac ✔️ 360744 (17%) ø 20424 (3%) ø
spike_lk_accel_gyro ⚰️ - - - - - -
spike_lk_audio ✔️ 126988 (6%) ø 14600 (2%) ø
spike_lk_behavior_kit ✔️ 189464 (9%) ø 48104 (9%) ø
spike_lk_ble ✔️ 229600 (10%) ø 28472 (5%) ø
spike_lk_bluetooth ✔️ 82948 (3%) ø 11544 (2%) ø
spike_lk_cg_animations ✔️ 145976 (6%) ø 46528 (8%) ø
spike_lk_color_kit ✔️ 65840 (3%) ø 13744 (2%) ø
spike_lk_command_kit ✔️ 214304 (10%) ø 52752 (10%) ø
spike_lk_config_kit ✔️ 127284 (6%) ø 14368 (2%) ø
spike_lk_coreled ✔️ 76292 (3%) ø 13688 (2%) ø
spike_lk_core_touch_sensor ✔️ 80508 (3%) ø 12248 (2%) ø
spike_lk_event_queue ✔️ 74800 (3%) ø 12072 (2%) ø
spike_lk_file_manager_kit ✔️ 139400 (6%) ø 14440 (2%) ø
spike_lk_file_reception ✔️ 336000 (16%) ø 27792 (5%) ø
spike_lk_flash_memory ✔️ 63880 (3%) ø 11448 (2%) ø
spike_lk_fs ✔️ 175668 (8%) ø 47928 (9%) ø
spike_lk_imu_kit ✔️ 92356 (4%) ø 12880 (2%) ø
spike_lk_lcd ✔️ 163312 (7%) ø 46688 (8%) ø
spike_lk_led_kit ✔️ 103424 (4%) ø 14528 (2%) ø
spike_lk_log_kit ✔️ 63288 (3%) ø 12256 (2%) ø
spike_lk_motion_kit ✔️ 105700 (5%) ø 15280 (2%) ø
spike_lk_motors ✔️ 62864 (2%) ø 11488 (2%) ø
spike_lk_qdac ✔️ 78852 (3%) ø 11808 (2%) ø
spike_lk_reinforcer ✔️ 211536 (10%) ø 49944 (9%) ø
spike_lk_rfid ✔️ 79084 (3%) ø 11504 (2%) ø
spike_lk_sensors_battery ✔️ 78388 (3%) ø 12600 (2%) ø
spike_lk_sensors_imu_lsm6dsox - - 89404 (4%) - 12808 (2%) -
spike_lk_sensors_imu_lsm6dsox_fusion_calibration - - 97852 (4%) - 12944 (2%) -
spike_lk_sensors_light ✔️ 60056 (2%) ø 11440 (2%) ø
spike_lk_sensors_microphone ✔️ 72496 (3%) ø 11504 (2%) ø
spike_lk_sensors_temperature_humidity ✔️ 67272 (3%) ø 11424 (2%) ø
spike_lk_serial_number ✔️ 133084 (6%) ø 14304 (2%) ø
spike_lk_ticker_timeout ✔️ 69052 (3%) ø 11632 (2%) ø
spike_lk_touch_sensor_kit ✔️ 87896 (4%) ø 12824 (2%) ø
spike_lk_update_process_app_base ✔️ 145452 (6%) ø 15584 (2%) ø
spike_lk_update_process_app_update ✔️ 77632 (3%) ø 12352 (2%) ø
spike_lk_watchdog_isr ✔️ 80196 (3%) ø 13288 (2%) ø
spike_lk_wifi ✔️ 116544 (5%) ø 14808 (2%) ø
spike_mbed_blinky ✔️ 58032 (2%) ø 11400 (2%) ø
spike_mbed_watchdog_ticker_vs_thread ✔️ 63208 (3%) ø 12448 (2%) ø
spike_stl_cxxsupport ✔️ 58456 (2%) ø 11400 (2%) ø

🗺️ Map files diff output

Click to show diff list
spike_lk_sensors_imu_lsm6dsox (click to expand)

Flash used: 89404 (4%) / total: 2097152
SRAM used: 12808 (2%) / total: 524288
spike_lk_sensors_imu_lsm6dsox_fusion_calibration (click to expand)

Flash used: 97852 (4%) / total: 2097152
SRAM used: 12944 (2%) / total: 524288

@codecov
Copy link

codecov bot commented Jan 10, 2023

Codecov Report

Merging #1245 (2085966) into develop (533502c) will not change coverage.
The diff coverage is n/a.

❗ Current head 2085966 differs from pull request most recent head 574ee02. Consider uploading reports for the commit 574ee02 to get more accurate results

@@           Coverage Diff            @@
##           develop    #1245   +/-   ##
========================================
  Coverage    98.70%   98.70%           
========================================
  Files          147      147           
  Lines         3788     3788           
========================================
  Hits          3739     3739           
  Misses          49       49           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ladislas ladislas force-pushed the ladislas/feature/ahrs-fusion branch 4 times, most recently from dca2820 to 3f25929 Compare January 16, 2023 15:13
@github-actions
Copy link

github-actions bot commented Feb 1, 2023

Version comparison

- Version Same as filename Same as os_version
os 1.3.0+1675757085 ✔️ ✔️
firmware
(os + bootloader)
1.3.0+1675757085 ✔️ ✔️

@ladislas ladislas force-pushed the ladislas/feature/ahrs-fusion branch 2 times, most recently from 07509e6 to 5d93e18 Compare February 1, 2023 13:15
@ladislas ladislas force-pushed the ladislas/feature/ahrs-fusion branch 3 times, most recently from d2abe92 to 1398594 Compare February 6, 2023 08:29
Copy link
Contributor

@HPezz HPezz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. One question about settings config

Comment on lines +39 to +49
const FusionAhrsSettings settings = {
.gain = 0.5F,
.accelerationRejection = 10.0F,
.magneticRejection = 0.0F,
.rejectionTimeout = static_cast<unsigned int>(5 * kODR_HZ), // ? # of samples in 5 seconds
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This answer to my previous question. Seems those parameters to have an influence on results or this is insignificant compared to calibration for instance ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they don't work on the same things.

calibration is the first thing that you need. working with uncalibrated values is like working with no values at all.

Once you have calibrated values, you can improve the results better.

spikes/lk_sensors_imu_lsm6dsox_fusion_calibration/main.cpp Outdated Show resolved Hide resolved
Copy link
Member

@YannLocatelli YannLocatelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except Copyright year and documentation, I need some clarification about performance and a usage of this very handy library.

@@ -0,0 +1,143 @@
// Leka - LekaOS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes, the spike does not logs anything. Is it logs itself or the computation that clog the output? In second case, that might impact performance of robot, especially for reinforcers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there "CPU usage" measurement to compare with the other method?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes, the spike does not logs anything. Is it logs itself or the computation that clog the output?

it's an issue with the LSM6DSOX and it happened before using Fusion -- I'm still trying to understand what is happening.

In second case, that might impact performance of robot, especially for reinforcers.

I don't know, but I'm pretty confident it won't change anything as the computation is very fast

Are there "CPU usage" measurement to compare with the other method?

no, as you know we don't have that.

but at 104Hz for the ODR, the computation was happening is less than 1ms, so no worries there.

As for performance and efficiency, see:

Comment on lines +91 to +99
const auto q_w = quaternion.element.w;
const auto q_x = quaternion.element.x;
const auto q_y = quaternion.element.y;
const auto q_z = quaternion.element.z;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since quaternion are hard to read and interpret, I don't think it is necessary to expose them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in IMUKit, I agree, they won't be exposed.

for this spike, they are necessary because they are sent to the x-IMU3 software for calibration. It's important to have the low level data.

as of "hard to read and interpret", they are mathematical constructs invented especially to make reasoning about 3D rotations easier.

People mostly want Yaw/Pitch/Roll but as soon as you start looking under the hood, you need quaternions

An amazing explanation by Ben Eater https://eater.net/quaternions

Comment on lines 71 to 83
// ? Apply calibration offsets
gyroscope =
FusionCalibrationInertial(gyroscope, FUSION_IDENTITY_MATRIX, FUSION_VECTOR_ONES, gyroscopeOffset);
accelerometer = FusionCalibrationInertial(accelerometer, FUSION_IDENTITY_MATRIX, FUSION_VECTOR_ONES,
accelerometerOffset);

// ? Update gyroscope offset correction algorithm
gyroscope = FusionOffsetUpdate(&global_offset, gyroscope);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the documentation and examples from github Fusion, but I still don't understand the difference between FusionCalibrationInertial and FusionOffsetUpdate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sonarcloud
Copy link

sonarcloud bot commented Feb 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 28 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ladislas ladislas merged commit 41f3e6c into develop Feb 7, 2023
@ladislas ladislas deleted the ladislas/feature/ahrs-fusion branch February 7, 2023 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - type: task Something to do
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants