File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
java/edu/wpi/first/math/kinematics
native/include/frc/kinematics Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -99,12 +99,19 @@ public static ChassisSpeeds discretize(
99
99
double vyMetersPerSecond ,
100
100
double omegaRadiansPerSecond ,
101
101
double dtSeconds ) {
102
+ // Construct the desired pose after a timestep, relative to the current pose. The desired pose
103
+ // has decoupled translation and rotation.
102
104
var desiredDeltaPose =
103
105
new Pose2d (
104
106
vxMetersPerSecond * dtSeconds ,
105
107
vyMetersPerSecond * dtSeconds ,
106
108
new Rotation2d (omegaRadiansPerSecond * dtSeconds ));
109
+
110
+ // Find the chassis translation/rotation deltas in the robot frame that move the robot from its
111
+ // current pose to the desired pose
107
112
var twist = new Pose2d ().log (desiredDeltaPose );
113
+
114
+ // Turn the chassis translation/rotation deltas into average velocities
108
115
return new ChassisSpeeds (twist .dx / dtSeconds , twist .dy / dtSeconds , twist .dtheta / dtSeconds );
109
116
}
110
117
Original file line number Diff line number Diff line change @@ -61,8 +61,15 @@ struct WPILIB_DLLEXPORT ChassisSpeeds {
61
61
units::meters_per_second_t vy,
62
62
units::radians_per_second_t omega,
63
63
units::second_t dt) {
64
+ // Construct the desired pose after a timestep, relative to the current
65
+ // pose. The desired pose has decoupled translation and rotation.
64
66
Pose2d desiredDeltaPose{vx * dt, vy * dt, omega * dt};
67
+
68
+ // Find the chassis translation/rotation deltas in the robot frame that move
69
+ // the robot from its current pose to the desired pose
65
70
auto twist = Pose2d{}.Log (desiredDeltaPose);
71
+
72
+ // Turn the chassis translation/rotation deltas into average velocities
66
73
return {twist.dx / dt, twist.dy / dt, twist.dtheta / dt};
67
74
}
68
75
You can’t perform that action at this time.
0 commit comments