How do I get latitude info from ar drone using nodejs?

310 Views Asked by At

When I use this I get an undefined error. latitude is undefined.

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(); .....

However if I change 1 line I can get back all gps data.

console.log(navdata.gps);

Why can't I just get back the latitude data specifically?

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);
   // do stuff with the GPS information....
});
droneClient.takeoff(); .....
1

There are 1 best solutions below

0
Yusril Dewantara On

you have to call gps first, use "if(navdata.gps){}, then put the gps property on it. but the result is 0. even using the number to activated the gps. the value of latitude and longitude will be "0".