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

how to access accelerometer data? #139

Closed koalapenguins closed 7 years ago

koalapenguins commented 7 years ago

Hi! I'm new here, so i'll do my best to ask clearly

Is there a function to access the accelerometer readings/data of the AR.Drone?

i have a feeling it's in the navdata part of this library, but i can't exactly find the function specifically for accelerometers

wiseman commented 7 years ago

You can get the attitude of the drone, is that sufficient? It's in navdata.demo.rotation. For example, this code (from https://github.com/wiseman/ardrone-browser-3d) computes a rotation matrix from the Euler angles in navdata.demo.rotation:

Drone.prototype.updateState = function(navdata) {
  var euler = navdata.demo.rotation;
  var m = new THREE.Matrix4();
  // I couldn't find documentation on the AR.Drone Euler angle order,
  // but this seems to work.
  m.makeRotationFromEuler(new THREE.Vector3(euler.roll * PI180,
                                            euler.yaw * -PI180,
                                            euler.pitch * PI180),
                          'YZX');
  this.matrix = m;
  this.matrixAutoUpdate = false;
  this.updateMatrixWorld(true);
};