Hello !
I am really struggling there. I am trying to achieve a POI while moving meaning that I would like my drone to keep looking at the poi while moving. Until now I managed to achieve POI but they are cancelled when moving. Have you any idea how to do it ?
Hello, do you have any idea on how to perform this type of feature ? Thanks !
Hello @Jatou ,
Can you share with us the exact code you are trying to run ?
And the associated logs to catch the “cancelled POI when moving” ?
Thanks,
Hugo
Hello, thanks for your reply, i’ll try to be as exhaustive as possible.
Here is the code i am using :
#!/usr/local/bin/python3.10
import logging
import olympe
import olympe.log
import os
import pprint
from olympe.controller import Disconnected
import time
import keyboard
# from olympe.messages.common.Common import Reboot
from olympe.messages import mission
# import rospy
############# Piloting ################
from olympe.messages.ardrone3.Piloting import TakeOff, Landing, moveBy, StartPilotedPOIV2, StopPilotedPOI, PCMD
from olympe.messages.ardrone3.PilotingState import FlyingStateChanged, PilotedPOIV2, GpsLocationChanged
from olympe.messages.move import extended_move_to
from olympe.enums.move import orientation_mode
from olympe.enums.ardrone3.Piloting import StartPilotedPOIV2_Mode
from olympe.enums.ardrone3.PilotingState import PilotedPOIV2_Status
############# PointNFly ################
from olympe.messages.pointnfly.Command import Deactivate, Execute, GetState
from olympe.messages.pointnfly.Event import Execution, State
from olympe.messages.pointnfly import Point
from olympe.enums.pointnfly import GimbalControlMode
DRONE_IP = os.environ.get("DRONE_IP", "192.168.42.1")
logger = logging.getLogger("olympe")
logger.setLevel(logging.WARNING)
target_reached = False
def test_main_mission():
drone = olympe.Drone(DRONE_IP)
try: # Connect to UAV
drone.connect()
drone.subscribe(on_GpsLocationChanged, expectation=GpsLocationChanged(_policy="wait"), queue_size=1)
drone.subscribe(on_PoiChanged, expectation=PilotedPOIV2(_policy="wait"), queue_size=1)
drone.subscribe(on_Execution, expectation=Execute(_policy="wait"), queue_size=1)
drone.subscribe(on_GetState, expectation=State(_policy="wait"), queue_size=1)
while drone.connected:
logger.warning("Press any key to continue...")
key = input()
logger.warning(f"You pressed {key}")
if key == 't':
drone(TakeOff() >> FlyingStateChanged(state="hovering", _timeout=10)).wait().success()
hovering_expectation = FlyingStateChanged(state="hovering", _timeout=10)
logger.warning(f"takeoff expect hovering : {hovering_expectation.explain()}")
elif key == 'm':
# drone(extended_move_to(latitude =XXX, longitude = XXX, altitude = 3.0, orientation_mode = orientation_mode.none, heading = 0.0, max_horizontal_speed = 10.0, max_vertical_speed = 10.0, max_yaw_rotation_speed = 5.0) >> FlyingStateChanged(state="hovering", _timeout=10)).wait().success()
drone(moveBy(10, 0, 2, 0) >> FlyingStateChanged(state="hovering", _timeout=10)).wait().success()
hovering_expectation = FlyingStateChanged(state="hovering", _timeout=10)
if hovering_expectation.success() :
target_reached = True
logger.warning(f"moveto expect hovering : {hovering_expectation.explain()}")
# while not hovering_expectation:
# lat = drone(GpsLocationChanged.args["latitude"])
# logger.warning(f"gps location : {lat}")
elif key == 'g':
drone(extended_move_to(latitude = XXX, longitude = XXX, altitude = 3.0, orientation_mode = orientation_mode.none, heading = 0.0, max_horizontal_speed = 10.0, max_vertical_speed = 10.0, max_yaw_rotation_speed = 5.0) >> FlyingStateChanged(state="hovering", _timeout=10)).wait().success()
# drone(PCMD(
# flag = 0 ,
# roll = 0 ,
# pitch = 0 ,
# yaw = 30 ,
# gaz = 0 ,
# timestampAndSeqNum = 0
# ))
# drone(moveBy(0, 5, 0, 0) >> FlyingStateChanged(state="hovering", _timeout=10)) # .wait().success()
# drone(StartPilotedPOIV2(latitude = XXX, longitude = XXX, altitude = 0.1, mode = StartPilotedPOIV2_Mode.locked_gimbal)).wait().success()
hovering_expectation = FlyingStateChanged(state="hovering", _timeout=10)
elif key == 'l':
drone(Landing()).wait().success()
expectation_landed = FlyingStateChanged(state="landed", _timeout=10)
logger.warning(f"landing expect : {expectation_landed.explain()}")
elif key == 'p':
# drone(StartPilotedPOIV2(latitude = XXX, longitude = XXX, altitude = 0.1, mode = StartPilotedPOIV2_Mode.locked_gimbal)).wait().success()
# expectation_poi= PilotedPOIV2(status="PilotedPOIV2_Status.RUNNING", _timeout=10)
# logger.warning(f"landing expect : {expectation_landed.explain()}")
point = Point(gimbal_control_mode = GimbalControlMode.locked, latitude = XXX, longitude = XXX, altitude = 1.0)
expectation_point = drone(Execute(point=point) >> State(active=dict(point=point)))
if not expectation_point.success():
logger.warning(f"{expectation_point.explain()}")
elif key == 'd':
expectation_point_deactivate = drone(Deactivate() >> State(idle=dict()))
if not expectation_point_deactivate.success():
logger.warning(f"{expectation_point_deactivate.explain()}")
elif key == 's':
drone(StopPilotedPOI()).wait().success()
elif key == 'o':
assert drone.disconnect()
except Exception as e:
logger.warning(f"Exception : {e}")
def on_GpsLocationChanged(event, controller):
lat = event.args["latitude"]
long = event.args["longitude"]
alt = event.args["altitude"]
if target_reached:
logger.warning(f"gps location lat : {lat}")
logger.warning(f"gps location long : {long}")
logger.warning(f"gps location alt : {alt}")
def on_PoiChanged(event, controller):
lat = event.args["latitude"]
long = event.args["longitude"]
alt = event.args["altitude"]
mode = event.args["mode"]
status = event.args["status"]
logger.warning(f"poi location lat : {lat}")
logger.warning(f"poi location long : {long}")
logger.warning(f"poi location alt : {alt}")
logger.warning(f"poi status : {mode}")
logger.warning(f"poi mode : {status}")
def on_Execution(event, controller):
if 'status' in event.args:
status = event.args["status"]
logger.warning(f"poi execution cb : {status}")
def on_GetState(event, controller):
if 'unavailable' in event.args:
unavailable = event.args["unavailable"]
logger.warning(f"poi getstate cb unavailable: {unavailable}")
elif 'idle' in event.args:
idle = event.args["idle"]
logger.warning(f"poi getstate cb idle : {idle}")
elif 'active' in event.args:
active = event.args["active"]
logger.warning(f"poi getstate cb active : {active}")
if __name__ == "__main__":
test_main_mission()
I execute it : python3.10 point_n_fly.py
with sphinx 2.15 and olympe 7.7.5.
Here are the logs :
olympe - test_main_mission - Press any key to continue...
t
2025-04-01 11:40:07,610 [WARNING] olympe - test_main_mission - You pressed t
2025-04-01 11:40:11,088 [WARNING] olympe - on_GetState - poi getstate cb idle : {}
2025-04-01 11:40:11,088 [WARNING] olympe - on_PoiChanged - poi location lat : 0.0
2025-04-01 11:40:11,088 [WARNING] olympe - on_PoiChanged - poi location long : 0.0
2025-04-01 11:40:11,088 [WARNING] olympe - on_PoiChanged - poi location alt : 0.0
2025-04-01 11:40:11,088 [WARNING] olympe - on_PoiChanged - poi status : PilotedPOIV2_Mode.free_gimbal
2025-04-01 11:40:11,088 [WARNING] olympe - on_PoiChanged - poi mode : PilotedPOIV2_Status.AVAILABLE
2025-04-01 11:40:11,101 [WARNING] olympe - test_main_mission - takeoff expect hovering :
ardrone3.PilotingState.FlyingStateChanged(state="hovering", policy=ExpectPolicy.check_wait)
2025-04-01 11:40:11,101 [WARNING] olympe - test_main_mission - Press any key to continue...
m
2025-04-01 11:40:26,081 [WARNING] olympe - test_main_mission - You pressed m
2025-04-01 11:40:35,386 [WARNING] olympe - test_main_mission - moveto expect hovering :
ardrone3.PilotingState.FlyingStateChanged(state="hovering", policy=ExpectPolicy.check_wait)
2025-04-01 11:40:35,386 [WARNING] olympe - test_main_mission - Press any key to continue...
p
2025-04-01 11:40:37,530 [WARNING] olympe - test_main_mission - You pressed p
2025-04-01 11:40:37,536 [WARNING] olympe - test_main_mission -
pointnfly.Event.State(
active=pointnfly.State.Active(
point=dict(
gimbal_control_mode="locked", latitude=XXX, longitude=XXX, altitude=1.0
)
)
)
2025-04-01 11:40:37,536 [WARNING] olympe - test_main_mission - Press any key to continue...
2025-04-01 11:40:37,541 [WARNING] olympe - on_GetState - poi getstate cb active : {'point': {'latitude': XXX, 'longitude':XXX, 'altitude': 1.0, 'gimbal_control_mode': <GimbalControlMode.locked: 0>}}
g
2025-04-01 11:40:50,449 [WARNING] olympe - test_main_mission - You pressed g
2025-04-01 11:40:50,567 [WARNING] olympe - on_GetState - poi getstate cb idle : {}
2025-04-01 11:40:54,854 [WARNING] olympe - test_main_mission - Press any key to continue...
l
2025-04-01 11:43:03,729 [WARNING] olympe - test_main_mission - You pressed l
2025-04-01 11:43:03,738 [WARNING] olympe - test_main_mission - landing expect :
ardrone3.PilotingState.FlyingStateChanged(state="landed", policy=ExpectPolicy.check_wait)
2025-04-01 11:43:03,738 [WARNING] olympe - test_main_mission - Press any key to continue...
2025-04-01 11:43:03,886 [WARNING] olympe - on_GetState - poi getstate cb unavailable: {'reasons': (<UnavailabilityReason.drone_not_flying: 6>,)}
2025-04-01 11:43:03,886 [WARNING] olympe - on_PoiChanged - poi location lat : 0.0
2025-04-01 11:43:03,886 [WARNING] olympe - on_PoiChanged - poi location long : 0.0
2025-04-01 11:43:03,886 [WARNING] olympe - on_PoiChanged - poi location alt : 0.0
2025-04-01 11:43:03,886 [WARNING] olympe - on_PoiChanged - poi status : PilotedPOIV2_Mode.free_gimbal
2025-04-01 11:43:03,887 [WARNING] olympe - on_PoiChanged - poi mode : PilotedPOIV2_Status.UNAVAILABLE
o
So I take off then move, perform a poi which is working and then move again and the state of the poi switches to idle : poi getstate cb idle : {}
It does this with move_to, extended_move_to etc…
Hello @Jatou,
It seems that you want to look at a point and keep looking at it while moving, right?
That’s not the purpose of POI then MoveBy. They act independently of each other.
You need to use PointNFly, as suggested in your other topic.
Hugo
Hello, thanks for the reply.
The thing is that in the PointNFly documentation it says that point and fly commands are mutually exclusive, isn’t it ?>
The documentation says that the point directive will be deactivated if the command deactivate is called or if a fly command occurs. But yes in the point_n_fly protobuf message :
// A directive requesting the drone to point at a given location.
// The drone will constantly point at the target as it moves, until the Point directive is deactivated or a Fly
// directive is executed.
What I finally don’t get is how to give a move order to the drone while keeping the poi order or in general while looking at a poi.
Hello,
Sorry but you can’t do that with PointNFly. The only way of doing this is using a FlightPlan.
Thibaut
Hello, thanks for the reply ! I will do that then !
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.