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

Add a way to toggle magnetometer in runtime #341

Merged
merged 24 commits into from
Oct 30, 2024
Merged

Conversation

ImUrX
Copy link
Member

@ImUrX ImUrX commented Aug 26, 2024

  • Added two packets for changing "config" of a sensor, and made config id 1 be magnetometer in all IMUs (to simplify stuff)
  • Implemented this toggle only for BNO currently as that's the only sensor I been using for testing
  • Added a new field in the sensor info that tells you all sensor config values

Fixes #230

@ImUrX ImUrX added Type: Enhancement Adds or improves a feature Area: IMU Support Supporting new IMUs or improving existing support labels Aug 26, 2024
@ImUrX ImUrX requested review from Eirenliel and Vyolex August 28, 2024 18:38
Copy link
Member

@TheDevMinerTV TheDevMinerTV left a comment

Choose a reason for hiding this comment

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

LGTM (except for that one thing)

src/sensors/bno080sensor.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Eirenliel Eirenliel left a comment

Choose a reason for hiding this comment

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

I don't like that mag status is an intrinsic property of a tracker, instead of a generic flag. I think it shouldn't be sent in SensorInfo, but should be sent separately in a more generic way like a list of sensor flags. Even if it's in SensorInfo, it should be more than just this one thing, imo.

The rest looks good.

@@ -298,6 +298,7 @@ void Connection::sendSensorInfo(Sensor& sensor) {
MUST(sendByte(sensor.getSensorId()));
MUST(sendByte(static_cast<uint8_t>(sensor.getSensorState())));
MUST(sendByte(static_cast<uint8_t>(sensor.getSensorType())));
MUST(sendByte(static_cast<uint8_t>(sensor.getMagStatus())));
Copy link
Member

Choose a reason for hiding this comment

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

I don't like that it's sent here. We're adding flags and configs, but still expanding the sensorInfo packet. It should be sent with the rest of the config.

Copy link
Member Author

@ImUrX ImUrX Aug 28, 2024

Choose a reason for hiding this comment

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

I mean sure, but then think of the tracker initialization in the server also, do we defer it until the sensor flag list is received? This sensor flag list when do we send it? What are we gonna use it for aside for mag?

I feel like magnetometer fits well in the sensor info as it makes sense to have it there, but if we are gonna add a flag list I want it to make sense and used for more than just magnetometer so it's something that everyone can agree on (which will take a lot longer)

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this information during initialization?

Copy link
Member Author

Choose a reason for hiding this comment

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

because it doesnt make sense for a initialized tracker to be missing data? i can add a new enum for it on server called "WAITING" and stuff 😭

aside from all that, how are we gonna make this work, do we just return a bitfield?

src/sensors/bno080sensor.cpp Outdated Show resolved Hide resolved
src/sensors/bno080sensor.cpp Outdated Show resolved Hide resolved
src/network/featureflags.h Outdated Show resolved Hide resolved
@@ -27,6 +27,8 @@
#include "sensor.h"
#include <BNO080.h>

#define FLAG_SENSOR_BNO0XX_MAG_ENABLED 1
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO flags shouldn't be sensor-specific, I would put them all (currently only one?) in some separate enum that is common. If flag is not implemented on some sensor it shouldn't be a problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

i like this idea

Copy link
Member Author

Choose a reason for hiding this comment

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

where should i put the flags? In SensorConfig?

Copy link
Member Author

Choose a reason for hiding this comment

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

hi?

Copy link
Member Author

Choose a reason for hiding this comment

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

😭

Copy link
Member

Choose a reason for hiding this comment

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

You can pick the place yourself, no need to be blocked by people that disappeared.

Copy link
Member

@Vyolex Vyolex left a comment

Choose a reason for hiding this comment

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

Just a quick review for now. It's been a while since I looked at the firmware, not really a fan of the amount of duplication that is present for the sensor configs. I'm wondering if we could consolidate them into types of configs rather than have a unique one for each IMU.

src/sensors/sensor.h Outdated Show resolved Hide resolved
src/network/connection.cpp Show resolved Hide resolved
src/network/connection.cpp Show resolved Hide resolved
@Eirenliel Eirenliel merged commit a9f5b1a into main Oct 30, 2024
2 checks passed
@Eirenliel Eirenliel deleted the feat/magnetometer-toggle branch October 30, 2024 18:23
gorbit99 pushed a commit to kounocom/SlimeVR-Tracker-ESP that referenced this pull request Nov 12, 2024
* Untested magnetometer toggle feature for BNO08X and overal packet structure for setting flags from the server

* Some build fixes

* refactor(configuration): rename `CalibrationConfig` to `SensorConfig`

* fix network package order

* typo found

* ignore clion files

* finish feature

* remove ota config that i used

* C skill issue on defines

* i have personal issues with C

* do a reset before

* reinit sensor

* Fix remaining merge errors

* remove BNO_USE_MAGNETOMETER_CORRECTION

* Update src/sensors/sensor.h

Co-authored-by: Lena <[email protected]>

* who loves tabs

* send sensorconfig instead of magdata on sensorinfo

* Bump protocol and firmware version

---------

Co-authored-by: Eiren Rain <[email protected]>
Co-authored-by: DevMiner <[email protected]>
Co-authored-by: Lena <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: IMU Support Supporting new IMUs or improving existing support Type: Enhancement Adds or improves a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switching magnetometer on and off at runtime
5 participants