Hello drone doesn't work

Hi,

I’m trying to test the “Hello, drone” example from Air SDK, but it’s not working. I wonder if it’s necessary install a trusted certificate to testing the example

Hi

Could you be more specific what is “not working”. What is happening? Are you using airsdk-cli? Does the mission build fails or is it the installation ? Is there any error logs ?

If you’re using airsdk-cli with the default options, a default developer certificate is generated on your machine and installed on the drone before the mission itself.

The gimbal doesn’t make the greeting movement. There is not any errors. My installation is before the updating of the SDK with de airsdk-cli, installing the packages from the terminal.

Hi,

I’m facing almost similar problem. I’m following “Hello, Drone!” - 7.5 (installed airsdk-cli) example and I’m able to install mission to simulated drone.

Screenshot from 2023-01-19 15-07-15

But i don’t know how to properly activate it

I saw that it is possible to upload and activate airsdk missions through ‘Olympe’ (i would prefer this method), but from this example it’s not clear how to make it. Default code not working.

import logging
import olympe
import olympe.log
import os
import pprint
from olympe.controller import Disconnected
from olympe.messages.common.Common import Reboot
from olympe.messages import mission


DRONE_IP = os.environ.get("DRONE_IP", "10.202.0.1")
HELLO_MISSION_URL = os.environ.get("HELLO_MISSION_URL", "com.parrot.missions.samples.hello.tar.gz")

olympe.log.update_config({"loggers": {"olympe": {"level": "INFO"}}})
logger = logging.getLogger("olympe")


def test_hello_mission():
    drone = olympe.Drone(DRONE_IP)
    with drone.mission.from_path(HELLO_MISSION_URL).open() as hello:
        # Mission messages modules are now available from the Python path
        from olympe.airsdk.messages.parrot.missions.samples.hello.Command import Say, Hold
        from olympe.airsdk.messages.parrot.missions.samples.hello.Event import count

        # Mission messages are also available under the Mission.messages dictionary
        assert hello.messages["parrot.missions.samples.hello"].Command.Say is Say
        assert hello.messages["parrot.missions.samples.hello"].Event.count is count

        # Install the 'hello' mission and reboot the drone
        assert drone.connect()
        assert hello.install(allow_overwrite=True)
        logger.info("Mission list: " + pprint.pformat(drone.mission.list_remote()))
        assert drone(Reboot() >> Disconnected()).wait()

        # Connect to the drone after reboot, load and activate the 'hello' mission
        assert drone.connect(retry=5)
        assert hello.wait_ready(5)

        # wait for the current mission to be activated
        mission_activated = drone(mission.state(state="active"))
        assert mission_activated.wait(), mission_activated.explain()

        logger.info("Mission list: " + pprint.pformat(drone.mission.list_remote()))

        # load and activate the hello mission
        mission_activated = drone(
            mission.load(uid=hello.uid)
            >> mission.activate(uid=hello.uid)
        )
        assert mission_activated.wait(), mission_activated.explain()

        # Make the drone say hello (nod its gimbal)
        assert drone(Say()).wait()
        counter = None

        # Wait for 3 nod of the drone gimbal
        for i in range(3):
            if counter is None:
                expectation = drone(count(_policy="wait")).wait(_timeout=10)
                assert expectation, expectation.explain()
                counter = expectation.received_events().last().args["value"]
            else:
                counter += 1
                expectation = drone(count(value=counter)).wait(_timeout=10)
                assert expectation, expectation.explain()

        # Stop and disconnect
        assert drone(Hold()).wait()
        expectation = drone(count(_policy="wait", _timeout=15)).wait()
        assert not expectation, expectation.explain()
        assert drone(count(value=counter, _policy="check"))
        assert drone.disconnect()


if __name__ == "__main__":
    test_hello_mission()

Error:

I tried to make little changes only to activate mission, gimbal stared moving, but it went to infint loop (gimbal move every ~10 seconds), and getting errors, code:

import logging
import olympe
import olympe.log
import os
import pprint
from olympe.controller import Disconnected
from olympe.messages.common.Common import Reboot
from olympe.messages import mission


DRONE_IP = os.environ.get("DRONE_IP", "10.202.0.1")
# HELLO_MISSION_URL = os.environ.get("HELLO_MISSION_URL", "com.parrot.missions.samples.hello.tar.gz")

olympe.log.update_config({"loggers": {"olympe": {"level": "INFO"}}})
logger = logging.getLogger("olympe")

def test_hello_mission():
    drone = olympe.Drone(DRONE_IP)
    # with drone.mission.from_path(HELLO_MISSION_URL).open() as hello:
    # Mission messages modules are now available from the Python path
    # from olympe.airsdk.messages.parrot.missions.samples.hello.Command import Say, Hold
    # from olympe.airsdk.messages.parrot.missions.samples.hello.Event import count

    # # Mission messages are also available under the Mission.messages dictionary
    # assert hello.messages["parrot.missions.samples.hello"].Command.Say is Say
    # assert hello.messages["parrot.missions.samples.hello"].Event.count is count

    # # Install the 'hello' mission and reboot the drone
    assert drone.connect()
    # assert hello.install(allow_overwrite=True)
    # logger.info("Mission list: " + pprint.pformat(drone.mission.list_remote()))
    # assert drone(Reboot() >> Disconnected()).wait()

    # Connect to the drone after reboot, load and activate the 'hello' mission
    # assert drone.connect(retry=5)
    # # assert hello.wait_ready(5)

    # # wait for the current mission to be activated
    # mission_activated = drone(mission.state(state="active"))
    # assert mission_activated.wait(), mission_activated.explain()

    # logger.info("Mission list: " + pprint.pformat(drone.mission.list_remote()))

    # load and activate the hello mission
    mission_activated = drone(
        mission.load(uid="com.parrot.missions.samples.hello")
        >> mission.activate(uid="com.parrot.missions.samples.hello")
    )

    assert mission_activated.wait(), mission_activated.explain()

    # Make the drone say hello (nod its gimbal)
    assert drone(Say()).wait()
    counter = None

    # Wait for 3 nod of the drone gimbal
    for i in range(3):
        if counter is None:
            expectation = drone(count(_policy="wait")).wait(_timeout=10)
            assert expectation, expectation.explain()
            counter = expectation.received_events().last().args["value"]
        else:
            counter += 1
            expectation = drone(count(value=counter)).wait(_timeout=10)
            assert expectation, expectation.explain()

    # Stop and disconnect
    # assert drone(Hold()).wait()
    expectation = drone(count(_policy="wait", _timeout=15)).wait()
    assert not expectation, expectation.explain()
    assert drone(count(value=counter, _policy="check"))
    assert drone.disconnect()

if __name__ == "__main__":
    test_hello_mission()

Also I would like to add some movements to this mission like takeoff and fly simple squere or something like that. Should i change /airsdk-samples/hello/guidance/hello/hello.py file to achieve that? (Based on documentation citation " Guidance ")

Hi DovydasPocius,

Did you ever figure out the reason for the gimbal infinitely nodding its head?

yes, the code was incorrect. Here is the correct one:

import logging
import olympe
import olympe.log
import os
import pprint
from olympe.controller import Disconnected
from olympe.messages.common.Common import Reboot
from olympe.messages import mission


# DRONE_IP = os.environ.get("DRONE_IP", "10.202.0.1")
# HELLO_MISSION_URL = os.environ.get("HELLO_MISSION_URL", "/home/droneteam/airsdk-samples/hello/.airsdk/out/hello-pc/images/com.parrot.missions.samples.hello.tar.gz")
DRONE_IP = os.environ.get("DRONE_IP", "192.168.42.1")
# there should your specific path to com.parrot.missions.samples.hello.tar.gz
HELLO_MISSION_URL = os.environ.get("HELLO_MISSION_URL", "/home/droneteam/airsdk-samples/hello/.airsdk/out/hello-classic/images/com.parrot.missions.samples.hello.tar.gz")

olympe.log.update_config({"loggers": {"olympe": {"level": "INFO"}}})
logger = logging.getLogger("olympe")


def test_hello_mission():
    drone = olympe.Drone(DRONE_IP)
    with drone.mission.from_path(HELLO_MISSION_URL).open() as hello:
        # Mission messages modules are now available from the Python path
        from olympe.airsdk.messages.parrot.missions.samples.hello.Command import Say, Hold
        from olympe.airsdk.messages.parrot.missions.samples.hello.Event import count

        # Mission messages are also available under the Mission.messages dictionary
        assert hello.messages["parrot.missions.samples.hello"].Command.Say is Say
        assert hello.messages["parrot.missions.samples.hello"].Event.count is count

        # Install the 'hello' mission and reboot the drone
        assert drone.connect()
      
        mission_activated = drone(
            mission.load(uid=hello.uid)
            >> mission.activate(uid=hello.uid)
        )
    

        # Make the drone say hello (nod its gimbal)
        assert drone(Say()).wait()
        counter = None

        # Wait for 3 nod of the drone gimbal
        for i in range(3):
            if counter is None:
                expectation = drone(count(_policy="wait")).wait(_timeout=10)
                assert expectation, expectation.explain()
                counter = expectation.received_events().last().args["value"]
            else:
                counter += 1
                expectation = drone(count(value=counter)).wait(_timeout=10)
                assert expectation, expectation.explain()

        # Stop and disconnect
        assert drone(Hold()).wait()
        expectation = drone(count(_policy="wait", _timeout=15)).wait()
        assert not expectation, expectation.explain()
        assert drone(count(value=counter, _policy="check"))
        assert drone.disconnect()


if __name__ == "__main__":
    test_hello_mission()

this code works on real drone ((“DRONE_IP”, “192.168.42.1”)) and simulation (“DRONE_IP”, “10.202.0.1”)

2 Likes

Thank you for providing your new code. Is there any particular reason why you use this code rather than the hello_test.py provided on GitHub? I am still very new to learning how to program the drone.