Introduction: How to Build a Mobile App for Your Drone
Gone are the days where drones were used only for taking pictures and videos. Nowadays, you can perform a variety of meaningful tasks using your drone. Drones are starting to automate tasks in many industries like agriculture, construction, photography, disaster management and real estate. Knowing how to build your own custom application, goes a long way in helping you achieve these tasks
In this post, I will tell you how you can develop your own mobile app for your Drone. I will be using FlytOS, a software framework provided by FlytBase. FlytOS is an ideal platform to develop research and commercial drone applications.
Step 1: Setup Your FlytBase Account and Download FlytSDK
The first thing you do is setup a FlytBase account. It's free and takes less than a minute.
Once your FlytBase account is up and running, go and download the android FlytSDK.
FlytSDK provides you with necessary pre-integrated client libraries. It also has an inbuilt mechanism for establishing a connection with the drone.
Step 2: Setup Android Studio and Start Developing Your App
Above is the image of the sample app I created using FlytAPIs and FlytSDK. You can find the source code on github. The FlytSDK has the required libraries for making a REST call and a websocket connection to FlytOS already integrated into it. I am making a simple android app which will give my drone two basic commands - to take off and to land. I will also set the option to set the take off altitude.
Here is my code for the take off command:
private class TakeOffRequest extends AsyncTask<Void, Void, String> { private Double takeoff_alt; public TakeOffRequest(Double val) { takeoff_alt = val; } @Override protected String doInBackground(Void... params) { try { //Rest url final String url = "http://"+ip+"/ros/"+namespace+"/navigation/take_off"; //params in json JSONObject param= new JSONObject(); param.put("takeoff_alt",takeoff_alt); //restTemplate object initialise for rest call RestTemplate restTemplate = new RestTemplate(); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); // make the rest call and recieve the response in "response" String response = restTemplate.postForObject(url,param.toString(), String.class); return response; } catch (Exception e) { Log.e("MainActivity", e.getMessage(), e); } return null; } //function called after a successful rest call @Override protected void onPostExecute(String response) { if (response!="") { try { //initialise a JSON object with the response string JSONObject resp = new JSONObject(response); //extract the required field from the JSON object // namespace=resp.getJSONObject("param_info").getString("param_value"); if (resp.getBoolean("success")) { Toast.makeText(getApplicationContext(), "Taking Off.", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Take Off rejected.", Toast.LENGTH_SHORT).show(); } } catch (JSONException | NullPointerException e) { } }else{ Toast.makeText(getApplicationContext(), "Failed to contact FlytPOD. Retry Take Off!", Toast.LENGTH_SHORT).show(); } } }
You can refer to android FlytSDK and start developing your own app here
Step 3: Download and Install FlytSIM and Test Your App
FlytSIM is a ROS-Gazebo environment where you get a simulated version of your drone application. It is a great tool to test your drone app before the first flight. FlytSIM gives you an idea how your drone will behave in the real world.
You can find the step-by-step guide to install FlytSIM here.
Every app you develop using FlytSDK will require you to enter the IP address of the device running FlytSIM(usually your laptop).
After installing FlytSIM, run it on your system and connect it to your Wi-Fi network. Connect your phone to the same Wi-Fi network and launch your app.
Now, you can start testing your application in the simulation environment.
While testing, be sure to check all the functionalities as it is a great way to find out bugs/errors if any.
Step 4: Install FlytOS on Your Companion Computer for Your Drone
Here is a step-by-step guide to install FlytOS . It supports multiple companion computers and provides dedicated support. Choose the companion computer you are using from the list, and download FlytOS. Once the installation is complete, you must activate the license for the navigation APIs to work. It's free to use.
Now, you are ready for your first flight.
Step 5: Get Ready for Field Test
Once the FlytOS is setup and your drone is ready, you can test your custom app. If you have followed the steps correctly, everything should work as expected.
Before you fly, be sure to check out the safety guidelines.
Congratulations you have successfully developed and deployed your own mobile app for your drone.
You can refer FlytAPI for further development and assistance.
Happy Flying!