The synchronous Crazyflie class is a wrapper around the “normal” Crazyflie class. It handles the asynchronous nature of the Crazyflie API and turns it into blocking functions. It is useful for simple scripts that performs tasks as a sequence of events.
Example:
with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
with PositionHlCommander(scf, default_height=0.5, default_velocity=0.2) as pc:
# fly onto a landing platform at non-zero height (ex: from floor to desk, etc)
pc.forward(1.0)
pc.left(1.0)
Classes
SyncCrazyflie
SyncCrazyflie(link_uri, cf=None)
Create a synchronous Crazyflie instance with the specified link_uri
Parameters
Name | Description |
---|---|
link_uri | The uri to use when connecting to the Crazyflie |
cf | Optional Crazyflie instance to use, None by default. If no object is supplied, a Crazyflie instance is created. This parameters is useful if you want to use a Crazyflie instance with log/param caching. |
Methods
def close_link(self)
def is_link_open(self)
def is_params_updated(self)
def open_link(self)
Open a link to a Crazyflie on the underlying Crazyflie instance.
This function is blocking and will return when the connection is established and TOCs for log and parameters have been downloaded or fetched from the cache.
Note: Parameter values have not been updated when this function returns. See the wait_for_params() method.
def wait_for_params(self)
Wait for parameter values to be updated.
During the connection sequence, parameter values are downloaded after the TOCs have been received. The open_link() method will return after the TOCs have been received but before the parameter values are downloaded. This method will block until the parameter values are received and can be used to make sure the connection sequence has terminated. In most cases this is not important, but radio bandwidth will be limited while parameters are downloaded due to the communication that is going on.
Example:
with SyncCrazyflie(uri, cf=Crazyflie(rw_cache='./cache')) as scf:
scf.wait_for_params()
# At this point the connection sequence is finished