Skip to content

Commit

Permalink
Allow for field centric or robot centric velocities on NavX2
Browse files Browse the repository at this point in the history
  • Loading branch information
viggy96 committed Nov 6, 2024
1 parent 83dffc7 commit c80d79c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/org/lasarobotics/hardware/kauailabs/NavX2.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ private void updateInputs() {
var chassisSpeeds = m_fieldCentricVelocities
? new ChassisSpeeds(getVelocityX(), getVelocityY(), getYawRate())
: ChassisSpeeds.fromFieldRelativeSpeeds(
getVelocityX(),
getVelocityY(),
getYawRate(),
Rotation2d.fromRadians(getYaw().in(Units.Radians))
);
getVelocityX(),
getVelocityY(),
getYawRate(),
Rotation2d.fromRadians(getYaw().in(Units.Radians))
);
m_inputs.isConnected = m_navx.isConnected();
m_inputs.rollAngle.mut_replace(getRoll());
m_inputs.pitchAngle.mut_replace(getPitch());
Expand Down Expand Up @@ -269,6 +269,7 @@ public void invertXYAxes(boolean invert) {
* Whether or not to make velocity readings field centric.
* <p>
* Defaults to false, so velocity readings are robot centric.
* Acceleration readings remain field centric regardless of this setting.
* @param fieldCentric
*/
public void fieldCentricVelocities(boolean fieldCentric) {
Expand Down

0 comments on commit c80d79c

Please sign in to comment.