feat: add PD and PID controller implementations (#804)
* feat: add a PID controller implementation * feat: add small rigid-body utilities + test interpolation test * fix: make scrolling weaker on macos * feat: add the option to use the PID controller in the character controller demo. * feat: add a stateless PD controller * feat(rapier_testbed): cleanup & support PidController in 2D too * chore: add comments for the PD and PID controllers * chore: update changelog * feat: rename PidErrors to PdErrors which is more accurate * fix cargo doc * chore: remove dead code * chore: make test module non-pub
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use crate::utils::character::{self, CharacterControlMode};
|
||||
use rapier3d::control::{KinematicCharacterController, PidController};
|
||||
use rapier3d::prelude::*;
|
||||
use rapier_testbed3d::Testbed;
|
||||
|
||||
@@ -83,10 +85,29 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let joint = RopeJointBuilder::new(2.0);
|
||||
impulse_joints.insert(character_handle, child_handle, joint, true);
|
||||
|
||||
/*
|
||||
* Callback to update the character based on user inputs.
|
||||
*/
|
||||
let mut control_mode = CharacterControlMode::Kinematic;
|
||||
let mut controller = KinematicCharacterController::default();
|
||||
let mut pid = PidController::default();
|
||||
|
||||
testbed.add_callback(move |graphics, physics, _, _| {
|
||||
if let Some(graphics) = graphics {
|
||||
character::update_character(
|
||||
graphics,
|
||||
physics,
|
||||
&mut control_mode,
|
||||
&mut controller,
|
||||
&mut pid,
|
||||
character_handle,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.set_character_body(character_handle);
|
||||
testbed.look_at(point![10.0, 10.0, 10.0], point![0.0, 0.0, 0.0]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user