Hi all,
I'm using a 3DRobotics teletry kit and I'm trying to make my 3DR qaudcopter to communicate realtime with
MATLAB. Since the telemetry kit has a UART interface, I tried creating a serial object with baudrate 57600 in MATLAB.(I tried using fread, and fgets functions to read data in MATLAB) But the data
that I receive in MATLAB is like if they were encyrted (refer the attachment). And ofcourse 3DR radio uses MAVLink protocol where packet encryption is done.
I don't know to decide whether the reason or for this is;
- encryption of MAVLink data packets, or
- mismatch of the format between the actual data received by the ground station and the serial object properties such as bit order, stop bit, parity bit,..etc ,
-or something else.
I would be truly grateful for some advice and ideas to come out of this dead end.
Cheers
Replies
The data is not encrypted it is just binary. The MAVLink is a binary messaging protocol, and Matlab is expecting null terminated ASCII. So to do what you propose you would need to bring in MAVLink parsing helper functions most likely into a realtime MEX function, and then pass readable data to Matlab. It is doable, but definitely a significant amount of work.
If you look in our code here:
https://github.com/fightingwalrus/iGCS/blob/master/iGCS/Comm/Interf...
The function consumeData: will be something similar to what you need. It basically goes through byte by byte and uses mavlink_parse_char helper function to reconstruct the MAVLink message before it is passed on to the rest of the system using the handlePacket function.
Thanks a lot Bryan;
" So to do what you propose you would need to bring in MAVLink parsing helper functions most likely into a realtime MEX function, and then pass readable data to Matlab."
I've never tried something like this before. I would be truly grateful if you could give me some basic idea or an example of how to implement this, specially parsing MAVLink helper functions to Matlab.
Mathworks has some tutorials on how create mex files run through one and create some "hello world" type example:
http://www.mathworks.com/help/matlab/write-cc-mex-files.html
I would start with decoding the heartbeat as defined here:
https://pixhawk.ethz.ch/mavlink/#HEARTBEAT
I don't have a matlab license so I can't help too much beyond that,
Bryan