Struct crazyflie_lib::Crazyflie
source · pub struct Crazyflie {
pub log: Log,
pub param: Param,
pub commander: Commander,
pub console: Console,
pub platform: Platform,
/* private fields */
}Expand description
§The Crazyflie
This struct is one-time use: Creating it will connect to a Crazyflie and once disconnected, either as requested by the lib user or as a result of a connection loss, the object cannot be reconnected. A new one need to be created to connect again.
See the crazyflie-lib crate root documentation for more context and information.
Fields§
§log: LogLog subsystem access
param: ParamParameter subsystem access
commander: CommanderCommander/setpoint subsystem access
console: ConsoleConsole subsystem access
platform: PlatformPlatform services
Implementations§
source§impl Crazyflie
impl Crazyflie
sourcepub async fn connect_from_uri(
executor: impl Executor,
link_context: &LinkContext,
uri: &str
) -> Result<Self>
pub async fn connect_from_uri( executor: impl Executor, link_context: &LinkContext, uri: &str ) -> Result<Self>
Open a Crazyflie connection to a given URI
This function opens a link to the given URI and calls Crazyflie::connect_from_link() to connect the Crazyflie.
The executor argument should be an async executor from the crate async_executors. See example in the
crate root documentation.
An error is returned either if the link cannot be opened or if the Crazyflie connection fails.
sourcepub async fn connect_from_link(
executor: impl Executor,
link: Connection
) -> Result<Self>
pub async fn connect_from_link( executor: impl Executor, link: Connection ) -> Result<Self>
Connect a Crazyflie using an existing link
Connect a Crazyflie using an existing connected link.
The executor argument should be an async executor from the crate async_executors. See example in the
crate root documentation.
This function will return an error if anything goes wrong in the connection process.
sourcepub async fn disconnect(&self)
pub async fn disconnect(&self)
Disconnect the Crazyflie
The Connection can be ended in two ways: either by dropping the Crazyflie object or by calling this disconnect() function. Once this function return, the Crazyflie is fully disconnected.
Once disconnected, any methods that uses the communication to the Crazyflie will return the error Error::Disconnected
sourcepub async fn wait_disconnect(&self) -> String
pub async fn wait_disconnect(&self) -> String
Wait for the Crazyflie to be disconnected
This function waits for the Crazyflie link to close and for the Crazyflie to fully disconnect. It returns a string describing the reason for the disconnection.
One intended use if to call and block on this function from an async task to detect a disconnection and, for example, update the state of a GUI.