amymcgovern / pyparrot

Python interface for Parrot Drones
MIT License
274 stars 129 forks source link

Is it possible to read sensor data other than battery life off of Parrot Swing via bluetooth? #225

Open Chris-Sorini opened 8 months ago

Chris-Sorini commented 8 months ago

I would like to read sensor data (speed_x, speed_y, speed_z, speed_ts, altitude, and battery state variables) from a Parrot Swing via bluetooth while it is in flight, but the values for all state variables except for battery do not change.

I have modified the example "demoMamboTricks.py" (https://github.com/amymcgovern/pyparrot/blob/master/examples/demoMamboTricks.py) to work with my Swing instead of a Mambo, changed use_wifi to False since I am using bluetooth, and have added the following after each of the lines in "demoMamboTricks.py" that print the flying state (i.e., print("flying state is %s" % mambo.sensors.flying_state)) to print the state variable values while in flight:

        print("flying state is %s" % mambo.sensors.flying_state)

        mambo.ask_for_state_update()
        mambo.smart_sleep(5)
        print("battery is %s" % mambo.sensors.battery)
        print("speed_x is %s" % mambo.sensors.speed_x)
        print("speed_y is %s" % mambo.sensors.speed_y)
        print("speed_ts is %s" % mambo.sensors.speed_ts)
        print("altitude is %s" % mambo.sensors.altitude)
        print("mambo.sensors_dict is: %s" % mambo.sensors.sensors_dict)
        print("mambo.sensors is: %s" % mambo.sensors)

Note that "mambo" in the above is an instance of the Swing class, not the Mambo class (I just kept the name mambo from the original example). Anyways, when I run this code, the battery state variable is clearly changing (decreasing) each time I print mambo.sensors.battery during the flight, but speed_x, speed_y, speed_z, speed_ts, altitude do not change (speed_x, speed_y, speed_z, speed_ts are always 0 whereas altitude is always -1). Does anyone either know why this is or know of any changes I can make to be able to read off the actual values of speed_x, speed_y, speed_z, speed_ts, and altitude during flight? Any suggestions would be greatly appreciated. Thanks!

Chris