Multiple responders with one initiator

Hi guys
I want to achieve a communication between Multiple responders with one initiator using DWM1001-dev
I have the ss_twr_init and responder example running on 2 modules.
I tried to modify them( customize messages between Initiator and responders) to get what I want but I got nothing
I would be so grateful if someone could help

Hi,
I already got this running, so I can assist you to achieve the same in your environment of choice.
in this query sm{"uwb_cmd":"twr","initiator":0,"responders":[1,2,3,4],"at_ms":100,"step_ms":10} I provide one initiator and a list of responders where the initiator sends one message for each and gets a response.

  • The first issue you have to solve is how can you identify each node (or uwb device) so that only the one you need answers each time. Unless you use addresses filtering which is another thing not provided in the examples.
  • The message sent from one device is a broadcast that can be heard by all devices, so you have to modify the message content to add the target id so that only that target answers and no one else
  • then send another message with another target and so on

if now we dive in the example code that can implement differently in your case if you want, here you can see the message structure that has source and dest

this is where the first message is created with source_initiator and dest_responder filling the source and dest fields

There is more to this on what are these source and dest coming from but I can explain that later on, so I let you rather ask on what would you like to know more about

In case you’re modifying the original Decawave example start with this :

  • use the same original message for responder 1 so that you have functional initiator + responder 1
  • modify the message for responder 2 and make a test with two devices only initiator + responder 2

with these two tests you figure out if what fails is simply modifying the messages or adding one more responder ?
only when both are running, then you create a new sample with two messages and one time you send the first then you send the second.

Using complete messages to identify nodes from the code is not ideal, a more convenient approach is to assign an id to each node and place it inside the message, but only do that once the first steps are working.

for info, this example is already running sm{"uwb_cmd":"twr","initiator":4,"responders":[0,1,2,3],"at_ms":100,"step_ms":10,"count":3,"count_ms":50}

that is a sequence to request the range from 4 devices and repeat the whole procedure x3 times

then with the serial json protocol and the simplemesh packets request response ranging devices can be called from python as simply as this

initiator = 0
responder = 1
range_measure = uwb_twr(initiator, responder)
print(f"mp> range-{i} ({initiator})->({responder}) = {range_measure}")

thank you so much
I will read them carefully and ask you

I tried to modify the code
but I only get the distance two
the problem is in this if “rx_buffer1” but I dont know how to fix it




image

In the responder code, you have to accept both msg1, and msg2.
That memcmp is a memory compare filter that kicks out everything but the expected frame.
If you want to accept ms1 and msg2, you have to compare to both and accept bot.
Or you can remove the variation like they did for the sequence counter.
Before modifying the code, you can create a pseudo code and define a protocol in the frame format, then adapt that concept to code.
In decawave demo samples using memcmp is not clean coding, that does not scale up to many nodes as it’s a waste to compare the whole frame plus the node identifiers are hardcoded.
In my code, the message is mapped on a structure from which the source has a field and is clearly tested.
In these lines you see different tests on the expected initiator and responder which are not hard coded rather given in runtime with the request.

did you use single sided twr or double sided twr ?

It’s double sided, you can see in the code the steps

  • first poll message from initiator
  • response from responder
  • final message from the initiator

The responder use it to calculate the tof with all params.

so if we suppose that the initiator is the tag and the responders are the anchors
indeed, the distance will be calculated in each anchor
isn’t ?

Correct, and to be more specific the responder is the node that receives the final message that completes the timing data needed for the calculation.
One option is to calculate the distance right away on that node same as the responder example, another option is to send this data to another node or server and perform it there.
Note that in the demo example, the distance is only available on the responder, so in case you want to expand this to a positioning system with trilateration or more, you’ll need to collect all distances in a central node or server to calculate the position. Could be the tag itself in case power is not an issue.

So who process and compute the location of the tag device? is it the anchors or the tag? or it can be both. if one of the anchor process the location, should it get the other anchors data through the tag or directly? when u guys mention ‘responder’ is that an anchor?

All these details are up to the system design.
Anchor refers to a node that has a fixed position, tag is moving that’s all. For Two way ranging (twr) any device tag or anchor can initiate or respond to a twr request.

Hi guys,
for the moment, I made a ds-communication between an initiator and a responder by modifying the samples code provided by decawave (written with c).
I would like to add one more reponder. I tried to implement it but I screwed up.
any help please !

Sure, I’ll try to help.
We have two approaches, look on the specific error or discuss a stratic approach. Given the details you shared we have to fallback on the secon approach.

When it comes to me, I never managed to get a proram running without debug. You make a design, then you define a test strategy that will validate your design assumptions.
In practice, that means

  • add print in safe locations that do not disturb the program timing
  • log with it all possible errors like status reg,…
  • debug with a step debugger in case you suspect a wrongly written statement in code
  • debug with pio and logic analyzer to check the proper timing
  • if that does not help, then write unit tests to each function and validate each modified step beween original and target program.

Once you point out which modified line leads to the issue the rest is easy.

I hope this help, keep in mind without test and debug nothing works not even with 20 years of experience.

Your test and debug coverage should cover 100% of your code, if not, that’s where your bug can hide.

I also provides a reference working program in c++ if you have questions about it you can ask, understanding it could help you adapt your program as you’re sure that mine is working.

okay @wassfila thank you so much for your answer

Hi all
I have a question please once I have distance between 3 responders and one initiator.
How do I get x,y,z to do the trilateration algorithm??

For the trilateration you need to input the position of three anchors and 3 ranges.

I did not implement an example using it yet as that’s the easiest part. I’m not sure at which level I’ll be coding. Simplest is to use a ready library or code few equations.

The solution space is big, you can either use an exact calculation or optimization technique. The answer for how to do trilateration is better answered by the dedicated wikipedia entry. Even if you use a ready library, you have to explain the technique you used and justify why you selected it among others, that’s a very likely question you’ll get

Here’s the link

Note that extending to a number >3 would be called multilateration.

Once you know what you want, you can find examples libraries, in case you go for a complex and tested solution

This is even a search of all libs with trilateration tag

thank you @wassfila for your response
I apperciate your help
Just one more question please: I am stuck with memcmp function I tried to adjust it to with 2 responders but I failed.
Do you know any implementation with c language could help ?

what problem do u hav with memcmp?

I suggest that you experiment with memcmp in a separate example that you can post that have nothing to do with UWB. Once you get familiar with memcmp, only then you should apply it to modify the UWB code.

As exercise try to print four different strings, then compare them one by one with memcmp, then print the output.