Connection¶
Missions¶
- Description :
A mission is a group of waypoints. Each way point consists of longitude, latitude and altitude. When you start a mission, the drone starts going from one waypoint to the other point. To upload a mission using ottofly :
1- Include mission_t header
#include <ottofly/mission_t.hpp>
2- Create an object from mission_t and add waypoints:
- Example :
ottofly::mission_t mission;
mission.add_new_waypoint(36.0994756887377832, -95.9255965054035187,7);
mission.add_new_waypoint(36.0993933346305624, -95.9253886342048645,12);
mission.add_new_waypoint(36.0992925590924472, -95.9253725409507751,5);
mission.add_new_waypoint(36.0992470475167408, -95.9255442023277283,9);
mission.add_new_waypoint(36.0992340442045574, -95.925774872303009, 3);
3- Start the mission by passing the object to vehile_copter object:
You can start the mission synchronously so that the execution will be blocked until the mission finishes.
- Example :
if(vehicle_copter.start_mission_sync(mission) != ottofly::command_result::succeed) { std::cerr << "start_mission failed!" << std::endl; return 0; }
You can start the mission Asynchronously so that the execution will NOT be blocked and you can check if the mission if finished or not.
- Example :
if(vehicle_copter.start_mission_async(mission) != ottofly::command_result::succeed) { std::cerr << "start_mission failed!" << std::endl; return 0; } while(!vehicle_copter.mission().is_finished()){ std::this_thread::sleep_for(std::chrono::milliseconds(200));///Time }
To clear all points in the mission:
vehicle_copter.clear_mission();
Telemetry commands¶
Using these commands, the developer will be able to read information about the drone. All the commands in this section are read-only and developers can use it to do specific navigation commands when some conditions are met.
Attitude¶
The attitude in the aeronautical frame (right-handed, Z-down, X-front, Y-right)
For more information check the Attitude in API Reference.
- Example :
std::cout << "Attitude : " <<
"roll : " <<
vehicle_copter.attitude().roll() <<
"pitch : " <<
vehicle_copter.attitude().pitch() <<
"yaw : " <<
vehicle_copter.attitude().yaw() <<
"rollspeed : " <<
vehicle_copter.attitude().rollspeed() <<
"pitchspeed : " <<
vehicle_copter.attitude().pitchspeed() <<
"yawspeed : " <<
vehicle_copter.attitude().yawspeed() <<
std::endl;
Battery Remaining¶
The percentage of remaining battery as integer [0-100].
For more information check battery_remaining in API Reference.
- Example :
auto battery_remaining = vehicle_copter.battery_remaining();
Autopilot Firmware¶
The type of autopilot (PX4,APM,...,unknown).
For more information check autopilot_firmware enum in API Reference.
- Example :
ottofly::autopilot_class pilot = vehicle_copter.autopilot();
if(pilot == ottofly::autopilot_class::APM) {
std::cout << "autopilot : " << "APM" << std::endl;
} else {
std::cout << "autopilot : " << "unknown" << std::endl;
}
Drone Type¶
The type of vehicle (quadrotor,hexarotor,...,unknown)
For more information check vehicle_type enum in API Reference.
- Example :
ottofly::vehicle_type type = vehicle_copter.type();
if (type == ottofly::vehicle_type::quadrotor) {
std::cout << "autopilot : " << "quadrotor" << std::endl;
} else {
std::cout << "autopilot : " << "else" << std::endl;
}
GPS Info¶
Global Positioning System (GPS). This is NOT the global position estimate of the system, but rather a RAW sensor value Coordinate frame is right-handed, Z-axis up (GPS frame).
For more information check gps_raw_int_t class in API Reference.
- Example :
std::cout << "gps_raw_int : " <<
" lat : " <<
vehicle_copter.gps_raw_int().lat() <<
" lon : " <<
vehicle_copter.gps_raw_int().lon() <<
" alt : " <<
vehicle_copter.gps_raw_int().alt() <<
" eph : " <<
vehicle_copter.gps_raw_int().eph() <<
" epv : " <<
vehicle_copter.gps_raw_int().epv() <<
" vel : " <<
vehicle_copter.gps_raw_int().vel() <<
" cog : " <<
vehicle_copter.gps_raw_int().cog() <<
" fix_type : " <<
unsigned(vehicle_copter.gps_raw_int().fix_type()) <<
" satellites_visible : " <<
unsigned(vehicle_copter.gps_raw_int().satellites_visible()) <<
std::endl;
Scaled Pressure¶
The state of the fixed wing navigation and position controller.
For more information check scaled_pressure_t class in API Reference.
- Example :
std::cout << "scaled_pressure : " <<
" press_abs : " <<
vehicle_copter.scaled_pressure().press_abs() <<
" press_diff_: " <<
vehicle_copter.scaled_pressure().press_diff() <<
" temperature_ : " <<
vehicle_copter.scaled_pressure().temperature() <<
std::endl;
Terrein Report¶
The terrein report form the drone.
For more information check terrain_report_t class in API Reference.
- Example :
std::cout << "terrain_report : " <<
" lat : " <<
vehicle_copter.terrain_report().lat() <<
" lon : " <<
vehicle_copter.terrain_report().lon() <<
" terrain_height" <<
vehicle_copter.terrain_report().terrain_height() <<
" current_height : " <<
vehicle_copter.terrain_report().current_height() <<
" spacing : " <<
vehicle_copter.terrain_report().spacing() <<
" pending : " <<
vehicle_copter.terrain_report().pending() <<
" loaded : " <<
vehicle_copter.terrain_report().loaded() <<
std::endl;
AHRS¶
Status of DCM attitude estimatorStatus of DCM attitude estimator.
For more information check AHRS_t class in API Reference.
- Example :
std::cout << "AHRS:" <<
vehicle_copter.ahrs().accel_weight() << " - " <<
vehicle_copter.ahrs().error_rp() << " - " <<
vehicle_copter.ahrs().error_yaw() << " - " <<
vehicle_copter.ahrs().omegaIx() << " - " <<
vehicle_copter.ahrs().omegaIy() << " - " <<
vehicle_copter.ahrs().omegaIz() << " - " <<
vehicle_copter.ahrs().renorm_val()<< std::endl;
Sensor Offsets¶
Offsets and calibrations values for hardware sensors. This makes it easier to debug the calibration process..
For more information check sensor_offsets class in API Reference.
- Example :
std::cout << "Sensor Offsets:" <<
vehicle_copter.sensor_offsets().mag_declination() << " - " <<
vehicle_copter.sensor_offsets().accel_cal_x() << " - " <<
vehicle_copter.sensor_offsets().accel_cal_y() << " - " <<
vehicle_copter.sensor_offsets().accel_cal_z() << " - " <<
vehicle_copter.sensor_offsets().gyro_cal_x() << " - " <<
vehicle_copter.sensor_offsets().gyro_cal_y() << " - " <<
vehicle_copter.sensor_offsets().gyro_cal_z() << " - " <<
vehicle_copter.sensor_offsets().mag_ofs_x() << " - " <<
vehicle_copter.sensor_offsets().mag_ofs_y() << " - " <<
vehicle_copter.sensor_offsets().mag_ofs_z() << " - " <<
vehicle_copter.sensor_offsets().raw_press() << " - " <<
vehicle_copter.sensor_offsets().raw_temp() <<std::endl;
Vibration¶
Vibration levels and accelerometer clipping.
For more information check vibration_t class in API Reference.
- Example :
std::cout << "vibration : " <<
" vibration_x : " <<
vehicle_copter.vibration().vibration_x() <<
" vibration_y : " <<
vehicle_copter.vibration().vibration_y() <<
" vibration_z" <<
vehicle_copter.vibration().vibration_z() <<
" clipping_0 : " <<
vehicle_copter.vibration().clipping_0() <<
" clipping_1 : " <<
vehicle_copter.vibration().clipping_1() <<
" clipping_2 : " <<
vehicle_copter.vibration().clipping_2() <<
RangeFinder¶
To get the distance from rangefinder sensor which is connected to I2C port in Pixhawk or Compass port in Intel Aero RTF.
- Example :
std::cout << "Distance From RangeFinder : " <<
vehicle_copter.rangefinder().distance()<<std::endl;
PX4FLOW Optical Flow¶
To get the information from PX4FLOW sensor which is connected to I2C port in Pixhawk or Compass port in Intel Aero RTF.
- Example :
std::cout<<"OPTICAL FLOW:"
<<vehicle_copter.optical_flow().flow_comp_m_x()
<<"-"<<vehicle_copter.optical_flow().flow_comp_m_y()
<<"-"<<vehicle_copter.optical_flow().flow_rate_x()
<<"-"<<vehicle_copter.optical_flow().flow_rate_y()
<<"-"<<vehicle_copter.optical_flow().flow_x()
<<"-"<<vehicle_copter.optical_flow().flow_y()
<<std::endl;
Configurations¶
OttoFly provides you the ability to change parameters within the configuration JSON file in res folder that comes with the SDK. All the parameters have default values. In the following section, we will explain the meaning of each parameter.Warning
The config.json file is essential for OttoFly to work. It is not recommended to play with these parameters if you are not fully aware about them.
{
"takeoff":{
"waiting_after_takeoff":500,
"percent_of_target_altitude":0.95,
"time_out":5000
},
"arm":{
"time_out":4000
},
"disarm":{
"time_out":3000
},
"change_flight_mode":{
"time_out":4000
},
"land":{
"land_target_altitude_lock":1.1,
"waiting_after_landing":1000,
"time_out":4000
},
"rtl":{
"time_out":10000
},
"commands":{
"sending_commands_interval":33,
"sending_movement_command_interval":1000,
"waiting_ack_response":1500
},
"connect":{
"time_out":5000
},
"logging":{
"_comment":"0:no_logging 1:production 2:verbose",
"logging_level":2,
"log_to_console":true,
"log_to_file":true
},
"mission":{
"waypoint_time_out":300,
"get_waypoint_count_time_out":500,
"get_waypoint_time_out":12000
}
}
Note
All time values are measured in milisecond and distances in meters.
- All time_out parameters represent the time that if the command exceeds it without result, it will fail.
- takeoff.percent_of_target_altitude : In takeoff command if the drone reaches 0.95*target_height, the command will be considered as sucessfully done and break blocking.
- land.land_target_altitude_lock : the altitude that land command breaks the blocking when it reaches it.
- commands.waiting_ack_response : the waiting time for acknowledgment from the drone.
- logging : check debugging section for logging parameters.
Depth System¶
Realsense¶
OttoFly is able to work with any system of Intel RealSense cameras, up to as many as 11 RealSense cameras. It can be easily integrated with OpenCV to perform complex and customized Computer Vision tasks. To work with the system:
- Configure the connected cameras: If you have multiple RealSense cameras, you should set the position for each camera within the software. The software accepts and recognizes 11 different positions. First, set “enabled” to be true. Next, get the serial number for each camera and assign the serial number of each camera to the position you set for that camera. Assign the serial number to the position within the configuration file config.json. The following example shows how to set a RealSense camera with serial number 2411009530 to the front position.
- Example :
"realsense":{
"enabled":true,
"rs_count":1,
"_comment":"set serial value for each camera according to its position or none",
"front":"2411009530",
"front_right":"none",
"front_left":"none",
"right":"none",
"left":"none",
"back":"none",
"back_right":"none",
"back_left":"none",
"up":"none",
"down":"none",
"front_up":"none"
}
- To initialize the system: Inside the configuration file, set the number of RealSense connected to the system with its associated serial numbers. If the system cannot access at least the same number specified in the configuration file, an exception will be thrown. This will be done during initialization of the system:
ottofly::vehicle vehicle_copter;
vehicle_copter.depth_system().initialize();
- Enable streaming (Depth or RGB) for each camera. For example, to enable RGB and Depth for the front camera:
using namespace ottofly::vision;
vehicle_copter.depth_system()[camera_position::front].enable_depth(640, 480);
vehicle_copter.depth_system()[camera_position::front].enable_rgb(640, 480);
- Reading one frame:
using namespace ottofly::vision;
vehicle_copter.depth_system()[camera_position::front].read();
- Getting the results:
using namespace ottofly::vision;
realsense_data result= vehicle_copter.depth_system()[camera_position::front].get_data();
- Getting the result as an OpenCV cv::Mat :
cv::Mat color_image = result.get_rgb_frame().clone();
cv::Mat depth_image = result.get_depth_frame().clone();
Complete Example: Streaming the RGB and Depth data. Applying Canny edge detector on the RGB stream and showing the three frames at the same time (Depth, RGB and the edges):
using namespace ottofly::vision;
using namespace cv;
ottofly::vehicle vehicle_copter;
vehicle_copter.depth_system().initialize();
vehicle_copter.depth_system()[camera_position::front].enable_depth(640, 480);
vehicle_copter.depth_system()[camera_position::front].enable_rgb(640, 480);
while(true) {
vehicle_copter.depth_system()[camera_position::front].read();
realsense_data result = vehicle_copter.depth_system()[camera_position::front].get_data();
auto color_image = result.get_rgb_frame().clone();
auto depth_image = result.get_depth_frame().clone();
if(color_image.empty() || depth_image.empty()) {
std::cout << "No Stream!\n";
continue;
}
Mat canny;
cvtColor(color_image, canny, ColorConversionCodes::COLOR_BGR2GRAY);
Canny(canny, canny, 50, 150);
cvtColor(canny, canny, ColorConversionCodes::COLOR_GRAY2BGR);
hconcat(color_image, canny, color_image);
copyMakeBorder(depth_image, depth_image, 0, 0, 0, depth_image.cols, BorderTypes::BORDER_CONSTANT, Scalar(0, 0, 0));
cvtColor(depth_image, depth_image, ColorConversionCodes::COLOR_GRAY2BGR);
vconcat(depth_image, color_image, color_image);
imshow("Color", color_image);
auto key = cv::waitKey(30);
if(key == 27)
break;
}
return 0;

Debugging¶
OttoFly Logging¶
OttoFly SDK provides extensive logging functionality for your code. Logging gives you the ability to explore the operation of your code, helping you to debug your code and determine the source of any error that may occure. There are three levels of logging in OttoFly:
- No logging: OttoFly will not log anything regarding your code for this option.
- Production: OttoFly will log information regarding critical commands and any errors that occur.
- Verbose: OttoFly will log each and every step executed within the code and provide information on any errors that occur.
Tip
It is strongly recommended to use verbose logging level whenever you are working on the project and you can disable it in production phase.
The default level of logging is verbose. Using the verbose level during the process of developing a new application is highly recommended, as this level will allow you to determine the source of any errors most accurately and allow you to confirm the logical flow of your application. You can change the logging level from the configuration file, where:
- 0 means no logging.
- 1 means production.
- 2 means verbose.
In addition to logging level, you can choose where the OttoFly SDK creates the logging information:
- Log to console: if this option is set to true, OttoFly will display the logging information directly on your console or computer screen.
- Log to file: if this option is set to true, OttoFly will write all logging messages to a logging file. The logging file will appear in a separate log folder in the same directory as your application files. OttoFly creates a new and separate log file each time you run your application, allowing you to track the effects of changes you made to the application between runs. This enables you to track changes during development and more easily undo changes if needed.
You can enable or disable one or both of the logging types at any time in the configuration file.
Tip
It is recommended to enable logging to file when you are working on the project so that you can send us your log files to help you fix any problems whenever it happens.
GCS Telemetry Logging¶
For the best experience, we recommend using Mission planner or APM Planner2 while developing your project or application. Using these functions, you can enable telemetry logging during the execution of your application, providing you with a greater wealth of information about the hardware operation and interaction with your application. Information about the hardware operation and interaction with your application proves particularly helpful when the commands within your application produce unusual or unexpected behavior from the drone, since the logging will provide insight into how exactly the hardware interprets a command or string of commands. You can enable GCS Telemetry logging from the GCS application in the configuration section. To enable GCS Telemetry logging, simply check the “enable Mavlink logging tlog” option. The GCS will create and write to a logging file into a tlogs folder in the same directory as your application files.
Flight stack Logging¶
Note
This section applies only to users developing applications using the Intel Aero RTF drone. It does not apply users utilizing SITL.
The OttoFly SDK provides additional logging opportunities when used in conjunction with the Intel Aero RTF. Flight stack logging is enabled by default and the logs created are placed in a specific path selected by the user. You can set the specific path for the log file in the Intel Aero RTF configuration file (not the OttoFly configuration file). For more information about this type of logging, please refer to the mavlink-router site.