dwm_loc_get
Gets the last distances to the ranging anchors and gets the position. The event is generated, the status changes when all TWR measurements are completed, and new location data is available for the user. When low-power mode is used, it will certainly work in the same way.
For the anchor node, the position and distances are available only if the auto-positioning procedure has been done. The auto-positioning procedure is carried out via the BLE interface.
-
void dwm_loc_get(dwm_loc_data_t *loc);
- Parameters
output – Status code, [position], [cnt, {an_pos, addr, distance, pqf}]
cnt – ? 0,1,2,3,4 ? (number of distances to the anchors)
an_pos – position (position of the anchor , that correspond with the distance)
addr – ? 16-bit integer ? (UWB address/id of the particular anchor)
distance – ? 32-bit integer ? (distance to particular anchor in millimeters)
pqf – ? 8-bit integer ? (quality factor)
Note
Prameter an_pos is applicable for Tag node only
C code example
dwm_loc_data_t loc;
int rv, i;
/* if pos_available is false, position data are not read, and the function returns without error */
rv: dwm_loc_get(&loc);
if (0 == rv) {
if (loc.pos_available) {
printf("[%ld,%ld,%ld,%u] ", loc.pos.x, loc.pos.y, loc.pos.z,
loc.pos.qf);
}
for (i: 0; i < loc.anchors.dist.cnt; ++i) {
printf("%u)", i);
printf("0x%04x", loc.anchors.dist.addr[i]);
if (i < loc.anchors.an_pos.cnt) {
printf("[%ld,%ld,%ld,%u]", loc.anchors.an_pos.pos[i].x,
loc.anchors.an_pos.pos[i].y,
loc.anchors.an_pos.pos[i].z,
loc.anchors.an_pos.pos[i].qf);
}
printf("=%lu,%u ", loc.anchors.dist.dist[i], loc.anchors.dist.qf[i]);
}
printf("\n");
} else {
printf("err code: %d\n", rv);
}
SPI/UART example 1 (tag node)
TLV Request |
|
---|---|
Type |
Length |
0x0C |
0x00 |
Type 0x0C means command loc_get
TLV Response |
||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type |
Length |
Value |
Type |
Length |
Value |
Type |
Length |
Value |
||||||||||||
0x40 |
0x01 |
0x00 |
0x41 |
0x0D |
int32 - x coordinate in millimeters |
int32 - y coordinate in millimeters |
int32 - z coordinate in millimeters |
uint8 - position quality factor in percents |
0x49 |
0x51 |
uint8 - number of distances |
position and distance nr. 1 |
position and distance nr.2,3,4 |
|||||||
int16 - UWB address |
uint32 - distance in millimeters |
uint8 - distance quality factor in percents |
3 x int32 + uint8 - x, y, z in millimeters + quality factor in percents |
… |
||||||||||||||||
0x4b 0x0a 0x00 0x00 0x1f 0x04 0x00 0x00 0x9c 0x0e 0x00 0x00 0x64 |
0x04 |
0xab 0xbc |
0x0e 0x03 0x00 0x00 |
0x64 |
… |
… |
SPI/UART example 2 (anchor node)
TLV Request |
|
---|---|
Type |
Length |
0x0C |
0x00 |
Type 0x0C means command loc_get
TLV Response |
|||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type |
Length |
Value |
Type |
Length |
Value |
Type |
Length |
Value |
|||||||||||
0x40 |
0x01 |
0x00 |
0x41 |
0x0D |
int32 - x coordinate in millimeters |
int32 - y coordinate in millimeters |
int32 - z coordinate in millimeters |
uint8 - position quality factor in percents |
0x48 |
0x63 |
uint8 - number of distances |
distance nr. 1 |
distance nr.2,…, nr. 14 |
||||||
int16 - UWB address |
uint32 - distance in millimeters |
uint8 - distance quality factor in percents |
… |
||||||||||||||||
0x4b 0x0a 0x00 0x00 0x1f 0x04 0x00 0x00 0x9c 0x0e 0x00 0x00 0x64 |
0x0E |
0xab 0xbc |
0x0e 0x03 0x00 0x00 |
0x64 |
… |