Parsing of Raw UDP ARnetworkAL

Product: [/Bebop2]

I’m trying to build a package in Go to control the Bebop2 drone based on the information I’ve found in the ARSDK_Protocols.pdf document, and in the ardrone3.xml file.

I have a question in regards to the number of bytes for the ARCommand part which I don’t quite understand.
Here is an example.

I get this package:

(in decimal)

2 127 75 23 0 0 0 1 4 6 0 137 146 75 60 159 186 239 58 74 247 29 192

According to the size section 23 0 0 0 this frame should be of 23 bytes which seems correct.

That leaves the following 16 bytes for the ARNetwork part.
1 4 6 0 137 146 75 60 159 186 239 58 74 247 29 192
If I’ve understood this correctly the first 3 bytes 1 4 6 should translate to the following in the ardrone3.xml.

project name=“ardrone3” id=“1”
class name=“PilotingState” id=“4”
cmd name=“AttitudeChanged” id=“6” buffer=“NON_ACK”

The arguments of AttitudeChanged should be made of 3 floats roll pitch yaw, and the size of a float is 4 bytes according to the document.

Based on all this information I break up the ARNetwork in the following sections.
1 4 6 0 137 146 75 60 159 186 239 58 74 247 29 192
1 4 6 , 3 bytes for project, class and cmd
0 137 146 75 60 159 186 239 58 74 247 29 192, the remaining I believed should be the 3 floats for the arguments, that should sum up to be 12 bytes total…but it’s not 12 it’s 13 bytes.

It is the 13th byte I really don’t understand based on the information I described above. The raw parsing of the UDP seems to be correct since the size parameter of the package and the totalt number of bytes in the package seems to be correct.

If anyone knows what I’m getting or doing wrong here, I would be really happy for any help :slight_smile:

You’re almost correct, but you missed one key point : the “cmd” field is on two bytes, not one :wink:

So for your command, you have:

  • project : 1
  • class : 4
  • cmd : 6 0 (which is indeed 6 since the data is in little endian : 0x0006)
  • roll : 137 146 75 60 (which is 0x3C4B9289 when converted to “natural order” 32 bits, and 0.012425073 as a float)
  • pitch : 159 186 239 58 (0x3AEFBA9F, or 0.001828987)
  • yaw.: 74 247 29 192 (0xC01DF74A, or -2.4682183)

Other than this detail, your parsing seems fine.

Regards,
Nicolas.

Thanks a lot @Nicolas , this is really great.
I must have missed that cmd field size in the protocols doc.

Looking at it now it now when I know the answer, it is pretty well described :slight_smile:
4.1 Command identifier The command is identified by its first 4 bytes: • Project or Feature ID (1 byte) • Class ID in the project/feature (1 byte) • Command ID in the class (2 bytes)

Again, thanks a lot :slight_smile: