Open guiccbr opened 8 years ago
Update: We have fixed it in PR #13, however, as pointed out in here, those states might be set when the vehicle is not flying, what's a problem if someone uses this flag to check if the vehicle is flying.
Since gazebo-sitl does use this flag to determine if the vehicle is flying or not here, we will need to take a closer look into it and implement a fix either by changing gzsitl (i.e. review how gazebo-sitl checks if the vehicle is flying) and/or creating a new public method in mavlink_vehicles saying if is_vehicle_flying().
Currently, mavlink_vehicles maps the more specific mavlink MAV_STATE enum to a more generic STATUS enum as follows:
MAV_STATE_UNINIT -> mavlink_vehicles::status::STANDBY MAV_STATE_BOOT -> mavlink_vehicles::status::STANDBY MAV_STATE_CALIBRATING -> mavlink_vehicles::status::STANDBY MAV_STATE_ACTIVE -> mavlink_vehicles::status::ACTIVE MAV_STATE_CRITICAL -> mavlink_vehicles::status::STANDBY MAV_STATE_EMERGENCY -> mavlink_vehicles::status::STANDBY MAV_STATE_POWEROFF -> mavlink_vehicles::status::STANDBY
This simplification has been placed taking in consideration only a specific use case: determine whether the vehicle is already flying (ACTIVE) or not (STANDBY). While testing It has been noted that the states STATE_CRITICAL and STATE_EMERGENCY might also be set during flight, and so, those should also be mapped to mavlink_vehiclse::status::ACTIVE. However, I'm not sure if that's the best approach.
As an example of use case: there are only three places in gazeb-sitl where this status flag is used (the first one is here). All of them use it just to determine if the vehicle is already flying. If not - and if auto_takeoff is enabled - gazebo-sitl requests takeoff.