XDK110
For the XDK we are going to open XDK Workbench, and we select use Mita Language.
You can copy from Tello/python/FlyControl/XDKTello/XDK/application.mita
/**
* Welcome to XDK LIVE.
*
* Not sure what to do now?
* Check out the "Getting started" guide in the Eclipse help.
*/
package main;
import platforms.xdk110;
var ban: int32;
var banlux: int32;
// Create a wireless connection named 'wireless'
setup wireless : WLAN {
ssid = "";
ipConfiguration = Dhcp();
authentification = Personal(psk = "");
}
// Create a MQTT instance
setup messaging : MQTT {
transport = wireless;
url = "mqtt://broker.hivemq.com:1883"; // Try differents brokers iot.eclipse.org, etc.
cleanSession = true;
clientId = "xdk110"; //Define your userID
var action = topic("xdk110/tello/action",1); //Define your own topic
}
//Flags that would help to block some actions.
every XDK110.startup {
ban = 0;//1 Derecha, 2 Izquierda, 3 Adelante, 4 Atras, 5 Izquierda y 6 Derecha
banlux = 0;
}
// When button one is pressed, send text via MQTT
every button_one.pressed {
messaging.action.write("takeoff"); //Drone Takeoff
}
every button_two.pressed {
messaging.action.write("land"); //Drone land
}
// Make a setup of sensors to get good data
setup Gyroscope_BMG160 {
range = Range_250s;
bandwidth = Bw_12Hz;
}
setup Gyroscope_BMI160 {
range = Range_250s;
bandwidth = BW_10_7Hz;
}
setup accelerometer{
}
//When XDK detect a single tap, drone fly up
every accelerometer.single_tap{
messaging.action.write("up");
}
//When XDK detect a double tap, drone fly down
every accelerometer.double_tap{
messaging.action.write("down");
}
//This function would run every 100 milliseconds.
//We read the input of gyroscope in the three dimensions, and whatever we detect we send an action to drone.
every 100 milliseconds {
var x = gyroscope.x_axis.read();
var y = gyroscope.y_axis.read();
var z = gyroscope.z_axis.read();
if(x>200 && ban!=1){ //X
//println('right');
messaging.action.write("right");
ban=1;
}else if(x<-200 && ban!=2){
//println('left');
messaging.action.write("left");
ban=2;
}else if(y>200 && ban!=3){//Y
//println('forward');
messaging.action.write("forward");
ban=3;
}else if(y<-200 && ban!=4){
//println('back');
messaging.action.write("back");
ban=4;
}else if(z>200 && ban!=5){//Z
//println('cw');
messaging.action.write("cw");
ban=5;
}else if(z<-200 && ban!=6){
//println('ccww');
messaging.action.write("ccww");
ban=6;
}
if(light.intensity.read() < 100 && banlux!=1){
messaging.action.write("flip");
banlux=1;
}
}
//We use this function to free the variable banlux, so we could request another time.
every 40 seconds{
banlux=0;
}
We need to flash this program to XDK and we wait so XDK could Connect to wifi and start publishing.
Error Fix WorkBench 3.4.0
We could present errors using some events from Accelerometer in workbench version 3.4.0
Accelerometer Fix - src-gen/SensorAccelerometer.c
in static void BMA280_IsrCallback, replace CmdProcessor_Enqueue with CmdProcessor_EnqueueFromIsr
in SensorAccelerometer_Enable, replace INTR_DISABLE with INTR_ENABLE
Last updated