Skip to content
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

isflying added #743

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

isflying added #743

wants to merge 9 commits into from

Conversation

HefnySco
Copy link
Contributor

@HefnySco HefnySco commented Aug 1, 2017

implement test criteria to know if a vehicle is flying or not.

@peterbarker
Copy link
Contributor

Terminology problem here.

None of the checks you've added here have anything to do with flying. A vehicle could pass all of those checks and be an AntennaTracker :-)

Determining whether a vehicle is in the air under its own steam is actually really quite hard. You really need to ask it what the probability of it being actively flying itself currently is. ArduPilot currently has such a concept for both Plane, and something related in Copter.

What were you hoping this particular check would represent about the vehicle?

@HefnySco
Copy link
Contributor Author

HefnySco commented Aug 1, 2017

You are correct 👍 .... It is a hard problem.
It is up to developer to use this feature based on vehicle types, it is similar like switching to Surface mode and your vehicle is a plane not a sub. However when vehicle type is plane or drone it works fine. I already use in in DronekitAPI in the Android Version.

isFlying is a variable already exists in Dronekit for Android here

@hamishwillee
Copy link
Contributor

ArduPilot currently has such a concept for both Plane, and something related in Copter.

@peterbarker Is there access to the test via a mavlink message? If so, that could be the check, and the rest could be some sort of fallback for other platforms.

It is up to developer to use this feature based on vehicle types, it is similar like switching to Surface mode and your vehicle is a plane not a sub. However when vehicle type is plane or drone it works fine. I already use in in DronekitAPI in the Android Version.

Dronekit isn't supposed to work like that. If you want to have ambiguous magic behaviour then ideally you'd define a superclass for that vehicle. Minimally you'd want to check the vehicle and make sure an error of some kind is returned for vehicles that don't fly.

@HefnySco
Copy link
Contributor Author

HefnySco commented Aug 4, 2017

@hamishwillee Do you suggest limiting it to plane and copter as follows:

  @property
  def isflying (self):
    if((self._vehicle_type != mavutil.mavlink.MAV_TYPE_QUADROTOR) and
        (self._vehicle_type != mavutil.mavlink.MAV_TYPE_FIXED_WING)):

        return None

    isFlying = ((self._system_status == Vehicle.MAV_STATE_ACTIVE) or 
        ((self._isflying == True) and (self._system_status == Vehicle.MAV_STATE_CRITICAL or Vehicle._system_status == self.MAV_STATE_EMERGENCY)))

    self._isflying = isFlying
            
    
        


    return self._isflying

@hamishwillee
Copy link
Contributor

hamishwillee commented Aug 4, 2017

@HefnySco I'd really defer to @peterbarker , since he is far more involved with this than me. This is the sort of thing I was thinking. A good alternative might be to have a more generic method - e.g. "isLaunched" or "isMoving" rather than isFlying, and have test conditions that also make sense for ground vehicles and subs.

I don't know the right tests to have in place to show something is flying/moving though.

@pietrodn
Copy link
Contributor

pietrodn commented Jan 8, 2019

Alternative idea... it may be not exactly what OP needs, but I had success with it on my drones, and it could give valuable information to users.

In DroneKit, we could monitor the EXTENDED_SYS_STATE MAVLink message to determine if the landed_state attribute is equal to MAV_LANDED_STATE_ON_GROUND.

In PX4, landed_state is equal to MAV_LANDED_STATE_ON_GROUND if and only if the land detector Finite State Machine is in the "Landed" state.

Clearly, it's important to document that such an attribute gives only access to the land detector state, and it may not represent the actual drone status (e.g. if the engines are "twitching", the land detector may fail to detect ground contact).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants