Skip to content

Commit

Permalink
Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
srimanachanta committed Oct 13, 2023
1 parent 893aa1e commit 87306e0
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 66 deletions.
2 changes: 1 addition & 1 deletion datalogtool/src/main/native/cpp/Downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ void Downloader::ThreadMain() {
continue;
}
lock.lock();
err: {}
err : {}
}
if (m_state == kDownload) {
m_state = kDownloadDone;
Expand Down
45 changes: 22 additions & 23 deletions ntcore/src/test/java/edu/wpi/first/networktables/RawTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

package edu.wpi.first.networktables;

import static org.junit.jupiter.api.Assertions.*;

import java.nio.ByteBuffer;
import java.util.Arrays;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

@SuppressWarnings("PMD.SimplifiableTestAssertion")
class RawTest {
private NetworkTableInstance m_inst;
Expand All @@ -30,9 +29,9 @@ void tearDown() {
void testGenericByteArray() {
GenericEntry entry = m_inst.getTopic("test").getGenericEntry("raw");
entry.setRaw(new byte[] {5}, 10);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{5});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {5});
entry.setRaw(new byte[] {5, 6, 7}, 1, 2, 15);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{6, 7});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {6, 7});
assertThrows(IndexOutOfBoundsException.class, () -> entry.setRaw(new byte[] {5}, -1, 2, 20));
assertThrows(IndexOutOfBoundsException.class, () -> entry.setRaw(new byte[] {5}, 1, -2, 20));
assertThrows(IndexOutOfBoundsException.class, () -> entry.setRaw(new byte[] {5}, 1, 1, 20));
Expand All @@ -42,9 +41,9 @@ void testGenericByteArray() {
void testRawByteArray() {
RawEntry entry = m_inst.getRawTopic("test").getEntry("raw", new byte[] {});
entry.set(new byte[] {5}, 10);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{5});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {5});
entry.set(new byte[] {5, 6, 7}, 1, 2, 15);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{6, 7});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {6, 7});
assertThrows(IndexOutOfBoundsException.class, () -> entry.set(new byte[] {5}, -1, 1, 20));
assertThrows(IndexOutOfBoundsException.class, () -> entry.set(new byte[] {5}, 1, -1, 20));
assertThrows(IndexOutOfBoundsException.class, () -> entry.set(new byte[] {5}, 1, 1, 20));
Expand All @@ -54,15 +53,15 @@ void testRawByteArray() {
void testGenericByteBuffer() {
GenericEntry entry = m_inst.getTopic("test").getGenericEntry("raw");
entry.setRaw(ByteBuffer.wrap(new byte[] {5}), 10);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{5});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {5});
entry.setRaw(ByteBuffer.wrap(new byte[] {5, 6, 7}).position(1), 15);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{6, 7});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {6, 7});
entry.setRaw(ByteBuffer.wrap(new byte[] {5, 6, 7}).position(1).limit(2), 16);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{6});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {6});
entry.setRaw(ByteBuffer.wrap(new byte[] {8, 9, 0}), 1, 2, 20);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{9, 0});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {9, 0});
entry.setRaw(ByteBuffer.wrap(new byte[] {1, 2, 3}).position(2), 0, 2, 25);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{1, 2});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {1, 2});
assertThrows(
IndexOutOfBoundsException.class,
() -> entry.setRaw(ByteBuffer.wrap(new byte[] {5}), -1, 1, 30));
Expand All @@ -78,15 +77,15 @@ void testGenericByteBuffer() {
void testRawByteBuffer() {
RawEntry entry = m_inst.getRawTopic("test").getEntry("raw", new byte[] {});
entry.set(ByteBuffer.wrap(new byte[] {5}), 10);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{5});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {5});
entry.set(ByteBuffer.wrap(new byte[] {5, 6, 7}).position(1), 15);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{6, 7});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {6, 7});
entry.set(ByteBuffer.wrap(new byte[] {5, 6, 7}).position(1).limit(2), 16);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{6});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {6});
entry.set(ByteBuffer.wrap(new byte[] {8, 9, 0}), 1, 2, 20);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{9, 0});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {9, 0});
entry.set(ByteBuffer.wrap(new byte[] {1, 2, 3}).position(2), 0, 2, 25);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{1, 2});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {1, 2});
assertThrows(
IndexOutOfBoundsException.class,
() -> entry.set(ByteBuffer.wrap(new byte[] {5}), -1, 1, 30));
Expand All @@ -104,13 +103,13 @@ void testGenericNativeByteBuffer() {
ByteBuffer bb = ByteBuffer.allocateDirect(3);
bb.put(new byte[] {5, 6, 7});
entry.setRaw(bb.position(1), 15);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{6, 7});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {6, 7});
entry.setRaw(bb.limit(2), 16);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{6});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {6});
bb.clear();
bb.put(new byte[] {8, 9, 0});
entry.setRaw(bb, 1, 2, 20);
assertArrayEquals(entry.getRaw(new byte[]{}), new byte[]{9, 0});
assertArrayEquals(entry.getRaw(new byte[] {}), new byte[] {9, 0});
assertThrows(IndexOutOfBoundsException.class, () -> entry.setRaw(bb, -1, 1, 25));
assertThrows(IndexOutOfBoundsException.class, () -> entry.setRaw(bb, 1, -1, 25));
assertThrows(IndexOutOfBoundsException.class, () -> entry.setRaw(bb, 2, 2, 25));
Expand All @@ -122,13 +121,13 @@ void testRawNativeByteBuffer() {
ByteBuffer bb = ByteBuffer.allocateDirect(3);
bb.put(new byte[] {5, 6, 7});
entry.set(bb.position(1), 15);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{6, 7});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {6, 7});
entry.set(bb.limit(2), 16);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{6});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {6});
bb.clear();
bb.put(new byte[] {8, 9, 0});
entry.set(bb, 1, 2, 20);
assertArrayEquals(entry.get(new byte[]{}), new byte[]{9, 0});
assertArrayEquals(entry.get(new byte[] {}), new byte[] {9, 0});
assertThrows(IndexOutOfBoundsException.class, () -> entry.set(bb, -1, 1, 25));
assertThrows(IndexOutOfBoundsException.class, () -> entry.set(bb, 1, -1, 25));
assertThrows(IndexOutOfBoundsException.class, () -> entry.set(bb, 2, 2, 25));
Expand Down
16 changes: 8 additions & 8 deletions wpilibj/src/main/java/edu/wpi/first/wpilibj/DriverStation.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ public void send(long timestamp) {
needToLog = true;
} else {
for (int i = 0; i < count; i++) {
if (axes.m_axes[i] != m_prevAxes.m_axes[i]) {
needToLog = true;
break;
}
if (axes.m_axes[i] != m_prevAxes.m_axes[i]) {
needToLog = true;
break;
}
}
}
if (needToLog) {
Expand All @@ -254,10 +254,10 @@ public void send(long timestamp) {
needToLog = true;
} else {
for (int i = 0; i < count; i++) {
if (povs.m_povs[i] != m_prevPOVs.m_povs[i]) {
needToLog = true;
break;
}
if (povs.m_povs[i] != m_prevPOVs.m_povs[i]) {
needToLog = true;
break;
}
}
}
if (needToLog) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ private static class DataStore implements AutoCloseable {
output.write(("currentVersion=" + fwVersion).getBytes(StandardCharsets.UTF_8));
}
} catch (IOException ex) {
DriverStation.reportError(
"Could not write " + fileName + ": " + ex, ex.getStackTrace());
DriverStation.reportError("Could not write " + fileName + ": " + ex, ex.getStackTrace());
}
}

Expand Down
9 changes: 3 additions & 6 deletions wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ private static <T extends RobotBase> void runRobot(Supplier<T> robotSupplier) {
robotName = elements[0].getClassName();
}
DriverStation.reportError(
"Unhandled exception instantiating robot " + robotName + " " + throwable,
elements);
"Unhandled exception instantiating robot " + robotName + " " + throwable, elements);
DriverStation.reportError(
"The robot program quit unexpectedly."
+ " This is usually due to a code error.\n"
Expand Down Expand Up @@ -353,8 +352,7 @@ private static <T extends RobotBase> void runRobot(Supplier<T> robotSupplier) {
output.write(WPILibVersion.Version.getBytes(StandardCharsets.UTF_8));
}
} catch (IOException ex) {
DriverStation.reportError(
"Could not write FRC_Lib_Version.ini: " + ex, ex.getStackTrace());
DriverStation.reportError("Could not write FRC_Lib_Version.ini: " + ex, ex.getStackTrace());
}
}

Expand All @@ -366,8 +364,7 @@ private static <T extends RobotBase> void runRobot(Supplier<T> robotSupplier) {
if (cause != null) {
throwable = cause;
}
DriverStation.reportError(
"Unhandled exception: " + throwable, throwable.getStackTrace());
DriverStation.reportError("Unhandled exception: " + throwable, throwable.getStackTrace());
errorOnExit = true;
} finally {
m_runMutex.lock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public synchronized void setPoses(List<Pose2d> poses) {
*/
public synchronized void setPoses(Pose2d... poses) {
m_poses.clear();
Collections.addAll(m_poses, poses);
Collections.addAll(m_poses, poses);
updateEntry();
}

Expand Down
3 changes: 1 addition & 2 deletions wpimath/src/main/java/edu/wpi/first/math/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,7 @@ public Matrix<R, C> lltDecompose(boolean lowerTriangular) {
return new Matrix<>(new SimpleMatrix(temp.getNumRows(), temp.getNumCols()));
}

throw new RuntimeException(
"Cholesky decomposition failed! Input matrix:\n" + m_storage);
throw new RuntimeException("Cholesky decomposition failed! Input matrix:\n" + m_storage);
}

return new Matrix<>(SimpleMatrix.wrap(chol.getT(null)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ private SimpleMatrix makeHermiteBasis() {
// [a₀] = [ 1 0 0 0][P'(i+1)]
hermiteBasis =
new SimpleMatrix(
4,
4,
true,
+2.0, +1.0, -2.0, +1.0, -3.0, -2.0, +3.0, -1.0, +0.0, +1.0, +0.0, +0.0, +1.0, +0.0,
+0.0, +0.0);
4, 4, true, +2.0, +1.0, -2.0, +1.0, -3.0, -2.0, +3.0, -1.0, +0.0, +1.0, +0.0, +0.0,
+1.0, +0.0, +0.0, +0.0);
}
return hermiteBasis;
}
Expand All @@ -123,10 +120,6 @@ private SimpleMatrix getControlVectorFromArrays(double[] initialVector, double[]
throw new IllegalArgumentException("Size of vectors must be 2");
}
return new SimpleMatrix(
4,
1,
true,
initialVector[0], initialVector[1],
finalVector[0], finalVector[1]);
4, 1, true, initialVector[0], initialVector[1], finalVector[0], finalVector[1]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ private SimpleMatrix makeHermiteBasis() {
// [a₀] = [ 1.0 0.0 0.0 0.0 0.0 0.0][P"(i+1)]
hermiteBasis =
new SimpleMatrix(
6,
6,
true,
-06.0, -03.0, -00.5, +06.0, -03.0, +00.5, +15.0, +08.0, +01.5, -15.0, +07.0, -01.0,
-10.0, -06.0, -01.5, +10.0, -04.0, +00.5, +00.0, +00.0, +00.5, +00.0, +00.0, +00.0,
+00.0, +01.0, +00.0, +00.0, +00.0, +00.0, +01.0, +00.0, +00.0, +00.0, +00.0, +00.0);
6, 6, true, -06.0, -03.0, -00.5, +06.0, -03.0, +00.5, +15.0, +08.0, +01.5, -15.0,
+07.0, -01.0, -10.0, -06.0, -01.5, +10.0, -04.0, +00.5, +00.0, +00.0, +00.5, +00.0,
+00.0, +00.0, +00.0, +01.0, +00.0, +00.0, +00.0, +00.0, +01.0, +00.0, +00.0, +00.0,
+00.0, +00.0);
}
return hermiteBasis;
}
Expand All @@ -134,7 +132,11 @@ private SimpleMatrix getControlVectorFromArrays(double[] initialVector, double[]
6,
1,
true,
initialVector[0], initialVector[1], initialVector[2],
finalVector[0], finalVector[1], finalVector[2]);
initialVector[0],
initialVector[1],
initialVector[2],
finalVector[0],
finalVector[1],
finalVector[2]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void testSimultaneousVisionMeasurements() {
measurement.getRotation().getDegrees()
- estimator.getEstimatedPosition().getRotation().getDegrees());

assertTrue(dx > 0.08 || dy > 0.08 || dtheta > 0.08, errorLog);
assertTrue(dx > 0.08 || dy > 0.08 || dtheta > 0.08, errorLog);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void testSimultaneousVisionMeasurements() {
measurement.getRotation().getDegrees()
- estimator.getEstimatedPosition().getRotation().getDegrees());

assertTrue(dx > 0.08 || dy > 0.08 || dtheta > 0.08, errorLog);
assertTrue(dx > 0.08 || dy > 0.08 || dtheta > 0.08, errorLog);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void testSimultaneousVisionMeasurements() {
measurement.getRotation().getDegrees()
- estimator.getEstimatedPosition().getRotation().getDegrees());

assertTrue(dx > 0.08 || dy > 0.08 || dtheta > 0.08, errorLog);
assertTrue(dx > 0.08 || dy > 0.08 || dtheta > 0.08, errorLog);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.spline.SplineParameterizer.MalformedSplineException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -151,7 +150,7 @@ void testMalformed() {
() ->
run(
new Pose2d(10, 10, Rotation2d.fromDegrees(90)),
List.of(new Translation2d(10, 10.5)),
List.of(new Translation2d(10, 10.5)),
new Pose2d(10, 11, Rotation2d.fromDegrees(-90))));
}
}

0 comments on commit 87306e0

Please sign in to comment.