[wpimath] Add structs for TrapezoidProfile.State and ExponentialProfile.State (#8163)

This commit is contained in:
Daniel Chen
2025-08-10 14:45:36 -04:00
committed by GitHub
parent 78fa67099e
commit f209ecb0cb
7 changed files with 145 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.math.trajectory.struct;
import static org.junit.jupiter.api.Assertions.assertEquals;
import edu.wpi.first.math.trajectory.ExponentialProfile;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import org.junit.jupiter.api.Test;
class ExponentialProfileStateStructTest {
private static final ExponentialProfile.State STATE = new ExponentialProfile.State(4.0, 5.0);
@Test
void testRoundtrip() {
ByteBuffer buffer = ByteBuffer.allocate(ExponentialProfile.State.struct.getSize());
buffer.order(ByteOrder.LITTLE_ENDIAN);
ExponentialProfile.State.struct.pack(buffer, STATE);
buffer.rewind();
assertEquals(STATE, ExponentialProfile.State.struct.unpack(buffer));
}
}

View File

@@ -0,0 +1,25 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.math.trajectory.struct;
import static org.junit.jupiter.api.Assertions.assertEquals;
import edu.wpi.first.math.trajectory.TrapezoidProfile;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import org.junit.jupiter.api.Test;
class TrapezoidProfileStateStructTest {
private static final TrapezoidProfile.State STATE = new TrapezoidProfile.State(4.0, 5.0);
@Test
void testRoundtrip() {
ByteBuffer buffer = ByteBuffer.allocate(TrapezoidProfile.State.struct.getSize());
buffer.order(ByteOrder.LITTLE_ENDIAN);
TrapezoidProfile.State.struct.pack(buffer, STATE);
buffer.rewind();
assertEquals(STATE, TrapezoidProfile.State.struct.unpack(buffer));
}
}