mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] Add ChassisSpeeds::ToTwist2d() to ChassisSpeeds (#6634)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import static edu.wpi.first.units.Units.Seconds;
|
||||
import edu.wpi.first.math.geometry.Pose2d;
|
||||
import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
import edu.wpi.first.math.geometry.Twist2d;
|
||||
import edu.wpi.first.math.kinematics.proto.ChassisSpeedsProto;
|
||||
import edu.wpi.first.math.kinematics.struct.ChassisSpeedsStruct;
|
||||
import edu.wpi.first.units.Angle;
|
||||
@@ -77,6 +78,19 @@ public class ChassisSpeeds implements ProtobufSerializable, StructSerializable {
|
||||
this(vx.in(MetersPerSecond), vy.in(MetersPerSecond), omega.in(RadiansPerSecond));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Twist2d from ChassisSpeeds.
|
||||
*
|
||||
* @param dtSeconds The duration of the timestep.
|
||||
* @return Twist2d.
|
||||
*/
|
||||
public Twist2d toTwist2d(double dtSeconds) {
|
||||
return new Twist2d(
|
||||
vxMetersPerSecond * dtSeconds,
|
||||
vyMetersPerSecond * dtSeconds,
|
||||
omegaRadiansPerSecond * dtSeconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Discretizes a continuous-time chassis speed.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user