Tags as Anchors for Swarm Positioning

All discussions related to the Loco Positioning system
Post Reply
snyderthorst
Beginner
Posts: 23
Joined: Thu Jun 28, 2018 12:00 am

Tags as Anchors for Swarm Positioning

Post by snyderthorst »

Hello,

I am attempting to implement a system to make the Crazyflies broadcast their own position and avoid each other. I have 10 Crazyflies and the LPS system running well. I was wondering if I could set the LPS tags on the Crazyflies to broadcast their position like the anchors do? Would that be a feasible system for collision avoidance? What would I need to implement and where? I have some guesses like the following function seems like a good place to start (Bottom of locodeck.c):

Code: Select all

void lpsHandleLppShortPacket(const uint8_t srcId, const uint8_t *data, const int length)
{
  uint8_t type = data[0];

  if (type == LPP_SHORT_ANCHORPOS) {
    if (srcId < LOCODECK_NR_OF_ANCHORS) {
      struct lppShortAnchorPos_s *newpos = (struct lppShortAnchorPos_s*)&data[1];
      algoOptions.anchorPosition[srcId].timestamp = xTaskGetTickCount();
      algoOptions.anchorPosition[srcId].x = newpos->x;
      algoOptions.anchorPosition[srcId].y = newpos->y;
      algoOptions.anchorPosition[srcId].z = newpos->z;
    }
  }
}
I am using TDoA 2, so I would prefer sticking with that for the time being, but I welcome any ideas or suggestions on implementing this.

Thanks!
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Tags as Anchors for Swarm Positioning

Post by arnaud »

If you want to send the position using the UWB radio I also think the LPP packet is a good place to start.

LPP packets are sent in between ranging packets, they are used as uplink to send messages to the anchor but I guess it could also be used to communicate between Crazyflies. Though you will have to avoid as much as possible having two Crazyflie sending theire position at the same time and since you have 10 Crazyflies and TDoA2 only has 8 timeslots there will need to be a bit of scheduling involved, maybe just sending the packet at random interval is the best possibility there.

First things is to send the packets, there is a function that queues a packet to be sent: https://github.com/bitcraze/crazyflie-f ... #L243-L261. In TDoA2 the packet is sent there: https://github.com/bitcraze/crazyflie-f ... #L301-L304. The code checks for the anchor ID since LPP is normally used to communicate with a specific anchor. You could add to the test a special destination of 0xFF to send the packet right away. Check also the send function to add the 0xff special case there as well.

The code you copied handle receiving LPP packets directly from the ranging packets, TDoA2 only calls this function when a ranging packet has been received: https://github.com/bitcraze/crazyflie-f ... Tag.c#L338. You will need to add a new packet type test to receive the LPP packet and analyse it: https://github.com/bitcraze/crazyflie-f ... Tag.c#L297.

This is not something we have ever done but it should be possible. I suggest you setup one of your lps node as a sniffer (there is a script in the lps-node firmware repos to use it as a fast binary sniffer), so that you can observe what is happening in the air.
snyderthorst
Beginner
Posts: 23
Joined: Thu Jun 28, 2018 12:00 am

Re: Tags as Anchors for Swarm Positioning

Post by snyderthorst »

Thank you! I will look into this.
Post Reply