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 – err_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 see error codes |
Type |
length |
Value |
|||
0x40 |
0x01 |
0x00 |
0x41 |
0x0D |
int 32_t -li ttle end ian, is x coo rdin ate in mill imet ers |
int 32_t -li ttle end ian, is y coo rdin ate in mill imet ers |
int 32_t -li ttle end ian, is z coo rdin ate in mill imet ers |
uin t8_t -is posi tion qua lity fa ctor in per cent s (0- 100) |
0x4b 0x0a 0x00 0x00 0x1f 0x04 0x00 0x00 0x9c 0x0e 0x00 0x00 0x64 |
TLV response (residue of the frame from previous table) |
|||||||
---|---|---|---|---|---|---|---|
** type** |
le ngth |
v alue |
|||||
0x49 |
0x51 |
u int8_t - number of di stance s e ncoded in the Value |
uin t16_t- UWB a ddress in little endian |
ui nt32_t - di stance in mil limete rs in little endian |
u int8_t -di stance q uality factor in pe rcents ( 0-100) |
po sition in st andard 13 byte format (x,y ,z,qf) |
… |
0x04 |
po sition and di stance nr. 1 |
nr. 2, 3, 4 |
Type 0x49 means position and distances of ranging anchors
SPI/UART example 2 (anchor node)
TLV request |
|
---|---|
type |
length |
0x0C |
0x00 |
Type 0x0C means command loc_get
TLV response |
||||||||
---|---|---|---|---|---|---|---|---|
t ype |
len gth |
va lue ** error c ode** |
t ype |
len gth |
va lue |
|||
0x40 |
0x01 |
0x00 |
0x41 |
0x0D |
in t32_t -l ittle en dian, is x coo rdina te in mill imete rs |
in t32_t -l ittle en dian, is y coo rdina te in mill imete rs |
in t32_t -l ittle en dian, is z coo rdina te in mill imete rs |
ui nt8_t -pos ition qu ality f actor in per cents (0 -100) |
0x4b 0x0a 0x00 0x00 0x1f 0x04 0x00 0x00 0x9c 0x0e 0x00 0x00 0x64 |
TLV response (residue of the frame from previous table) |
||||||
---|---|---|---|---|---|---|
type |
Length |
value |
||||
0x48 |
0x63 |
uint8_t number of di stances encoded in the Value |
uint16_t - UWB address in little endian |
uint32_t distance in mil limeter s in little endian |
uint8_t distance quality factor in percents (0-100) |
… |
0x0E |
d istance nr. 1 |
nr. 2 … nr. 14 |
Type 0x48 means distances of ranging anchors