mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-09 08:38:02 -06:00
arm pids
This commit is contained in:
@@ -146,10 +146,10 @@ public class RobotContainer {
|
|||||||
|
|
||||||
|
|
||||||
new JoystickButton(getDeadbandedOperatorController(), XboxController.A_BUTTON)
|
new JoystickButton(getDeadbandedOperatorController(), XboxController.A_BUTTON)
|
||||||
.whileTrue(new RunCommand(() -> new PivotCommand(m_robotArm, 135)));
|
.onTrue(new PivotCommand(m_robotArm, 135));
|
||||||
|
|
||||||
new JoystickButton(getDeadbandedOperatorController(), XboxController.B_BUTTON)
|
new JoystickButton(getDeadbandedOperatorController(), XboxController.B_BUTTON)
|
||||||
.whileTrue(new RunCommand(() -> m_robotArm.m_pivot.set(TalonFXControlMode.Position, 135), m_robotArm));
|
.onTrue(new PivotCommand(m_robotArm, 210));
|
||||||
|
|
||||||
new JoystickButton(getDeadbandedOperatorController(), XboxController.X_BUTTON)
|
new JoystickButton(getDeadbandedOperatorController(), XboxController.X_BUTTON)
|
||||||
.onTrue(new InstantCommand(() -> m_robotClaw.toggle()));
|
.onTrue(new InstantCommand(() -> m_robotClaw.toggle()));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package frc4388.robot.commands;
|
package frc4388.robot.commands;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||||
import frc4388.utility.Gains;
|
import frc4388.utility.Gains;
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ public abstract class PelvicInflammatoryDisease extends CommandBase {
|
|||||||
// Returns true when the command should end.
|
// Returns true when the command should end.
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinished() {
|
public boolean isFinished() {
|
||||||
|
SmartDashboard.putBoolean("isFinished", Math.abs(getError()) < tolerance);
|
||||||
return Math.abs(getError()) < tolerance;
|
return Math.abs(getError()) < tolerance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package frc4388.robot.commands;
|
package frc4388.robot.commands;
|
||||||
|
|
||||||
|
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||||
import frc4388.robot.subsystems.Arm;
|
import frc4388.robot.subsystems.Arm;
|
||||||
|
|
||||||
public class PivotCommand extends PelvicInflammatoryDisease {
|
public class PivotCommand extends PelvicInflammatoryDisease {
|
||||||
@@ -12,7 +13,7 @@ public class PivotCommand extends PelvicInflammatoryDisease {
|
|||||||
|
|
||||||
/** Creates a new ArmCommand. */
|
/** Creates a new ArmCommand. */
|
||||||
public PivotCommand(Arm arm, double target) {
|
public PivotCommand(Arm arm, double target) {
|
||||||
super(0.6, 0, 0, 0, 0);
|
super(6, 1.5, 0, 0, 0.015);
|
||||||
this.arm = arm;
|
this.arm = arm;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
addRequirements(arm);
|
addRequirements(arm);
|
||||||
@@ -20,11 +21,12 @@ public class PivotCommand extends PelvicInflammatoryDisease {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getError() {
|
public double getError() {
|
||||||
return (arm.getArmRotation() - target) / 360;
|
return (target - arm.getArmRotation()) / 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runWithOutput(double output) {
|
public void runWithOutput(double output) {
|
||||||
|
SmartDashboard.putNumber("pivot output", output);
|
||||||
arm.setRotVel(output);
|
arm.setRotVel(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ public class Arm extends SubsystemBase {
|
|||||||
if ((degrees < 2 && vel < 0) || (degrees > 110 && vel > 0)) {
|
if ((degrees < 2 && vel < 0) || (degrees > 110 && vel > 0)) {
|
||||||
m_pivot.set(ControlMode.PercentOutput, 0);
|
m_pivot.set(ControlMode.PercentOutput, 0);
|
||||||
} else if (degrees > 90 && vel > 0) {
|
} else if (degrees > 90 && vel > 0) {
|
||||||
m_pivot.set(ControlMode.PercentOutput, .2 * vel);
|
m_pivot.set(ControlMode.PercentOutput, .15 * vel);
|
||||||
} else {
|
} else {
|
||||||
m_pivot.set(ControlMode.PercentOutput, .4 * vel);
|
m_pivot.set(ControlMode.PercentOutput, .3 * vel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user