felixge / node-ar-drone

A node.js client for controlling Parrot AR Drone 2.0 quad-copters.
http://nodecopter.com/
MIT License
1.76k stars 428 forks source link

A GPS example #94

Closed ibekmezci closed 10 years ago

ibekmezci commented 10 years ago

I am a new developer for Ar Drone. I am trying to develop a waypoint based navigation project. Can you give a sample code for accessing GPS data from Ar Drone?

wiseman commented 10 years ago

Once you've activated GPS in navdata (see issue #75), you can access it like any other navdata:

client.on('navdata', function(navdata) {
  console.log(navdata.gps.latitude + ', ' + navdata.gps.longitude + ', ' + navdata.gps.elevation);
});

I haven't used GPS data much, but a few other things you might want to consider:

See https://github.com/felixge/node-ar-drone/blob/master/lib/navdata/parseNavdata.js#L546 for the complete set of GPS data (requires AR.Drone firmware 2.4.8).

Finally, reliable and accurate waypoint navigation is probably best handled on-board the vehicle, so you can get a faster feedback loop and not worry quite so much about losing the comms link. AR.Drone supports this functionality via the mavlink protocol: You can upload waypoints and then have the drone execute a mission following those waypoints (I think). You can use a ground control station like QGroundControl to do this, or you can write your own code that uses the mavlink waypoint protocol--MAVProxy is a bunch of Python code that would help with that, or you could try one of the node mavlink implementations (e.g. https://github.com/omcaree/node-mavlink).