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

Added calibrate command to UdpControl and Client #51

Closed wiseman closed 11 years ago

wiseman commented 11 years ago

Added a new AT command, "CALIB", which according to the SDK docs "asks the drone to calibrate the magnetometer (must be flying)."

Tested from a repl. Note that this causes the drone to yaw 360 degrees.

The command takes a single argument, which is a device number. Currently the only device the SDK defines is the magnetometer, which is device number 0.

yocontra commented 11 years ago

What was your use case for adding this? Just curious

wiseman commented 11 years ago

I want to be able to get accurate magnetometer/compass/heading info for things like augmented reality overlays and display on the ardrone-webflight HUD.

wiseman commented 11 years ago

Note that to enable magnetometer values in navdata, you need to do

function navdata_option_mask(c) {
  return 1 << c;
}

// From the SDK.
var default_navdata_options = (
  navdata_option_mask(arDroneConstants.options.DEMO) |
  navdata_option_mask(arDroneConstants.options.VISION_DETECT));

client.config('general:navdata_options',
              default_navdata_options |
              navdata_option_mask(arDroneConstants.options.MAGNETO));

This implies it might be useful to add a navdata_option_mask function and export the constants from node-ar-drone.

yocontra commented 11 years ago

LGTM - just needs some documentation on the README

yocontra commented 11 years ago

Also I agree we should be exporting the constants (and as much as possible) from the module. Looking forward to a PR for that

felixge commented 11 years ago

@wiseman :sparkling_heart: thx for the patch!