Register your drone as a device type into IoT Server

OK, first things first. If you need more about WSO2 IoT Server, go ahead and read this . If you want to create a new device type start from scratch for the WSO2 IoT Server I advice you to read these articles: Creating a new device type for WSO2 IoT Server via the Maven Archetype and In depth of device plugin in WSO2 IoT Server.

In this article I will explain how to run this as a simulator.

1. What is going on under the hood?

I would call it as drone analyzer rather controller or something else. Drone analyzer is designed for monitoring real time stats coming from the device, do some batch analytics on drone stream after storing considerable amount of data and real time decision making basted on predefined conditions on drone stream. Last point which I mentioned is quite interesting right? If you read this entirely. You will definitely have a idea how this is being done. Before look into what is happening in depth, let’s look at basic architectural diagram how this thing works.

Figure 01

Sometime drones come with an interface where we can fetch code into drone and test what we intended do with it. But most of the time drone manufactures don’t allow to upload third party code into drones. So that is why in the figure 01, there are two ways you can send drone current stats into message broker. Anyhow there should be a way to get drone current stats and push data into message broker. In this sample implementation there is an agent which gets drone stats and push data to message broker through MQTT.

Before going further if you don’t have any idea about event stream, event receiver, execution plan and event store please read section 3 on this and follow rest of this article.

In here, let’s define s1 as org.wso2.iot.devices.droneStats. That is event stream name. Event receiver which subscribes to a given particular topic and then event publisher is used to get published data on this stream. Here a UI publisher is connected through web socket in order to get real time feeds which agent is publishing. Here is the event stream agent is publishing.

"name": "org.wso2.iot.devices.droneStats",
"version": "1.0.0",
"nickName": "droneStats",
"description": "droneStats data received from the Device",
"metaData": [
"payloadData": [
{"name": "quatanium_val_q1", "type": "DOUBLE"},
{"name": "quatanium_val_q2", "type": "DOUBLE"},
{"name": "quatanium_val_q3", "type": "DOUBLE"},
{"name": "quatanium_val_q4", "type": "DOUBLE"},
{"name": "velocity_x", "type": "DOUBLE"},
{"name": "velocity_y", "type": "DOUBLE"},
{"name": "velocity_z", "type": "DOUBLE"},
{"name": "global_location_lat", "type": "DOUBLE"},
{"name": "global_location_alt", "type": "DOUBLE"},
{"name": "global_location_lon", "type": "DOUBLE"},
{"name": "battery_level", "type": "DOUBLE"},
{"name": "battery_voltage", "type": "DOUBLE"},
{"name": "pitch", "type": "DOUBLE"},
{"name": "roll", "type": "DOUBLE"},
{"name": "yaw", "type": "DOUBLE"}

Obviously this might be varied according to your drone. But next article will explain how to map customize event stream to existing event stream using an execution plain.

2. Install this device type into IoT Server

To install this device type plugin, First download WOS2 IoT Server and copy the downloaded file to a preferred location and unzip it. The unzipped folder rename as IOTS_HOME. Drone analyzer sample implementation you can find out in IOTS_HOME/samples folder. In order to install this you need to configure the device-deployer.xml file that is in the IoTS_HOME directory. More information about how to configure and install it into IoT server follow this.

3. Register and Simulate Drone Analyzer

Access the device management console. Example: https://localhost:9443/devicemgt. Then you will see the newly created device type in the device page similar to this.

Then click on try button in order to view device type page.

To download and register your drone, click on download button then drone agent will be downloaded.

To try out the drone analyzer, type running downloaded agent by copying the downloaded agent to a preferred location and unzip it. Afterwords start agent application run with root privileges. It will ask some questions and then chose run as simulator.

Then go to device view page in order to view current stats of drone. Here is the snapshot I have taken.

To view analytics of this device, click on ‘View Device Analytics’ button lower left corner.