Access Copter mode of operation from AP_MotorsMatrix

Hello folks,
I am fairly new to the ardupilot codebase and I want to try something with the AP_MotorsMatrix.cpp class.
However, for my code I want to access the current flight mode of my drone and do a case-check to only do certain operations on e.g. Land mode.
Is there a way to access the flight-mode to see in which mode the drone is currently operating?

Thanks a lot!
Greetings!

Hello @arduNoo

I think the simplest way to do that is to define a getter and setter functions in your library and at the high-level in you ArduCopter repo you can set this variable to flag about being in Land Mode for your library.

AP_Vehicle vehicle = AP_Vehicle::get_singleton();
uint8_t mode = vehicle.get_mode();
2 Likes