-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
What is the expected behavior?
The icm20498 magnetometer should return values in a +/- 4900 uT range as indicated by the datasheet.
What is the actual behavior?
The magnetometer returns absurdly high values.
ex: -188374.5781 x 18856.1875 y 190086.9531 z
Steps to reproduce.
Call read_magnetometer(ec) from icm20948.cpp component
Build or installation Logs.
More Information.
It seems like the scaling for the magnetometer in the icm20948 component is applied incorrectly at line 699 in icm20948.cpp:
template <espp::icm20948::Interface I>
Icm20948<I>::Value Icm20948<I>::read_magnetometer(std::error_code &ec) {
std::lock_guard<std::recursive_mutex> lock(base_mutex_);
RawValue raw = get_magnetometer_raw(ec);
if (ec) {
return {0.0f, 0.0f, 0.0f};
}
float sensitivity = get_magnetometer_sensitivity();
Value value = {
static_cast<float>(raw.x) / sensitivity,
static_cast<float>(raw.y) / sensitivity,
static_cast<float>(raw.z) / sensitivity,
};
// update values
mag_values_ = value;
return value;
}get_magnetometer_sensitivity() returns the scaling factor in uT/LSB so should be applied by multiplying not dividing.
Changing this locally returns values in the expected range.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working