Arquivos
NodeCopterHack/node_modules/ar-drone/journal/2012-11-06.md
T
2013-08-10 13:15:52 +01:00

1.6 KiB

I want to improve the API for the library to help with a few things:

  • debugging
  • logging
  • ease of use

The new API I imagine would be like this:

var client = arDrone.createClient()
client.control.takeoff(function(err, result) {
  client.control.up(1);

  console.log(client.toJSON());
  // {
  // navdata: { ... },
  // control: { ... },
  // }

});

Separation of APIs

client.navdata.on('data');
client.control.on('data');
client.video.on('data');
var h264 = client.video.h264();

Logging

Another important aspect is to get logging right. I could imagine this to work:

client.log.tsv('prefix');
client.log.json('file');

Control

Let's define the control API

control.upDown     = 0;
control.leftRight  = 0;
control.frontBack  = 0;
control.upDown     = 0;
control.fly        = 0;
control.emergency  = 0;
control.configs    = [];

Nadata

navdata.batteryPercentage = 0;
navdata.altitudeMeters    = 0;

Output folder

/example /navdata.tsv /control.movement.tsv /control.config.tsv /log.txt

Re-desiging the AT interface

client.control.atUdpStream.write(message);
client.control.atUdpStream.on('data', function(message) {
  // message.id keeps track of the packet number
  // message.commands holds individual at commands
});
atMessage.write(new AtCommand('ref', 121, 12));
atMessage.write(new AtCommand('pcmd', 121, 12));

More thinking on message / at command streams:

var commands [
  atCommandSequence.ref(...),
  atCommandSequence.pcmd(...),
  atCommandSequence.config(...),
];

var message = atMessageSequence.next(commands);
return message;