Code your drone: How to add additional hardware to Flyver

The Flyver team continues to do amazing work growing their offerings and we are excited to be partnering with them in sharing their insights.  For those of you familiar with Flyver, or those of you with a software development background looking to make your drone do some amazing things, read on and, in this article you will learn how to add additional hardware to Flyver.

In Flyver all sensors and outputs are connected to the Flyver Message Queue. This makes the system very flexible and scalable, allowing for all kinds of devices to work with the SDK

Flyver Configuration I

IOIO OTG Sensors

Android / Java

Adding new IOIO sensors requires basic knowledge about input/outputs. This article assumes familiarity with the topic and that the user will be able to select the right pins.

Wire your sensor to the IOIO OTG board.

  1. Add a new class under FlyverCore -> statedata -> IOOISensors
  2. Extend the IOIOSensor class.
  3. Register pins under setup(). Details could be find under the IOIO OTG documentation
  4. Write your input data gathering under the loop of process(). Details could be find under the IOIO OTG documentation
  5. Send data thorough the message queue with sendData(Object); This data follows the selected topic and could be obtained back from anywhere though the consumer interface of the message queue.
  6. Initialize sensor under FlyverCore -> BaseApp.java

Existing sensor implementations There are already implementations of few sensors which could be used and modified easily. FlyverCore -> statedata -> IOIOSensors

Example:

public class UsRangeFinder extends IOIOSensor{

private int triggerPin;
private int echoPin;
float distance;
private PwmOutput trigger; // Ultrasonic range finder trigger
private PulseInput echo;  // Ultrasoni range finder echo

public UsRangeFinder(String TOPIC, int triggerPin, int echoPin) {
    super(TOPIC);
    this.triggerPin = triggerPin;
    this.echoPin = echoPin;

}

@Override
public void setup(IOIO ioio_) throws ConnectionLostException {

    echo = ioio_.openPulseInput(echoPin, PulseInput.PulseMode.POSITIVE);
    trigger = ioio_.openPwmOutput(triggerPin,16);

}

@Override
public void process(IOIO ioio_) throws ConnectionLostException, InterruptedException {

    trigger.setPulseWidth(8000);
    distance = (echo.getDuration() * 1000 * 1000 ) / 29f / 2f;
    if (distance>2 && distance < 700){
        sendData(distance);
    }
}
}

Getting the sensor data example

public class FloorDistanceSensor implements FlyverMQConsumer {
											

Peter Mihaylov

Description: Peter is the head content creator for the drone startup Flyver. The company’s goal is to create a unified SDK and marketplace that will allow developers to create and publish apps that will work on any drone. Right now the Flyver SDK is in beta stage, but you can subscribe to their mailing list and monitor their progress here.

float distance;

/* Constants */
public static String TOPIC = “distance”;
/* End of */

public LocationServicesSubsciber(){
MainController.getInstance().getMessageQueue().registerConsumer(this, TOPIC);
}
@Override
public void dataReceived(FlyverMQMessage message) {
distance = (Float) message.data;
}
}

IOIO OTG Outputs

  1. Add a new class under FlyverCore -> microcontrollers -> IOOIOutputs
  2. Extend the IOIOOutput class.
  3. Register pins under setup(). Details could be find under the IOIO OTG documentation
  4. Write your output data under the loop of process(). Details could be find under theIOIO OTG documentation
  5. Initialize output under FlyverCore -> BaseApp.java

Android USB Devices

Android naturally supports many USB devices which could be used. At this moment Flyver SDK does not have support for devices which are not supported by Android. Support of depth cameras, infrared cameras and more is expected.

Related posts

Leave a Comment