Storage and persistence#
Air SDK allows to write custom mission data to the drone’s storage that will be persisted across launches and reboots.
To persist data Air SDK provides you with a writable path. This path can be retrieved either:
From the Flight Supervisor state machine (Python) using the mission object:
mission_data_root = self.mission.env.get_root_data_dir()
From the following environment variable in Services:
C++
const char *missionDataRoot = getenv("MISSION_DATA");
if (missionDataRoot != nullptr) {
...
}
Python
import os
missionDataRoot = os.getenv('MISSION_DATA')
if missionDataRoot is not None:
...
The data written to that path will be available through MTP/PTP under the folder missions-data when the drone is connected to a computer through USB.
Note
It is also possible to write temporary data:
From the Flight Supervisor with the function get_root_data_tmp_dir()
From the Services with the environment variable ‘MISSION_DATA_TMP’
Important
Please note that it is not possible for a mission to write to the SD card. Only the default photo and video recording can be done on the SD card.
Configuration files#
The path to configuration files of the mission in its root filesystem (where
etc
, share
, … directories can be found) can be retrieved:
From Flight Supervisor:
mission_configuration_root = self.mission.env.get_product_cfg_dir()
From Guidance:
C++
std::string missionConfigurationRoot = guidance->getConfigDir();
Python
mission_configuration_root = guidance.get_config_dir()
From Services:
C++
const char *missionConfigurationRoot = getenv("MISSION_PRODUCT_ROOT_CFG");
if (missionConfigurationRoot != nullptr) {
...
}
Python
import os
mission_configuration_root = os.getenv('MISSION_PRODUCT_ROOT_CFG')
if mission_configuration_root is not None:
...