Add Basic Sim Example (#237)

* WIP adding sim pose example

* WIP making examples buildable like WPI. Not quite there yet....

* Make examples runnable

* remove lock

* add lock

* WIP Adding a simpler example for simulation

* Spotless Apply

* Added simulation-supporting aim and range example

* Spotless, revised hand usage to be consistent across examples, and propagated required -1.0's to non-sim examples.

Co-authored-by: Prateek Machiraju <prateek.machiraju@gmail.com>
This commit is contained in:
Chris Gerth
2021-01-26 22:26:15 -06:00
committed by GitHub
parent 4c15a46cda
commit 0330467874
19 changed files with 708 additions and 29 deletions

View File

@@ -36,12 +36,14 @@ void Robot::TeleopPeriodic() {
units::degree_t{result.GetBestTarget().GetPitch()});
// Use this range as the measurement we give to the PID controller.
forwardSpeed = forwardController.Calculate(
// -1.0 required to ensure positive PID controller effort _increases_ range
forwardSpeed = -1.0* forwardController.Calculate(
range.to<double>(), GOAL_RANGE_METERS.to<double>());
// Also calculate angular power
rotationSpeed =
turnController.Calculate(result.GetBestTarget().GetYaw(), 0);
// -1.0 required to ensure positive PID controller effort _increases_ yaw
rotationSpeed = -1.0 * turnController.Calculate(
result.GetBestTarget().GetYaw(), 0);
} else {
// If we have no targets, stay still.
forwardSpeed = 0;
@@ -50,7 +52,7 @@ void Robot::TeleopPeriodic() {
} else {
// Manual Driver Mode
forwardSpeed =
xboxController.GetY(frc::GenericHID::JoystickHand::kRightHand);
-1.0 * xboxController.GetY(frc::GenericHID::JoystickHand::kRightHand);
rotationSpeed =
xboxController.GetX(frc::GenericHID::JoystickHand::kLeftHand);
}