nodequad

Aeroquad

declaration
Aeroquad

Option name Type Description
uri string An URI to connect to (optional)
opts.driver object The driver instance to use (one of Aeroquad.drivers; see lib/drivers)
opts.protocol object The protocol instance to use (one of Aeroquad.protocols; see lib/protocols)
config object An optional flight configuration object, if not specified the configuration under etc/config.json will be used

The Nodequad object representing the state and control of a single vehicle. The returned instance is a subclass of event emitter and allows wildcard events.

var Aeroquad = module.exports = function Aeroquad(uri, opts, config) {
	events.EventEmitter2.call(this, { wildcard: true });

	opts = opts || {};

state

property
this.state

State object of available stateful properties which can be subscribed to for streaming of data

this.state = {
		vehicle: {
			roll:  		undefined,
			pitch: 		undefined,
			yaw:   		undefined,
			throttle:   undefined,
			mode:       undefined,
			aux1:       undefined,
			aux2:       undefined,
			aux3:       undefined,
			aux4:       undefined
		},

		mag: {
			x: undefined,
			y: undefined,
			z: undefined
		},

		gps: {
			state: 	   undefined,
			lat: 	   undefined,
			lon: 	   undefined,
			height:    undefined,
			course:    undefined,
			speed:     undefined,
			accuracy:  undefined,
			sats:      undefined,
			fixtime:   undefined,
			sentences: undefined,
			idlecount: undefined
		},

		battery: {
			voltage: 		undefined,
			current: 		undefined,
			used_capacity: 	undefined
		},

		rssi: undefined
	};

Events from the protocol and driver are propogated so they are observeable on the nodequad object.

this.comm.driver.on('*.*', passEvents('driver.'));
	this.comm.protocol.on('*.*', passEvents('protocol.'));

	this.comm.protocol.on('config.**', passEvents());
	this.comm.protocol.on('state.**', passEvents());

getDriver

method
Aeroquad.prototype.getDriver() ->Object

Returns the current working driver

Aeroquad.prototype.getDriver = function getDriver() {
	return this.comm.driver;
};

getProtocol

method
Aeroquad.prototype.getProtocol() ->Object

Returns the current working protocol

Aeroquad.prototype.getProtocol = function getProtocol() {
	return this.comm.protocol;
};

connect

method
Aeroquad.prototype.connect()

Option name Type Description
uri String uri to connect (optional; driver defaulted)
cb Function

Connect to the vehicle

Aeroquad.prototype.connect = function connect(uri, cb) {
	this.comm.driver.connect(uri, cb);
};

probe

method
Aeroquad.prototype.probe()

Option name Type Description
probeResultsCb Function callback to receive probe results after timeout has expired for all ports
connectCb Function if a callback is passed, automatically connect to first found vehicle and return once connected

Probe attached ports for an available vehicle, may also chain .andConnect() to connect to first found vehicle

Aeroquad.prototype.probe = function probe(probeResultsCb, connectCb) {
	var self = this;
	this.comm.driver.probe(probeResultsCb, connectCb);
};

sync

method
Aeroquad.prototype.sync()

Option name Type Description
path String of config or state to sync, wildcards supported

Sync a config or state path from vehicle (preferring vehicle data as source of truth)

Aeroquad.prototype.sync = function sync(path) {
	this.comm.protocol.sync(path);
};

stream

method
Aeroquad.prototype.stream() ->Object

Option name Type Description
path String of config or state to stream, wildcards supported

Begin or end streaming of data from vehicle

Aeroquad.prototype.stream = function stream(path) {
	this.comm.protocol.stream(path);

	return {
		pause: function pause() {
			this.comm.protocol.pauseStream(path);
		}
	};
};

Vector

method
Aeroquad.Vector()

Option name Type Description
x Integer
y Integer
z Integer

Creates and returns an instance of Aeroquad.Vector

Aeroquad.Vector = function vector() {
	var instance = Object.create(Vector.prototype);
	Vector.apply(instance, Array.prototype.slice.call(arguments));
	return instance;
};

protocols

property
Aeroquad.protocols

Available protocols to use

Aeroquad.protocols = protocols;

drivers

property
Aeroquad.drivers

Available communication drivers to use

Aeroquad.drivers   = drivers;