diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml new file mode 100644 index 0000000000..fcce8a5b52 --- /dev/null +++ b/.github/workflows/integration-test.yml @@ -0,0 +1,129 @@ +name: Choreo -> ChoreoLib Integration Test + +on: [pull_request, push] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + generate: + name: "Generate trajectories for integration test" + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + token: ${{secrets.GITHUB_TOKEN}} + + - name: Install Linux dependencies + run: | + sudo apt-get update -q + sudo apt-get install -y \ + build-essential \ + curl \ + file \ + libayatana-appindicator3-dev \ + libgtk-3-dev \ + librsvg2-dev \ + libssl-dev \ + libwebkit2gtk-4.0-dev \ + wget + + - name: Set up sccache + uses: mozilla-actions/sccache-action@v0.0.5 + - name: Cargo test Generate latest + run: cargo test -- --include-ignored integration_tests::generate::generate::generate_latest + - uses: actions/upload-artifact@v4 + with: + name: swerve.traj + path: ./src-core/test-tmp-latest/swerve/swerve.traj + - uses: actions/upload-artifact@v4 + with: + name: differential.traj + path: ./src-core/test-tmp-latest/differential/differential.traj + + test-host: + needs: [generate] + env: + MACOSX_DEPLOYMENT_TARGET: 13.3 + strategy: + fail-fast: false + matrix: + include: + - os: windows-2022 + artifact-name: Windows-x86_64 + build-options: + - os: ubuntu-22.04 + + # FIXME: Link failure on commands library + # - os: windows-2022 + # artifact-name: Windows-aarch64 + # build-options: -Pbuildwinarm64 -Ponlywindowsarm64 + + - os: macOS-13 + artifact-name: macOS-x86_64 + build-options: + + - os: macOS-14 + artifact-name: macOS-arm64 + build-options: + + name: "Test C++ and Java / ${{ matrix.artifact-name }}" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + persist-credentials: false + token: ${{secrets.GITHUB_TOKEN}} + + - name: Fetch all history and metadata + run: git fetch --prune --unshallow + + - name: Download swerve trajectory + uses: actions/download-artifact@v4 + with: + path: ./choreolib/src/test/resources/ + pattern: "swerve.traj" + - name: Download differential trajectory + uses: actions/download-artifact@v4 + with: + path: ./choreolib/src/test/resources/ + pattern: "differential.traj" + - uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: 17 + + - name: Test with Gradle + working-directory: choreolib + run: ./gradlew test -Dprofile=integration ${{ matrix.build-options }} + + test-python: + name: "Test Python" + needs: [generate] + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + token: ${{secrets.GITHUB_TOKEN}} + + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - run: pip3 install build wheel pytest + + - run: python3 -m build + working-directory: ./choreolib/py + - run: pip3 install --no-cache-dir dist/*.whl + working-directory: ./choreolib/py + - run: pytest + working-directory: ./choreolib/py + + + diff --git a/choreolib/build.gradle b/choreolib/build.gradle index 872187f2d9..b47900d9c3 100644 --- a/choreolib/build.gradle +++ b/choreolib/build.gradle @@ -75,6 +75,9 @@ test { events "failed" exceptionFormat "full" } + if (System.properties['profile'] != 'integration') { + exclude '**/IntegrationTest*' + } } if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxarm32') || project.hasProperty('onlylinuxarm64') || project.hasProperty('onlywindowsarm64')) { diff --git a/choreolib/src/test/java/choreo/IntegrationTests.java b/choreolib/src/test/java/choreo/IntegrationTests.java new file mode 100644 index 0000000000..2f0cafb034 --- /dev/null +++ b/choreolib/src/test/java/choreo/IntegrationTests.java @@ -0,0 +1,20 @@ +package choreo; + +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.File; +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import choreo.Choreo; +import choreo.trajectory.TrajectoryTestHelper; +import edu.wpi.first.wpilibj.Filesystem; + +public class IntegrationTests { + @Test + void readDeployDirectory() throws IOException { + var swerveString = TrajectoryTestHelper.getResourceFileAsString("swerve.traj"); + Choreo.loadTrajectoryString(swerveString); + } +} diff --git a/choreolib/src/test/java/choreo/trajectory/TrajectoryTestHelper.java b/choreolib/src/test/java/choreo/trajectory/TrajectoryTestHelper.java index 650b65e5d6..91028d64d7 100644 --- a/choreolib/src/test/java/choreo/trajectory/TrajectoryTestHelper.java +++ b/choreolib/src/test/java/choreo/trajectory/TrajectoryTestHelper.java @@ -3,7 +3,13 @@ package choreo.trajectory; import edu.wpi.first.math.geometry.Pose2d; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.util.List; +import java.util.stream.Collectors; public class TrajectoryTestHelper { private static final double DT = 0.005; @@ -58,4 +64,22 @@ Trajectory linearTrajectory( return (Trajectory) trajectory; } + + /** + * Reads given resource file as a string. + * + * @param fileName path to the resource file + * @return the file's contents + * @throws IOException if read fails for any reason + */ +public static String getResourceFileAsString(String fileName) throws IOException { + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + try (InputStream is = classLoader.getResourceAsStream(fileName)) { + if (is == null) return null; + try (InputStreamReader isr = new InputStreamReader(is); + BufferedReader reader = new BufferedReader(isr)) { + return reader.lines().collect(Collectors.joining(System.lineSeparator())); + } + } +} } diff --git a/choreolib/src/test/resources/swerve.traj b/choreolib/src/test/resources/swerve.traj new file mode 100644 index 0000000000..54f7d7d625 --- /dev/null +++ b/choreolib/src/test/resources/swerve.traj @@ -0,0 +1,113 @@ +{ + "name":"swerve", + "version":1, + "snapshot":{ + "waypoints":[ + {"x":1.0, "y":1.0, "heading":0.0, "intervals":27, "split":false, "fixTranslation":true, "fixHeading":true, "overrideIntervals":false}, + {"x":2.0, "y":2.0, "heading":1.5707963267948966, "intervals":27, "split":false, "fixTranslation":false, "fixHeading":false, "overrideIntervals":false}, + {"x":3.0, "y":3.0, "heading":3.141592653589793, "intervals":40, "split":false, "fixTranslation":true, "fixHeading":false, "overrideIntervals":false}], + "constraints":[ + {"from":"first", "to":null, "data":{"type":"StopPoint", "props":{}}, "enabled":true}, + {"from":"last", "to":null, "data":{"type":"StopPoint", "props":{}}, "enabled":true}, + {"from":"first", "to":"last", "data":{"type":"KeepInRectangle", "props":{"x":0.0, "y":0.0, "w":16.54, "h":8.21}}, "enabled":true}, + {"from":0, "to":0, "data":{"type":"MaxVelocity", "props":{"max":1.0}}, "enabled":true}, + {"from":2, "to":2, "data":{"type":"MaxAcceleration", "props":{"max":10.0}}, "enabled":true}, + {"from":2, "to":2, "data":{"type":"MaxAngularVelocity", "props":{"max":0.0}}, "enabled":true}, + {"from":2, "to":2, "data":{"type":"PointAt", "props":{"x":0.0, "y":3.0, "tolerance":0.017453292519943295, "flip":false}}, "enabled":true}, + {"from":2, "to":2, "data":{"type":"KeepInCircle", "props":{"x":3.008779128082097, "y":2.9378172513097525, "r":1.0}}, "enabled":true}, + {"from":0, "to":1, "data":{"type":"KeepInLane", "props":{"tolerance":0.01}}, "enabled":true}, + {"from":1, "to":1, "data":{"type":"KeepOutCircle", "props":{"x":3.0, "y":0.0, "r":1.0}}, "enabled":true}], + "targetDt":0.05 + }, + "params":{ + "waypoints":[ + {"x":{"exp":"1 m", "val":1.0}, "y":{"exp":"1 m", "val":1.0}, "heading":{"exp":"0 rad", "val":0.0}, "intervals":27, "split":false, "fixTranslation":true, "fixHeading":true, "overrideIntervals":false}, + {"x":{"exp":"2 m", "val":2.0}, "y":{"exp":"2 m", "val":2.0}, "heading":{"exp":"1.5707963267948966 rad", "val":1.5707963267948966}, "intervals":27, "split":false, "fixTranslation":false, "fixHeading":false, "overrideIntervals":false}, + {"x":{"exp":"3 m", "val":3.0}, "y":{"exp":"3 m", "val":3.0}, "heading":{"exp":"3.141592653589793 rad", "val":3.141592653589793}, "intervals":40, "split":false, "fixTranslation":true, "fixHeading":false, "overrideIntervals":false}], + "constraints":[ + {"from":"first", "to":null, "data":{"type":"StopPoint", "props":{}}, "enabled":true}, + {"from":"last", "to":null, "data":{"type":"StopPoint", "props":{}}, "enabled":true}, + {"from":"first", "to":"last", "data":{"type":"KeepInRectangle", "props":{"x":{"exp":"0 m", "val":0.0}, "y":{"exp":"0 m", "val":0.0}, "w":{"exp":"16.54 m", "val":16.54}, "h":{"exp":"8.21 m", "val":8.21}}}, "enabled":true}, + {"from":0, "to":0, "data":{"type":"MaxVelocity", "props":{"max":{"exp":"1 m / s", "val":1.0}}}, "enabled":true}, + {"from":2, "to":2, "data":{"type":"MaxAcceleration", "props":{"max":{"exp":"10 m / s ^ 2", "val":10.0}}}, "enabled":true}, + {"from":2, "to":2, "data":{"type":"MaxAngularVelocity", "props":{"max":{"exp":"0 rad / s", "val":0.0}}}, "enabled":true}, + {"from":2, "to":2, "data":{"type":"PointAt", "props":{"x":{"exp":"0 m", "val":0.0}, "y":{"exp":"3 m", "val":3.0}, "tolerance":{"exp":"1 deg", "val":0.017453292519943295}, "flip":false}}, "enabled":true}, + {"from":2, "to":2, "data":{"type":"KeepInCircle", "props":{"x":{"exp":"3.0087791280820966 m", "val":3.008779128082097}, "y":{"exp":"2.9378172513097525 m", "val":2.9378172513097525}, "r":{"exp":"1 m", "val":1.0}}}, "enabled":true}, + {"from":0, "to":1, "data":{"type":"KeepInLane", "props":{"tolerance":{"exp":"0.01 m", "val":0.01}}}, "enabled":true}, + {"from":1, "to":1, "data":{"type":"KeepOutCircle", "props":{"x":{"exp":"3 m", "val":3.0}, "y":{"exp":"0 m", "val":0.0}, "r":{"exp":"1 m", "val":1.0}}}, "enabled":true}], + "targetDt":{ + "exp":"0.05 s", + "val":0.05 + } + }, + "trajectory":{ + "sampleType":"Swerve", + "waypoints":[0.0,2.52565,2.52566], + "samples":[ + {"t":0.0, "x":1.0, "y":1.0, "heading":0.0, "vx":0.0, "vy":0.0, "omega":0.0, "ax":2.14295, "ay":2.12633, "alpha":2.16603, "fx":[30.64662,30.63035,42.25215,42.27503], "fy":[41.98714,30.36204,30.34229,41.9817]}, + {"t":0.09354, "x":1.00938, "y":1.0093, "heading":0.0, "vx":0.20046, "vy":0.1989, "omega":0.20262, "ax":1.89118, "ay":1.87058, "alpha":2.16258, "fx":[26.37231,26.35736,37.96389,37.98043], "fy":[37.62883,26.02091,26.00248,37.62016]}, + {"t":0.18709, "x":1.0364, "y":1.03609, "heading":0.01895, "vx":0.37736, "vy":0.37388, "omega":0.40491, "ax":1.66028, "ay":1.64129, "alpha":2.15097, "fx":[22.33393,22.60481,34.14851,33.87629], "fy":[33.55329,22.00942,22.27975,33.82908]}, + {"t":0.28063, "x":1.07896, "y":1.07825, "heading":0.05683, "vx":0.53267, "vy":0.52741, "omega":0.60612, "ax":1.4481, "ay":1.43399, "alpha":2.0596, "fx":[18.73848,19.49393,30.52635,29.76832], "fy":[29.52833,18.4966,19.25437,30.28795]}, + {"t":0.37417, "x":1.13513, "y":1.13386, "heading":0.11353, "vx":0.66813, "vy":0.66155, "omega":0.79878, "ax":1.25174, "ay":1.24393, "alpha":2.07525, "fx":[15.08004,16.44574,27.50484,26.13655], "fy":[26.00325,14.94539,16.31505,27.37217]}, + {"t":0.46771, "x":1.2031, "y":1.20118, "heading":0.18825, "vx":0.78522, "vy":0.77791, "omega":0.9929, "ax":1.06892, "ay":1.06754, "alpha":1.81946, "fx":[12.41634,14.37718,23.94857,21.98581], "fy":[21.96146,12.39154,14.35669,23.9243]}, + {"t":0.56126, "x":1.28123, "y":1.27862, "heading":0.28113, "vx":0.88521, "vy":0.87777, "omega":1.1631, "ax":0.89757, "ay":0.90191, "alpha":1.89271, "fx":[8.99701,11.75721,21.53816,18.77694], "fy":[18.84978,9.07027,11.83424,21.61076]}, + {"t":0.6548, "x":1.36796, "y":1.36468, "heading":0.38992, "vx":0.96917, "vy":0.96214, "omega":1.34015, "ax":0.73587, "ay":0.74477, "alpha":1.51552, "fx":[7.20675,10.30156,17.82721,14.7322], "fy":[14.88242,7.35801,10.45561,17.977]}, + {"t":0.74834, "x":1.46184, "y":1.45794, "heading":0.51528, "vx":1.03801, "vy":1.03181, "omega":1.48191, "ax":0.58223, "ay":0.59432, "alpha":1.50735, "fx":[4.44766,8.16071,15.35915,11.64652], "fy":[11.85127,4.65378,8.36856,15.5634]}, + {"t":0.84188, "x":1.56149, "y":1.55705, "heading":0.65391, "vx":1.09247, "vy":1.0874, "omega":1.62291, "ax":0.435, "ay":0.44946, "alpha":1.20421, "fx":[2.87928,6.70489,11.91888,8.09406], "fy":[8.33922,3.12584,6.95228,12.16355]}, + {"t":0.93543, "x":1.66558, "y":1.66074, "heading":0.80572, "vx":1.13316, "vy":1.12944, "omega":1.73556, "ax":0.29358, "ay":0.30858, "alpha":0.92303, "fx":[1.48305,4.73994,8.50388,5.24792], "fy":[5.50251,1.7389,4.99597,8.75807]}, + {"t":1.02897, "x":1.77286, "y":1.76774, "heading":0.96807, "vx":1.16062, "vy":1.15831, "omega":1.8219, "ax":0.15709, "ay":0.17076, "alpha":0.82715, "fx":[-0.4345,3.14292,5.77831,2.20181], "fy":[2.43382,-0.20148,3.37574,6.01004]}, + {"t":1.12251, "x":1.88212, "y":1.87684, "heading":1.13849, "vx":1.17532, "vy":1.17428, "omega":1.89927, "ax":0.032, "ay":0.02813, "alpha":0.28418, "fx":[-0.56416,0.65766,1.65238,0.43134], "fy":[0.36528,-0.6295,0.59198,1.58618]}, + {"t":1.21605, "x":1.9922, "y":1.98681, "heading":1.31615, "vx":1.17831, "vy":1.17691, "omega":1.92586, "ax":-0.09078, "ay":-0.11134, "alpha":0.33092, "fx":[-2.6185,-0.89239,-0.46992,-2.19547], "fy":[-2.54538,-2.96797,-1.24217,-0.81987]}, + {"t":1.3096, "x":2.10203, "y":2.09641, "heading":1.4963, "vx":1.16982, "vy":1.1665, "omega":1.95681, "ax":-0.22097, "ay":-0.23877, "alpha":-0.28263, "fx":[-2.99931,-4.5209,-4.5183,-2.99636], "fy":[-3.29906,-3.30177,-4.82357,-4.82098]}, + {"t":1.40314, "x":2.21049, "y":2.20448, "heading":1.67935, "vx":1.14915, "vy":1.14416, "omega":1.93037, "ax":-0.35291, "ay":-0.36049, "alpha":-0.27105, "fx":[-5.17578,-6.65814,-6.83027,-5.34773], "fy":[-5.47662,-5.30458,-6.78703,-6.95912]}, + {"t":1.49668, "x":2.31644, "y":2.30993, "heading":1.85992, "vx":1.11614, "vy":1.11044, "omega":1.90502, "ax":-0.49203, "ay":-0.47158, "alpha":-0.78317, "fx":[-6.73997,-10.8681,-9.99848,-5.87031], "fy":[-5.52253,-6.3922,-10.52033,-9.6507]}, + {"t":1.59022, "x":2.41869, "y":2.41174, "heading":2.03812, "vx":1.07011, "vy":1.06633, "omega":1.83176, "ax":-0.62092, "ay":-0.58979, "alpha":-0.91762, "fx":[-8.97767,-13.70742,-12.14579,-7.41604], "fy":[-6.88647,-8.44817,-13.17793,-11.6163]}, + {"t":1.68377, "x":2.51607, "y":2.50891, "heading":2.20947, "vx":1.01203, "vy":1.01116, "omega":1.74592, "ax":-0.75336, "ay":-0.70167, "alpha":-1.26755, "fx":[-11.38365,-17.46731,-14.24522,-8.16157], "fy":[-7.28212,-10.50431,-16.58811,-13.36597]}, + {"t":1.77731, "x":2.60745, "y":2.60043, "heading":2.37279, "vx":0.94156, "vy":0.94552, "omega":1.62735, "ax":-0.90905, "ay":-0.78771, "alpha":-1.49179, "fx":[-14.52379,-21.1417,-16.40156,-9.78364], "fy":[-7.71938,-12.4597,-19.07804,-14.33765]}, + {"t":1.87085, "x":2.69154, "y":2.68543, "heading":2.52501, "vx":0.85652, "vy":0.87184, "omega":1.48781, "ax":-0.97, "ay":-0.96611, "alpha":-1.66766, "fx":[-15.92025,-23.02036,-17.07868,-9.97859], "fy":[-9.91185,-15.85384,-22.95489,-17.01249]}, + {"t":1.96439, "x":2.76742, "y":2.76276, "heading":2.66419, "vx":0.76578, "vy":0.78147, "omega":1.33181, "ax":-1.13529, "ay":-1.038, "alpha":-1.87853, "fx":[-19.26818,-26.80699,-19.35369,-11.81503], "fy":[-10.15916,-17.61289,-25.15347,-17.69861]}, + {"t":2.05794, "x":2.83409, "y":2.83131, "heading":2.78877, "vx":0.65959, "vy":0.68437, "omega":1.15609, "ax":-1.35745, "ay":-1.05105, "alpha":-1.89232, "fx":[-22.89994,-31.08957,-23.27948,-15.09046], "fy":[-9.87709,-17.68768,-25.88027,-18.06725]}, + {"t":2.15148, "x":2.88985, "y":2.89073, "heading":2.89691, "vx":0.53261, "vy":0.58605, "omega":0.97908, "ax":-1.43004, "ay":-1.21199, "alpha":-2.19919, "fx":[-24.63219,-33.87552,-24.01621,-14.77453], "fy":[-11.06298,-20.92264,-30.17062,-20.30633]}, + {"t":2.24502, "x":2.93341, "y":2.94025, "heading":2.9885, "vx":0.39884, "vy":0.47268, "omega":0.77336, "ax":-1.06943, "ay":-1.80483, "alpha":-2.1783, "fx":[-18.51721,-28.20067,-17.86218,-8.18242], "fy":[-20.68731,-31.02561,-40.71589,-30.36951]}, + {"t":2.33856, "x":2.96604, "y":2.97657, "heading":3.06084, "vx":0.2988, "vy":0.30385, "omega":0.5696, "ax":-0.91068, "ay":-2.19498, "alpha":-2.94958, "fx":[-18.01273,-28.03817,-12.96433,-2.94631], "fy":[-24.78552,-39.85796,-49.89286,-34.80729]}, + {"t":2.43211, "x":2.99001, "y":2.99539, "heading":3.11412, "vx":0.21361, "vy":0.09853, "omega":0.29368, "ax":-2.28362, "ay":-1.05331, "alpha":-3.1396, "fx":[-43.2935,-51.03749,-34.38711,-26.65668], "fy":[-5.71988,-22.36683,-30.12324,-13.4562]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.36898, "ay":0.26699, "alpha":0.35743, "fx":[7.76658,6.70599,4.78783,5.84449], "fy":[4.11099,6.03087,4.96951,3.05453]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.35878, "ay":0.24638, "alpha":0.32034, "fx":[7.30175,6.62494,4.90547,5.57891], "fy":[3.66835,5.38873,4.71182,2.99473]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.34849, "ay":0.22706, "alpha":0.28737, "fx":[6.87951,6.51963,4.97727,5.33448], "fy":[3.27027,4.81293,4.45331,2.91272]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.33803, "ay":0.20893, "alpha":0.26619, "fx":[6.50951,6.42016,4.99109,5.07844], "fy":[2.88351,4.31249,4.22355,2.79577]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.32733, "ay":0.19187, "alpha":0.24634, "fx":[6.16636,6.29216,4.96977,4.84261], "fy":[2.53939,3.86147,3.98767,2.66621]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.3163, "ay":0.17579, "alpha":0.23497, "fx":[5.85991,6.16263,4.90097,4.59742], "fy":[2.20788,3.46917,3.7722,2.51119]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.30489, "ay":0.16058, "alpha":0.22283, "fx":[5.56636,6.00226,4.80601,4.36968], "fy":[1.91535,3.11128,3.54739,2.35154]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.29301, "ay":0.14614, "alpha":0.21679, "fx":[5.29677,5.83541,4.67137,4.13256], "fy":[1.63453,2.79839,3.33716,2.17331]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.2806, "ay":0.13239, "alpha":0.20853, "fx":[5.02848,5.63662,4.51723,3.90908], "fy":[1.38804,2.50741,3.11564,1.99625]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.26757, "ay":0.11921, "alpha":0.20485, "fx":[4.77408,5.42841,4.3286,3.67431], "fy":[1.15055,2.25049,2.90492,1.80495]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.25387, "ay":0.10652, "alpha":0.19807, "fx":[4.51194,5.18778,4.12466,3.44884], "fy":[0.94223,2.00563,2.68163,1.61823]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":-0.0, "omega":-0.0, "ax":0.23942, "ay":0.09423, "alpha":0.19502, "fx":[4.25599,4.93603,3.88912,3.20903], "fy":[0.73908,1.78636,2.46665,1.41938]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":0.0, "omega":-0.0, "ax":0.22416, "ay":0.08225, "alpha":0.18845, "fx":[3.98564,4.65152,3.64017,2.97413], "fy":[0.55994,1.57171,2.23797,1.22624]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":0.0, "omega":-0.0, "ax":0.20801, "ay":0.07047, "alpha":0.18517, "fx":[3.71572,4.35459,3.36063,2.72149], "fy":[0.38178,1.37617,2.01551,1.02121]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":0.0, "omega":-0.0, "ax":0.1909, "ay":0.05881, "alpha":0.17823, "fx":[3.42665,4.02422,3.06775,2.46979], "fy":[0.22289,1.17975,1.77786,0.82116]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":0.0, "omega":-0.0, "ax":0.17277, "ay":0.04719, "alpha":0.17435, "fx":[3.13369,3.67983,2.74394,2.19731], "fy":[0.06112,0.99735,1.54402,0.60809]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":0.0, "omega":-0.0, "ax":0.15354, "ay":0.0355, "alpha":0.16674, "fx":[2.81814,3.30052,2.40563,1.92264], "fy":[-0.08535,0.80986,1.29264,0.39796]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":0.0, "omega":-0.0, "ax":0.13316, "ay":0.02365, "alpha":0.16195, "fx":[2.49514,2.90481,2.03538,1.62498], "fy":[-0.23779,0.63199,1.04181,0.17289]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":-0.0, "vy":0.0, "omega":-0.0, "ax":0.11156, "ay":0.01154, "alpha":0.15328, "fx":[2.14674,2.47157,1.64889,1.32317], "fy":[-0.37783,0.44534,0.76989,-0.05197]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":0.08866, "ay":-0.00091, "alpha":0.14697, "fx":[1.78731,2.01849,1.22957,0.99727], "fy":[-0.52596,0.26375,0.49406,-0.29375]}, + {"t":2.52565, "x":3.0, "y":3.0, "heading":-3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":0.06441, "ay":-0.01381, "alpha":0.13635, "fx":[1.39964,1.52395,0.79239,0.66664], "fy":[-0.66338,0.06949,0.19212,-0.53811]}, + {"t":2.52566, "x":3.0, "y":3.0, "heading":-3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":0.03874, "ay":-0.02727, "alpha":0.12725, "fx":[0.99642,1.00506,0.32246,0.31193], "fy":[-0.81009,-0.1254,-0.11942,-0.80064]}, + {"t":2.52566, "x":3.0, "y":3.0, "heading":-3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":0.01158, "ay":-0.04139, "alpha":0.11301, "fx":[0.56141,0.43933,-0.1662,-0.04659], "fy":[-0.94654,-0.33784,-0.46377,-1.06805]}, + {"t":2.52566, "x":3.0, "y":3.0, "heading":3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":-0.01713, "ay":-0.05628, "alpha":0.09894, "fx":[0.1044,-0.15608,-0.68556,-0.42831], "fy":[-1.09289,-0.55882,-0.8245,-1.35318]}, + {"t":2.52566, "x":3.0, "y":3.0, "heading":3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":-0.04746, "ay":-0.07206, "alpha":0.07837, "fx":[-0.38914,-0.80518,-1.22326,-0.81136], "fy":[-1.22822,-0.80378,-1.22653,-1.6446]}, + {"t":2.52566, "x":3.0, "y":3.0, "heading":3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":-0.07946, "ay":-0.08886, "alpha":0.05599, "fx":[-0.91423,-1.48961,-1.7865,-1.2163], "fy":[-1.3741,-1.06874,-1.65246,-1.95057]}, + {"t":2.52566, "x":3.0, "y":3.0, "heading":3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":-0.11321, "ay":-0.1068, "alpha":0.02517, "fx":[-1.48212,-2.23611,-2.36617,-1.61849], "fy":[-1.50708,-1.36614,-2.13017,-2.26316]}, + {"t":2.52566, "x":3.0, "y":3.0, "heading":3.14159, "vx":0.0, "vy":0.0, "omega":-0.0, "ax":-0.0, "ay":0.0, "alpha":0.0, "fx":[0.0,0.0,-0.0,-0.0], "fy":[-0.0,0.0,0.0,-0.0]}], + "splits":[0] + }, + "events":[ + {"name":"Marker", "from":{"target":0, "targetTimestamp":0.0, "offset":{"exp":"0 s", "val":0.0}}, "event":null}, + {"name":"Marker", "from":{"target":1, "targetTimestamp":2.5256481440269156, "offset":{"exp":"0 s", "val":0.0}}, "event":{"type":"sequential", "data":{"commands":[ + {"type":"parallel", "data":{"commands":[ + {"type":"deadline", "data":{"commands":[ + {"type":"race", "data":{"commands":[ + {"type":"named", "data":{"name":""}}, + {"type":"wait", "data":{"waitTime":{"exp":"0 s", "val":0.0}}}]}}]}}]}}]}}}] + # } + \ No newline at end of file diff --git a/src-core/src/integration_tests/generate.rs b/src-core/src/integration_tests/generate.rs index f402cfc2e9..8f27718d08 100644 --- a/src-core/src/integration_tests/generate.rs +++ b/src-core/src/integration_tests/generate.rs @@ -6,6 +6,7 @@ mod generate { thread::{self, JoinHandle}, }; + use crate::spec::TRAJ_SCHEMA_VERSION; use crate::{ file_management::{self, WritingResources}, generation::generate::generate, @@ -20,16 +21,25 @@ mod generate { async fn test_0_differential() { test_generate("differential", "0").await; } + #[tokio::test] + #[ignore] + async fn generate_latest() { + test_generate_dir("./test-tmp-latest/differential".into(), "differential", format!("{TRAJ_SCHEMA_VERSION}").as_str()).await; + test_generate_dir("./test-tmp-latest/swerve".into(), "swerve", format!("{TRAJ_SCHEMA_VERSION}").as_str()).await; + } async fn test_generate(drive_type: &str, version: &str) { let test_dir: PathBuf = format!("./test-tmp-{version}-{drive_type}").into(); + test_generate_dir(test_dir, drive_type, version).await; + } + async fn test_generate_dir(test_dir: PathBuf, drive_type: &str, version: &str) { let original_chor: PathBuf = format!("../test-jsons/project/{version}/{drive_type}.chor").into(); let test_chor: PathBuf = test_dir.join(format!("{drive_type}.chor")); let original_traj: PathBuf = format!("../test-jsons/trajectory/{version}/{drive_type}.traj").into(); let test_traj: PathBuf = test_dir.join(format!("{drive_type}.traj")); - let _ = fs::create_dir(test_dir.clone()).or_else(|_| fs::remove_dir(test_dir)); + let _ = fs::create_dir_all(test_dir.clone()).or_else(|_| fs::remove_dir(test_dir)); // don't modify the original files fs::copy(original_chor.clone(), test_chor.clone()).unwrap(); fs::copy(original_traj.clone(), test_traj.clone()).unwrap(); diff --git a/src/document/2025/DocumentTypes.ts b/src/document/2025/DocumentTypes.ts index a2d38fbcd9..24a6e82928 100644 --- a/src/document/2025/DocumentTypes.ts +++ b/src/document/2025/DocumentTypes.ts @@ -1,7 +1,7 @@ import { ConstraintData } from "../ConstraintDefinitions"; import { Dimensions } from "../ExpressionStore"; -export const TRAJ_SCHEMA_VERSION = 0; +export const TRAJ_SCHEMA_VERSION = 1; export const PROJECT_SCHEMA_VERSION = 1; export type Expr = { exp: string; val: number };