mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-22 06:41:39 +00:00
Updated documentation. Fixed setChassisSpeeds
This commit is contained in:
@@ -10,6 +10,7 @@ import edu.wpi.first.math.geometry.Transform2d;
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
import edu.wpi.first.math.kinematics.ChassisSpeeds;
|
||||
import edu.wpi.first.math.kinematics.SwerveModulePosition;
|
||||
import edu.wpi.first.math.trajectory.Trajectory;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.Field2d;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
@@ -168,17 +169,16 @@ public class SwerveDrive
|
||||
}
|
||||
|
||||
/**
|
||||
* Set field-relative chassis speeds with closed-loop velocity control.
|
||||
* Set chassis speeds with closed-loop velocity control.
|
||||
*
|
||||
* @param chassisSpeeds Field-relative.
|
||||
* @param chassisSpeeds Chassis speeds to set.
|
||||
*/
|
||||
public void setChassisSpeeds(ChassisSpeeds chassisSpeeds)
|
||||
{
|
||||
setModuleStates(kinematics.toSwerveModuleStates(ChassisSpeeds.fromFieldRelativeSpeeds(chassisSpeeds, getYaw())),
|
||||
setModuleStates(kinematics.toSwerveModuleStates(chassisSpeeds),
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the current pose (position and rotation) of the robot, as reported by odometry.
|
||||
*
|
||||
@@ -225,6 +225,16 @@ public class SwerveDrive
|
||||
swerveDrivePoseEstimator.resetPosition(getYaw(), getModulePositions(), pose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post the trajectory to the field
|
||||
*
|
||||
* @param trajectory the trajectory to post.
|
||||
*/
|
||||
public void postTrajectory(Trajectory trajectory)
|
||||
{
|
||||
field.getObject("Trajectory").setTrajectory(trajectory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current module states (azimuth and velocity)
|
||||
*
|
||||
@@ -425,7 +435,7 @@ public class SwerveDrive
|
||||
|
||||
field.setRobotPose(swerveDrivePoseEstimator.getEstimatedPosition());
|
||||
|
||||
double[] moduleStates = new double[8];
|
||||
double[] moduleStates = new double[swerveModules.length * 2];
|
||||
for (SwerveModule module : swerveModules)
|
||||
{
|
||||
SmartDashboard.putNumber("Module" + module.moduleNumber + "Absolute Encoder", module.getAbsolutePosition());
|
||||
|
||||
Reference in New Issue
Block a user