-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
ICM20948 integration into MPU9250 driver #10116
Conversation
@bkueng Could you look into this? |
I'm a bit lost what to do about the insufficient flash size on px4fmu-v2 reported by jenkins. |
These are two short indoor test flights with the ICM as full IMU (in the GNSS, attached to the top of the cube). Together with the internal I2C MPU and lsm303d (SPI MPU9250 disabled): ICM as only IMU: These were done quickly on an old DJI flamewheel configuration with pooor tuning, all I could do today because of heavy rain outside - so don't wonder ;-) The flights themselves were pretty short (about 30 seconds) because of the surroundings. Outdoors I also have no problems with the magnetometer. The ICM only configuration gave me oscillations on roll and nick that the multi-sensor-flight didn't show. They are nicely visible in the log however, so probably not the sensor. |
@flochir I'm trying to start the ICM with the -M flag because I just want to use the magnetometer, but when I do I get a hardfault. Do you see the same behaviour? If I remove the -M flag and start it normally it works, although I get also accel and gyro, which I don't want. |
@DanielePettenuzzo I've got another problem with the -M switch however. Currently the -M switch just disables the publishing of accel and gyro data (naive assumption that would suffice...). However the calibration routine still detects the presence of the sensors and complains that they're there, but have never published. Any hint what would be the best way to set the two sensors to disabled/not create the device files and still instantiate the objects? edit: posted before I read your second comment |
Thanks for the fix! |
Here's the accelerometer calibration log with active icm in magnetometer only mode:
Doing this right from my point of view would mean moving the accelerometer CDEV to its own subclass like the gyro, then not initializing it in the first place. But maybe that would be better done with a (really needed I think) thorough rework of the whole driver, maybe when adapting it to the new driver base classes in the pipeline. So any hints on how to prevent accel/gyro from being used completely, and doing this "cleanly", as intermediate solution? |
I did two 10 minute flights with the icm working as the only magnetometer without issues. As a workaround for the not yet working "-M" switch/calibration problem, I loaded the ICM driver last (as the fourth accel/gyro, so it didn't get calibrated). The other magnetometers had been disabled, so the flight was with the ICM as magnetometer only and the adapted mpu9250 driver working on the two integrated MPUs. |
@flochir I will have another look tomorrow. I need to have a look at what the calibration checks |
@flochir the calibration uses the accel0, accel1, accel2. This device is created here: https://github.com/PX4/Firmware/blob/0450b5d0cac452b3e24091ef3248bc6f7a899560/src/drivers/imu/mpu9250/mpu9250.cpp#L429 and we can add an if statement also here. This should solve the calibration issue although I still don't like that the mpu9250 class creates the mpu9250_icm_accel_ext device although it is not used. I will think of a solution tomorrow. |
@flochir flochir#2 this should solve your calibration issue. Now the only remaining issue is that the mpu9250_icm_accel_ext device is still created by the mpu9250 class even when it's mag only. This doesn't seem to have any side effects but it should be fixed. I will think of how we can restructure the driver in such a way that we can get rid of all these if(!_magnetometer_only) statements. |
I also tested with the mpu9250 on a pixracer and everything seems to work. |
Great, thanks again! I'm currently trying to write a separate driver node for the accelerometer, like there is for the gyro, so we don't need to create the device. |
Done, now it calbrates with -M and without creating the accel/gyro devices. |
@flochir everything works for you now? I tested it and if I start accel, gyro and mag then everything works, but with the -M flag I get a reboot when I start the driver. Do you also see this behaviour? What board are you using? I'm using pixhawk 4. I wonder if the hardfault triggering is different between stem32f4 and stm32f7 microcontrollers. |
No hardfault here:
Did you check where the hardfault is triggered? Did you try the ICM as full IMU? When I did I had quite some oscillations with about 1 or 2 Hz in flight and a bit of weird behaviour running "handheld" at high thrust, while the sensor data, sampling rate etc. looked ok. Not entirely sure yet if this couldn't be a driver issue after all. |
Has there been an update on this? Thanks! |
The code being merged in is significantly out-of-date with master. If you pull master then try to merge the driver in you will run into build failures. |
@mwingerson Sorry, no updates yet, I was out of the country.
Yes - can you elaborate? The driver treats the AK09916 as a subsystem of ICM20948, just as the original MPU9250 driver did for AK8963. |
@DanielePettenuzzo Did you get any insights on your setup? |
@flochir |
@flochir |
The Here GNSS used to work with PX4, as long as they equipped it with the hmc5883. Maybe that was the info you got. They switched to ICM20948 when the HMC was discontinued. |
@jonathan84clark Btw. if you get inconsistent mags check if the sensor rotation is correct. |
@flochir |
@flochir Jonathan L Clark |
@flochir I'll spend some time on it tomorrow |
e23d9dc
to
05282ad
Compare
This should now fit into px4fmu-v2. I've gutted a number of things we can live without. Let's do one final test pass so that we can finally get this in. Has this been tested across all the different cases we care about?
|
bcba6bb
to
e3d4704
Compare
@flochir I pushed the cleanup commit to your branch again (it was lost in your last push). |
@dagar for the |
@dagar Sorry, I got used too much to force pushing on this I guess. |
@DanielePettenuzzo no, they don't have a crazyflie. Perhaps you or @RomanBapst could try it quickly? |
@dagar @DanielePettenuzzo |
tested on pixhawk v4 pro |
@dagar should we order a few Crazyflie's? |
Fixed temperature conversion for MPU9250/ICM20948. Included missing check for PX4_I2C_OBDEV_MPU9250 in main.cpp. Added explicit bus for internal MPU9250 on Pixhawk 2.1 to avoid implicit start of an externally attached device with wrong orientation. Took out printing checked registers from print_info, as it interferes with a driver running icm20948 in parallel by causing unexpected register bank switches.
mpu9250: added a few if statements to check the _magnetometer_only flag
…code to be able to not setup gyro/accel devices.
mpu9250: don't call _set_pollrate twice because first time ring buffers are not initialized mpu9250: set _call_interval to zero when stopping driver (avoids one more work queue call after stop) mpu9250: move call_interval=0 to deconstructor
…ter only mode. mpu9250: fix mag rotation, other minor fixes, make format
Fix in rc.sensors, uncommented hmc5883 driver start. Moved ioctl handlers to CDev-inheriting classes to get clean escalation of unhandled ioctls to superclass
1a274a1
to
6e09d9e
Compare
Rebased, only touched rc.sensors. @dagar, I put the mpu9250 driver call for icm20948 into the "Begin Optional drivers" section. Is this the rigth place? |
6e09d9e
to
651546b
Compare
Testing looks good, let's finally get this in. We really need to get the basic driver structure under control, this could have been a much simpler process. Thanks everyone |
I condensed the history of #9362 in this new PR to make a clear review of the changes easier and get up to date with the master branch.
The data delivered by the ICM looks good. Set Rotation 6/270° Yaw for the external magnetometer for a Here GNSS mounted in flight direction (I kept the chips own coordinate system to not obfuscate it by rotating it fitting to a specific device). rc.sensors is modified to activate the whole IMU in the Here GNSS (on Pixhawk 2/2.1) for testing purposes. To use only the magnetometer: mpu9250 -X -R 6 -M start
I'm thinking about improvements to the bus_options[] array and the associated bulk of device path definitions - they increased a lot with the new bus options added through the master branch while I was working on this. I would still need to add some to make the set complete. In the end the path strings are redundant information in bus_options[] and can be generated from bus, bus type and device type.
I'll add a test flight log as soon as possible.