Industriële fabricage
Industrieel internet der dingen | Industriële materialen | Onderhoud en reparatie van apparatuur | Industriële programmering |
home  MfgRobots >> Industriële fabricage >  >> Manufacturing Technology >> Productieproces

AR Drone 2.0 + 1Sheeld: Real-time vluchtdata streaming naar PC

Onderdelen en benodigdheden

Arduino Mega 2560 × 2
1Sheeld × 1
AR Drone 2.0 × 1
XBee modules × 2

Over dit project

Dit project laat zien hoe je diverse vluchtgegevens die worden vastgelegd door een smartphone in real-time naar je kunt streamen. Denk aan versnellingsmeter, GPS-positie, geluidsniveau, oriëntatie, gyroscoop en meer.

We gebruiken twee Arduino's voor datacontrole: een gemonteerd op de drone en een aangesloten op de computer. Twee XBee-modules zorgen voor de draadloze communicatie van de 1Sheeld-data naar je PC.

Een leuke en toegankelijke manier om alle sensoren en functionaliteiten van je smartphone te benutten, en tegelijkertijd mooie luchtfoto's te maken!

Code

Master Code (C/C++)

Deze code laad je op de Arduino die verbonden is met de PC. Deze stuurt de Arduino op de drone.

Eerst moet je de AltSoftSerial-bibliotheek downloaden: https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

#include <AltSoftSerial.h>
int verifica=0;
AltSoftSerial xBee;
char c;
char h;
char stop='s';

void setup() {
  Serial.begin(115200);
  Serial.println("Master OK");
  Serial.println();
  Serial.println("Toets in voor:");
  Serial.println("'o' oriëntatiesensor waarde");
  Serial.println("'a' versnellingsensor waarde");
  Serial.println("'b' helderheidssensor waarde");
  Serial.println("'g' GPS positie");
  Serial.println("'m' microfoon geluid");
  Serial.println("'p' een foto maken");
  xBee.begin(9600);
}

void loop() {
  Serial.flush();
  if (Serial.available()>0) {
    c = Serial.read();
    if(c=='o'||c=='a'||c=='m'||c=='g'||c=='b'||c=='p'){
      // Orienteeringsdata
      if(c=='o'){
        Serial.println("Oriëntatie");
        c='1';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='o';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          } while(xBee.available()>0);
          delay(100);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analyse gestopt");
            c='0';
            Serial.println();
            Serial.println("Toets in voor:");
            Serial.println("'o' oriëntatiesensor waarde");
            Serial.println("'a' versnellingsensor waarde");
            Serial.println("'b' helderheidssensor waarde");
            Serial.println("'g' GPS positie");
            Serial.println("'m' microfoon geluid");
            Serial.println("'p' een foto maken");
            xBee.print(c);
            i=11;
          }
        }
      }
      // Versnellingsdata
      if(c=='a'){
        Serial.println("Versnelling");
        c='2';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='a';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          } while(xBee.available()>0);
          delay(100);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analyse gestopt");
            c='0';
            Serial.println();
            Serial.println("Toets in voor:");
            Serial.println("'o' oriëntatiesensor waarde");
            Serial.println("'a' versnellingsensor waarde");
            Serial.println("'b' helderheidssensor waarde");
            Serial.println("'g' GPS positie");
            Serial.println("'m' microfoon geluid");
            Serial.println("'p' een foto maken");
            xBee.print(c);
            i=11;
          }
        }
      }
      // Helderheidsdata
      if(c=='b'){
        Serial.println("Helderheid");
        c='3';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='b';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          } while(xBee.available()>0);
          delay(50);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analyse gestopt");
            c='0';
            Serial.println();
            Serial.println("Toets in voor:");
            Serial.println("'o' oriëntatiesensor waarde");
            Serial.println("'a' versnellingsensor waarde");
            Serial.println("'b' helderheidssensor waarde");
            Serial.println("'g' GPS positie");
            Serial.println("'m' microfoon geluid");
            Serial.println("'p' een foto maken");
            xBee.print(c);
            i=11;
          }
        }
      }
      // GPS-data
      if(c=='g'){
        Serial.println("GPS Positie");
        c='4';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='g';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          } while(xBee.available()>0);
          delay(500);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analyse gestopt");
            c='0';
            Serial.println();
            Serial.println("Toets in voor:");
            Serial.println("'o' oriëntatiesensor waarde");
            Serial.println("'a' versnellingsensor waarde");
            Serial.println("'b' helderheidssensor waarde");
            Serial.println("'g' GPS positie");
            Serial.println("'m' microfoon geluid");
            Serial.println("'p' een foto maken");
            xBee.print(c);
            i=11;
          }
        }
      }
      // Microfoon data
      if(c=='m'){
        Serial.println("Microfoon");
        c='5';
        xBee.print(c);
        for(int i=0; i<10;i++){
          delay(20);
          c='m';
          xBee.print(c);
          do{
            h=0;
            h=xBee.read();
            Serial.print(h);
          } while(xBee.available()>0);
          delay(100);
          i=i-1;
          if(Serial.available()>0);
          if(stop==Serial.read()){
            Serial.println("Analyse gestopt");
            c='0';
            Serial.println();
            Serial.println("Toets in voor:");
            Serial.println("'o' oriëntatiesensor waarde");
            Serial.println("'a' versnellingsensor waarde");
            Serial.println("'b' helderheidssensor waarde");
            Serial.println("'g' GPS positie");
            Serial.println("'m' microfoon geluid");
            Serial.println("'p' een foto maken");
            xBee.print(c);
            i=11;
          }
        }
      }
      // Foto maken
      if(c=='p'){
        Serial.println("Foto maken");
        c='6';
        xBee.print(c);
        delay(20);
        c='p';
        Serial.println();
        Serial.println("Toets in voor:");
        Serial.println("'o' oriëntatiesensor waarde");
        Serial.println("'a' versnellingsensor waarde");
        Serial.println("'b' helderheidssensor waarde");
        Serial.println("'g' GPS positie");
        Serial.println("'m' microfoon geluid");
        Serial.println("'p' een foto maken");
        xBee.print(c);
      }
    }
  }
}

Slave Code (C/C++)

Deze code laad je op de Arduino die op de drone gemonteerd is. Deze verzamelt de data en stuurt deze naar de grondstation.

Benodigde bibliotheken:

#include <OneSheeld.h>
#include <AltSoftSerial.h>

char variabele;
AltSoftSerial xBee;
char master;
int voce=0;

void setup(){
  Serial.begin(115200);
  Serial.println("Slave ok");
  OneSheeld.begin();
  xBee.begin(9600);
}

void loop(){
  receiveEvent();
  requestEvent();
}

void receiveEvent(){
  while(xBee.available()>0){
    master=xBee.read();
    variabele=master;
  }
}

void requestEvent(){
  if(variabele=='o'){
    xBee.print("As X: ");
    xBee.print(OrientationSensor.getX());
    xBee.print(" As Y: ");
    xBee.print(OrientationSensor.getY());
    xBee.print(" As Z: ");
    xBee.println(OrientationSensor.getZ());
    variabele=0;
  }
  if(variabele=='a'){
    xBee.print("As X: ");
    xBee.print(AccelerometerSensor.getX());
    xBee.print(" As Y: ");
    xBee.print(AccelerometerSensor.getY());
    xBee.print(" As Z: ");
    xBee.println(AccelerometerSensor.getZ());
    variabele=0;
  }
  if(variabele=='g'){
    xBee.print("Lengtegraad: ");
    xBee.print(GPS.getLongitude());
    xBee.print(" Breedtegraad: ");
    xBee.println(GPS.getLatitude());
    variabele=0;
  }
  if(variabele=='m'){
    xBee.print("dB: ");
    xBee.println(Mic.getValue());
    variabele=0;
  }
  if(variabele=='b'){
    xBee.print("Lumen: ");
    xBee.println(LightSensor.getValue());
    variabele=0;
  }
  if(variabele=='p'){
    Camera.setFlash(ON);
    Camera.rearCapture();
    xBee.println("Foto gemaakt");
    variabele=0;
  }
  // Spraaksynthese feedback
  if(variabele=='1'){ TextToSpeech.say("analyse oriëntatie"); variabele=0; }
  if(variabele=='2'){ TextToSpeech.say("analyse versnelling"); variabele=0; }
  if(variabele=='3'){ TextToSpeech.say("analyse helderheid"); variabele=0; }
  if(variabele=='4'){ TextToSpeech.say("analyse GPS positie"); variabele=0; }
  if(variabele=='5'){ TextToSpeech.say("analyse decibel geluid"); variabele=0; }
  if(variabele=='6'){ TextToSpeech.say("foto aan het maken"); variabele=0; }
  if(variabele=='0'){ TextToSpeech.say("analyse gestopt"); variabele=0; }
}

Schema

Dit is de verbinding tussen Arduino en XBee, hetzelfde voor de Arduino die verbindt met de computer en de Arduino op de drone.

AR Drone 2.0 + 1Sheeld: Real-time vluchtdata streaming naar PC

Productieproces

  1. Drone Pi: Een Dual-Mode Multiwii & Raspberry Pi Quadcopter voor Smartphone en Remote Besturing
  2. AI kartografieert informele nederzettingen wereldwijd vanaf lage-resolutie satellietbeelden
  3. Onderhoudsdocumentatie onder de knie: Een betrouwbare aanpak om je assets te beschermen
  4. Moet u uw pomp coaten? De voor- en nadelen afwegen
  5. Nauwkeurigheid & Prestaties Van Uw Waterstraalsnijmachine Verbeteren
  6. De Cloud Revolutie: Hoe Cloud Computing IT, Beveiliging en Carrières Transformeert
  7. Hoe Smartphones de Toekomst van Connected Cars Vormgeven
  8. 6 Manieren Waarop AI & IoT Bedrijfsoperaties Revolusioneren in 2019
  9. Edge Computing & IoT Strategie Inzichten van IoT World 2019
  10. Elbit Systems: Leidende composietoplossingen voor Israël en de VS
  11. Evolutie van de Wereldwijde Kleurstofindustrie: Eco-vriendelijke Shifts, Regulatorische Strengheid en Technologische Innovatie