-
Notifications
You must be signed in to change notification settings - Fork 427
Add remaining navdata options #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
95cd887
Make JSHint happy.
efc4841
Add lookup for detection types.
6b08477
Add flying modes
dfdb6b3
Add new types based on structs from C SDK.
bac622c
Add two utility functions.
ddde825
Alter `demo` navdata block.
b613e99
Use `droneTimeToMilliseconds` utility function.
154d4c9
Be consistent with `gyrometers`
9877ea0
Alter `demo` navdata block.
7ca3214
Add all missing navdata blocks (`magneto`, `windSpeed`, `games`, etc).
2f89091
Add functions required for dealing with navdata masks.
c2c6615
Addressing spacing and syntax errors from a borked commit.
01e008e
Need to supply context b/c NavdataReader methods use `this`.
d1d3dc5
Remove detritus which is causing errors.
ae85943
Adding items which, somehow, were omitted from 7ca3214.
af8c0d8
Not entirely sure this is correct, but going with it.
d8d5af6
chaining
0e10a64
config test
ff9be5c
s/gyrometers/gyroscopes/g
7d73d46
Whitespace change
a14ff5c
Display wifi signal strength as a percentage
c8cfd40
Adding some example scripts
cc061b9
Updated to resemble `examples/png-stream.js`.
28b868d
Whitespace change.
86ee70c
Missed one in ff9be5c.
074e839
Merge branch 'master' of git://github.com/Contra/node-ar-drone
6fefecb
Try to ensure we're only calling properties of the passed object.
8a32645
Maintain consistency across examples.
0cdd93a
Clean up `png-stream-replace` example.
f97da77
fix the `navdata.demo` tests I broke.
8f71098
Fix `navdata.rawMeasures` tests I broke.
ae591cf
Reverting to approach that allows test to pass.
7e80cad
Fix two typos in the `navdata` keys.
3a4b716
Add two properties for navdata option masks.
f3a5900
Some guesses about units for various navdata properties.
b84a4f5
It's already in the `rawMeasures` object, it doesn't need `Raw` as as…
4a87e5b
It's in the `rawMeasures` object. It doesn't need `Raw` as a suffix, …
136eae4
Revert "It's in the `rawMeasures` object. It doesn't need `Raw` as a …
ef89029
And so ends, "`rebase -i` Fail. A four-commit play", by John Schulz.
0508a55
Be consistent. Units are not included in other keys.
7261424
Rollback d8d5af6 (especially b/c it's involved in felixge/#28).
e0b18c2
Revert "config test"
513dd17
Maintain consistent formatting.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var arDrone = require('..'); | ||
var constants = require('../lib/constants'); | ||
var maskingFunctions = require('../lib/navdata/maskingFunctions'); | ||
var TAG_TYPE_MASK = maskingFunctions.TAG_TYPE_MASK; | ||
var maskFromNavdataOptions = maskingFunctions.maskFromNavdataOptions; | ||
|
||
// get a reference to the drone | ||
var client = arDrone.createClient(); | ||
|
||
// log all errors | ||
client.on('error', function (err) { | ||
console.log('ERROR:', err); | ||
}); | ||
|
||
// increase the frequency of the navadata updates | ||
client.config('general:navdata_demo', 'FALSE'); | ||
|
||
// control the keys in the navdata | ||
var optionsMask = maskFromNavdataOptions( | ||
constants.options.DEMO, | ||
constants.options.VISION_DETECT, | ||
constants.options.EULER_ANGLES | ||
); | ||
client.config('general:navdata_options', optionsMask); | ||
|
||
// detect multiple tag types | ||
client.config('detect:detect_type', constants.CAD_TYPE.MULTIPLE_DETECTION_MODE); | ||
|
||
// look for oriented roundel underneath | ||
var vMask = TAG_TYPE_MASK(constants.TAG_TYPE.H_ORIENTED_ROUNDEL); | ||
client.config('detect:detections_select_v', vMask); | ||
|
||
// look for a shell tag in front | ||
var hMask = TAG_TYPE_MASK(constants.TAG_TYPE.SHELL_TAG_V2); | ||
client.config('detect:detections_select_h', hMask); | ||
|
||
// log navdata | ||
client.on('navdata', console.log); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var arDrone = require('..'); | ||
var constants = require('../lib/constants'); | ||
var maskingFunctions = require('../lib/navdata/maskingFunctions'); | ||
var maskFromNavdataOptions = maskingFunctions.maskFromNavdataOptions; | ||
|
||
// get a reference to the drone | ||
var client = arDrone.createClient(); | ||
|
||
// log all errors | ||
client.on('error', function (err) { | ||
console.log('ERROR:', err); | ||
}); | ||
|
||
// increase the frequency of the navadata updates | ||
client.config('general:navdata_demo', 'FALSE'); | ||
|
||
// control the keys in the navdata | ||
var optionsMask = maskFromNavdataOptions( | ||
constants.options.DEMO, | ||
constants.options.VISION_DETECT, | ||
constants.options.EULER_ANGLES | ||
); | ||
client.config('general:navdata_options', optionsMask); | ||
|
||
// detect multiple tag types | ||
client.config('detect:detect_type', constants.CAD_TYPE.ORIENTED_ROUNDEL); | ||
|
||
// set the drone's "flying mode" | ||
var flyingMode = constants.FLYING_MODE.HOVER_ON_TOP_OF_ORIENTED_ROUNDEL; | ||
client.config('control:flying_mode', flyingMode); | ||
|
||
// set the altitude where the drone should hover | ||
var millimeters = 1000; | ||
client.config('control:hovering_range', millimeters); | ||
|
||
// log navdata | ||
client.on('navdata', console.log); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Run this to receive a png image stream from your drone. | ||
|
||
var arDrone = require('..'); | ||
var http = require('http'); | ||
var server = http.createServer(function(req, res) { | ||
|
||
var pngStream; | ||
if (!pngStream) { | ||
pngStream = arDrone.createPngStream(); | ||
pngStream.on('error', function (err) { | ||
console.error('pngStream ERROR: ' + err); | ||
}); | ||
} | ||
|
||
var boundary = 'boundary'; | ||
res.writeHead(200, { | ||
'Content-Type': 'multipart/x-mixed-replace; boundary=' + boundary | ||
}); | ||
|
||
pngStream.on('data', function writePart(pngBuffer) { | ||
// part header | ||
res.write('--' + boundary + '\n'); | ||
res.write('Content-Type: image/png\n'); | ||
res.write('Content-length: ' + pngBuffer.length + '\n'); | ||
res.write('\n'); | ||
// part body | ||
res.write(pngBuffer); | ||
}); | ||
}); | ||
|
||
var port = 8080; | ||
server.listen(port, function () { | ||
console.log('Serving latest png on', port); | ||
}); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var arDrone = require('..'); | ||
var client = arDrone.createClient(); | ||
client.createRepl(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var arDrone = require('..'); | ||
var client = arDrone.createClient(); | ||
|
||
// return all navdata | ||
client.config('general:navdata_demo', 'FALSE'); | ||
|
||
// log navdata | ||
client.on('navdata', function (navdata) { | ||
console.log('// NAVDATA\n', navdata); | ||
}); | ||
|
||
client.on('error', function (err) { | ||
console.log('ERROR:', err); | ||
}); | ||
|
||
client | ||
.after(2*1000, function () { | ||
console.log('// TAKEOFF\n'); | ||
this.takeoff(); | ||
}) | ||
.after(8*1000, function () { | ||
console.log('// LAND\n'); | ||
this.land(); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var constants = require('../constants'); | ||
|
||
exports.NAVDATA_NUM_TAGS = Object.keys(constants.options).length; | ||
exports.NAVDATA_OPTION_FULL_MASK = (1<<exports.NAVDATA_NUM_TAGS) - 1; | ||
|
||
exports.TAG_TYPE_MASK = function (tagtype) { | ||
return (tagtype == 0) ? 0 : 1 << (tagtype - 1); | ||
}; | ||
|
||
exports.NAVDATA_OPTION_MASK = function (option) { | ||
return 1 << option; | ||
}; | ||
|
||
exports.maskFromNavdataOptions = function (options) { | ||
if (!Array.isArray(options)) { | ||
options = Array.prototype.slice.call(arguments); | ||
} | ||
|
||
var masks = options.map(exports.NAVDATA_OPTION_MASK); | ||
var mask = masks.reduce(function (prev, curr) { | ||
return prev | curr; | ||
}); | ||
|
||
return mask; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet example. I'm happy to merge it along with this patch, but it doesn't really belong to it I think.