pub struct Commander { /* private fields */ }Expand description
§Low level setpoint subsystem
This struct implements methods to send low level setpoints to the Crazyflie. See the commander module documentation for more context and information.
Implementations§
Source§impl Commander
§Legacy RPY+ setpoint
This setpoint was originally the only one present in the Crazyflie and has been (ab)used to
implement the early position control and other assisted and semi-autonomous mode.
impl Commander
§Legacy RPY+ setpoint
This setpoint was originally the only one present in the Crazyflie and has been (ab)used to implement the early position control and other assisted and semi-autonomous mode.
Sourcepub async fn setpoint_rpyt(
&self,
roll: f32,
pitch: f32,
yawrate: f32,
thrust: u16,
) -> Result<()>
pub async fn setpoint_rpyt( &self, roll: f32, pitch: f32, yawrate: f32, thrust: u16, ) -> Result<()>
Sends a Roll, Pitch, Yawrate, and Thrust setpoint to the Crazyflie.
By default, unless modified by parameters, the arguments are interpreted as:
roll- Desired roll angle (degrees)pitch- Desired pitch angle (degrees)yawrate- Desired yaw rate (degrees/second)thrust- Thrust as a 16-bit value (0 = 0% thrust, 65535 = 100% thrust)
Note: Thrust is locked by default for safety. To unlock, send a setpoint with thrust = 0 once before sending nonzero thrust values.
Example:
cf.commander.setpoint_rpyt(0.0, 0.0, 0.0, 0); // Unlocks thrust
cf.commander.setpoint_rpyt(0.0, 0.0, 0.0, 1000); // Sets thrust to 1000Source§impl Commander
§Generic setpoints
These setpoints are implemented in such a way that they are easy to add in the Crazyflie firmware
and in libs like this one. So if you have a use-case not covered by any of the existing setpoint
do not hesitate to implement and contribute your dream setpoint :-).
impl Commander
§Generic setpoints
These setpoints are implemented in such a way that they are easy to add in the Crazyflie firmware and in libs like this one. So if you have a use-case not covered by any of the existing setpoint do not hesitate to implement and contribute your dream setpoint :-).
Sourcepub async fn setpoint_position(
&self,
x: f32,
y: f32,
z: f32,
yaw: f32,
) -> Result<()>
pub async fn setpoint_position( &self, x: f32, y: f32, z: f32, yaw: f32, ) -> Result<()>
Sends an absolute position setpoint in world coordinates, with yaw as an absolute orientation.
§Arguments
x- Target x position (meters, world frame)y- Target y position (meters, world frame)z- Target z position (meters, world frame)yaw- Target yaw angle (degrees, absolute)
Sourcepub async fn setpoint_velocity_world(
&self,
vx: f32,
vy: f32,
vz: f32,
yawrate: f32,
) -> Result<()>
pub async fn setpoint_velocity_world( &self, vx: f32, vy: f32, vz: f32, yawrate: f32, ) -> Result<()>
Sends a velocity setpoint in the world frame, with yaw rate control.
§Arguments
vx- Target velocity in x (meters/second, world frame)vy- Target velocity in y (meters/second, world frame)vz- Target velocity in z (meters/second, world frame)yawrate- Target yaw rate (degrees/second)
Sourcepub async fn setpoint_zdistance(
&self,
roll: f32,
pitch: f32,
yawrate: f32,
zdistance: f32,
) -> Result<()>
pub async fn setpoint_zdistance( &self, roll: f32, pitch: f32, yawrate: f32, zdistance: f32, ) -> Result<()>
Sends a setpoint with absolute height (distance to the surface below), roll, pitch, and yaw rate commands.
§Arguments
roll- Desired roll angle (degrees)pitch- Desired pitch angle (degrees)yawrate- Desired yaw rate (degrees/second)zdistance- Target height above ground (meters)
Sourcepub async fn setpoint_hover(
&self,
vx: f32,
vy: f32,
yawrate: f32,
zdistance: f32,
) -> Result<()>
pub async fn setpoint_hover( &self, vx: f32, vy: f32, yawrate: f32, zdistance: f32, ) -> Result<()>
Sends a setpoint with absolute height (distance to the surface below), and x/y velocity commands in the body-fixed frame.
§Arguments
vx- Target velocity in x (meters/second, body frame)vy- Target velocity in y (meters/second, body frame)yawrate- Target yaw rate (degrees/second)zdistance- Target height above ground (meters)
Sourcepub async fn setpoint_manual(
&self,
roll: f32,
pitch: f32,
yawrate: f32,
thrust_percentage: f32,
rate: bool,
) -> Result<()>
pub async fn setpoint_manual( &self, roll: f32, pitch: f32, yawrate: f32, thrust_percentage: f32, rate: bool, ) -> Result<()>
Sends a manual control setpoint for roll, pitch, yaw rate, and thrust percentage.
If rate is false, roll and pitch are interpreted as angles (degrees). If rate is true, they are interpreted as rates (degrees/second).
§Arguments
roll- Desired roll (degrees or degrees/second, depending onrate)pitch- Desired pitch (degrees or degrees/second, depending onrate)yawrate- Desired yaw rate (degrees/second)thrust_percentage- Thrust as a percentage (0 to 100)rate- If true, use rate mode; if false, use angle mode
Sourcepub async fn setpoint_stop(&self) -> Result<()>
pub async fn setpoint_stop(&self) -> Result<()>
Sends a STOP setpoint, immediately stopping the motors. The Crazyflie will lose lift and may fall.
Sourcepub async fn notify_setpoint_stop(
&self,
remain_valid_milliseconds: u32,
) -> Result<()>
pub async fn notify_setpoint_stop( &self, remain_valid_milliseconds: u32, ) -> Result<()>
Notify the firmware that low-level setpoints have stopped.
This tells the Crazyflie to drop the current low-level setpoint priority, allowing the High-level commander (or other sources) to take control again.
§Arguments
remain_valid_milliseconds- How long (in ms) the last low-level setpoint should remain valid before it is considered stale. Use0to make the hand-off immediate; small non-zero values can smooth transitions if needed.
§Examples
Hand control back to the High-level commander after a manual low-level burst:
// ... you were sending low-level setpoints here ...
cmd.notify_setpoint_stop(0).await?; // allow HL commander to resume