gpsar.drone

Get GPS data from Ar Drone 2.0


I need the real time GPS coordinates from the AR Drone 2.0 which has the flight recorder in it.And i couldn't find any method to get the values from GPS directly. Is there any way i could get the GPS data from the AR Drone


Solution

  • Here is what's working for me:

    var arDrone = require('ar-drone');
    var droneClient = arDrone.createClient();
    droneClient.config('general:navdata_demo', 'FALSE'); // get back all data the copter can send
    droneClient.config('general:navdata_options', 777060865); // turn on GPS
    
    droneClient.on('navdata', function(navdata) {
       console.log(navdata.gps.latitude + ', ' + navdata.gps.longitude);
       // do stuff with the GPS information....
    });
    droneClient.takeoff(); .....
    

    This code alone did not get me the GPS information. I also had to comment out part of the parseNavdata.js (in ar-drone/lib/navdata) code. Look for: "'gps': function(reader) {" ~line 546 in my file. Comment out the bottom half of that function:

    'gps': function(reader) {
        return {
          latitude:             reader.double64(),
          longitude:            reader.double64(),
          elevation:            reader.double64(),
          hdop:                 reader.double64(),
          data_available:       reader.int32(),
          unk_0:                timesMap(8, reader.uint8, reader),
          lat0:                 reader.double64(),
          lon0:                 reader.double64(),
          lat_fuse:             reader.double64(),
          lon_fuse:             reader.double64(),
          gps_state:            reader.uint32(),
          unk_1:                timesMap(40, reader.uint8, reader),
          vdop:                 reader.double64(),
          pdop:                 reader.double64(),
          speed:                reader.float32(),
          last_frame_timestamp: droneTimeToMilliSeconds(reader.uint32()),
          degree:               reader.float32(),
          degree_mag:           reader.float32()
    //      unk_2:                timesMap(16, reader.uint8, reader),
    //      channels:             timesMap(12, reader.satChannel, reader),
    //      gps_plugged:          reader.int32(),
    //      unk_3:                timesMap(108, reader.uint8, reader),
    //      gps_time:             reader.double64(),
    //      week:                 reader.uint16(),
    //      gps_fix:              reader.uint8(),
    //      num_satellites:       reader.uint8(),
    //      unk_4:                timesMap(24, reader.uint8, reader),
    //      ned_vel_c0:           reader.double64(),
    //      ned_vel_c1:           reader.double64(),
    //      ned_vel_c2:           reader.double64(),
    //      pos_accur_c0:         reader.double64(),
    //      pos_accur_c1:         reader.double64(),
    //      pos_accur_c2:         reader.double64(),
    //      speed_accur:          reader.float32(),
    //      time_accur:           reader.float32(),
    //      unk_5:                timesMap(72, reader.uint8, reader),
    //      temperature:          reader.float32(),
    //      pressure:             reader.float32()
        };
    

    Other posts (https://github.com/felixge/node-ar-drone/issues/75) imply that this has been fixed and merged, but that must not be the case.