Skip to content

Commit

Permalink
added video
Browse files Browse the repository at this point in the history
  • Loading branch information
nheidloff committed Jan 7, 2016
1 parent e5a5e53 commit c7da8d6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -10,7 +10,9 @@ In order to run this project I used the [Anki Overdrive](https://anki.com/en-us/

![alt text](https://raw.githubusercontent.com/IBM-Bluemix/node-mqtt-for-anki-overdrive/master/screenshots/photo-small.jpg "Photo")

Disclaimer: I followed the documentation on the [Anki Drive SDK](http://developer.anki.com/drive-sdk/docs/programming-guide) site. The code below works for my current setup. I haven't checked other platforms, firmeware versions etc. For some data, esp. the offsets, I had to guess how to interpretate the data from the cars since I hadn't found any documentation.
[![Video](screenshots/video.jpg)](https://www.youtube.com/watch?v=Wo4zeQxxOOI)

Disclaimer: I followed the documentation on the [Anki Drive SDK](http://developer.anki.com/drive-sdk/docs/programming-guide) site. The code below works for my current setup. I haven't checked other platforms, firmware versions etc. For some data, esp. the offsets, I had to guess how to interpretate the data from the cars since I hadn't found any documentation.

Author: Niklas Heidloff [@nheidloff](http://twitter.com/nheidloff)

Expand Down Expand Up @@ -90,6 +92,8 @@ In order to understand the collision prevention feature you need to understand h

![alt text](https://raw.githubusercontent.com/IBM-Bluemix/node-mqtt-for-anki-overdrive/master/screenshots/offset.jpg "Offset")

![alt text](https://raw.githubusercontent.com/IBM-Bluemix/node-mqtt-for-anki-overdrive/master/screenshots/tracks.jpg "Tracks")

I've developed a simple sample that shows that GroundShock and Skull can never collide. The cars send status updates about their current offset which is tracked in the cloud (Node-RED flow). When Skull (red car) wants to turn left the flow checks whether it would still have enough distance to GroundShock (blue car) and vise versa.

![alt text](https://raw.githubusercontent.com/IBM-Bluemix/node-mqtt-for-anki-overdrive/master/screenshots/collision-prevention2.png "Collision Prevention")
22 changes: 17 additions & 5 deletions receivedMessages.js
Expand Up @@ -38,7 +38,7 @@ module.exports = function() {
}

else if (messageId == '25') {
// example: tbd
// example: <Buffer 05 19 6e 26 00 00>
var desc = 'Version Received';
var version = data.readUInt16LE(2);
console.log('Message: ' + messageId, data, desc + ' - version: ' + version);
Expand All @@ -56,7 +56,7 @@ module.exports = function() {
}

else if (messageId == '27') {
// example: tbd
// example: <Buffer 03 1b 50 0f>
var desc = 'Battery Level Received';
var level = data.readUInt16LE(2);
console.log('Message: ' + messageId, data, desc + ' - level: ' + level);
Expand All @@ -76,17 +76,29 @@ module.exports = function() {
else if (messageId == '39') {
// example: <Buffer 10 27 21 28 48 e1 86 c2 02 01 47 00 00 00 02 fa 00>
var desc = 'Localization Position Update Received';
var pieceLocation = data.readUInt8(2);
var pieceId = data.readUInt8(3); // in my starter kit:
// 1 x straight: 36
// 1 x straight: 39
// 1 x straight: 40
// 1 x curve: 20
// 1 x curve: 23
// 2 x curve: 18
// 2 x curve: 17
// 1 x start/finish: 34 (long) and 33 (short)
var offset = data.readFloatLE(4);
var speed = data.readUInt16LE(8);
console.log('Message: ' + messageId, data, desc + ' - offset: ' + offset + ' speed: ' + speed);

console.log('Message: ' + messageId, data, desc + ' - offset: ' + offset + ' speed: ' + speed + ' - pieceId: ' + pieceId + ' pieceLocation: ' + pieceLocation);;
if (mqttClient) {
mqttClient.publish('iot-2/evt/' + messageId + '/fmt/json', JSON.stringify({
"d" : {
"description" : desc,
"date": date,
"offset": offset,
"speed": speed
"speed": speed,
"pieceId": pieceId,
"pieceLocation": pieceLocation
}
}), function () {
});
Expand Down
Binary file added screenshots/tracks.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/video.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c7da8d6

Please sign in to comment.