helloworld
This commit is contained in:
parent
f43822b675
commit
864306c9bf
1 changed files with 8 additions and 8 deletions
|
@ -44,22 +44,22 @@ public class ftc2024_autonome extends LinearOpMode {
|
||||||
*/
|
*/
|
||||||
public double runPid(double angle2go){
|
public double runPid(double angle2go){
|
||||||
robotOrientation = imu.getRobotYawPitchRollAngles();
|
robotOrientation = imu.getRobotYawPitchRollAngles();
|
||||||
angle2go = (angle2go*180)/Math.PI
|
angle2go = (angle2go*180)/Math.PI;
|
||||||
double yaw = robotOrientation.getYaw(AngleUnit.RADIANS);
|
double P = 0.5;
|
||||||
double lastPos;
|
|
||||||
// command -1.0<command<1.0
|
|
||||||
double command = (angle2go-yaw)/2*Math.PI;
|
|
||||||
while (opModeIsActive()){
|
while (opModeIsActive()){
|
||||||
yaw = robotOrientation.getYaw(AngleUnit.RADIANS);
|
yaw = robotOrientation.getYaw(AngleUnit.RADIANS);
|
||||||
double currentPos = yaw;
|
double currentPos = yaw;
|
||||||
double error = currentPos-lastPos;
|
double error = yaw-currentpos;
|
||||||
lastPos = currentPos;
|
double command = (P * error)/Math.PI;
|
||||||
command += P * error;
|
command = clamp(command,.6);
|
||||||
lm.setPower(command);
|
lm.setPower(command);
|
||||||
rm.setPower(-command);
|
rm.setPower(-command);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
double clamp(double value, double max) {
|
||||||
|
return Math.max(-max, Math.min(max, value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runOpMode() {
|
public void runOpMode() {
|
||||||
|
|
Loading…
Reference in a new issue