Post on 28-Feb-2020
FlytDocsRelease
sharvashish_das
January 21 2016
Contents
1 About FlytSim 3
2 FlytSim Installation Guide 521 FlytSim binaries 522 Build FlytSim from source 6
3 FlytSim Basics 731 Launch FlytSim 732 Kill FlytSim 7
4 Onboard App 941 Execute built-in Demo Apps 942 Create and Compile custom app 1243 Execute custom app 1444 Install custom app 15
5 Web and Mobile Apps 1751 Introduction 1752 Development Environment Setup 1853 Creating and Running a Web Application Project 1854 Sample Web Application 1955 Creating and Running a Mobile Application Project 2256 Sample Mobile Application 23
6 About FlytOS 29
7 List of APIs 3171 Navigation APIs 3172 Parameter Handling APIs 3273 Setup APIs 3274 Vision APIs 32
8 FlytAPI - onboard 3381 Navigation APIs 33
9 FlytAPI - RESTWebsocket 4391 Navigation APIs 43
i
ii
FlytDocs Release
Welcome to Flyt the next generation platform for commercial drone applications It is by design open for developers tobuild advanced drone applications using its open APIs Flyt consists of FlytOS the software framework and FlytPODthe integrated hardware
FlytOS is based on Linux and ROS (Robot Operating System) making it an ideal platform for research and commercialdrone applications It can interact with any compatible droneautopilot using its adapter layer and exposes high levelFlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integrate payloads and also providesadvanced APIs using its onboard modules These rich set of APIs allow for easy development of onboard businesslogic as well as remote monitoring and control through web and mobile apps The modular design of FlytOS allowsfor integration with external ROSLinux libraries and custom data plumbing between onboard and offboard apps Thevision of FlytOS is to provide a standard language for the drone developers to talk to their drones
FlytPOD is an integrated hardware stack with a hybrid architecture consisting of a Pixhawk like custom board tightlycoupled with the Odroid XU4 SBC It has an onboard WiFi router and several interfaces for custom payloads ra-dio receivers and special sensors etc It comes with PX4 and FlytOS preloaded for an out-of-the-box ready-to-flyexperience
This documentation gives all the inputs to get you started with Flyt You can learn about FlytOS and get a detailedreference for all the FlytAPIs It provides a step by step guide to install and get started with FlytSim simulation onyour laptop You can refer to the sample apps and start building your own onboard and webmobile apps and test themwith FlytSim
Checkout and participate in our forums and interact with the community sharing your use cases feedback and anythingyou need help with You can always reach out to us for any issues at supportflytbasecom
Contents 1
FlytDocs Release
2 Contents
CHAPTER 1
About FlytSim
FlytSim offers a 3D SITL(Software In The Loop) simulation environment for testing user apps without the dronehardware It is a ROS-Gazebo based environment where the drone and its world are simulated programmaticallygenerating the state variables while the control algorithms applied are same as onboard the drone (PX4) The FlytAPIsare also available in FlytSim and thus the user apps built with these APIs can be tested on a computer supporting anative Linux environment using FlytSim FlytSim is based on Pixhawk SITL customised to work with FlytAPIsPlease follow the FlytSim Installation Guide to install FlytSim package and Flytsim Tutorials to start testing your appand see it in action
3
FlytDocs Release
4 Chapter 1 About FlytSim
CHAPTER 2
FlytSim Installation Guide
Before you can start off with installing FlytSim make sure you fulfill all the following dependencies
bull Intel 64 bit architecture
bull Linux - Ubuntu 1404
bull ROS - Indigo
FlytSim is based on Gazebo2 which comes in packaged with ROS Indigo If in case you have an upgraded versionof Gazebo please install Gazebo2 before moving ahead in this tutorial In future we will add support for upgradedversions of Gazebo as well
We have provided the following two approaches for installing FlytSim
bull FlytSim binaries - the preferred approach
bull Build FlytSim from source
21 FlytSim binaries
To install FlytSim binaries
bull Go to the FlytSim download page Download the FlytSimv10zip file Once downloaded unzip the file tofind flytsim_10-1_amd64deb which is the FlytSim debian paclkage and flytsim_installsh an install scriptAlternatively you can create your own install script by copying the following lines
binbash install script for FlytSim TODO for future download md5 file and check md5sum
installing known dependenciesapt-get install ros-indigo-octomap-ros ros-indigo-octomap-msgs libgoogle-glog-dev ros-indigo-control-toolboxinstalling FlytSim packagedpkg -i flytsim_10-1_amd64deb
exit 0
bull Make the install script executable
$ chmod +x ltpath to install scriptgtflytsim_installsh
bull Install FlytSim by executing the install script with sudo privileges
5
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
Contents
1 About FlytSim 3
2 FlytSim Installation Guide 521 FlytSim binaries 522 Build FlytSim from source 6
3 FlytSim Basics 731 Launch FlytSim 732 Kill FlytSim 7
4 Onboard App 941 Execute built-in Demo Apps 942 Create and Compile custom app 1243 Execute custom app 1444 Install custom app 15
5 Web and Mobile Apps 1751 Introduction 1752 Development Environment Setup 1853 Creating and Running a Web Application Project 1854 Sample Web Application 1955 Creating and Running a Mobile Application Project 2256 Sample Mobile Application 23
6 About FlytOS 29
7 List of APIs 3171 Navigation APIs 3172 Parameter Handling APIs 3273 Setup APIs 3274 Vision APIs 32
8 FlytAPI - onboard 3381 Navigation APIs 33
9 FlytAPI - RESTWebsocket 4391 Navigation APIs 43
i
ii
FlytDocs Release
Welcome to Flyt the next generation platform for commercial drone applications It is by design open for developers tobuild advanced drone applications using its open APIs Flyt consists of FlytOS the software framework and FlytPODthe integrated hardware
FlytOS is based on Linux and ROS (Robot Operating System) making it an ideal platform for research and commercialdrone applications It can interact with any compatible droneautopilot using its adapter layer and exposes high levelFlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integrate payloads and also providesadvanced APIs using its onboard modules These rich set of APIs allow for easy development of onboard businesslogic as well as remote monitoring and control through web and mobile apps The modular design of FlytOS allowsfor integration with external ROSLinux libraries and custom data plumbing between onboard and offboard apps Thevision of FlytOS is to provide a standard language for the drone developers to talk to their drones
FlytPOD is an integrated hardware stack with a hybrid architecture consisting of a Pixhawk like custom board tightlycoupled with the Odroid XU4 SBC It has an onboard WiFi router and several interfaces for custom payloads ra-dio receivers and special sensors etc It comes with PX4 and FlytOS preloaded for an out-of-the-box ready-to-flyexperience
This documentation gives all the inputs to get you started with Flyt You can learn about FlytOS and get a detailedreference for all the FlytAPIs It provides a step by step guide to install and get started with FlytSim simulation onyour laptop You can refer to the sample apps and start building your own onboard and webmobile apps and test themwith FlytSim
Checkout and participate in our forums and interact with the community sharing your use cases feedback and anythingyou need help with You can always reach out to us for any issues at supportflytbasecom
Contents 1
FlytDocs Release
2 Contents
CHAPTER 1
About FlytSim
FlytSim offers a 3D SITL(Software In The Loop) simulation environment for testing user apps without the dronehardware It is a ROS-Gazebo based environment where the drone and its world are simulated programmaticallygenerating the state variables while the control algorithms applied are same as onboard the drone (PX4) The FlytAPIsare also available in FlytSim and thus the user apps built with these APIs can be tested on a computer supporting anative Linux environment using FlytSim FlytSim is based on Pixhawk SITL customised to work with FlytAPIsPlease follow the FlytSim Installation Guide to install FlytSim package and Flytsim Tutorials to start testing your appand see it in action
3
FlytDocs Release
4 Chapter 1 About FlytSim
CHAPTER 2
FlytSim Installation Guide
Before you can start off with installing FlytSim make sure you fulfill all the following dependencies
bull Intel 64 bit architecture
bull Linux - Ubuntu 1404
bull ROS - Indigo
FlytSim is based on Gazebo2 which comes in packaged with ROS Indigo If in case you have an upgraded versionof Gazebo please install Gazebo2 before moving ahead in this tutorial In future we will add support for upgradedversions of Gazebo as well
We have provided the following two approaches for installing FlytSim
bull FlytSim binaries - the preferred approach
bull Build FlytSim from source
21 FlytSim binaries
To install FlytSim binaries
bull Go to the FlytSim download page Download the FlytSimv10zip file Once downloaded unzip the file tofind flytsim_10-1_amd64deb which is the FlytSim debian paclkage and flytsim_installsh an install scriptAlternatively you can create your own install script by copying the following lines
binbash install script for FlytSim TODO for future download md5 file and check md5sum
installing known dependenciesapt-get install ros-indigo-octomap-ros ros-indigo-octomap-msgs libgoogle-glog-dev ros-indigo-control-toolboxinstalling FlytSim packagedpkg -i flytsim_10-1_amd64deb
exit 0
bull Make the install script executable
$ chmod +x ltpath to install scriptgtflytsim_installsh
bull Install FlytSim by executing the install script with sudo privileges
5
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
ii
FlytDocs Release
Welcome to Flyt the next generation platform for commercial drone applications It is by design open for developers tobuild advanced drone applications using its open APIs Flyt consists of FlytOS the software framework and FlytPODthe integrated hardware
FlytOS is based on Linux and ROS (Robot Operating System) making it an ideal platform for research and commercialdrone applications It can interact with any compatible droneautopilot using its adapter layer and exposes high levelFlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integrate payloads and also providesadvanced APIs using its onboard modules These rich set of APIs allow for easy development of onboard businesslogic as well as remote monitoring and control through web and mobile apps The modular design of FlytOS allowsfor integration with external ROSLinux libraries and custom data plumbing between onboard and offboard apps Thevision of FlytOS is to provide a standard language for the drone developers to talk to their drones
FlytPOD is an integrated hardware stack with a hybrid architecture consisting of a Pixhawk like custom board tightlycoupled with the Odroid XU4 SBC It has an onboard WiFi router and several interfaces for custom payloads ra-dio receivers and special sensors etc It comes with PX4 and FlytOS preloaded for an out-of-the-box ready-to-flyexperience
This documentation gives all the inputs to get you started with Flyt You can learn about FlytOS and get a detailedreference for all the FlytAPIs It provides a step by step guide to install and get started with FlytSim simulation onyour laptop You can refer to the sample apps and start building your own onboard and webmobile apps and test themwith FlytSim
Checkout and participate in our forums and interact with the community sharing your use cases feedback and anythingyou need help with You can always reach out to us for any issues at supportflytbasecom
Contents 1
FlytDocs Release
2 Contents
CHAPTER 1
About FlytSim
FlytSim offers a 3D SITL(Software In The Loop) simulation environment for testing user apps without the dronehardware It is a ROS-Gazebo based environment where the drone and its world are simulated programmaticallygenerating the state variables while the control algorithms applied are same as onboard the drone (PX4) The FlytAPIsare also available in FlytSim and thus the user apps built with these APIs can be tested on a computer supporting anative Linux environment using FlytSim FlytSim is based on Pixhawk SITL customised to work with FlytAPIsPlease follow the FlytSim Installation Guide to install FlytSim package and Flytsim Tutorials to start testing your appand see it in action
3
FlytDocs Release
4 Chapter 1 About FlytSim
CHAPTER 2
FlytSim Installation Guide
Before you can start off with installing FlytSim make sure you fulfill all the following dependencies
bull Intel 64 bit architecture
bull Linux - Ubuntu 1404
bull ROS - Indigo
FlytSim is based on Gazebo2 which comes in packaged with ROS Indigo If in case you have an upgraded versionof Gazebo please install Gazebo2 before moving ahead in this tutorial In future we will add support for upgradedversions of Gazebo as well
We have provided the following two approaches for installing FlytSim
bull FlytSim binaries - the preferred approach
bull Build FlytSim from source
21 FlytSim binaries
To install FlytSim binaries
bull Go to the FlytSim download page Download the FlytSimv10zip file Once downloaded unzip the file tofind flytsim_10-1_amd64deb which is the FlytSim debian paclkage and flytsim_installsh an install scriptAlternatively you can create your own install script by copying the following lines
binbash install script for FlytSim TODO for future download md5 file and check md5sum
installing known dependenciesapt-get install ros-indigo-octomap-ros ros-indigo-octomap-msgs libgoogle-glog-dev ros-indigo-control-toolboxinstalling FlytSim packagedpkg -i flytsim_10-1_amd64deb
exit 0
bull Make the install script executable
$ chmod +x ltpath to install scriptgtflytsim_installsh
bull Install FlytSim by executing the install script with sudo privileges
5
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
Welcome to Flyt the next generation platform for commercial drone applications It is by design open for developers tobuild advanced drone applications using its open APIs Flyt consists of FlytOS the software framework and FlytPODthe integrated hardware
FlytOS is based on Linux and ROS (Robot Operating System) making it an ideal platform for research and commercialdrone applications It can interact with any compatible droneautopilot using its adapter layer and exposes high levelFlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integrate payloads and also providesadvanced APIs using its onboard modules These rich set of APIs allow for easy development of onboard businesslogic as well as remote monitoring and control through web and mobile apps The modular design of FlytOS allowsfor integration with external ROSLinux libraries and custom data plumbing between onboard and offboard apps Thevision of FlytOS is to provide a standard language for the drone developers to talk to their drones
FlytPOD is an integrated hardware stack with a hybrid architecture consisting of a Pixhawk like custom board tightlycoupled with the Odroid XU4 SBC It has an onboard WiFi router and several interfaces for custom payloads ra-dio receivers and special sensors etc It comes with PX4 and FlytOS preloaded for an out-of-the-box ready-to-flyexperience
This documentation gives all the inputs to get you started with Flyt You can learn about FlytOS and get a detailedreference for all the FlytAPIs It provides a step by step guide to install and get started with FlytSim simulation onyour laptop You can refer to the sample apps and start building your own onboard and webmobile apps and test themwith FlytSim
Checkout and participate in our forums and interact with the community sharing your use cases feedback and anythingyou need help with You can always reach out to us for any issues at supportflytbasecom
Contents 1
FlytDocs Release
2 Contents
CHAPTER 1
About FlytSim
FlytSim offers a 3D SITL(Software In The Loop) simulation environment for testing user apps without the dronehardware It is a ROS-Gazebo based environment where the drone and its world are simulated programmaticallygenerating the state variables while the control algorithms applied are same as onboard the drone (PX4) The FlytAPIsare also available in FlytSim and thus the user apps built with these APIs can be tested on a computer supporting anative Linux environment using FlytSim FlytSim is based on Pixhawk SITL customised to work with FlytAPIsPlease follow the FlytSim Installation Guide to install FlytSim package and Flytsim Tutorials to start testing your appand see it in action
3
FlytDocs Release
4 Chapter 1 About FlytSim
CHAPTER 2
FlytSim Installation Guide
Before you can start off with installing FlytSim make sure you fulfill all the following dependencies
bull Intel 64 bit architecture
bull Linux - Ubuntu 1404
bull ROS - Indigo
FlytSim is based on Gazebo2 which comes in packaged with ROS Indigo If in case you have an upgraded versionof Gazebo please install Gazebo2 before moving ahead in this tutorial In future we will add support for upgradedversions of Gazebo as well
We have provided the following two approaches for installing FlytSim
bull FlytSim binaries - the preferred approach
bull Build FlytSim from source
21 FlytSim binaries
To install FlytSim binaries
bull Go to the FlytSim download page Download the FlytSimv10zip file Once downloaded unzip the file tofind flytsim_10-1_amd64deb which is the FlytSim debian paclkage and flytsim_installsh an install scriptAlternatively you can create your own install script by copying the following lines
binbash install script for FlytSim TODO for future download md5 file and check md5sum
installing known dependenciesapt-get install ros-indigo-octomap-ros ros-indigo-octomap-msgs libgoogle-glog-dev ros-indigo-control-toolboxinstalling FlytSim packagedpkg -i flytsim_10-1_amd64deb
exit 0
bull Make the install script executable
$ chmod +x ltpath to install scriptgtflytsim_installsh
bull Install FlytSim by executing the install script with sudo privileges
5
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
2 Contents
CHAPTER 1
About FlytSim
FlytSim offers a 3D SITL(Software In The Loop) simulation environment for testing user apps without the dronehardware It is a ROS-Gazebo based environment where the drone and its world are simulated programmaticallygenerating the state variables while the control algorithms applied are same as onboard the drone (PX4) The FlytAPIsare also available in FlytSim and thus the user apps built with these APIs can be tested on a computer supporting anative Linux environment using FlytSim FlytSim is based on Pixhawk SITL customised to work with FlytAPIsPlease follow the FlytSim Installation Guide to install FlytSim package and Flytsim Tutorials to start testing your appand see it in action
3
FlytDocs Release
4 Chapter 1 About FlytSim
CHAPTER 2
FlytSim Installation Guide
Before you can start off with installing FlytSim make sure you fulfill all the following dependencies
bull Intel 64 bit architecture
bull Linux - Ubuntu 1404
bull ROS - Indigo
FlytSim is based on Gazebo2 which comes in packaged with ROS Indigo If in case you have an upgraded versionof Gazebo please install Gazebo2 before moving ahead in this tutorial In future we will add support for upgradedversions of Gazebo as well
We have provided the following two approaches for installing FlytSim
bull FlytSim binaries - the preferred approach
bull Build FlytSim from source
21 FlytSim binaries
To install FlytSim binaries
bull Go to the FlytSim download page Download the FlytSimv10zip file Once downloaded unzip the file tofind flytsim_10-1_amd64deb which is the FlytSim debian paclkage and flytsim_installsh an install scriptAlternatively you can create your own install script by copying the following lines
binbash install script for FlytSim TODO for future download md5 file and check md5sum
installing known dependenciesapt-get install ros-indigo-octomap-ros ros-indigo-octomap-msgs libgoogle-glog-dev ros-indigo-control-toolboxinstalling FlytSim packagedpkg -i flytsim_10-1_amd64deb
exit 0
bull Make the install script executable
$ chmod +x ltpath to install scriptgtflytsim_installsh
bull Install FlytSim by executing the install script with sudo privileges
5
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 1
About FlytSim
FlytSim offers a 3D SITL(Software In The Loop) simulation environment for testing user apps without the dronehardware It is a ROS-Gazebo based environment where the drone and its world are simulated programmaticallygenerating the state variables while the control algorithms applied are same as onboard the drone (PX4) The FlytAPIsare also available in FlytSim and thus the user apps built with these APIs can be tested on a computer supporting anative Linux environment using FlytSim FlytSim is based on Pixhawk SITL customised to work with FlytAPIsPlease follow the FlytSim Installation Guide to install FlytSim package and Flytsim Tutorials to start testing your appand see it in action
3
FlytDocs Release
4 Chapter 1 About FlytSim
CHAPTER 2
FlytSim Installation Guide
Before you can start off with installing FlytSim make sure you fulfill all the following dependencies
bull Intel 64 bit architecture
bull Linux - Ubuntu 1404
bull ROS - Indigo
FlytSim is based on Gazebo2 which comes in packaged with ROS Indigo If in case you have an upgraded versionof Gazebo please install Gazebo2 before moving ahead in this tutorial In future we will add support for upgradedversions of Gazebo as well
We have provided the following two approaches for installing FlytSim
bull FlytSim binaries - the preferred approach
bull Build FlytSim from source
21 FlytSim binaries
To install FlytSim binaries
bull Go to the FlytSim download page Download the FlytSimv10zip file Once downloaded unzip the file tofind flytsim_10-1_amd64deb which is the FlytSim debian paclkage and flytsim_installsh an install scriptAlternatively you can create your own install script by copying the following lines
binbash install script for FlytSim TODO for future download md5 file and check md5sum
installing known dependenciesapt-get install ros-indigo-octomap-ros ros-indigo-octomap-msgs libgoogle-glog-dev ros-indigo-control-toolboxinstalling FlytSim packagedpkg -i flytsim_10-1_amd64deb
exit 0
bull Make the install script executable
$ chmod +x ltpath to install scriptgtflytsim_installsh
bull Install FlytSim by executing the install script with sudo privileges
5
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
4 Chapter 1 About FlytSim
CHAPTER 2
FlytSim Installation Guide
Before you can start off with installing FlytSim make sure you fulfill all the following dependencies
bull Intel 64 bit architecture
bull Linux - Ubuntu 1404
bull ROS - Indigo
FlytSim is based on Gazebo2 which comes in packaged with ROS Indigo If in case you have an upgraded versionof Gazebo please install Gazebo2 before moving ahead in this tutorial In future we will add support for upgradedversions of Gazebo as well
We have provided the following two approaches for installing FlytSim
bull FlytSim binaries - the preferred approach
bull Build FlytSim from source
21 FlytSim binaries
To install FlytSim binaries
bull Go to the FlytSim download page Download the FlytSimv10zip file Once downloaded unzip the file tofind flytsim_10-1_amd64deb which is the FlytSim debian paclkage and flytsim_installsh an install scriptAlternatively you can create your own install script by copying the following lines
binbash install script for FlytSim TODO for future download md5 file and check md5sum
installing known dependenciesapt-get install ros-indigo-octomap-ros ros-indigo-octomap-msgs libgoogle-glog-dev ros-indigo-control-toolboxinstalling FlytSim packagedpkg -i flytsim_10-1_amd64deb
exit 0
bull Make the install script executable
$ chmod +x ltpath to install scriptgtflytsim_installsh
bull Install FlytSim by executing the install script with sudo privileges
5
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 2
FlytSim Installation Guide
Before you can start off with installing FlytSim make sure you fulfill all the following dependencies
bull Intel 64 bit architecture
bull Linux - Ubuntu 1404
bull ROS - Indigo
FlytSim is based on Gazebo2 which comes in packaged with ROS Indigo If in case you have an upgraded versionof Gazebo please install Gazebo2 before moving ahead in this tutorial In future we will add support for upgradedversions of Gazebo as well
We have provided the following two approaches for installing FlytSim
bull FlytSim binaries - the preferred approach
bull Build FlytSim from source
21 FlytSim binaries
To install FlytSim binaries
bull Go to the FlytSim download page Download the FlytSimv10zip file Once downloaded unzip the file tofind flytsim_10-1_amd64deb which is the FlytSim debian paclkage and flytsim_installsh an install scriptAlternatively you can create your own install script by copying the following lines
binbash install script for FlytSim TODO for future download md5 file and check md5sum
installing known dependenciesapt-get install ros-indigo-octomap-ros ros-indigo-octomap-msgs libgoogle-glog-dev ros-indigo-control-toolboxinstalling FlytSim packagedpkg -i flytsim_10-1_amd64deb
exit 0
bull Make the install script executable
$ chmod +x ltpath to install scriptgtflytsim_installsh
bull Install FlytSim by executing the install script with sudo privileges
5
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
$ sudo ltpath to install scriptgtflytsim_installsh
bull Just in case you see any dependency issues cropping up in your screen other than that of Gazebo2 whileexecuting the install script kindly run the following command and execute the install script again
$ sudo apt-get -f install
bull If versions other than Gazebo2 is installed in your system you might encounter dependency issue for Gazebo2We are working to provide support for higher versions of Gazebo as well Till then please install Gazebo2 inyour system before running the install script again
22 Build FlytSim from source
Currently efforts are being put to make FlytSim source code available in github
6 Chapter 2 FlytSim Installation Guide
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 3
FlytSim Basics
31 Launch FlytSim
Once you have installed FlytSim you are ready to build your own apps and run it out on the simulation software Tolaunch FlytSim run this command in the terminal
$ $(rospack find core_api)scriptsstart_flytOSsh --sitl
Note For first time Gazebo users Gazebo might take some time to launch Be Patient
The above command would launch ROS and Gazebo A quadrotor model-Iris will be automatically spawned for youto start executing your app You can use FlytAPIs in your command line to do some simple maneuvers For example
To make the vehicle take off at its spot execute this command in your terminal$ rosservice call flytpodnavigationtake_off takeoff_alt 20
To send a position setpoint to the vehicle in NED frame execute this command in your terminalrosservice call flytpodnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 30 y 10 z -20angular x 00 y 00 z 00
tolerance 00async falserelative falseyaw_valid falsesetpoint_type 0
Caution Gazebo runs in ENU frame hence the above setpoints given in NED Frame would be transformed toENU Frame by Gazebo
To know more about such commands please refer to FlytAPIs for more details
32 Kill FlytSim
To kill this instance of FlytSim run this command in your terminal
7
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
$ $(rospack find core_api)scriptskill_flytOSsh --sitl
8 Chapter 3 FlytSim Basics
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 4
Onboard App
41 Execute built-in Demo Apps
FlytSim package comes with Demo apps which can be executed to do simple navigation tasks Currently CPP andPython based FlytAPIs are available hence DemoApps for both CPP and Python have been provided All the sampleapps can be found at our github link
411 Demo App 1
This demo app makes the robot takeoff move in a square trajectory of side length 5m and land once the entire missionis over
Below is a demo youtube video of the same app
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp1 and its executable demoapp1 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp1
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) Taking Offnavposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)navland() Landing
9
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
CPP - Code Explained
bull You must include the following header file to make FlytAPI-navigation available for the script
include ltcore_script_bridgenavigation_bridgehgt
bull Create an object of class Navigation through which you can call any navigation FlytAPI
Navigation nav
bull TakeOff command could be sent to vehicle with relative takeoff altitude in metres as argument Over here thetakeoff altitude is 3m
navtakeoff(30) Taking Off
Caution You must ensure to call takeoff() before sending any other position setpoints takeoff() inherentlycalls arm() hence calling arm() directly also arms the vehicle and makes it responsive towards next setpointcommands
bull Position Setpoints could be sent to the vehicle with (xyz) in metres in Local-NED Frame as argument
navposition_set(50-3) Sending Position Setpointsnavposition_set(55-3)navposition_set(05-3)navposition_set(00-3)
bull Land command must be used to send the vehicle into Landing mode
navland() Landing
bull Please refer to FlytAPIs to get more information on the available list of APIs
Python - Execution
The source code demoapp1py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp1py
Python - Code
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
10 Chapter 4 Onboard App
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
Python - Code Explained
bull Imports and initialization
from flyt_python import api
bull Creating instance of navigation class from flyt_pythonapi
nav = apinavigation() instance of flyt navigation class
bull Actual flight logic
By default position_set() is synchronous in action ie your script will wait for the vehicle to reach the specified targetbefore continuing to execute the next command Visit FlytAPIs for more information
navarm()print taking offnavtakeoff(30)print going along the setpointsnavposition_set(50-3)navposition_set(55-3)navposition_set(05-3)navposition_set(00-3)print Donenavland()print wait for the vehicle to land
412 Demo App 2
Note This demo requires arguments to be passed
This demo app makes the robot takeoff move in a square trajectory of side length provided as an argument to thescript and land once the entire mission is over
CPP - Execution
The source code of this app is located at FlytFlytAppsOnboardsrcDemoApp2 and its executable demoapp2 is atFlytFlytAppsOnboardinstall To execute this app run the following command in your terminal
$ FlytFlytAppsOnboardinstalldemoapp2 3 here 3 is passed as an argument one could send any other float value
CPP - Code
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
if(argc lt 2)stdcoutltltnThis app expects argumentsnexit(0)
41 Execute built-in Demo Apps 11
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
float side_length = stdstof(argv[1]) Convert Argument from string to floatnavtakeoff(30) Taking Offnavposition_set(side_length0-3) Sending Position Setpoints with side length accepted from scriptnavposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland() Landing
Python - Execution
The source code demoapp2py of this app is located at FlytFlytAppsOnboardinstall To execute this app run thefollowing command in your terminal
$ python FlytFlytAppsOnboardinstalldemoapp2py 3 here 3 is passed as an argument one could send any other float value
Python - Code
usrbinenv python
from flyt_python import apiimport argparse
nav = apinavigation() instance of flyt navigation class
parsing command line argumentsparser = argparseArgumentParser(description=Process a float value)parseradd_argument(side metavar=side_length type=float help=side length of the square)args = parserparse_args()
lets flyside_length = argssideprint flying in square side_lengthnavtakeoff(30)navposition_set(side_length0-3)navposition_set(side_lengthside_length-3)navposition_set(0side_length-3)navposition_set(00-3)navland()print done flying wait for quad to land
42 Create and Compile custom app
To begin with one can download the above two demo apps (CPP and Python) from our github link under OnboardAppsfolder Once downloaded follow the following steps to create your own app
421 CPP
bull Create a directory where you want to keep the source files of your onboard apps
12 Chapter 4 Onboard App
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_cpp_appgt
bull Create your own ltmy_first_cpp_appgtcpp file You can use the following snippet to start building your app
include ltcore_script_bridgenavigation_bridgehgtinclude ltiostreamgt
Navigation navint main(int argc char argv[])
navtakeoff(30) OR navarm() Write your own logic below
bull Copy CMakeListstxt from the downloaded DemoApp1 and paste it inside ltmy_first_cpp_appgt This is theCMakeListstxt file of DemoApp1 To find how to configure this file for ltmy_first_cpp_appgt go to CMake-Liststxt - Explained
cmake_minimum_required(VERSION 283)project(demoapp1)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
bull Create a build directory to host all your build files
$ mkdir ltbuildgt
bull Inside build directory run the cmake command
$ cmake
bull To build your cpp file run the make command
$ make
CMakeListstxt - Explained
bull Enter your project name - ltmy_first_cpp_appgt
project(demoapp1)
bull Make Navigation FlytAPI Library - core_script_bridge and other dependencies available for yourltmy_first_cpp_appgtcpp
42 Create and Compile custom app 13
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
find_package(catkin REQUIRED COMPONENTS core_script_bridge)find_package(Boost REQUIRED COMPONENTS system python)find_package(PythonLibs 27 REQUIRED)include_directories($catkin_INCLUDE_DIRS $PYTHON_INCLUDE_DIRS)
bull Give a suitable name ltmy_first_cpp_appgt to your executable and link it with libraries
add_executable(demoapp1 demoapp1cpp)target_link_libraries(demoapp1 $catkin_LIBRARIES $Boost_LIBRARIES $PYTHON_LIBRARIES)
bull Add the following install command to install your created ltmy_first_cpp_appgt executable target to install space- FlytFlytAppsOnboardinstall This would allow webmobile apps to execute your installed scripts remotely
install(TARGETS demoapp1DESTINATION FlytFlytAppsOnboardinstall COMPONENT Runtime
)
422 Python
bull Create a directory where you want to keep the source files of your onboard apps
$ mkdir ltsitl_onboard_appsgt
bull Create a directory inside ltsitl_onboard_appsgt for your first app
$ mkdir ltmy_first_python_appgt
bull Create your own ltmy_first_python_appgtpy file You can use the following snippet to start building your app
usrbinenv python
from flyt_python import apinav = apinavigation() instance of flyt navigation class
Write your own logic below
43 Execute custom app
431 CPP
bull After compiling your ltmy_first_cpp_appgt project your executable ltmy_first_cpp_appgt will be created insideltbuildgt directory
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_cpp_appgt cpp executable from terminal
432 Python
bull If FlytSim is not launched launch FlytSim using this command
bull Execute your ltmy_first_python_appgtpy python script from terminal
14 Chapter 4 Onboard App
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
44 Install custom app
441 CPP
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelyrun this command in your terminal
$ sudo cmake -DCOMPONENT=Runtime -P cmake_installcmake
442 Python
To install your app into FlytFlytAppsOnboardinstall space so that your AndroidWeb App could execute it remotelymake your python script executable
$ sudo chmod +x ltmy_first_python_appgtpy
and copy this script to mentioned location
$ sudo cp ltmy_first_python_appgtpy FlytFlytAppsOnboardinstall
44 Install custom app 15
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
16 Chapter 4 Onboard App
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 5
Web and Mobile Apps
51 Introduction
This document deals with the instructions and step by step guide for creating Web and Mobile apps for your DroneThe Web apps can be developed using HTML CSS and JS however in the case of Mobile apps there are two ways ofdoing so The conventional way is to build a mobile app in JAVA using IDEs such as Eclipse or Android Studio Theother way of going about creating mobile apps is to reuse the Web app code ie a simple HTMLCSS and JS projectand convert that into a mobile app using frameworks such as Cordova and Phonegap This allows for sharing the samecodebase for creating cross-platform mobile apps
Here we will delve into the second approach developing a web app with HTML CSS JSJquery and Cordova engineThese apps will allow you to remotely monitor and command your drone You will also see how to get custom datafrom the Drone on your app
The IDE that we have selected for this project is Intellij Idea The GUI and the client side coding is done in HTMLCSS and JSJquery then reusing the code to create mobile apps using Ionic as the front end framework for both Weband Mobile apps
511 Front end Framework
Ionic is free and open source and offers a library of mobile optimized HTML CSS and JS components reusableand customizable UI elements and other tools for building highly interactive mobile appsWe will be using Ionic forthe front end development of Web apps since we will be converting these Web apps into Mobile apps later in thistutorialIonic uses Cordova engine which is a mobile development framework that uses web technologies for crossplatform app development You can refer to Ionic getting started guide for further instructions and to make yourselffamiliarized with the Ionic framework For details about Cordova you can look at their documentation here
Note There are many other Web and Mobile app front end frameworks available You can use any framework thatyou are comfortable with The UI of an app may have to be designed separately for web and mobile for platformspecific optimizations
512 IDE
The IDE that we have used here is IntelliJ IDEA There are many other options available so feel free to use one that youare comfortable with IntelliJ IDEA supports Ionic( Front end framework) and allows you to create PhonegapCordovaprojects Since we will be using both these softwares make sure the IDE that you use supports them For moreinformation on IntelliJ IDEA click here
17
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
52 Development Environment Setup
For a quick start you can follow the steps given below to install Ionic Cordova and IntelliJ IDEA
1 Please install Nodejs v4 (Nodejs v5 does not work at the moment with Ionic) To install nodejs go to this link
2 To install the latest Ionic and Cordova use the following command $ npm install -g cordovaionic
3 Follow the Android and iOS platform guides to install required platform dependencies (SDKs)
Note Follow this step for Mobile app development only iOS development requires Mac OS X iOS simu-lator through the Ionic CLI requires the ios-sim npm package which can be installed with the command sudonpm -g install ios-sim
4 IntelliJ IDEA also requires JDK 7 To install JDK 7 go to this link
5 Go to the link here to install IntelliJ IDEA
53 Creating and Running a Web Application Project
Once all components are setup you can begin app development by creating a new project in IntelliJ IDEA
531 Steps to Create New Project for Web App
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure Static Web is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
18 Chapter 5 Web and Mobile Apps
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
532 Building and Running the Project
You can build and run the app using IntelliJ IDEA in a browser Follow the steps below to do so
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
54 Sample Web Application
Note The source code for the sample webmobile apps is available in github in above mentioned repository for yourreference
Following is a simple demonstration of how to build a Web application for your drone This application allows youto trigger an on-board script that sends commands to your drone to trace a square of user defined dimension We willalso see how to stream live data from your drone
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone trace a square
3 The JS code that calls the on-board script is as follows
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
54 Sample Web Application 19
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
20 Chapter 5 Web and Mobile Apps
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
Live data streaming from drone
In this example we stream live data of location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)
54 Sample Web Application 21
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
Note Please note that you will have to change the IP address in the FlytDemo_web JS file to the IP address ofthe device you run FlytSim on This is required so that data can be received on any external device that you haveconnected
55 Creating and Running a Mobile Application Project
551 Steps to Create New Project for Mobile App
Note Most of the steps involved in creating a Mobile app are similar to that of a Web app except that you will haveto select PhoneGapCordova Project instead of Static Web while creating a new project
Follow the steps below to get create a mobile app
1 Launch IntelliJ IDEA and click on create new project
2 Select Static Web in the new window on the left side
3 Make sure PhoneGapCordova App is selected on the right and click on next
4 Fill up details of your project viz Project Name and Project Location Click on Finish
5 New project opens up You can createedit your HTML CSS and JSJquery files here
The front end of the app is developed in HTML CSS JSJquery using the Ionic components
22 Chapter 5 Web and Mobile Apps
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
To use these components in your app the Ionic libraries have to be included in your HTML files Here is a list of Ionicfiles that have to be included
1 ioniccss
2 ionicmincss
3 ionicbundlejs
4 ionicbundleminjs
5 fonts file
Also include eventemitter2minjs and then roslibjs in your HTML pages
ltscript type=textjavascript src=httpcdnrobotwebtoolsorgEventEmitter2currenteventemitter2minjsgtltscriptgtltscript type=textjavascript src=httpcdnrobotwebtoolsorgroslibjscurrentroslibminjsgtltscriptgt
552 Building and Running the Project
You can build and run the app using IntelliJ IDEA in either a browser based emulator or load the app on your mobiledevice
Running in Browser
bull Go to view
bull Click on the Open in browser option
bull Select the browser of your choice
Running in Device
bull Connect mobile device to computer using a USBuUSB cable
bull Select Specify target in IntelliJ Idea corresponding to your device (Refresh if necessary)
bull Click on Run button to start building your app and to install it on the device
56 Sample Mobile Application
In the earlier section we had built a Web app for the drone we can also build an AndroidiOS application by convertingthis Web app using Cordova This application allows you to trigger an on-board script from a mobile that sendscommand to your drone to trace a square and receive live data from it
Just like in the Web app an on-board script is executed here as well to make the drone navigate in a particular manner
Following are the components for this application
Button to Execute Script
1 Here we create a simple button using the Ionic component lsquoButtonrsquo The HTML code for which is as follows
ltbutton class=button button-block button-positive id=squaregtExecute Squareltbuttongt
2 This button when clicked executes the on-board script which makes the drone form a square
3 The JS code that calls the on-board script is as follows
56 Sample Mobile Application 23
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
$(square)click(function()var msgdata=msgdata[app_name]=app2msgdata[arguments]=3$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+ros+namespace+navigationexec_script
The above mentioned code allows you to execute the on-board script with default square dimension We now see howto use user defined square dimension to do the same
Text-Box for accepting Square dimension
1 First create a text area that accepts input from the user The input here will be the Square dimension Use thefollowing Ionic code for creating the input text box
ltlabel class=item item-inputgtltinput type=text placeholder=Enter Square Dimension id=dimensiongtltlabelgt
2 On clicking the button created in step 1 the dimension set by the user is sent to the on-board script The scriptis then executed and the drone forms a square of the dimension set by the user
24 Chapter 5 Web and Mobile Apps
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
Live data streaming from drone
In this example we request location status from the drone using topic Local Position
1 First create a list using the code given below Ionic provides a collection of lists that can be used
ltdiv class=itemgtltdiv class=rowgt
ltdiv class=col col-20 col-offset-10gtXltdivgtltdiv class=col col-65 col-offset-20 id=posxgtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtYltdivgtltdiv class=col col-65 col-offset-20 id=posygtltdivgt
ltdivgtltdivgtltdiv class=itemgt
ltdiv class=rowgtltdiv class=col col-20 col-offset-10gtZltdivgtltdiv class=col col-65 col-offset-20 id=poszgtltdivgt
ltdivgtltdivgt
2 We have also used the Ionic Grid component in order to arrange the elements of the list
3 Before you can stream data the namespace and websocket have to be set Use the code given below
$ajax(type POSTdataType jsondata JSONstringify(msgdata)url http+ip+rosget_global_namespace
4 And for initializing websocket use the following code snippet
56 Sample Mobile Application 25
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
var ros = new ROSLIBRos(url ws+ip+websocket) roson(connection function() consolelog(Connected to websocket server)) roson(error function(error) consolelog(Error connecting to websocket server error)) roson(close function() consolelog(Connection to websocket server closed))
5 The JS to initialize Local Position topic and to subscribe to it is as follows The data is being displayed in theHTML list
var listenerLocalPosition = new ROSLIBTopic(ros rosname +namespace+mavroslocal_positionlocalmessageType geometry_msgsTwistStampedthrottle_rate 200)listenerLocalPositionsubscribe(function(message) $(posx)html(messagetwistlinearx)$(posy)html(messagetwistlineary)$(posz)html(messagetwistlinearz)
)
26 Chapter 5 Web and Mobile Apps
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
56 Sample Mobile Application 27
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
Note Please note that you will have to change the IP address in the FlytDemo JS file to the IP address of the deviceyou run FlytSim on This is required so that data can be received on any external device that you have connected
28 Chapter 5 Web and Mobile Apps
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 6
About FlytOS
FlytOS is the software framework of Flyt It is based on Linux and ROS (Robot Operating System) making it an idealplatform for research and commercial drone applications It can interact with any compatible droneautopilot using itsadapter layer and exposes high level FlytAPIs in ROS CPP Python REST and Websocket It makes it easy to integratecustom payload and also provides advanced APIs using its onboard modules These rich set of APIs allow for easydevelopment of onboard business logic as well as remote monitoring and control through web and mobile apps Themodular design of FlytOS allows for integration with external ROSLinux libraries and custom data plumbing betweenonboard and offboard apps
FlytOS will come preloaded with FlytPOD Alternately it will also be available for download and can then be installedon a LinuxROS based computer This setup allows for integration with any compatible droneautopilot
The apps developed with FlytAPIs can talk to compatible droneautopilot as well as can be tested in a virtualROSGazebo environment using FlytSim The vision of FlytOS is to provide a standard language for the drone devel-opers to talk to their drones
29
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
30 Chapter 6 About FlytOS
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 7
List of APIs
This document lists out all the available FlytAPIs
71 Navigation APIs
These APIs can be used to send navigational commands to the vehicle and access telemetry data from the vehicle
711 Commands
These are the list of available APIs for sending commands to the vehicle
bull Arm (onboard) (REST)
bull Disarm (onboard) (REST)
bull Takeoff (onboard) (REST)
bull Land (onboard) (REST)
bull Position Setpoint (onboard) (REST)
bull Velocity Setpoint (onboard) (REST)
bull Attitude Setpoint (onboard) (REST)
bull Position HoldLoiterHover (onboard) (REST)
bull Execute Onboard CPPPython Script (onboard) (REST)
bull Waypoint Handling
ndash Send Waypoints
ndash Get Waypoints
ndash Clear Waypoints
ndash Jump to a specific Waypoint
ndash Pause Waypoints
ndash ExecuteResume Waypoints
31
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
712 Access Telemetry Data
These are the list of available APIs for accessing telemetry data from the vehicle
bull Attitude
ndash Euler (onboard) (REST)
ndash Quaternion (onboard) (REST)
bull Position
ndash Local NED Frame (onboard) (REST)
ndash Global LLA Frame (onboard) (REST)
72 Parameter Handling APIs
These APIs help you in tweaking system parameters
bull Get Global Namespace
bull Param Create
bull Param Set
bull Param Get
bull Param Get_all
bull Param Delete
bull Param Save
bull Param Load
73 Setup APIs
These APIs help you in setting up your vehicle This FlytAPI documentation is under construction
bull Sensor Calibration
bull ESC Calibration
bull RC Calibration
bull Actuator Testing
bull Autopilot Reboot
74 Vision APIs
These APIs provide image capture API and some image processing APIs This FlytAPI documentation is underconstruction
32 Chapter 7 List of APIs
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 8
FlytAPI - onboard
FlytAPIs have been extended from ROS to CPP Python REST and Websocket This document describes all theavailable onboard(ROSCPPPython) FlytAPIs in details
Caution This guide is under active development
81 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
811 ARM
Danger This command might turn on the motors if their ESCs are powered up
This API arms the vehicle passes controller outputs to the mixer
ROS
Service Name flytsimnavigationarm
Service Type core_apiArm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationarm
33
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
CPP
int Navigationarm(void)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navarm())
coutltltSystem ARMEDelse
coutltltFailed to ARM system
Python
navigationarm(self)
Returns 0 if the vehicle gets ARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navarm()
812 Disarm
This API disarms the vehicle disconnects controller outputs from the mixer
ROS
Service Name flytsimnavigationdisarm
Service Type core_apiDisarm below is its description
Request NULLResponse return success=true if command is successful
---bool success
Usage
rosservice call flytsimnavigationdisarm
CPP
int Navigationdisarm(void)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
34 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navif(navdisarm())
coutltltSystem DISARMEDelse
coutltltFailed to DISARM system
Python
navigationdisarm(self)
Returns 0 if the vehicle gets DISARMED else returns 1
Usage
from flyt_python import apinav = apinavigation()navdisarm()
813 TakeOff
This API sends takeoff command to the autopilot The API accepts takeoff_alt argument which specifies the TakeOffheight in meters above the current positon It must always be a positive quantity
Note This API runs in synchronous mode which means the API call wonrsquot return unless either the provided take-off_alt is achieved or timeout(30secs) called
ROS
Service Name flytsimnavigationtake_off
Service Type core_apiTakeOff below is its description
Request expects take off altitude in metresResponse returns success=true is takeoff altitude is reached
float32 takeoff_alt---bool success
Usage
rosservice call flytsimnavigationtake_off takeoff_alt 30
CPP
int Navigationtake_off(float takeoff_alt = 50)
Parameters
bull takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
81 Navigation APIs 35
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavtake_off(30)
Python
navigationtake_off(self takeoff_alt = 50)
Parameters takeoff_alt ndash TakeOff Altitude in meters with default value of 50
Returns 0 if the vehicle reaches takeoff_alt before timeout=30sec else returns 1
Usage
from flyt_python import apinav = apinavigation()navtake_off(30)
814 Land
This API sends land command to the autopilot Currently you cannot send arbitrary position coordinates to land onthe vehicle considers its current local position at the time of triggering this command as its landing coordinates
Note This API runs in asynchronous mode which means the API call would return as soon as landing command hasbeen sent to the autopilot irrespective of whether the vehicle has landed or not
ROS
Service Name flytsimnavigationland
Service Type core_apiLand below is its description
Request NULLResponse return success=true if Land command sent successfully to autopilot
---bool success
Usage
rosservice call flytsimnavigationland
CPP
int Navigationland(void)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
36 Chapter 8 FlytAPI - onboard
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavland()
Python
navigationland(self)
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navland()
815 Position Setpoint
This API sends position setpoint command to the autopilot Additionally you can send yaw setpoint (yaw_valid flagmust be set true) to the vehicle as well Some abstract features have been added such as toleranceacceptance-radiussynchronousasynchronous mode sending setpoints relative to current position (relative flag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the positionsetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationposition_set
Service Type core_apiPositionSet below is its description
Request expects position setpoint via twisttwistlinearxlinearylinearzRequest expects yaw setpoint via twisttwistangularz (send yaw_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
int8 SETPOINT_TYPE_POSITION = 0int8 SETPOINT_TYPE_TAKEOFF = 3int8 SETPOINT_TYPE_LAND = 4
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_validint8 setpoint_type---bool success
Usage
81 Navigation APIs 37
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
rosservice call flytsimnavigationposition_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 10 y 35 z -50angular x 00 y 00 z 05
tolerance 00async falserelative falseyaw_valid truesetpoint_type 0
sends (xyz)=(1035-50) yaw=012 tolerance=10m relative=false async=false yaw_valid=truedefault value of tolerance=10m if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters default value=10m
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
38 Chapter 8 FlytAPI - onboard
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
bull tolerance (float) ndash Acceptance radius in meters default value=10m
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
816 Velocity Setpoint
This API sends velocity setpoint command to the autopilot Additionally you can send yaw_rate setpoint(yaw_rate_valid flag must be set true) to the vehicle as well Some abstract features have been added such astoleranceacceptance-radius synchronousasynchronous mode sending setpoints relative to current velocity (relativeflag must be set true)
Tip Asynchronous mode - The API call would return as soon as the command has been sent to the autopilotirrespective of whether the vehicle has reached the given setpoint or not
Tip Synchronous mode - The API call would wait for the function to return which happens when either the velocitysetpoint is reached or timeout=30secs is over
ROS
Service Name flytsimnavigationvelocity_set
Service Type core_apiVelocitySet below is its description
Request expects velocity setpoint via twisttwistlinearxlinearylinearzRequest expects yaw_rate setpoint via twisttwistangularz (send yaw_rate_valid=true)Response return success=true (if async=false ampamp if setpoint reached before timeout = 30sec) || (if async=true ampamp command sent to autopilot)
geometry_msgsTwistStamped twistfloat32 tolerancebool asyncbool relativebool yaw_rate_valid---bool success
Usage
rosservice call flytsimnavigationvelocity_set twistheaderseq 0stamp secs 0 nsecs 0frame_id
twistlinear x 05 y 02 z -01angular x 00 y 00 z 01
81 Navigation APIs 39
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
tolerance 0async falserelative falseyaw_rate_valid true
sends (vxvyvz)=(0502-01) yaw_rate=01 tolerance=10ms relative=false async=false yaw_rate_valid=truedefault value of tolerance=10ms if left at 0
CPP
int position_set(float x float y float z float yaw_setpoint = 0 float tolerance = 0 bool relative = falsebool async = false bool yaw_valid = false)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint ndash Yaw Setpoint in radians
bull yaw_valid ndash Must be set to true if yaw setpoint is provided
bull tolerance ndash Acceptance radius in meters
bull relative ndash If true position setpoints relative to current position is sent
bull async ndash If true asynchronous mode is set
Returns For async=true returns 0 if the command is successfully sent to the vehicle else returns1 For async=false returns 0 if the vehicle reaches given setpoint before timeout=30secs elsereturns 1
Usage
include ltcore_script_bridgenavigation_bridgehgt
Navigation navnavposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
Python
navigationposition_set(self x y z yaw=00 tolerance=00 relative=False async=Falseyaw_valid=False)
Parameters
bull xyz ndash Position Setpoint in NED-Frame
bull yaw_setpoint (float) ndash Yaw Setpoint in radians
bull yaw_valid (bool) ndash Must be set to true if yaw setpoint is provided
bull tolerance (float) ndash Acceptance radius in meters
bull relative (bool) ndash If true position setpoints relative to current position is sent
bull async (bool) ndash If true asynchronous mode is set
Returns 0 if the land command is successfully sent to the vehicle else returns 1
Usage
40 Chapter 8 FlytAPI - onboard
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
from flyt_python import apinav = apinavigation()navposition_set(10 35 -50 012 50 false false true)sends (xyz)=(1035-50) yaw=012 tolerance=50m relative=false async=false yaw_valid=true
81 Navigation APIs 41
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
42 Chapter 8 FlytAPI - onboard
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
CHAPTER 9
FlytAPI - RESTWebsocket
FlytAPIs have been extended from ROS to REST and Websocket This document describes all the availableRESTWebsocket FlytAPIs in details
Caution This guide is under active development
91 Navigation APIs
These APIs allows you to have navigational control over your vehicle and also provides vehicle telemetry data forfurther processing
911 Namespace
This namespace is a part of the url for all other rest calls and websocket connectionThis has to be the first rest callbefore any other rest call or web socket connection
43
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
REST
URL
httpltipgtrosget_global_namespaceltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falseparam_info
param_value [String]
true command accepted by system and returnsnamespaceparam_info the namespace value
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosget_global_namespacerdquosuccess function(data)
consolelog(data)
)
912 Arm
Arming the drone means you are ready to fly In this mode the controller outputs are passed to the mixer
44 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
REST
URL
httpltipgtrosnavigationarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system armsfalse command rejected by system and system remainsdisarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationarmrdquosuccess function(data)
consolelog(data)
)
913 Disarm
Disarming the drone means you have finished flying and the drone can be handled and safe to approach In disarmedstate the drone does not react to any RC inputs given or mission execution commands
91 Navigation APIs 45
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
REST
URL
httpltipgtrosnavigationdisarmltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and system disarmsfalse command rejected by system and system remainsarmed
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationdisarmrdquosuccess function(data)
consolelog(data)
)
914 Takeoff
Takeoff command arms the drone and the drone hovers at a given height Height is provided as a parameter to this APIcall
46 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
91 Navigation APIs 47
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
REST
URL
httpltipgtrosnavigationtake_offltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
takeoff_alt [numeric float]
Examplemsgdata=
takeoff_alt 300
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone takesofffalse command rejected by system and system remainsas it is
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotakeoff_altrdquo]=400$ajax(
type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosrdquo+namespace+rdquonavigationtake_offrdquosuccess function(data)
consolelog(data)
)48 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
915 Land
Land command brings th e drone down to the specified local coordinated This does not disarm the system
REST
URL
httpltipgtrosnavigationlandltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone landsfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationlandrdquosuccess function(data)
consolelog(data)
)
91 Navigation APIs 49
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
916 Hover
This command commands the vehicle to hover at the current location It overrides any previous mission being carriedout and starts hovering
REST
URL
httpltipgtrosnavigationposition_holdltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the dronehovering at a locationfalse command rejected by system and systemcontinues with current mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
$ajax(type ldquoPOSTrdquodataType ldquojsonrdquodata JSONstringify(msgdata)url ldquohttpltipgtrosnavigationposition_holdrdquosuccess function(data)
consolelog(data)
)
50 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
917 Position Setpoint
This command commands the vehicle to go to a specified location and hover It overrides any previous mission beingcarried out and starts hovering
91 Navigation APIs 51
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
52 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
REST
URL
httpltipgtrosnavigationposition_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move towards the defined locationfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationposition_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear x yz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The radial value within which the setpoint isconsidered reachedrelative Decides whether the give xyz coordination aresupposed to be taken relative to the current location
or relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
91 Navigation APIs 53
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
918 Velocity Setpoint
This command commands the vehicle to attain a specified velocity in the specified direction It overrides any previousmission being carried out
54 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
91 Navigation APIs 55
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
REST
URL
httpltipgtrosnavigationvelocity_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
linearx [numeric float]y [numeric float]z [numeric float]
angular
z [numeric float]
tolerance [numeric float]async [boolean]relative [boolean]yaw_valid [boolean]
Example
msgdata=twist
twistlinear
x 200y 300z -100
angular
z 10
tolerance 200async truerelative falseyaw_valid true
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the set velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquolinearrdquo]=msgdatatwisttwistlinear[rdquoxrdquo]=200msgdatatwisttwistlinear[rdquoyrdquo]=300msgdatatwisttwistlinear[rdquozrdquo]=-100msgdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquozrdquo]=100msgdata[rdquotolerancerdquo]=200msgdata[rdquoasyncrdquo]=truemsgdata[rdquorelativerdquo]=falsemsgdata[rdquoyaw_validrdquo]=true
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationvelocity_setrdquosuccess function(data)
consolelog(data)
)
NOTE
linear xyz xyz local position coordinates withrespect to NEDangular z used for heading when yaw_valid set totruetolerance The range with respect to set velocity withinwhich the setpoint is considered reachedrelative Decides whether the given xyz coordinationare supposed to be taken relative to the current locationor relative to originyaw_valid Decides whether to use angular z value fordeciding the setpoint heading or just use defaultheading
56 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
919 Attitude Setpoint
This command commands the vehicle to attain a specified attitude It overrides any previous mission being carriedout
91 Navigation APIs 57
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
58 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
REST
URL
httpltipgtrosnavigationattitude_setltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
twisttwist
angularx [numeric float]y [numeric float]z [numeric float]
thrust [numeric float]
Example
msgdata=twist
twistlinear
x 200y 300z -100
thrust 60000
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsto move to to attain the given velocityfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquotwistrdquo]=msgdatatwist[rdquotwistrdquo]=masdatatwisttwist[rdquoangularrdquo]=msgdatatwisttwistangular[rdquoxrdquo]=200msgdatatwisttwistangular[rdquoyrdquo]=300msgdatatwisttwistangular[rdquozrdquo]=-100msgdata[rdquothrustrdquo]=60000
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationattitude_setrdquosuccess function(data)
consolelog(data)
)
NOTE
angular xyz roll pitch yaw values for attitudesetpoint
91 Navigation APIs 59
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
9110 Execute Script
This command commands the vehicle to perform a predefined or user defined scripts when called with specific appname and its respective parameters It overrides any previous mission being carried out
60 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
91 Navigation APIs 61
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
REST
URL
httpltipgtrosnavigationexec_scriptltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090ltnamespacegt Name of the flytpod (default flytpod)which is required for every rest call and can be
fetched from get namespace rest call
METHOD GET POSTDATA PARAMS
data JSONstringify(msgdata)msgdata=
app_name [String]arguments [String]
Example
msgdata=app_name ldquoapp12rdquoarguments ldquo2 45 4 runrdquo
SUCCESS RESPONSE
Code 200Content
success true falsetrue command accepted by system and the drone startsexecuting the scriptfalse command rejected by system and systemcontinues with existing mission
ERROR RESPONSE
Code 404resource not found
SAMPLE CALL
var msgdata=msgdata[rdquoapp_namerdquo]= ldquoapp12rdquomsgdata[rdquoargumentsrdquo]= ldquo2 45 4 runrdquo
$ajax(type ldquoGETrdquodataType ldquojsonrdquodata JSONstringify(msgdata)urlldquohttpltipgtrosltnamespacegtnavigationexec_scriptrdquosuccess function(data)
consolelog(data)
)
NOTE
app_name The name of the script to be executedarguments List of arguments required by the scriptsent in a single string seperated by spaces
62 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
9111 Websocket Initiallisation
Websocket needs to be initialised once in every session It requires additional libraries eventemitterjs and roslibjsto be included in case of web based client
Socket
URL
wsltipgtwebsocketltipgt IP of the flytpod in the network along with port
eg 192168xxxx9090
SAMPLE CALL
var ros= new ROSLIBRos(url lsquowsltipgtwebsocketrsquo
)
roson(lsquoconnectionrsquo function() consolelog(lsquoConnected to websocketserverrsquo)
)
roson(lsquoerrorrsquo function() consolelog(lsquoError connecting towebsocket serverrsquo error)
)
roson(lsquoclosersquo function() consolelog(lsquoConnection to websocketserver closedrsquo)
)
9112 Attitude data
Fetches real time attitude data at required rate To be done after initialization of websocket
91 Navigation APIs 63
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerImu = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavrosimudatarsquomessageType lsquosensor_msgsImursquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messageorientationx)consolelog(messageorientationy)consolelog(messageorientationz)consolelog(messageorientationw)consolelog(messageangular_velocityx)consolelog(messageangular_velocityy)consolelog(messageangular_velocityz)consolelog(messagelinear_accelerationx)consolelog(messagelinear_accelerationy)consolelog(messagelinear_accelerationz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required attitude datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
9113 Local Position data
Fetches real time local position data at required rate To be done after initialization of websocket
64 Chapter 9 FlytAPI - RESTWebsocket
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
Socket
INITIALISATION SAMPLE
var listenerLocalPosition = new ROSLIBTopic(ros rosname lsquoltnamespacegtmavroslocal_positionlocalrsquomessageType lsquogeometry_msgsTwistStampedrsquothrottle_rate 200
)
ltnamespacegt Name of the flytpod (default flytpod)which is required for every socket subscription and canbe fetched from get namespace rest call
SUBSCRIPTION SAMPLE
listenerImusubscribe(function(message) consolelog(messagetwistlinearx)consolelog(messagetwistlineary)consolelog(messagetwistlinearz)consolelog(messagetwistangularx)consolelog(messagetwistangulary)consolelog(messagetwistangularz)
)
NOTES
ros Pointed to the ros object created in theinitialization of a web socket connectionname Requires the name of the topic which gives outthe required datamessageType Set the type of predefined data structureused to deliver the required local position datathrottle_rate Sets the rate at which callbacks are calledin miliseconds
91 Navigation APIs 65
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
FlytDocs Release
66 Chapter 9 FlytAPI - RESTWebsocket
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67
Index
Aapi 32 41api_list 29
Nnavigationarm() (built-in function) 34navigationdisarm() (built-in function) 35navigationland() (built-in function) 37navigationposition_set() (built-in function) 38 40navigationtake_off() (built-in function) 36Navigationarm (C++ function) 34Navigationdisarm (C++ function) 34Navigationland (C++ function) 36Navigationtake_off (C function) 35
Pposition_set (C++ function) 38 40
67