Too many ping failures, when connecting using docker

I’m trying to control the ANAFI Ai drone from my Macbook using a docker container, while i know this isn’t technically supported I want to be able to use it for testing AirSDK flightplans so I have a couple of questions.

  1. While the drone responds to my requests, it does not work all the time. I keep getting error messages.
2022-07-14 12:44:59,365 [INFO]  olympe.backend - _do_create - device callbacks have been added to arsdk_ctrl
2022-07-14 12:44:59,366 [INFO]  olympe.scheduler - _create_pomp_loop - Creating pomp loop
2022-07-14 12:44:59,371 [INFO]  olympe.media - _create_pomp_loop - Creating pomp loop
2022-07-14 12:44:59,437 [INFO]  olympe.backend - _device_added_cb - DiscoveryNet: New device has been detected: ‘ANAFI Ai 001995’
2022-07-14 12:44:59,441 [INFO]  olympe.drone - _connecting_cb - Connecting to device: ANAFI Ai 001995
2022-07-14 12:44:59,441 [INFO]  olympe.drone - _connect_impl - Connection in progress...
2022-07-14 12:44:59,588 [INFO]  olympe.drone.ANAFI Ai 001995 - _connected_cb - Connected to device: ANAFI Ai 001995
2022-07-14 12:44:59,589 [INFO]  olympe.drone.ANAFI Ai 001995 - _connected_cb - {‘c2d_port’: 2233,
 ‘c2d_update_port’: 51,
 ‘c2d_user_port’: 21,
 ‘proto_v’: 3,
 ‘qos_mode’: 0,
 ‘status’: 0}
2022-07-14 12:44:59,589 [INFO]  olympe.drone.ANAFI Ai 001995 - _create_command_interface - Command interface has been created
/usr/local/lib/python3.8/dist-packages/tzlocal/unix.py:164: UserWarning: Can not find any timezone configuration, defaulting to UTC.
  warnings.warn(‘Can not find any timezone configuration, defaulting to UTC.’)
2022-07-14 12:44:59,591 [INFO]  olympe.drone.ANAFI Ai 001995 - _send_command_impl - common.Common.CurrentDateTime(datetime=‘20220714T124459+0000’) has been sent to the device
2022-07-14 12:44:59,593 [INFO]  olympe.drone.ANAFI Ai 001995 - _send_command_impl - common.Common.AllStates() has been sent to the device
2022-07-14 12:45:00,097 [WARNING]       olympe.drone.ANAFI Ai 001995 - _on_sync_done - Time synchronization failed for b'192.168.42.1'
ç2022-07-14 12:45:04,590 [INFO]         olympe.drone.ANAFI Ai 001995 - _link_quality_cb - Link quality: tx=0, rx=-1, rx_useful=-1
2022-07-14 12:45:05,376 [ERROR]         olympe.drone.ANAFI Ai 001995 - connect - ’192.168.42.1 connection timed out
2022-07-14 12:45:05,377 [WARNING]       olympe.drone.ANAFI Ai 001995 - async_disconnect - Cannot disconnect while a connection is in progress
2022-07-14 12:45:05,377 [ERROR]         olympe.drone.ANAFI Ai 001995 - disconnect - Cannot disconnect properly: True <olympe.arsdkng.discovery.DiscoveryNet object at 0x7fded7c65910>
2022-07-14 12:45:05,378 [INFO]  olympe.pdraw.ANAFI Ai 001995 - _create_pomp_loop - Creating pomp loop
2022-07-14 12:45:05,380 [INFO]  olympe.pdraw.ANAFI Ai 001995 - _create_pomp_loop - Creating pomp loop
2022-07-14 12:45:05,382 [INFO]  olympe.drone.ANAFI Ai 001995 - _send_command_impl - gimbal.set_target(gimbal_id=0, control_mode=‘position’, yaw_frame_of_reference=‘none’, yaw=0.0, pitch_frame_of_reference=‘absolute’, pitch=45.0, roll_frame_of_reference=‘none’, roll=0.0) has been sent to the device
2022-07-14 12:45:07,588 [ERROR]         ulog - arsdk - net Too many ping failures
2022-07-14 12:45:07,589 [INFO]  olympe.drone.ANAFI Ai 001995 - _link_status_cb - Link status: 0
2022-07-14 12:45:07,590 [INFO]  olympe.pdraw.ANAFI Ai 001995 - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-4
2022-07-14 12:45:07,696 [INFO]  olympe.pdraw.ANAFI Ai 001995 - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-3
2022-07-14 12:45:07,698 [INFO]  olympe.drone.ANAFI Ai 001995 - _disconnected_cb - Disconnected from device: ANAFI Ai 001995
2022-07-14 12:45:07,700 [INFO]  olympe.drone.ANAFI Ai 001995 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7fded7b75880>
2022-07-14 12:45:07,701 [INFO]  olympe.media - _websocket_event_reader - websocket closed
2022-07-14 12:45:07,703 [INFO]  olympe.drone.ANAFI Ai 001995 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7fded7b753a0>
2022-07-14 12:45:07,704 [INFO]  olympe.drone.ANAFI Ai 001995 - disconnect - Disconnection with the device OK. IP: b'192.168.42.1'
2022-07-14 12:45:07,721 [INFO]  olympe.drone.ANAFI Ai 001995 - _on_device_removed - <olympe.arsdkng.cmd_itf.DisconnectedEvent object at 0x7fded7b75a30>
2022-07-14 12:45:07,722 [INFO]  olympe.media - _shutdown - olympe.media shutdown
2022-07-14 12:45:07,722 [INFO]  olympe.scheduler - _destroy_pomp_loop - Pomp loop has been destroyed: subscribers_thread
2022-07-14 12:45:08,028 [INFO]  olympe.backend - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-1
2022-07-14 12:45:08,706 [INFO]  olympe.media - _destroy_pomp_loop - Pomp loop has been destroyed: Thread-2

Docker image

FROM ubuntu:focal
SHELL [“/bin/bash”, “-c”]
RUN DEBIAN_FRONTEND=“noninteractive” \
    apt-get update && \
    apt-get install -y python3 python3-distutils curl libgl1 && \
    rm -rf /var/lib/apt/lists/*
RUN python3 <(curl https://bootstrap.pypa.io/get-pip.py)
RUN python3 -m pip install parrot-olympe
# For testing purposes
COPY main.py .
ENTRYPOINT [ “python3", “main.py” ]

Olympe script

import os
import time
import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, Landing
from olympe.messages import gimbal
DRONE_IP = os.environ.get(“DRONE_IP”, “192.168.42.1")
def test_connection():
    drone = olympe.Drone(DRONE_IP)
    drone.connect()
    drone(gimbal.set_target(
        gimbal_id=0,
        control_mode=“position”,
        yaw_frame_of_reference=“none”, # None instead of absolute
        yaw=0.0,
        pitch_frame_of_reference=“absolute”,
        pitch=45.0,
        roll_frame_of_reference=“none”, # None instead of absolute
        roll = 0.0,
    )).wait()
    drone.disconnect()
if __name__ == “__main__“:
    test_connection()

I’m wondering what the issue is, since it seems that it can’t get a proper connection. The implementation worked perfectly from the Ubuntu computer, but on the Macbook its unreliable. I’m wondering why that might be the case, and if there is any way to fix it.

  1. My second question is to know if it is possible to activate AirSDK flightplans without using Olympe? I am able to upload flightplans to a simulated drone by using curl requests, but from doing research I can’t seem to find any way off activating them without using Olympe. There isn’t any documentation on the API.

Hi there,

The issue is that ANAFI Ai is not directly reachable on its “192.168.42.1” Wifi IP address like former generations of Parrot drones. The Anafi Ai firmware disable the possibility to connect to a drone directly (not through a SkyController) from a PC or a Smartphone over WiFi by default (a firewall on the drone is preventing it).

Thus, it is no longer possible to connect to a drone 192.168.42.1 address over wifi with Olympe without first enabling the “Direct connection” setting of the drone.

To enable this “Direct connection” setting (once and for all for your drone), you can use the FreeFlight 7 application when you’re connected to your Anafi Ai through your SkyController 4.

Currently, you can’t activate a mission through the webserver API (that is something that we’re working on but I have no ETA for this feature for the moment). You need a GroundSDK / Olympe / FreeFlight 7 or OpenFlight 7 to send the mission.activate SDK command

For now, the best you can do with the webserver API is installing your mission as the new default mission :
PUT /api/v1/mission/missions/?is_default=yes
This will make your mission activated by default after rebooting your drone.
To restore the Parrot “default” mission (the firmware builtin default mission) you have to delete your mission :
DELETE /api/v1/mission/missions/<uid>
and reboot your drone.

1 Like

Thank you for your reply @ndessart.

  1. Direct connection was already set to Yes on the drone. Tried setting it to no, and setting it to yes again, and it unfortunately didn’t work. If this is a firewall issue, is there any way of turning it off?

  2. Does the mission activation apply for flightplans as well? Will test for myself, but would like to know if its officially supported.

Hi,

After reading your initial logs again, it seems to me that it’s rather a connectivity issue between your container and the drone. SDK TCP connection seems OK but the SDK UDP datagrams aren’t passing through your network setup. This cannot be explained by the Anafi AI firewall and must probably come from your setup.

AirSDK missions : software applications running on the drone
Flightplan : mavlink formatted file containing waypoints. Those flightplan files can be sent to the drone through the webserver API.

AirSDK Missions and Fligthplans are completely different things. In my initial response, I was assuming you were asking for information on AirSDK Missions.

Using Flightplans with Olympe

First you need a Flightplan file. You can either create a Flightplan file with FreeFlight 7 or create your own following the Parrot Flightplan mavlink file specification is available here.

You then need to upload your mavlink Flightplan file to the drone using the drone webserver API.

Module Upload REST API (v1)

Upload a flight plan

PUT /api/v1/upload/flightplan

Response:

  • Success:

200 string unique id generated for the uploaded flight plan (in response body)

  • Error:
400 if the request is incorrect (method is not PUT for instance)
415 if there is an error with the flight plan file (bad format or too big for instance)
500 if there is a server internal error

Example:

Upload a flight plan (oldest flight plan could be removed if too many have been uploaded)

PUT /api/v1/upload/flightplan

“68238cd792d215bdfdddc7bbb6d10db4”

Once uploaded to the drone, flightplans can be started with Olympe with the common.Mavlink.Start command
The first parameter of this command is actually the flightplan id returned by the Flightplan upload REST request.

Thanks for the reply @ndessart.

I will look more into that. It’s probably as you say from my setup. I’ll give any updates if I figure something out. As previously said I am running the Dockerfile from my Macbook with a direct wifi connection. It can be because its not supported. However, the strange thing is that I have absolutely no problems when I run the exact same script from my Ubuntu computer.

My bad, I meant GroundSDK flightplan. I am aware of how to upload flightplans with the API, I want to know if its possible to start it without olympe like you previously mentioned with the AirSDK mission. Is it possible to do PUT /api/v1/flightplan/flightplans/?is_default=yes? And does the flightplan support deletion of missions? I know they get deleted when you restart the drone, but would be nice to be able to do it manually as well. I have tried something similar to what you posted, but it doesnt work.

No there is no such API for flightplans. Flightplans have to be initiated by a GroundSDK/Olympe command.

I think that this might be an oversight but, currently I’m afraid there is no DELETE flightplan REST API.

Thanks for the reply. I think the problem with the docker image is because I’m using
docker run --network host . The problem is that it is only supported properly on Ubuntu which makes sense. However, when i try to either expose all ports, or create my own bridge network, it still gives me the same ping error. Will post any updates.

When I upload the flightplan to the drone from my computer i can see it on the drone webserver, however when I go under the “Projects/Flight Plan” folder on the Parrot FreeFlight 7 app, i can’t seem to find it. Is it because they are not the same flightplan and/or its not supported by the app?