How to write new mission programmatically?

I have read the whole AirSDK documentation and I’m still unclear on how to start from scratch to create a new mission consisting of both existing and custom services. So far, I’ve installed Sphinx and have managed to build and load the HelloDrone mission. It worked as expected, but didn’t provide a lot of insight in how to make my own mission.

I’m coming from a ROS and Android programming background, so maybe that’s biasing me, but I’m trying to figure out how the whole directory should be structured and what files are required for a minimal example and I’m not seeing it. The HelloDrone code is helpful to some degree for the latter, but doesn’t show me how to start from scratch. For instance, does my new package need to live in a certain directory inside the airsdk directory? And if not, what do I need to do to make sure the airsdk knows about it?

1 Like

Hello,

There two types of AirSDK missions :

  • A full mission, with functionalities of the three main customizable processes: flight supervisor, guidance modes and services. You can refer to this page on how to write a full mission.
  • A service, which is standalone processes dedicated to a specific Flight mission and run into a separated Linux process. Services can be computer vision algorithms, neural networks, communication protocols… You can refer to this page on how to write a service.

There will be soon more examples in the documentation.

The HelloDrone mission is a full mission.
You could start by modifying the HelloDrone mission.

Thanks for your reply!

I see that HelloDrone is a full mission and it’s definitely helpful to some degree, but I’m missing some basic first steps, e.g. I don’t see how to make sure my custom mission (yet to be developed) is linked to the airsdk overall library because in the instructions, when we pull hellodrone, it’s pulled from the web, not from a local copy, which would enable me to reproduce the directory structure. Specifically, I’m referring to these instructions for building the HelloDrone mission:

./build.sh -p hello-pc -t all -j
./build.sh -p hello-pc -t sync --reboot

Seems like this makes a symlink or something. If I were to manually clone HelloDrone, where would I clone it? Inside /airsdk/products?

Additionally, if I want to inspect missions as suggested via the REST API, this instruction is given

GET /api/v1/mission/missions

with no additional context. I tried running it in terminal even though it doesn’t look like a terminal command, no luck, as expected. I tried testing it in Postman, no response either. It would be nice if it were set up like a typical REST server with a local url. How is this command supposed to be used?

Thanks!

Mission

Seems like this makes a symlink or something. If I were to manually clone HelloDrone, where would I clone it? Inside /airsdk/products?

Once you have completed this step (cloning-the-workspace) you should have the following structure in your workspace:

build/
build.sh
packages/
└── airsdk-samples
    ├── README.md
    └── hello
        ├── atom.mk
        ├── autopilot-plugins
        ├── messages
        ├── product
        └── services
products/
README

The HelloDrone mission is situated in packages/airsdk-samples/hello directory. For the rest of this post it is assumed that our current working directory is packages/airsdk-samples/hello.

Should you want to make changes to this mission you can:

  • edit messages/protobuf/parrot/missions/samples/hello/airsdk/messages.proto to specify your custom messages that can get exchanged between your mission and your ground application (GroundSdkDemo, OpenFlight, etc…)
  • edit autopilot-plugins/fsup and/or autopilot-plugins/guidance to specify custom stages. This is for a full type mission.
  • edit services/native/sample.cpp (for a C++) service. The HelloDrone mission service is written in C++ but you can have services written in python (python service skeleton). If you add C++ files to the mission you should update atom.mk file to include those files.

Here is a atom.mk for a python service living in services/python/python_skeleton.py:

LOCAL_PATH := $(call my-dir)

mission.name := my-mission
mission.package := org.exemple.$(subst _,-,$(mission.name))
mission.uid := org.$(mission.package)

mission.mission-dir := missions/$(mission.uid)
mission.payload-dir := $(mission.mission-dir)/payload
mission.services-dir := $(mission.payload-dir)/services

include $(CLEAR_VARS)

LOCAL_MODULE := airsdk-$(mission.name)-service
LOCAL_DESCRIPTION := mission description
LOCAL_CATEGORY_PATH := airsdk/missions/$(mission.name)

LOCAL_SRC_FILES := $(call all-files-under,python,.py)
LOCAL_CODECHECK_PYTHON := flake8

LOCAL_COPY_FILES := python/python_skeleton.py:$(mission.services-dir)/$(LOCAL_MODULE)
LOCAL_COPY_DIRS := python/uploader:$(mission.services-dir)/uploader

LOCAL_LIBRARIES := \
	libarsdk-pbpy \

include $(BUILD_CUSTOM)

You can have more information in the packages/airsdk-samples/hello/README.md.

Mission inspection

Additionally, if I want to inspect missions as suggested via the REST API, this instruction is given

GET /api/v1/mission/missions

with no additional context.

Once you have your computer connected to the drone’s Wifi you can run on a terminal :

curl -X GET http://192.168.42.1/api/v1/mission/missions

or
You can go to the drone web server address at http://192.168.42.1/#/ or http://anafi-ai.local/#/ using your browser and select the Missions tab, to see what missions are installed in your drone.

5 Likes

Thanks so much for the detailed response! That is exactly the information I was looking for :smile:

Suppose I want to make a new mission based on a copy of hello, but rename and modify it. How would the build command (ie: ./build.sh -p hello-pc -t all -j) change?

for the record, I tried the obvious, ./build.sh -p <my_package> -t all -j and ./build.sh -p <my_package>-pc -t all -j and I get the message:

[E] '<my_package>' is not a valid product

Prior to trying to build, I also tried to find all the relevant places to change the package or directory names and update them, but I made no changes to the technical mission code.

Hi,

The hello mission has a product directory in it, which is referenced by the -p hello-pc part of the build command.
In order for the build system to find your own product directory, you also need to symlink it inside the root <SDK>/products/ directory (as the hello one is done).

You should have something like this:

$ ls -l <SDK>/packages/my_mission/
   atom.mk
   [... other omitted]
   product/

$ ls -l <SDK>/products/
   hello -> ../packages/airsdk-samples/hello/product
   my_mission -> ../packages/my_mission/product

Then you should be able to build your mission by using ./build.sh -p my_mission-[pc|classic] -t all
However, if you copied the products folder from the hello mission, you will probably need to run a config task first : ./build.sh -p my_mission-[pc|classic] -t xconfig (graphical version), or -t menuconfig (command-line version) to select the proper packages to be built.

Regards,
Nicolas.

Thanks so much! And lastly, if I wanted to add some basic guidance to the HelloDrone mission, what are the commands for take off, land, and go to waypoint? With the old SDK for Parrot Bebop there was a list of general commands like that (including many more, like take picture, rotate, etc, but those 3 would be the bare minimum to do anything interesting).

And I assume this guidance would live inside the file guidance/python/hello.py?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.