I try to get the GPS position of the drone at any time.
Actually, I use PositionChanged
event, but that suppose that the drone has already move (for example, for a take-off).
I didn’t find any solution to get the GPS position when the drone has not yet taken off.
Do you have any suggestions ?
Thank you!
1 Like
Hi,
Before take off when the drone acquire its first GPS fix, the HomeChanged event message should be sent by the drone with its current GPS location.
from olympe.messages.ardrone3.GPSSettingsState import HomeChanged
Nicolas
Hi, have you already solved how to get the GPS position of the drone at all times?
Could you share the code please?
Thank you for your answers, it does work.
Here my code:
# -*- coding: UTF-8 -*-
from __future__ import print_function # python2/3 compatibility for the print function
import olympe
from olympe.messages.ardrone3.PilotingState import PositionChanged
from olympe.messages.ardrone3.GPSSettingsState import GPSFixStateChanged
from olympe.messages.ardrone3.Piloting import TakeOff
from olympe.messages.ardrone3.GPSSettingsState import HomeChanged
# Connection
drone = olympe.Drone("10.202.0.1")
drone.connection()
# Wait for GPS fix
drone(GPSFixStateChanged(_policy = 'wait'))
print("GPS position before take-off :", drone.get_state(HomeChanged))
# Take-off
drone(TakeOff()).wait()
print("GPS position after take-off : ", drone.get_state(PositionChanged))
drone.disconnection()
2 Likes
Yes, each time you call drone.get_state(PositionChanged)
you will get the new position if the drone moved.
1 Like
thank you very much, I really thank you