|
我使用的是基于DECA WAVE Release修改的代码,测距流程几乎没有变动。但是为何我使用串口查看时间戳却是错误的?
附上我接收到final帧计算距离,并且打印的代码。这里的printf2是重写的打印函数。
这样写的目的是验证前两次打印和后两次打印数据。我输出的顺序不同,结果却不一样?
- Ra = (int64)((anchorRespRxTime - tagPollTxTime) & MASK_40BIT);
- Db = (int64)((inst->txu.anchorRespTxTime - inst->tagPollRxTime) & MASK_40BIT);
- // response final round trip delay time is calculated as
- // (tagFinalRxTime - anchorRespTxTime) - (tagFinalTxTime - anchorRespRxTime)
- Rb = (int64)((tagFinalRxTime - inst->txu.anchorRespTxTime) & MASK_40BIT);
- Da = (int64)((tagFinalTxTime - anchorRespRxTime) & MASK_40BIT);
- RaRbxDaDb = (((double)Ra))*(((double)Rb))
- - (((double)Da))*(((double)Db));
- RbyDb = ((double)Rb + (double)Db);
- RayDa = ((double)Ra + (double)Da);
- //time-of-flight
- inst->tof = (int64) ( RaRbxDaDb/(RbyDb + RayDa) );
- uwb_fppl = dwGetReceivePower();
-
- printf2("tagPollTxTime %16X, tagPollRxTime %16X \r\n",tagPollTxTime,inst->tagPollRxTime) ;
- printf2("anchorRespTxTime %16X, anchorRespRxTime %16X \r\n",inst->txu.anchorRespTxTime,anchorRespRxTime) ;
- printf2("tagFinalTxTime %16X, tagFinalRxTime %16X \r\n",tagFinalTxTime,tagFinalRxTime) ;
-
- printf2("tagPollTxTime %16X, tagPollRxTime %16X \r\n",tagPollTxTime,inst->tagPollRxTime) ;
- printf2("anchorRespTxTime %16X, anchorRespRxTime %16X \r\n",inst->txu.anchorRespTxTime,anchorRespRxTime) ;
- printf2("tagFinalTxTime %16X, tagFinalRxTime %16X \r\n\r\n",tagFinalTxTime,tagFinalRxTime) ;
-
- printf2("anchorRespRxTime %16X, tagPollTxTime %16X \r\n",anchorRespRxTime,tagPollTxTime) ;
- printf2("tagFinalTxTime %16X, anchorRespRxTime %16X \r\n",tagFinalTxTime,anchorRespRxTime) ;
- printf2("tagFinalTxTime %16X, tagPollTxTime %16X \r\n",tagFinalTxTime,tagPollTxTime) ;
- printf2("anchorRespTxTime %16X, tagPollRxTime %16X \r\n",inst->txu.anchorRespTxTime,inst->tagPollRxTime) ;
- printf2("tagFinalRxTime %16X, anchorRespTxTime %16X \r\n",tagFinalRxTime,inst->txu.anchorRespTxTime) ;
- printf2("tagPollRxTime %16X, tagFinalRxTime %16X \r\n",inst->tagPollRxTime,tagFinalRxTime) ;
-
- printf2("Ra %8x, Rb %8x, Da %8x, Db %8x, tof %8x \r\n ",Ra,Rb,Da,Db,inst->tof);
- reportTOF(inst);
- inst->newrange = 1;
复制代码
测距都是行得通的。也是有距离值的,但是不知道这个距离是如何算出来的。为何打印的顺序会导致输出的结果不同?
还有一个问题是,inst->txu.anchorRespTxTime,也就是respond的发送时间戳是在哪里保存的,在代码中没看到赋值。
图片附上收到的数据示例
|
|