EKF2 delays with external IMU

@bresch My goal is to get /mavros/imu/data → AI Model → UDP → New uORB topic → EKF2 → AI-corrected State Estimation.

As of now, I’m able to send my data to the new uORB topic. But EKF2 by default relies on vehicle_imu, the minute I try to switch from that to my new uORB topic, mavros/imu/data stops publishing and that kills my input to the AI Model.

When I say mavros/imu/data stops publishing, I mean - its frequency drops to hearbeats or “no new messages”. While on the PX4 terminal, I keep getting “poll timeout 0, 22” errors.

Interestingly, the minute I switch back to vehice_imu, everything falls back in place and starts working properly. I’m making this switch based on a simple custom parameter I defined (0 for Normal-mode, 1 for AI-mode)

My only question now is - How exactly to register/subscribe to vehicle_imu/New uORB topic so as to keep receiving SITL imu data and pass that to my AI model without killing /mavros/imu/data. I’m also fine with receiving my imu data in some other way apart from mavros (as long as I can receive it).

I have also detailed my issue here - Allow EKF2 to use AI-corrected IMU without disrupting the raw IMU stream · Issue #25773 · PX4/PX4-Autopilot · GitHub. I’m using ROS1 Noetic and PX4 v1.13.0