8
8
import edu .wpi .first .math .geometry .Rotation2d ;
9
9
import edu .wpi .first .math .kinematics .ChassisSpeeds ;
10
10
import edu .wpi .first .math .trajectory .TrapezoidProfile ;
11
+ import edu .wpi .first .wpilibj .smartdashboard .SmartDashboard ;
11
12
import edu .wpi .first .wpilibj2 .command .CommandBase ;
12
13
import frc .robot .drive .Drivetrain ;
13
14
@@ -21,27 +22,35 @@ public MotionProfileTurn(Drivetrain drive, double offset) {
21
22
this .drive = drive ;
22
23
this .offset = offset ;
23
24
addRequirements (drive );
24
- controller = new ProfiledPIDController (0.0 , 0.0 , 0.0 , new TrapezoidProfile .Constraints (10 , 10 ));
25
- controller .enableContinuousInput (-Math .PI , Math .PI );
26
25
}
27
26
28
27
@ Override
29
28
public void initialize () {
30
- target = offset + drive .getPose ().getRotation ().getRadians ();
29
+ // target = offset + drive.getPose().getRotation().getRadians();
30
+ SmartDashboard .putString ("Turning" , "Enabled" );
31
+ target = 0 ;
32
+ controller = new ProfiledPIDController (0.35 , 0.0 , 0.0 , new TrapezoidProfile .Constraints (10 , 10 ), 0.02 );
33
+ controller .enableContinuousInput (-Math .PI , Math .PI );
31
34
}
32
35
33
36
@ Override
34
37
public void execute () {
35
38
double theta = drive .getPose ().getRotation ().getRadians ();
36
- double feedback = controller .calculate (theta , 0 );
39
+ double feedback = controller .calculate (theta , 1 );
37
40
double feedforward = controller .getSetpoint ().velocity ;
41
+ SmartDashboard .putNumber ("Theta Angle" , theta );
42
+ SmartDashboard .putNumber ("Turning Feedforward" , feedforward );
38
43
drive .drive (new ChassisSpeeds (0 , 0 , feedforward ), false );
44
+ target ++;
45
+ SmartDashboard .putNumber ("Loops" , target );
46
+ // drive.drive(new ChassisSpeeds(0, 0, 1), false);
39
47
}
40
48
41
49
// Called once the command ends or is interrupted.
42
50
@ Override
43
51
public void end (boolean interrupted ) {
44
52
drive .brake ();
53
+ SmartDashboard .putString ("Turning" , "Disabled" );
45
54
}
46
55
47
56
// Returns true when the command should end.
0 commit comments