When I use the MoveTo function after TakeOff, the function works, but when I use MoveTo after MoveBy, nothing happen. I don’t understand why.
Here an example code where the MoveTo doesn’t do anything:
import math
import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, moveBy, Landing, moveTo, Circle
from olympe.messages.ardrone3.PilotingState import moveToChanged, FlyingStateChanged, PositionChanged, AttitudeChanged
from olympe.messages.ardrone3.GPSSettingsState import GPSFixStateChanged
from olympe.messages.ardrone3.PilotingState import GpsLocationChanged
from olympe.enums.ardrone3.Piloting import MoveTo_Orientation_mode
drone = olympe.Drone("10.202.0.1")
drone.connection()
# Take-off
drone(
FlyingStateChanged(state="hovering", _policy="check")
| FlyingStateChanged(state="flying", _policy="check")
| (
GPSFixStateChanged(fixed=1, _timeout=10, _policy="check_wait")
>> (
TakeOff(_no_expect=True)
& FlyingStateChanged(
state="hovering", _timeout=10, _policy="check_wait")
)
)
).wait()
# Get the home position
drone_location = drone.get_state(GpsLocationChanged)
# Move 10m
drone(
moveBy(10, 0, 0, math.pi)
>> FlyingStateChanged(state="hovering", _timeout=20)
).wait().success()
# Go back home
drone(
moveTo(drone_location["latitude"], drone_location["longitude"], drone_location["altitude"], MoveTo_Orientation_mode.TO_TARGET, 0.0)
>> moveToChanged(latitude=drone_location["latitude"], longitude=drone_location["longitude"], altitude=drone_location["altitude"], orientation_mode=MoveTo_Orientation_mode.TO_TARGET, status='DONE', _policy='wait')
>> FlyingStateChanged(state="hovering", _timeout=5)
).wait()
# Landing
drone(
Landing()
>> FlyingStateChanged(state="landed", _timeout=5)
).wait()
drone.disconnection()
Here the log I get:
|09/07/2019 08:24:01.419707|_recv_cmd_cb ardrone3.GPSSettingsState.GPSFixStateChanged(fixed=1)|
|---|---|
|09/07/2019 08:24:01.421269|_send_command Ardrone3.Piloting.TakeOff(): has been sent asynchronously|
|09/07/2019 08:24:01.423618|_recv_cmd_cb ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=12)|
|09/07/2019 08:24:01.426100|_recv_cmd_cb common.MavlinkState.MavlinkFilePlayingStateChanged(state=MavlinkFilePlayingStateChanged_State.stopped, filepath='', type=MavlinkFilePlayingStateChanged_Type.flightPlan)|
|09/07/2019 08:24:01.427568|_recv_cmd_cb common.FlightPlanState.ComponentStateListChanged(component=ComponentStateListChanged_Component.GPS, State=1)|
|09/07/2019 08:24:01.443506|_recv_cmd_cb common.FlightPlanState.ComponentStateListChanged(component=ComponentStateListChanged_Component.Calibration, State=1)|
|09/07/2019 08:24:01.447843|_recv_cmd_cb common.FlightPlanState.ComponentStateListChanged(component=ComponentStateListChanged_Component.TakeOff, State=1)|
|09/07/2019 08:24:01.449354|_recv_cmd_cb common.FlightPlanState.AvailabilityStateChanged(AvailabilityState=1)|
|09/07/2019 08:24:01.452474|_recv_cmd_cb ardrone3.GPSState.HomeTypeAvailabilityChanged(type=HomeTypeAvailabilityChanged_Type.FIRST_FIX, available=4)|
|09/07/2019 08:24:01.453767|_recv_cmd_cb ardrone3.GPSState.HomeTypeChosenChanged(type=HomeTypeChosenChanged_Type.FIRST_FIX)|
|09/07/2019 08:24:01.465463|_recv_cmd_cb common.RunState.RunIdChanged(runId='65F5FF')|
|09/07/2019 08:24:05.492359|_send_command Ardrone3.Piloting.MoveBy(c_double(10.0), c_double(0.0), c_double(0.0), c_double(3.141592653589793)): has been sent asynchronously|
|09/07/2019 08:24:05.498305|_recv_cmd_cb ardrone3.GPSState.HomeTypeAvailabilityChanged(type=HomeTypeAvailabilityChanged_Type.TAKEOFF, available=1)|
|09/07/2019 08:24:05.499754|_recv_cmd_cb ardrone3.GPSState.HomeTypeChosenChanged(type=HomeTypeChosenChanged_Type.TAKEOFF)|
|09/07/2019 08:24:05.501712|_recv_cmd_cb ardrone3.PilotingState.NavigateHomeStateChanged(state=NavigateHomeStateChanged_State.available, reason=NavigateHomeStateChanged_Reason.enabled)|
|09/07/2019 08:24:05.502779|_recv_cmd_cb animation.availability(values='horizontal_panorama|dronie|horizontal_reveal|vertical_reveal|twist_up')|
|09/07/2019 08:24:05.523245|_recv_cmd_cb animation.availability(values='')|
|09/07/2019 08:24:06.395053|_recv_cmd_cb user_storage.capabilities(supported_features='format_when_ready_allowed|format_result_evt_supported|format_progress_evt_supported')|
|09/07/2019 08:24:06.396085|_recv_cmd_cb user_storage.supported_formatting_types(supported_types='full|quick')|
|09/07/2019 08:24:06.397406|_recv_cmd_cb user_storage.capabilities(supported_features='format_when_ready_allowed|format_result_evt_supported|format_progress_evt_supported')|
|09/07/2019 08:24:06.398059|_recv_cmd_cb user_storage.supported_formatting_types(supported_types='full|quick')|
|09/07/2019 08:24:06.398631|_recv_cmd_cb user_storage.state(physical_state=phy_state.undetected, file_system_state=fs_state.unknown, attribute='', monitor_enabled=0, monitor_period=0)|
|09/07/2019 08:24:06.399279|_recv_cmd_cb user_storage.info(name='', capacity=0)|
|09/07/2019 08:24:06.401143|_recv_cmd_cb camera.recording_state(cam_id=0, available=availability.available, state=state.inactive, start_timestamp=0)|
|09/07/2019 08:24:06.405972|_recv_cmd_cb ardrone3.MediaRecordState.VideoStateChangedV2(state=VideoStateChangedV2_State.stopped, error=VideoStateChangedV2_Error.ok)|
|09/07/2019 08:24:06.407329|_recv_cmd_cb mediastore.state(state=state.indexing)|
|09/07/2019 08:24:06.408459|_recv_cmd_cb mediastore.state(state=state.indexed)|
|09/07/2019 08:24:06.409451|_recv_cmd_cb mediastore.counters(video_media_count=0, photo_media_count=0, video_resource_count=0, photo_resource_count=0)|
|09/07/2019 08:24:14.975638|_recv_cmd_cb ardrone3.PilotingEvent.moveByEnd(dX=9.900297164916992, dY=-0.0018132030963897705, dZ=-0.0031625032424926758, dPsi=6.517730799515675e-10, error=MoveByEnd_Error.ok)|
|09/07/2019 08:24:15.600378|_recv_cmd_cb common.CommonState.BatteryStateChanged(percent=99)|
|09/07/2019 08:24:35.022351|_send_command Ardrone3.Piloting.MoveTo(c_double(48.878899993189485), c_double(2.3677804621113245), c_double(0.0), c_uint(1), c_double(0.0)): has been sent asynchronously|
|09/07/2019 08:24:44.669101|_recv_cmd_cb common.CommonState.BatteryStateChanged(percent=98)|
|09/07/2019 08:24:55.068102|_send_command Ardrone3.Piloting.Landing(): has been sent asynchronously|
|09/07/2019 08:24:55.076181|_recv_cmd_cb ardrone3.PilotingState.moveToChanged(latitude=48.878899993189485, longitude=2.3677804621113245, altitude=0.0, orientation_mode=MoveToChanged_Orientation_mode.TO_TARGET, heading=-91.91930389404297, status=MoveToChanged_Status.CANCELED)|
|09/07/2019 08:24:55.087303|_recv_cmd_cb follow_me.state(mode=mode.none, behavior=behavior.idle, animation=animation.none, animation_available='')|
|09/07/2019 08:25:00.117741|disconnection we are not disconnected yet|
Thank you