Lighthouse + Swarm setup

Discussions related to positioning systems where the position is calculated outside the Crazyflie and sent to the device using radio, including MoCap systems
Post Reply
stupid_moron
Beginner
Posts: 22
Joined: Tue Jan 21, 2020 7:05 am

Lighthouse + Swarm setup

Post by stupid_moron »

I have my Lighthouse setup and tested with the examples>swarm>hl-commander-swarm.py

Looking into the cflib>crazyflie>high_level_commander.py
I notice that there is a function called "def set_group_mask(self,groupmask=ALL_GROUPS)"

I was wondering how do i utalise this function? Suppose I only have 2 CF and would like them to:
1) Take off to 0.5m Together
2) CF1 hover, CF2 to increase height to 1m and hover
3) Both CF Perform the same size square(1m square)
4) CF1 to hover, CF2 to decrease height to 0.5m and hover
5) Landing together

I am planning to do more complicated task such as CF1 doing 1 flight pattern and CF 2 to do a differet flight pattern.
kristoffer
Bitcraze
Posts: 630
Joined: Tue Jun 30, 2015 7:47 am

Re: Lighthouse + Swarm setup

Post by kristoffer »

I have not worked with the group mask my self, but my understanding of the functionality is as follows:

The group mask is an 8 bit field with one bit for each group.
A Crazyflie can belong to one or multiple groups, set by calling the set_group_mask() function
When you call a high level commander function, for instance takeoff(), you specify which groups(s) this call should be applied to by setting a bit mask in the group_mask parameter.

An example:

CF1 belongs to group 3:

Code: Select all

cf1.high_level_commander.set_group_mask(2**3)
CF2 belongs to group 3 and 4

Code: Select all

cf2.high_level_commander.set_group_mask(2**4 | 2**3)
Move both CF1 and CF2 one meter in X

Code: Select all

cf1.high_level_commander.go_to(1, 0, 0, 0, 1, relative=true, group_mask(2**3))
cf2.high_level_commander.go_to(1, 0, 0, 0, 1, relative=true, group_mask(2**3))
Move only CF2 one meter in Y

Code: Select all

cf1.high_level_commander.go_to(0, 1, 0, 0, 1, relative=true, group_mask(2**4))
cf2.high_level_commander.go_to(0, 1, 0, 0, 1, relative=true, group_mask(2**4))
It can probably be handy when implementing a "broadcast" to all crazyflies in a swarm, but the same functionality could also be done in python.
Post Reply