Home › Forums › GP9 Product Support › Angle units
This topic contains 11 replies, has 2 voices, and was last updated by Steve Graves 11 months, 1 week ago.
-
AuthorPosts
-
Steve GravesI am finally processing data. So I start with the pitch and roll angles. While all discussions are about degrees it seems the units are in radians. For example, I lean the unit at an angle somewhere around 45 degree pitch with some roll. The readings I get are
Platform Pitch = 0.620495
Platform Roll = -0.541879If I assume radians convert to angles, I get
Platform Pitch = 35.55
Platform Roll = -31.04These are more reasonable values. Is this right? Or do I have some other problem?
Thanks,
Steve -
Hi Steve,
The Euler Angle outputs are in degrees, but the values in the Euler Angle registers have to be scaled to get the angle outputs. For example, pitch and roll are stored in register address 120, and yaw is stored in register 121. Pitch is stored as a signed 16-bit integer in the high-order 16 bits of register 120. To convert that integer to the actual angle, you multiply the integer by 0.01098632812 to obtain the angle in degrees.
If you are logging data with the Serial Interface, then it will do all of that for you automatically. If you are using your own parser, you’ll want to double-check that the register contents are being extracted correctly.
-
Steve GravesThank you. I was dividing by 5215.18917 which is the same. Now I know that I have some coding issue and as you suggested the first place I will look is at the code reading the registers. I have a two step process. All the registers I need for a KLV packet are read into memory. Then I process them. I am probably doing something wrong when reading into memory.
Thanks,
Steve -
In my experience, the most common problem is how the data is extracted from the packet and combined into a data type. Suppose that the packet data is being held in an array called ‘data[]’, and that ‘data[0]’ is the location of the first byte of register 120 (pitch and roll). e.g. the ‘snp’ header and the packet-type and address bytes that preceded the data have been removed. C-code for extracting the data might look like the following:
Int16 pitch = ((Int16)data[0] << 8) | data[1];
Int16 roll = ((Int16)data[2] << 8) | data[3];float f_pitch = (float)pitch*0.01098632812f;
float f_roll = (float)roll*0.01098632812f;If the data came in a batch packet (which it will if this packet was automatically transmitted by the UM7), then you can also get yaw:
Int16 yaw = ((Int16)data[4] << 8) | data[5];
float f_yaw = (float)yaw*0.01098632812f;Of course, the exact order that you recombine the serial data to form the short integers depends on the endianness of your machine, and of the language you are using (as I recall, Python’s endianness is fixed regardless of architecture). But in C on an x86 CPU (Intel or AMD), the above should work just fine.
-
Steve GravesCaleb,
Below is a dump of a communication session. The GP9 is tilted at an angle (30-45 degree) with some roll. As you can see Register 0x78 returned Data = 0xee 0x14 0x0c 0xdc that gives the following
Platform Pitch = 0.631233 iRaw = 0x00000cdc
Platform Roll = -0.879738 iRaw = 0xffffee140x73 0x6e 0x70 0x80 0x75 0x2b 0x11 0xca 0x98 0x03 0xe4
Add = 0x75 Data = 0x2b 0x11 0xca 0x98 dw = 0x2b11ca980x73 0x6e 0x70 0x80 0x78 0xee 0x14 0x0c 0xdc 0x04 0x33
Add = 0x78 Data = 0xee 0x14 0x0c 0xdc dw = 0xee140cdc0x73 0x6e 0x70 0x80 0x84 0x41 0xdf 0xe4 0xd4 0x05 0x2d
Add = 0x84 Data = 0x41 0xdf 0xe4 0xd4 dw = 0x41dfe4d40x73 0x6e 0x70 0x80 0x85 0xc2 0xa5 0x19 0xa3 0x04 0x79
Add = 0x85 Data = 0xc2 0xa5 0x19 0xa3 dw = 0xc2a519a30x73 0x6e 0x70 0x80 0x86 0x41 0x70 0x00 0x00 0x03 0x08
Add = 0x86 Data = 0x41 0x70 0x00 0x00 dw = 0x41700000Platform Pitch = 0.631233 iRaw = 0x00000cdc
Platform Roll = -0.879738 iRaw = 0xffffee14Thanks Steve
-
Hi Steve,
Let’s have a look at the first set of data you referenced:
0xee140cdc
The raw pitch value in hex is 0xee14, which corresponds to a decimal value of -4588. -4588*0.01098632812 = -50.4 degrees.
The raw roll value in hex is 0x0cdc, which corresponds to a decimal value of 3292. 3292*0.01098632812 = 36.2 degrees.I used this handy hex to decimal converter to convert the hex value to signed 16-bit decimal: http://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html
-
Looks like the scale factor is wrong. 1/5215.18917 = 0.00019. The correct scale factor is 0.01098…
That’s an error in the datasheet! My apologies for the confusion. You should either multiply by 0.01098632812 or divide by 91.0222.
-
Steve GravesCaleb,
Below is a dump of most of the registers in the device. I have disconnected the antenna to force the accelerometers to generate the attitude data. The device is not moving, so the GPS has no information to get pitch, roll, etc.As before, I show the raw serial stream, then the decoded data. The checksums all match. I am not sure of your endianness, I have used the checksum as a guide. It is big endian with the most significant byte first. I have played around with little endian, the numbers seemed better, but still not quite right.
Steve
0x73 0x6e 0x70 0x80 0x0e 0x00 0x00 0x00 0x00 0x01 0xdf
Add = 0x0e Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x0f 0x00 0x00 0x00 0x00 0x01 0xe0
Add = 0x0f Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x10 0x00 0x00 0x00 0x00 0x01 0xe1
Add = 0x10 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x00 0x50 0x00 0x00 0x00 0x02 0x21
Add = 0x00 Data = 0x50 0x00 0x00 0x00 dw = 0x500000000x73 0x6e 0x70 0x80 0x01 0x00 0x00 0x00 0x00 0x01 0xd2
Add = 0x01 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x02 0x00 0x00 0x00 0x00 0x01 0xd3
Add = 0x02 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x03 0x00 0x00 0x00 0x00 0x01 0xd4
Add = 0x03 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x04 0x00 0x00 0x00 0x00 0x01 0xd5
Add = 0x04 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x05 0x00 0x00 0x00 0x00 0x01 0xd6
Add = 0x05 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x06 0x00 0x00 0x00 0x00 0x01 0xd7
Add = 0x06 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x07 0x00 0x00 0x00 0x00 0x01 0xd8
Add = 0x07 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x08 0x50 0x00 0x00 0x00 0x02 0x29
Add = 0x08 Data = 0x50 0x00 0x00 0x00 dw = 0x500000000x73 0x6e 0x70 0x80 0x09 0x41 0xdf 0xe4 0x9e 0x04 0x7c
Add = 0x09 Data = 0x41 0xdf 0xe4 0x9e dw = 0x41dfe49e0x73 0x6e 0x70 0x80 0x0a 0xc2 0xa5 0x19 0xaf 0x04 0x0a
Add = 0x0a Data = 0xc2 0xa5 0x19 0xaf dw = 0xc2a519af0x73 0x6e 0x70 0x80 0x0b 0x42 0x6c 0x66 0x66 0x03 0x56
Add = 0x0b Data = 0x42 0x6c 0x66 0x66 dw = 0x426c66660x73 0x6e 0x70 0x80 0x0c 0x00 0x00 0x00 0x00 0x01 0xdd
Add = 0x0c Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x0d 0x00 0x00 0x00 0x00 0x01 0xde
Add = 0x0d Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x0e 0x00 0x00 0x00 0x00 0x01 0xdf
Add = 0x0e Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x0f 0x00 0x00 0x00 0x00 0x01 0xe0
Add = 0x0f Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x10 0x00 0x00 0x00 0x00 0x01 0xe1
Add = 0x10 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x55 0x00 0x0f 0x30 0x20 0x02 0x85
Add = 0x55 Data = 0x00 0x0f 0x30 0x20 dw = 0x000f30200x73 0x6e 0x70 0x80 0x56 0x00 0x0a 0x00 0x04 0x02 0x35
Add = 0x56 Data = 0x00 0x0a 0x00 0x04 dw = 0x000a00040x73 0x6e 0x70 0x80 0x57 0x00 0x02 0x00 0x00 0x02 0x2a
Add = 0x57 Data = 0x00 0x02 0x00 0x00 dw = 0x000200000x73 0x6e 0x70 0x80 0x58 0x47 0x90 0xa8 0xc2 0x04 0x6a
Add = 0x58 Data = 0x47 0x90 0xa8 0xc2 dw = 0x4790a8c20x73 0x6e 0x70 0x80 0x59 0x00 0x2a 0x09 0xbc 0x03 0x19
Add = 0x59 Data = 0x00 0x2a 0x09 0xbc dw = 0x002a09bc0x73 0x6e 0x70 0x80 0x5a 0xf1 0x87 0x00 0x00 0x03 0xa3
Add = 0x5a Data = 0xf1 0x87 0x00 0x00 dw = 0xf18700000x73 0x6e 0x70 0x80 0x5b 0x47 0x90 0xa8 0xc2 0x04 0x6d
Add = 0x5b Data = 0x47 0x90 0xa8 0xc2 dw = 0x4790a8c20x73 0x6e 0x70 0x80 0x5c 0x00 0x13 0xff 0x5b 0x03 0x9a
Add = 0x5c Data = 0x00 0x13 0xff 0x5b dw = 0x0013ff5b0x73 0x6e 0x70 0x80 0x5d 0x00 0x5f 0x00 0x00 0x02 0x8d
Add = 0x5d Data = 0x00 0x5f 0x00 0x00 dw = 0x005f00000x73 0x6e 0x70 0x80 0x5e 0x47 0x90 0xa8 0xc1 0x04 0x6f
Add = 0x5e Data = 0x47 0x90 0xa8 0xc1 dw = 0x4790a8c10x73 0x6e 0x70 0x80 0x5f 0x00 0x3f 0x7d 0xb3 0x03 0x9f
Add = 0x5f Data = 0x00 0x3f 0x7d 0xb3 dw = 0x003f7db30x73 0x6e 0x70 0x80 0x60 0x47 0x90 0xa8 0xc7 0x04 0x77
Add = 0x60 Data = 0x47 0x90 0xa8 0xc7 dw = 0x4790a8c70x73 0x6e 0x70 0x80 0x61 0x41 0xfd 0x03 0x03 0x03 0x76
Add = 0x61 Data = 0x41 0xfd 0x03 0x03 dw = 0x41fd03030x73 0x6e 0x70 0x80 0x62 0xc5 0x8f 0xe8 0x00 0x04 0x6f
Add = 0x62 Data = 0xc5 0x8f 0xe8 0x00 dw = 0xc58fe8000x73 0x6e 0x70 0x80 0x63 0x00 0x00 0x00 0x00 0x02 0x34
Add = 0x63 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x64 0xbc 0x37 0x3a 0xb8 0x04 0x1a
Add = 0x64 Data = 0xbc 0x37 0x3a 0xb8 dw = 0xbc373ab80x73 0x6e 0x70 0x80 0x65 0xbe 0x84 0x8d 0x87 0x04 0x8c
Add = 0x65 Data = 0xbe 0x84 0x8d 0x87 dw = 0xbe848d870x73 0x6e 0x70 0x80 0x66 0x3c 0xa6 0x8a 0x5c 0x03 0xff
Add = 0x66 Data = 0x3c 0xa6 0x8a 0x5c dw = 0x3ca68a5c0x73 0x6e 0x70 0x80 0x67 0x47 0x90 0xa8 0xc8 0x04 0x7f
Add = 0x67 Data = 0x47 0x90 0xa8 0xc8 dw = 0x4790a8c80x73 0x6e 0x70 0x80 0x68 0x3d 0xbf 0x48 0x6a 0x03 0xe7
Add = 0x68 Data = 0x3d 0xbf 0x48 0x6a dw = 0x3dbf486a0x73 0x6e 0x70 0x80 0x69 0x40 0xb9 0xdd 0x22 0x04 0x32
Add = 0x69 Data = 0x40 0xb9 0xdd 0x22 dw = 0x40b9dd220x73 0x6e 0x70 0x80 0x6a 0xc0 0xf7 0x5c 0xae 0x04 0xfc
Add = 0x6a Data = 0xc0 0xf7 0x5c 0xae dw = 0xc0f75cae0x73 0x6e 0x70 0x80 0x6b 0x47 0x90 0xa8 0xc8 0x04 0x83
Add = 0x6b Data = 0x47 0x90 0xa8 0xc8 dw = 0x4790a8c80x73 0x6e 0x70 0x80 0x6c 0x41 0x95 0x0c 0xfd 0x04 0x1c
Add = 0x6c Data = 0x41 0x95 0x0c 0xfd dw = 0x41950cfd0x73 0x6e 0x70 0x80 0x6d 0xc3 0x22 0x21 0xd3 0x04 0x17
Add = 0x6d Data = 0xc3 0x22 0x21 0xd3 dw = 0xc32221d30x73 0x6e 0x70 0x80 0x6e 0x42 0xc0 0x93 0xd2 0x04 0xa6
Add = 0x6e Data = 0x42 0xc0 0x93 0xd2 dw = 0x42c093d20x73 0x6e 0x70 0x80 0x6f 0x47 0x90 0xa8 0xc1 0x04 0x80
Add = 0x6f Data = 0x47 0x90 0xa8 0xc1 dw = 0x4790a8c10x73 0x6e 0x70 0x80 0x70 0x47 0xc6 0x65 0xd8 0x04 0x8b
Add = 0x70 Data = 0x47 0xc6 0x65 0xd8 dw = 0x47c665d80x73 0x6e 0x70 0x80 0x71 0x47 0x90 0xa8 0xc2 0x04 0x83
Add = 0x71 Data = 0x47 0x90 0xa8 0xc2 dw = 0x4790a8c20x73 0x6e 0x70 0x80 0x72 0x41 0xfc 0xd2 0xd3 0x05 0x25
Add = 0x72 Data = 0x41 0xfc 0xd2 0xd3 dw = 0x41fcd2d30x73 0x6e 0x70 0x80 0x73 0x42 0x03 0xb5 0x55 0x03 0x93
Add = 0x73 Data = 0x42 0x03 0xb5 0x55 dw = 0x4203b5550x73 0x6e 0x70 0x80 0x74 0x00 0x00 0x00 0x00 0x02 0x45
Add = 0x74 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x75 0x4b 0x2f 0xbf 0x50 0x03 0xcf
Add = 0x75 Data = 0x4b 0x2f 0xbf 0x50 dw = 0x4b2fbf500x73 0x6e 0x70 0x80 0x76 0x13 0x0b 0x39 0xcb 0x03 0x69
Add = 0x76 Data = 0x13 0x0b 0x39 0xcb dw = 0x130b39cb0x73 0x6e 0x70 0x80 0x77 0x45 0xa5 0xa9 0x8a 0x04 0x65
Add = 0x77 Data = 0x45 0xa5 0xa9 0x8a dw = 0x45a5a98a0x73 0x6e 0x70 0x80 0x78 0xea 0xdf 0x11 0xb4 0x04 0xd7
Add = 0x78 Data = 0xea 0xdf 0x11 0xb4 dw = 0xeadf11b40x73 0x6e 0x70 0x80 0x79 0x10 0x26 0x00 0x00 0x02 0x80
Add = 0x79 Data = 0x10 0x26 0x00 0x00 dw = 0x102600000x73 0x6e 0x70 0x80 0x7a 0x45 0xa5 0xa9 0x8d 0x04 0x6b
Add = 0x7a Data = 0x45 0xa5 0xa9 0x8d dw = 0x45a5a98d0x73 0x6e 0x70 0x80 0x7b 0x41 0x54 0xa3 0xf0 0x04 0x74
Add = 0x7b Data = 0x41 0x54 0xa3 0xf0 dw = 0x4154a3f00x73 0x6e 0x70 0x80 0x7c 0xc0 0xd7 0xa2 0x4a 0x04 0xd0
Add = 0x7c Data = 0xc0 0xd7 0xa2 0x4a dw = 0xc0d7a24a0x73 0x6e 0x70 0x80 0x7d 0xc2 0x61 0x99 0x9d 0x04 0xa7
Add = 0x7d Data = 0xc2 0x61 0x99 0x9d dw = 0xc261999d0x73 0x6e 0x70 0x80 0x7e 0x45 0xa5 0xa9 0x93 0x04 0x75
Add = 0x7e Data = 0x45 0xa5 0xa9 0x93 dw = 0x45a5a9930x73 0x6e 0x70 0x80 0x7f 0xc0 0x76 0xa3 0xbc 0x04 0xe5
Add = 0x7f Data = 0xc0 0x76 0xa3 0xbc dw = 0xc076a3bc0x73 0x6e 0x70 0x80 0x80 0xc0 0x04 0x3f 0x3a 0x03 0x8e
Add = 0x80 Data = 0xc0 0x04 0x3f 0x3a dw = 0xc0043f3a0x73 0x6e 0x70 0x80 0x81 0x00 0x00 0x00 0x00 0x02 0x52
Add = 0x81 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x82 0x00 0x00 0x00 0x00 0x02 0x53
Add = 0x82 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x83 0x45 0xa5 0xa9 0x99 0x04 0x80
Add = 0x83 Data = 0x45 0xa5 0xa9 0x99 dw = 0x45a5a9990x73 0x6e 0x70 0x80 0x84 0x41 0xdf 0xe4 0xd3 0x05 0x2c
Add = 0x84 Data = 0x41 0xdf 0xe4 0xd3 dw = 0x41dfe4d30x73 0x6e 0x70 0x80 0x85 0xc2 0xa5 0x19 0xb8 0x04 0x8e
Add = 0x85 Data = 0xc2 0xa5 0x19 0xb8 dw = 0xc2a519b80x73 0x6e 0x70 0x80 0x86 0x40 0x2c 0xcc 0xcd 0x04 0x5c
Add = 0x86 Data = 0x40 0x2c 0xcc 0xcd dw = 0x402ccccd0x73 0x6e 0x70 0x80 0x87 0xc3 0x17 0xcc 0xcd 0x04 0xcb
Add = 0x87 Data = 0xc3 0x17 0xcc 0xcd dw = 0xc317cccd0x73 0x6e 0x70 0x80 0x88 0x40 0x8b 0xed 0xca 0x04 0xdb
Add = 0x88 Data = 0x40 0x8b 0xed 0xca dw = 0x408bedca0x73 0x6e 0x70 0x80 0x89 0x47 0x8c 0x42 0x14 0x03 0x83
Add = 0x89 Data = 0x47 0x8c 0x42 0x14 dw = 0x478c42140x73 0x6e 0x70 0x80 0x8a 0x49 0x70 0x50 0xc0 0x04 0x24
Add = 0x8a Data = 0x49 0x70 0x50 0xc0 dw = 0x497050c00x73 0x6e 0x70 0x80 0x8b 0x00 0x00 0x00 0x00 0x02 0x5c
Add = 0x8b Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x8c 0x00 0x00 0x00 0x00 0x02 0x5d
Add = 0x8c Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x8d 0x00 0x00 0x00 0x00 0x02 0x5e
Add = 0x8d Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x8e 0x00 0x00 0x00 0x00 0x02 0x5f
Add = 0x8e Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x8f 0x00 0x00 0x00 0x00 0x02 0x60
Add = 0x8f Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x90 0x00 0x00 0x00 0x00 0x02 0x61
Add = 0x90 Data = 0x00 0x00 0x00 0x00 dw = 0x000000000x73 0x6e 0x70 0x80 0x91 0x3d 0xdd 0x78 0xdd 0x04 0xd1
Add = 0x91 Data = 0x3d 0xdd 0x78 0xdd dw = 0x3ddd78dd0x73 0x6e 0x70 0x80 0x92 0xbe 0x18 0xc1 0x5c 0x04 0x56
Add = 0x92 Data = 0xbe 0x18 0xc1 0x5c dw = 0xbe18c15c0x73 0x6e 0x70 0x80 0x93 0xbd 0xa7 0x43 0x51 0x04 0x5c
Add = 0x93 Data = 0xbd 0xa7 0x43 0x51 dw = 0xbda743510x73 0x6e 0x70 0x80 0x94 0x38 0xfb 0x0d 0x12 0x03 0xb7
Add = 0x94 Data = 0x38 0xfb 0x0d 0x12 dw = 0x38fb0d120x73 0x6e 0x70 0x80 0x95 0x38 0xfd 0x8a 0xef 0x05 0x14
Add = 0x95 Data = 0x38 0xfd 0x8a 0xef dw = 0x38fd8aef0x73 0x6e 0x70 0x80 0x96 0x38 0xfa 0x65 0xdc 0x04 0xda
Add = 0x96 Data = 0x38 0xfa 0x65 0xdc dw = 0x38fa65dc0x73 0x6e 0x70 0x80 0x97 0x40 0x1d 0x57 0x75 0x03 0x91
Add = 0x97 Data = 0x40 0x1d 0x57 0x75 dw = 0x401d57750x73 0x6e 0x70 0x80 0x98 0x40 0x8b 0x09 0xd3 0x04 0x10
Add = 0x98 Data = 0x40 0x8b 0x09 0xd3 dw = 0x408b09d30x73 0x6e 0x70 0x80 0x99 0x41 0xfb 0x0c 0x33 0x03 0xe5
Add = 0x99 Data = 0x41 0xfb 0x0c 0x33 dw = 0x41fb0c33 -
Steve GravesCaleb,
Oops. I was busy constructing my email and didn’t see your response. I will change the value.Steve
-
Steve GravesCaleb,
Wait, I am still confused. The datasheet shows the most significant word of the registers as the roll. Above you show it as pitch. Am I missing something?Steve
-
No, you are right, the high order bytes are roll.
-
Steve GravesHi Caleb,
I wanted to let you know that the difference in those two factors is 180/pi. That is 5215.18917/91.0222 = 180/pi. That is the conversion factor for radians to angles. So the original factor gives radians.Steve
-
AuthorPosts