Merge branch 'main' into 2027

This commit is contained in:
Peter Johnson
2025-11-29 10:41:16 -08:00
8 changed files with 41 additions and 17 deletions

View File

@@ -52,11 +52,11 @@ jobs:
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v2027')
- name: Build with Gradle
uses: addnab/docker-run-action@v3
uses: addnab/docker-run-action@3e77f186b7a929ef010f183a9e24c0f9955ea609
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/work -w /work -e ARTIFACTORY_PUBLISH_USERNAME -e ARTIFACTORY_PUBLISH_PASSWORD -e GITHUB_REF -e CI
run: df . && rm -f semicolon_delimited_script && echo $GITHUB_REF && ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
run: df . && echo $GITHUB_REF && ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
env:
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

View File

@@ -53,11 +53,11 @@ jobs:
with:
fetch-depth: 0
- name: Build with Gradle
uses: addnab/docker-run-action@v3
uses: addnab/docker-run-action@3e77f186b7a929ef010f183a9e24c0f9955ea609
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/work -w /work -e GITHUB_REF -e CI
run: df . && rm -f semicolon_delimited_script && echo $GITHUB_REF && ./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
run: df . && echo $GITHUB_REF && ./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
- name: Check free disk space
run: df .
- uses: actions/upload-artifact@v4

View File

@@ -50,7 +50,7 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen
- C++ compiler
- On Linux, install GCC 11 or greater
- On Windows, install [Visual Studio Community 2022](https://visualstudio.microsoft.com/vs/community/) and select the C++ programming language during installation (Gradle can't use the build tools for Visual Studio)
- On macOS 13.3 or newer, install Xcode 14 or later (the command-line build tools are insufficient).
- On macOS, install the Xcode command-line build tools via `xcode-select --install`. Xcode 14 or later is required.
- ARM compiler toolchain
- Run `./gradlew installRoboRioToolchain` after cloning this repository
- If the WPILib installer was used, this toolchain is already installed

View File

@@ -90,7 +90,7 @@ wpi::units::ampere_t ElevatorSim::GetCurrentDraw() const {
double kA = 1.0 / m_plant.B(1, 0);
using Kv_t = wpi::units::unit_t<wpi::units::compound_unit<
wpi::units::volt, wpi::units::inverse<wpi::units::meters_per_second>>>;
Kv_t Kv = Kv_t{kA * m_plant.A(1, 1)};
Kv_t Kv = Kv_t{-kA * m_plant.A(1, 1)};
wpi::units::meters_per_second_t velocity{m_x(1)};
wpi::units::radians_per_second_t motorVelocity = velocity * Kv * m_gearbox.Kv;

View File

@@ -100,3 +100,15 @@ TEST(ElevatorSimTest, Stability) {
wpi::math::Vectord<1>{12.0}, 20_ms * 50)(0)},
sim.GetPosition(), 1_cm);
}
TEST(ElevatorSimTest, CurrentDraw) {
auto const motor = frc::DCMotor::KrakenX60(2);
frc::sim::ElevatorSim sim(motor, 20, 8_kg, 0.1_m, 0_m, 1_m, true, 0_m,
{0.01, 0.0});
EXPECT_DOUBLE_EQ(0.0, sim.GetCurrentDraw().value());
sim.SetInputVoltage(motor.Voltage(motor.Torque(60_A), 0_rad_per_s));
sim.Update(100_ms);
// current draw should start at 60 A and decrease as the back emf catches up
EXPECT_TRUE(0_A < sim.GetCurrentDraw() && sim.GetCurrentDraw() < 60_A);
}

View File

@@ -124,4 +124,16 @@ class ElevatorSimTest {
sim.getPosition(),
0.01);
}
@Test
void testCurrentDraw() {
var motor = DCMotor.getKrakenX60(2);
var sim = new ElevatorSim(motor, 20, 8.0, 0.1, 0.0, 1.0, true, 0.0, 0.01, 0.0);
assertEquals(0.0, sim.getCurrentDrawAmps());
sim.setInputVoltage(motor.getVoltage(motor.getTorque(60.0), 0.0));
sim.update(0.100);
// current draw should start at 60 A and decrease as the back emf catches up
assertTrue(0.0 < sim.getCurrentDrawAmps() && sim.getCurrentDrawAmps() < 60.0);
}
}

View File

@@ -73,6 +73,16 @@ public final class AngularMomentumUnit extends MultUnit<LinearMomentumUnit, Dist
return VelocityUnit.combine(this, time);
}
/**
* Combines this angular momentum by an angular velocity to yield a unit of moment of inertia.
*
* @param omega the unit of angular velocity
* @return the moment of inertia unit
*/
public MomentOfInertiaUnit per(AngularVelocityUnit omega) {
return MomentOfInertiaUnit.combine(this, omega);
}
/**
* Creates a ratio unit between this unit and an arbitrary other unit.
*
@@ -94,14 +104,4 @@ public final class AngularMomentumUnit extends MultUnit<LinearMomentumUnit, Dist
public double convertFrom(double magnitude, AngularMomentumUnit otherUnit) {
return fromBaseUnits(otherUnit.toBaseUnits(magnitude));
}
/**
* Multiplies this angular momentum by an angular velocity to yield a unit of moment of inertia.
*
* @param omega the unit of angular velocity
* @return the moment of inertia unit
*/
public MomentOfInertiaUnit mult(AngularVelocityUnit omega) {
return MomentOfInertiaUnit.combine(this, omega);
}
}

View File

@@ -378,7 +378,7 @@ public final class Units {
/** The standard SI unit for moment of inertia. */
public static final MomentOfInertiaUnit KilogramSquareMeters =
KilogramMetersSquaredPerSecond.mult(RadiansPerSecond);
KilogramMetersSquaredPerSecond.per(RadiansPerSecond);
// VoltageUnit
/** The base unit of electric potential. */