eschnou / ardrone-autonomy

Provides key building blocks to create autonomous flight applications with the #nodecopter (AR.Drone).
http://eschnou.github.com/ardrone-autonomy
MIT License
152 stars 53 forks source link

Validate EKF inputs #3

Closed eschnou closed 10 years ago

eschnou commented 11 years ago

Not sure how this can happen, but it seems the ekf can be called with malformed data. Anyway, it would be good practice to check data input.


/home/ganeshk/node-ar-drone/node_modules/ardrone-autonomy-master/lib/EKF.js:37
    var pitch = data.demo.rotation.pitch.toRad()
                         ^
TypeError: Cannot read property 'rotation' of undefined
    at EKF.predict (/home/ganeshk/node-ar-drone/node_modules/ardrone-autonomy-master/lib/EKF.js:37:26)
    at Controller._processNavdata (/home/ganeshk/node-ar-drone/node_modules/ardrone-autonomy-master/lib/Controller.js:248:15)
    at Client.<anonymous> (/home/ganeshk/node-ar-drone/node_modules/ardrone-autonomy-master/lib/Controller.js:60:18)
    at Client.EventEmitter.emit (events.js:95:17)
    at Client._handleNavdata (/home/ganeshk/node-ar-drone/node_modules/ar-drone/lib/Client.js:114:8)
    at UdpNavdataStream.EventEmitter.emit (events.js:95:17)
    at UdpNavdataStream._handleMessage (/home/ganeshk/node-ar-drone/node_modules/ar-drone/lib/navdata/UdpNavdataStream.js:71:10)
    at Socket.EventEmitter.emit (events.js:98:17)
    at UDP.onMessage (dgram.js:437:8)
jessecravens commented 11 years ago

Seeing the same issue.

peterjaap commented 10 years ago

I've found the problem; the Controller tries to load the data.demo object which contains all the pitch etc information before the AR Drone has instantialized it and filled it with data. So, in Controller.js, replace line 58 which reads;

if (!this._busy) {

with;

if (!this._busy && d.demo) {

And you're good to go!