pub struct PdController {
pub lin_kp: Vector<f32>,
pub lin_kd: Vector<f32>,
pub ang_kp: AngVector<f32>,
pub ang_kd: AngVector<f32>,
pub axes: AxesMask,
}Expand description
A Proportional-Derivative (PD) controller.
This is useful for controlling a rigid-body at the velocity level so it matches a target pose.
This is a PID controller without the Integral part to keep the API immutable, while having a behaviour generally sufficient for games.
Fields§
§lin_kp: Vector<f32>The Proportional gain applied to the instantaneous linear position errors.
This is usually set to a multiple of the inverse of simulation step time
(e.g. 60 if the delta-time is 1.0 / 60.0).
lin_kd: Vector<f32>The Derivative gain applied to the instantaneous linear velocity errors.
This is usually set to a value in [0.0, 1.0] where 0.0 implies no damping
(no correction of velocity errors) and 1.0 implies complete damping (velocity errors
are corrected in a single simulation step).
ang_kp: AngVector<f32>The Proportional gain applied to the instantaneous angular position errors.
This is usually set to a multiple of the inverse of simulation step time
(e.g. 60 if the delta-time is 1.0 / 60.0).
ang_kd: AngVector<f32>The Derivative gain applied to the instantaneous angular velocity errors.
This is usually set to a value in [0.0, 1.0] where 0.0 implies no damping
(no correction of velocity errors) and 1.0 implies complete damping (velocity errors
are corrected in a single simulation step).
axes: AxesMaskThe axes affected by this controller.
Only coordinate axes with a bit flags set to true will be taken into
account when calculating the errors and corrections.
Implementations§
Source§impl PdController
impl PdController
Sourcepub fn new(kp: f32, kd: f32, axes: AxesMask) -> PdController
pub fn new(kp: f32, kd: f32, axes: AxesMask) -> PdController
Initialized the PD controller with uniform gain.
The same gain are applied on all axes. To configure per-axes gains, construct
the PdController by setting its fields explicitly instead.
Only the axes specified in axes will be enabled (but the gain values are set
on all axes regardless).
Sourcepub fn linear_rigid_body_correction(
&self,
rb: &RigidBody,
target_pos: Point<f32>,
target_linvel: Vector<f32>,
) -> Vector<f32>
pub fn linear_rigid_body_correction( &self, rb: &RigidBody, target_pos: Point<f32>, target_linvel: Vector<f32>, ) -> Vector<f32>
Calculates the linear correction from positional and velocity errors calculated automatically from a rigid-body and the desired positions/velocities.
The unit of the returned value depends on the gain values. In general, kd is proportional to
the inverse of the simulation step so the returned value is a linear rigid-body velocity
change.
Sourcepub fn angular_rigid_body_correction(
&self,
rb: &RigidBody,
target_rot: Rotation<f32>,
target_angvel: AngVector<f32>,
) -> AngVector<f32>
pub fn angular_rigid_body_correction( &self, rb: &RigidBody, target_rot: Rotation<f32>, target_angvel: AngVector<f32>, ) -> AngVector<f32>
Calculates the angular correction from positional and velocity errors calculated automatically from a rigid-body and the desired positions/velocities.
The unit of the returned value depends on the gain values. In general, kd is proportional to
the inverse of the simulation step so the returned value is an angular rigid-body velocity
change.
Sourcepub fn rigid_body_correction(
&self,
rb: &RigidBody,
target_pose: Isometry<f32>,
target_vels: RigidBodyVelocity<f32>,
) -> RigidBodyVelocity<f32>
pub fn rigid_body_correction( &self, rb: &RigidBody, target_pose: Isometry<f32>, target_vels: RigidBodyVelocity<f32>, ) -> RigidBodyVelocity<f32>
Calculates the linear and angular correction from positional and velocity errors calculated automatically from a rigid-body and the desired poses/velocities.
The unit of the returned value depends on the gain values. In general, kd is proportional to
the inverse of the simulation step so the returned value is a rigid-body velocity
change.
Sourcepub fn correction(
&self,
pose_errors: &PdErrors,
vel_errors: &PdErrors,
) -> RigidBodyVelocity<f32>
pub fn correction( &self, pose_errors: &PdErrors, vel_errors: &PdErrors, ) -> RigidBodyVelocity<f32>
Calculates the linear and angular correction from the given positional and velocity errors.
The unit of the returned value depends on the gain values. In general, kd is proportional to
the inverse of the simulation step so the returned value is a rigid-body velocity
change.
Trait Implementations§
Source§impl Clone for PdController
impl Clone for PdController
Source§fn clone(&self) -> PdController
fn clone(&self) -> PdController
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PdController
impl Debug for PdController
Source§impl Default for PdController
impl Default for PdController
Source§impl PartialEq for PdController
impl PartialEq for PdController
impl Copy for PdController
impl StructuralPartialEq for PdController
Auto Trait Implementations§
impl Freeze for PdController
impl RefUnwindSafe for PdController
impl Send for PdController
impl Sync for PdController
impl Unpin for PdController
impl UnwindSafe for PdController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.