Skip to content

WIP: Multi gyro support#5762

Closed
jukkaaakko wants to merge 9 commits into
iNavFlight:masterfrom
jukkaaakko:MultiGyroSupport
Closed

WIP: Multi gyro support#5762
jukkaaakko wants to merge 9 commits into
iNavFlight:masterfrom
jukkaaakko:MultiGyroSupport

Conversation

@jukkaaakko

Copy link
Copy Markdown
Contributor

WIP & experimental

@digitalentity digitalentity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review round 1.

I think we should treat read/calibration operations as using multiple sensors all the time - including averaging etc. Best approach would be to unify and decouple read/calibrate code from gyroDev alltogether.

I think we should have a list of gyros, but I can refactor that once we get iteration one working.

Comment thread src/main/sensors/gyro.c
case SECOND:
#ifdef USE_DUAL_GYRO
gyroDev[0].imuSensorToUse = gyroConfig()->gyro_to_use;
gyroDev[0].imuSensorToUse = gyroConfig()->gyro_to_use;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is potentially unsafe if in future we introduce more possible values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True. I think same applies to accelerometer also.

Comment thread src/main/fc/fc_msp.c Outdated

case MSP_SENSOR_ALIGNMENT:
sbufWriteU8(dst, gyroConfig()->gyro_align);
sbufWriteU8(dst, gyroConfig()->gyro2_align);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will require Configurator support as well. I recommend adding new fields to the end of MSP frame.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will remove gyro2_align and acc2_align from fc_msp.

Comment thread src/main/fc/fc_msp.c Outdated
case MSP_SET_SENSOR_ALIGNMENT:
if (dataSize >= 4) {
gyroConfigMutable()->gyro_align = sbufReadU8(src);
gyroConfigMutable()->gyro2_align = sbufReadU8(src);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is unsafe. If we receive a legacy frame of old format, this will cause incorrect values to be set. Move the new fields to the end of the frame and use dataSize to check if we have received an old/new frame and act accordingly.

@digitalentity digitalentity added this to the 2.6 milestone May 19, 2020
@digitalentity
digitalentity changed the base branch from development to master June 8, 2020 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants