Classes
CachedCfFactory
CachedCfFactory(ro_cache=None, rw_cache=None)
Factory class that creates Crazyflie instances with TOC caching to reduce connection time.
Methods
def construct(self, uri)
Swarm
Swarm(uris, factory=<cflib.crazyflie.swarm._Factory object>)
Runs a swarm of Crazyflies. It implements a functional-ish style of sequential or parallel actions on all individuals of the swarm.
When the swarm is connected, a link is opened to each Crazyflie through SyncCrazyflie instances. The instances are maintained by the class and are passed in as the first argument in swarm wide actions.
Constructs a Swarm instance and instances used to connect to the Crazyflies
Parameters
Name | Description |
---|---|
uris | A set of uris to use when connecting to the Crazyflies inthe swarm |
factory | A factory class used to create the instances that are used to open links to the Crazyflies. Mainly used for unit testing. |
Class variables
Reporter
Methods
def close_links(self)
Close all open links
def get_estimated_positions(self)
Return a dict
, keyed by URI and with the SwarmPosition namedtuples as
value, with the estimated (x, y, z) of each Crazyflie in the swarm.
def open_links(self)
Open links to all individuals in the swarm
def parallel(self, func, args_dict=None)
Execute a function for all Crazyflies in the swarm, in parallel. One thread per Crazyflie is started to execute the function. The threads are joined at the end. Exceptions raised by the threads are ignored.
For a more detailed description of the arguments, see sequential()
Parameters
Name | Description |
---|---|
func | The function to execute |
args_dict | Parameters to pass to the function |
def parallel_safe(self, func, args_dict=None)
Execute a function for all Crazyflies in the swarm, in parallel. One thread per Crazyflie is started to execute the function. The threads are joined at the end and if one or more of the threads raised an exception this function will also raise an exception.
For a more detailed description of the arguments, see sequential()
Parameters
Name | Description |
---|---|
func | The function to execute |
args_dict | Parameters to pass to the function |
def reset_estimators(self)
Reset estimator on all members of the swarm and wait for a stable positions. Blocks until position estimators finds a position.
def sequential(self, func, args_dict=None)
Execute a function for all Crazyflies in the swarm, in sequence.
The first argument of the function that is passed in will be a
SyncCrazyflie instance connected to the Crazyflie to operate on.
A list of optional parameters (per Crazyflie) may follow defined by
the args_dict
. The dictionary is keyed on URI and has a list of
parameters as value.
Example:
def my_function(scf, optional_param0, optional_param1)
...
args_dict = {
URI0: [optional_param0_cf0, optional_param1_cf0],
URI1: [optional_param0_cf1, optional_param1_cf1],
...
}
swarm.sequential(my_function, args_dict)
Parameters
Name | Description |
---|---|
func | The function to execute |
args_dict | Parameters to pass to the function |
SwarmPosition
SwarmPosition(x, y, z)
SwarmPosition(x, y, z)
Ancestors (in MRO)
- builtins.tuple
Instance variables
x
Alias for field number 0
y
Alias for field number 1
z
Alias for field number 2