hybridgroup / node-bebop

A Node.js client for controlling Parrot Bebop & Bebop2 quadcopters.
http://nodebebop.com
MIT License
146 stars 61 forks source link

mavlink.start not working? #25

Closed Mezcall closed 8 years ago

Mezcall commented 8 years ago

Hello,

I'm trying to run a flightPlan in mavlink format, but i get an error: It seems that this lib cannot parse the string? there is no write method in string type.

Code and error description bellow.

code: var obj = { filepath: "flightPlan.mavlink", type:"flightPlan" }; drone.Mavlink.start(obj);

error: \node_modules\node-bebop\lib\commandToBuffer.js:64 types[part.type].write(buffer, parseInt(part.value, 10), offset); ^

TypeError: types[part.type].write is not a function at path..\node_modules\node-bebop\lib\commandToBuffer.js:64:22 at Array.forEach (native) at writeBuffer (path..\node_modules\node-bebop\lib\commandToBuffer.js:61:11) at module.exports (path..\node_modules\node-bebop\lib\commandToBuffer.js:73:10) at Mavlink.start (path..\node_modules\node-bebop\lib\Mavlink.js:13:16) at path..\node_modules\node-bebop\examples\mavlink.js:11:19 at null. (path..\node_modules\node-bebop\lib\bebop.js:255:7) at null. (path..\node_modules\node-bebop\lib\bebop.js:273:5) at emitOne (events.js:77:13) at Socket.emit (events.js:169:7)

Thank you

deadprogram commented 8 years ago

OK, here is where I'm at:

I've updated 2 of the examples examples/events.js and examples/flightplan.js

The event named "AvailabilityStateChanged" seems to be the one that indicates that the drone is ready to start an autopilot sequence.

Here was my output:

$ node examples/events.js 
ready
69
landed
unknown <Buffer 01 0a 02 00 00 00 00 00 00 00 00 00 00>
ComponentStateListChanged { component: 'Calibration', State: 1 }
ComponentStateListChanged { component: 'GPS', State: 0 }
ComponentStateListChanged { component: 'Mavlink_File', State: 1 }
ComponentStateListChanged { component: 'TakeOff', State: 1 }
AvailabilityStateChanged { AvailabilityState: 0 }
MavlinkFilePlayingStateChanged { state: 'stopped',
  filepath: '/data/ftp/internal_000/flightplans/flightPlan.mavlink\u0000\u0000\u0000\u0000\u0000',
  type: 'unknown enum' }
GPSFixStateChanged { fixed: 0 }
68
67
66
65
64
63
62
GPSFixStateChanged { fixed: 1 }
ComponentStateListChanged { component: 'GPS', State: 1 }
AvailabilityStateChanged { AvailabilityState: 1 }
This is where we would try to call Mavlink.start()
61
60

https://github.com/hybridgroup/node-bebop/blob/bugfix/mavlink-commands/examples/events.js#L26

So I modified examples/flightplan.js to take this into account, however it is night here now, and I cannot try any more autopilot antics until daylight.

However, this might work https://github.com/hybridgroup/node-bebop/blob/bugfix/mavlink-commands/examples/flightplan.js#L28

brunoua commented 8 years ago

As soon as stop raining here I test. If you can test before me, tell me something please.

Regards

brunoua commented 8 years ago

@deadprogram I tested the flightplan.js however, even will all conditions met, the state is paused... Once you get to test there, tell me something please.

deadprogram commented 8 years ago

You got a different state than stopped? Please paste your output.

deadprogram commented 8 years ago

I've got it working. Give me a few minutes to fix another error, and test a few more things out.

brunoua commented 8 years ago

I just have the stopped state... Now i cant run it to have the output. If you have this working please tell me how Thanks

deadprogram commented 8 years ago

OK get the latest code I just pushed, it should work for you:

$ node examples/flightplan.js                                                                                                                      
ready
BatteryStateChanged
52
FlyingStateChanged
landed
unknown <Buffer 01 0a 02 00 00 00 00 00 00 00 00 00 00>
ComponentStateListChanged { component: 'Calibration', State: 1 }
ComponentStateListChanged { component: 'GPS', State: 1 }
ComponentStateListChanged { component: 'Mavlink_File', State: 1 }
ComponentStateListChanged { component: 'TakeOff', State: 1 }
AvailabilityStateChanged { AvailabilityState: 1 }
MavlinkFilePlayingStateChanged { state: 'stopped',
  filepath: '/data/ftp/internal_000/flightplans/flightPlan.mavlink\u0000\u0000\u0000\u0000\u0000',
  type: 'unknown enum' }
GPSFixStateChanged { fixed: 1 }
MavlinkFilePlayingStateChanged { state: 'playing',
  filepath: '\u0000\u0000\u0000\u0000\u0000',
  type: 'invalid enum' }
ComponentStateListChanged { component: 'Mavlink_File', State: 1 }
ComponentStateListChanged { component: 'TakeOff', State: 1 }
ComponentStateListChanged { component: 'TakeOff', State: 1 }
AvailabilityStateChanged { AvailabilityState: 1 }
FlyingStateChanged
takingOff
FlyingStateChanged
hovering
MavlinkFilePlayingStateChanged { state: 'playing',
  filepath: '\u0000\u0000\u0000\u0000\u0000',
  type: 'invalid enum' }
MavlinkFilePlayingStateChanged { state: 'playing',
  filepath: '/data/ftp/internal_000/flightplans/flightPlan.mavlink\u0000\u0000\u0000\u0000\u0000',
  type: 'unknown enum' }
FlyingStateChanged
flying
BatteryStateChanged
51
BatteryStateChanged
50
BatteryStateChanged
49
MavlinkFilePlayingStateChanged { state: 'paused',
  filepath: '/data/ftp/internal_000/flightplans/flightPlan.mavlink\u0000\u0000\u0000\u0000\u0000',
  type: 'unknown enum' }
FlyingStateChanged
MavlinkFilePlayingStateChanged { state: 'stopped',
  filepath: '/data/ftp/internal_000/flightplans/flightPlan.mavlink\u0000\u0000\u0000\u0000\u0000',
  type: 'unknown enum' }
FlyingStateChanged
landed
brunoua commented 8 years ago

I like your output :) As soon as it stops raining i will test

Thank you

brunoua commented 8 years ago

The flightPlan.mavlink file must be in the "examples" or is what is already in the drone?

deadprogram commented 8 years ago

It uses the path to what is in the drone. You can upload a file to the drone via FTP, the path just needs to match where it gets uploaded to.

That file was just to have an example of the file format on hand for future use.

brunoua commented 8 years ago

Okay, exactly what I thought. Once I have feedback I put here.

Thank you very much @deadprogram

brunoua commented 8 years ago

@deadprogram I tested now and it worked.

Thank you for your work and patience

deadprogram commented 8 years ago

Hi everyone we've just released v0.5.0 which has many improvements including the Mavlink stuff thanks especially to @brunoua for helping debug/test it. Please give it a try, and if needed reopen this issue. Thanks!