dwm_loc_get
获取到测距锚的最后距离并获取位置. 当完成所有 TWR 测量后,事件生成,状态改变,用户可获得新的位置数据. 当使用低功耗模式时,也会以同样的方式工作.
对于锚节点,只有在完成自动定位程序后,才能获得位置和距离数据. 自动定位程序是通过 BLE 接口执行的.
-
void dwm_loc_get(dwm_loc_data_t *loc);
- 参数
output – 状态代码, [position], [cnt, {an_pos, addr, distance, pqf}]
cnt – 0,1,2,3,4 (与锚点的距离)
an_pos – 位置 (与距离相对应的锚点位置)
addr – 16位整数 (特定锚点的UWB地址/ID)
distance – 32 位整数(到特定锚点的距离,以毫米为单位)
pqf – 8位整数 (质量因子)
注解
参数**an_pos**仅适用于**标签节点**
C代码示例
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 示例 1 (标签节点)
TLV 请求 |
|
---|---|
类型 |
长度 |
0x0C |
0x00 |
类型0x0C 表示 loc_get 命令
TLV 响应 |
||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
类型 |
长度 |
价值 |
类型 |
长度 |
价值 |
类型 |
长度 |
价值 |
||||||||||||
0x40 |
0x01 |
0x00 |
0x41 |
0x0D |
int32 - x坐标,单位为毫米 |
int32 - y坐标,单位为毫米 |
int32 - z坐标,单位为毫米 |
uint8 - 以百分数为单位的位置质量因子 |
0x49 |
0x51 |
uint8 -距离数 |
位置和距离 nr.2,3,4 |
位置和距离 nr. 2,3,4 |
|||||||
int16 - UWB 地址 |
uint32 - 距离,以毫米为单位 |
uint8 - 距离质量因子(百分比) |
3 x int32 + uint8 - 以毫米为单位的 x、y、z + 以百分数为单位的质量系数 |
… |
||||||||||||||||
0x4b 0x0a 0x00 0x00 0x1f 0x04 0x00 0x00 0x9c 0x0e 0x00 0x00 0x64 |
0x04 |
0xab 0xbc |
0x0e 0x03 0x00 0x00 |
0x64 |
… |
… |
SPI/UART 示例 2(锚节点)
TLV 请求 |
|
---|---|
类型 |
长度 |
0x0C |
0x00 |
类型0x0C 表示 loc_get 命令
TLV 响应 |
|||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
类型 |
长度 |
价值 |
类型 |
长度 |
价值 |
类型 |
长度 |
价值 |
|||||||||||
0x40 |
0x01 |
0x00 |
0x41 |
0x0D |
int32 - x坐标,单位为毫米 |
int32 - y坐标,单位为毫米 |
int32 - z坐标,单位为毫米 |
uint8 - 以百分数为单位的位置质量因子 |
0x48 |
0x63 |
uint8 -距离数 |
距离 nr. 1 |
距离 nr.2,…, nr. 14 |
||||||
int16 - UWB 地址 |
uint32 - 距离,以毫米为单位 |
uint8 - 距离质量因子(百分比) |
… |
||||||||||||||||
0x4b 0x0a 0x00 0x00 0x1f 0x04 0x00 0x00 0x9c 0x0e 0x00 0x00 0x64 |
0x0E |
0xab 0xbc |
0x0e 0x03 0x00 0x00 |
0x64 |
… |