Changing autopilot

I am changing the autopilot to control the same vehicle during a flight on Gazebo. All the PX4 instances are connected to the QGC and Gazebo throughout a middle software.
228918837_417750462950046_3030363668402874663_n
I have done experiences and the software seems to work fine with any of the three PX4 instance, all receiving commands from the QGC. But when I try to change during a flight the vehicle ignores. Why does Gazebo ignore other autopilot commands?

I am not sure if I understand your problem correctly, so let me rephrase : you have 1 vehicle model in gazebo, 3 autopilots. during mid flight you change which autopilot is controlling your gazebo model. However new autopilot seems to not be able control the vehicle. (so does vehicle just fall?)
If so I would first check qgcs mavlink inspector to see if the active vehicle is really changed, and if new autpilot is reaaly sending messages. Then I would make sure that non-active autopilots are in-sync with active autopilot. For example is armed status same with the active vehicle, is the mod correct etc. Because if they are not you would be just putting unarmed vehicle to a midflight position etc.
sorry inadvance if I misunderstood your question

1 Like

Thanks by your help! You have understood the problem correctly. After testing the software I have noticed the problem belongs to the Redundancy Manager software. There are many threads running to poll and forward messages between Gazebo (TCP), the 3 x PX4 and the QGC (UDP). I have another thread just to receive the votes from the pilots to select the right instance and that thread is not running, so the software selects the wrong instance. The software is fine but the computer canโ€™t run so many threads at the same time, so it ignores one or another.

It seems the problem is solved with some โ€œsleep()โ€ functions inside the threads to give enough time to let the processor run all the other threads. pthread_condition_wait and pthread_condition_signal do not work well at my software since Iโ€™m polling messages from Gazebo or PX4 that I do not have time control to decide when the program must change to the correct thread. There is no a specific order.