Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wpimath] Remove unit suffixes from variable and function names #7529

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,31 @@ jobs:
development
retention-days: 1

PathWeaver:
name: "Build - PathWeaver"
needs: [build-artifacts]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
repository: wpilibsuite/PathWeaver
fetch-depth: 0
- name: Patch PathWeaver to use local development
run: sed -i "s/wpilibTools.deps.wpilibVersion.*/wpilibTools.deps.wpilibVersion = \'$YEAR\.424242\.+\'/" dependencies.gradle
- uses: actions/download-artifact@v4
with:
name: MavenArtifacts
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Move artifacts
run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v4
with:
name: PathWeaver Build
path: |
build/allOutputs/
retention-days: 7
# PathWeaver:
# name: "Build - PathWeaver"
# needs: [build-artifacts]
# runs-on: ubuntu-24.04
# steps:
# - uses: actions/checkout@v4
# with:
# repository: wpilibsuite/PathWeaver
# fetch-depth: 0
# - name: Patch PathWeaver to use local development
# run: sed -i "s/wpilibTools.deps.wpilibVersion.*/wpilibTools.deps.wpilibVersion = \'$YEAR\.424242\.+\'/" dependencies.gradle
# - uses: actions/download-artifact@v4
# with:
# name: MavenArtifacts
# - uses: actions/setup-java@v4
# with:
# java-version: 17
# distribution: 'temurin'
# - name: Move artifacts
# run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
# - name: Build with Gradle
# run: ./gradlew build
# - uses: actions/upload-artifact@v4
# with:
# name: PathWeaver Build
# path: |
# build/allOutputs/
# retention-days: 7
Original file line number Diff line number Diff line change
Expand Up @@ -1025,10 +1025,10 @@ public interface LoggerFunction {
/**
* Runs main run loop with timeout.
*
* @param timeoutSeconds Timeout in seconds.
* @param timeout Timeout in seconds.
* @return 3 on timeout, 2 on signal, 1 on other.
*/
public static native int runMainRunLoopTimeout(double timeoutSeconds);
public static native int runMainRunLoopTimeout(double timeout);

/** Stops main run loop. */
public static native void stopMainRunLoop();
Expand Down
4 changes: 2 additions & 2 deletions cscore/src/main/native/cpp/jni/CameraServerJNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2085,9 +2085,9 @@ Java_edu_wpi_first_cscore_CameraServerJNI_runMainRunLoop
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_cscore_CameraServerJNI_runMainRunLoopTimeout
(JNIEnv*, jclass, jdouble timeoutSeconds)
(JNIEnv*, jclass, jdouble timeout)
{
return cs::RunMainRunLoopTimeout(timeoutSeconds);
return cs::RunMainRunLoopTimeout(timeout);
}

/*
Expand Down
11 changes: 10 additions & 1 deletion cscore/src/main/native/include/cscore_runloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@
#pragma once

namespace cs {

void RunMainRunLoop();
int RunMainRunLoopTimeout(double timeoutSeconds);

/**
* Runs main run loop with timeout.
*
* @param timeout Timeout in seconds.
*/
int RunMainRunLoopTimeout(double timeout);

void StopMainRunLoop();

} // namespace cs
7 changes: 4 additions & 3 deletions cscore/src/main/native/linux/RunLoopHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ static wpi::Event& GetInstance() {
}

namespace cs {

void RunMainRunLoop() {
wpi::Event& event = GetInstance();
wpi::WaitForObject(event.GetHandle());
}

int RunMainRunLoopTimeout(double timeoutSeconds) {
int RunMainRunLoopTimeout(double timeout) {
wpi::Event& event = GetInstance();
bool timedOut = false;
bool signaled =
wpi::WaitForObject(event.GetHandle(), timeoutSeconds, &timedOut);
bool signaled = wpi::WaitForObject(event.GetHandle(), timeout, &timedOut);
if (timedOut) {
return 3;
}
Expand All @@ -35,4 +35,5 @@ void StopMainRunLoop() {
wpi::Event& event = GetInstance();
event.Set();
}

} // namespace cs
6 changes: 4 additions & 2 deletions cscore/src/main/native/objcpp/RunLoopHelpers.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>

namespace cs {

void RunMainRunLoop() {
if (CFRunLoopGetMain() != CFRunLoopGetCurrent()) {
NSLog(@"This method can only be called from the main thread");
Expand All @@ -16,15 +17,16 @@ void RunMainRunLoop() {
CFRunLoopRun();
}

int RunMainRunLoopTimeout(double timeoutSeconds) {
int RunMainRunLoopTimeout(double timeout) {
if (CFRunLoopGetMain() != CFRunLoopGetCurrent()) {
NSLog(@"This method can only be called from the main thread");
return -1;
}
return CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeoutSeconds, false);
return CFRunLoopRunInMode(kCFRunLoopDefaultMode, timeout, false);
}

void StopMainRunLoop() {
CFRunLoopStop(CFRunLoopGetMain());
}

}
7 changes: 4 additions & 3 deletions cscore/src/main/native/windows/RunLoopHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ static wpi::Event& GetInstance() {
}

namespace cs {

void RunMainRunLoop() {
wpi::Event& event = GetInstance();
wpi::WaitForObject(event.GetHandle());
}

int RunMainRunLoopTimeout(double timeoutSeconds) {
int RunMainRunLoopTimeout(double timeout) {
wpi::Event& event = GetInstance();
bool timedOut = false;
bool signaled =
wpi::WaitForObject(event.GetHandle(), timeoutSeconds, &timedOut);
bool signaled = wpi::WaitForObject(event.GetHandle(), timeout, &timedOut);
if (timedOut) {
return 3;
}
Expand All @@ -35,4 +35,5 @@ void StopMainRunLoop() {
wpi::Event& event = GetInstance();
event.Set();
}

} // namespace cs
18 changes: 7 additions & 11 deletions hal/src/main/java/edu/wpi/first/hal/AddressableLEDJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,25 @@ public class AddressableLEDJNI extends JNIWrapper {
* those.
*
* @param handle the Addressable LED handle
* @param highTime0NanoSeconds high time for 0 bit (default 400ns)
* @param lowTime0NanoSeconds low time for 0 bit (default 900ns)
* @param highTime1NanoSeconds high time for 1 bit (default 900ns)
* @param lowTime1NanoSeconds low time for 1 bit (default 600ns)
* @param highTime0 high time for 0 bit in nanoseconds (default 400 ns)
* @param lowTime0 low time for 0 bit in nanoseconds (default 900 ns)
* @param highTime1 high time for 1 bit in nanoseconds (default 900 ns)
* @param lowTime1 low time for 1 bit in nanoseconds (default 600 ns)
* @see "HAL_SetAddressableLEDBitTiming"
*/
public static native void setBitTiming(
int handle,
int highTime0NanoSeconds,
int lowTime0NanoSeconds,
int highTime1NanoSeconds,
int lowTime1NanoSeconds);
int handle, int highTime0, int lowTime0, int highTime1, int lowTime1);

/**
* Sets the sync time.
*
* <p>The sync time is the time to hold output so LEDs enable. Default set for WS2812B and WS2815.
*
* @param handle the Addressable LED handle
* @param syncTimeMicroSeconds the sync time (default 280us)
* @param syncTime the sync time in microseconds (default 280 μs)
* @see "HAL_SetAddressableLEDSyncTime"
*/
public static native void setSyncTime(int handle, int syncTimeMicroSeconds);
public static native void setSyncTime(int handle, int syncTime);

/**
* Starts the output.
Expand Down
8 changes: 4 additions & 4 deletions hal/src/main/java/edu/wpi/first/hal/DIOJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ public class DIOJNI extends JNIWrapper {
* going at any time.
*
* @param dioPortHandle the digital port handle
* @param pulseLengthSeconds the active length of the pulse (in seconds)
* @param pulseLength the active length of the pulse in seconds
* @see "HAL_Pulse"
*/
public static native void pulse(int dioPortHandle, double pulseLengthSeconds);
public static native void pulse(int dioPortHandle, double pulseLength);

/**
* Generates a single digital pulse on multiple channels.
Expand All @@ -101,10 +101,10 @@ public class DIOJNI extends JNIWrapper {
* any time.
*
* @param channelMask the channel mask
* @param pulseLengthSeconds the active length of the pulse (in seconds)
* @param pulseLength the active length of the pulse in seconds
* @see "HAL_PulseMultiple"
*/
public static native void pulseMultiple(long channelMask, double pulseLengthSeconds);
public static native void pulseMultiple(long channelMask, double pulseLength);

/**
* Checks a DIO line to see if it is currently generating a pulse.
Expand Down
19 changes: 8 additions & 11 deletions hal/src/main/native/include/hal/AddressableLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,15 @@ void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
* needs to be set for those.
*
* @param[in] handle the Addressable LED handle
* @param[in] highTime0NanoSeconds high time for 0 bit (default 400ns)
* @param[in] lowTime0NanoSeconds low time for 0 bit (default 900ns)
* @param[in] highTime1NanoSeconds high time for 1 bit (default 900ns)
* @param[in] lowTime1NanoSeconds low time for 1 bit (default 600ns)
* @param[in] highTime0 high time for 0 bit in nanoseconds (default 400 ns)
* @param[in] lowTime0 low time for 0 bit in nanoseconds (default 900 ns)
* @param[in] highTime1 high time for 1 bit in nanoseconds (default 900 ns)
* @param[in] lowTime1 low time for 1 bit in nanoseconds (default 600 ns)
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAddressableLEDBitTiming(HAL_AddressableLEDHandle handle,
int32_t highTime0NanoSeconds,
int32_t lowTime0NanoSeconds,
int32_t highTime1NanoSeconds,
int32_t lowTime1NanoSeconds,
int32_t highTime0, int32_t lowTime0,
int32_t highTime1, int32_t lowTime1,
int32_t* status);

/**
Expand All @@ -101,12 +99,11 @@ void HAL_SetAddressableLEDBitTiming(HAL_AddressableLEDHandle handle,
* WS2812B and WS2815.
*
* @param[in] handle the Addressable LED handle
* @param[in] syncTimeMicroSeconds the sync time (default 280us)
* @param[in] syncTime the sync time in microseconds (default 280 μs)
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAddressableLEDSyncTime(HAL_AddressableLEDHandle handle,
int32_t syncTimeMicroSeconds,
int32_t* status);
int32_t syncTime, int32_t* status);

/**
* Starts the output.
Expand Down
10 changes: 5 additions & 5 deletions hal/src/main/native/include/hal/DIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ HAL_Bool HAL_GetDIODirection(HAL_DigitalHandle dioPortHandle, int32_t* status);
* single pulse going at any time.
*
* @param[in] dioPortHandle the digital port handle
* @param[in] pulseLengthSeconds the active length of the pulse (in seconds)
* @param[in] pulseLength the active length of the pulse in seconds
* @param[out] status Error status variable. 0 on success.
*/
void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLengthSeconds,
void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLength,
int32_t* status);

/**
Expand All @@ -171,10 +171,10 @@ void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLengthSeconds,
* single pulse going at any time.
*
* @param[in] channelMask the channel mask
* @param[in] pulseLengthSeconds the active length of the pulse (in seconds)
* @param[out] status Error status variable. 0 on success.
* @param[in] pulseLength the active length of the pulse in seconds
* @param[out] status Error status variable. 0 on success.
*/
void HAL_PulseMultiple(uint32_t channelMask, double pulseLengthSeconds,
void HAL_PulseMultiple(uint32_t channelMask, double pulseLength,
int32_t* status);

/**
Expand Down
9 changes: 3 additions & 6 deletions hal/src/main/native/sim/AddressableLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,12 @@ void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
}

void HAL_SetAddressableLEDBitTiming(HAL_AddressableLEDHandle handle,
int32_t highTime0NanoSeconds,
int32_t lowTime0NanoSeconds,
int32_t highTime1NanoSeconds,
int32_t lowTime1NanoSeconds,
int32_t highTime0, int32_t lowTime0,
int32_t highTime1, int32_t lowTime1,
int32_t* status) {}

void HAL_SetAddressableLEDSyncTime(HAL_AddressableLEDHandle handle,
int32_t syncTimeMicroSeconds,
int32_t* status) {}
int32_t syncTime, int32_t* status) {}

void HAL_StartAddressableLEDOutput(HAL_AddressableLEDHandle handle,
int32_t* status) {
Expand Down
5 changes: 2 additions & 3 deletions hal/src/main/native/sim/DutyCycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ int32_t HAL_GetDutyCycleHighTime(HAL_DutyCycleHandle dutyCycleHandle,
return 0;
}

double periodSeconds = 1.0 / SimDutyCycleData[dutyCycle->index].frequency;
double periodNanoSeconds = periodSeconds * 1e9;
return periodNanoSeconds * SimDutyCycleData[dutyCycle->index].output;
double period = 1e9 / SimDutyCycleData[dutyCycle->index].frequency; // ns
return period * SimDutyCycleData[dutyCycle->index].output;
}

int32_t HAL_GetDutyCycleOutputScaleFactor(HAL_DutyCycleHandle dutyCycleHandle,
Expand Down
9 changes: 3 additions & 6 deletions hal/src/main/native/systemcore/AddressableLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,15 @@ void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
}

void HAL_SetAddressableLEDBitTiming(HAL_AddressableLEDHandle handle,
int32_t highTime0NanoSeconds,
int32_t lowTime0NanoSeconds,
int32_t highTime1NanoSeconds,
int32_t lowTime1NanoSeconds,
int32_t highTime0, int32_t lowTime0,
int32_t highTime1, int32_t lowTime1,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}

void HAL_SetAddressableLEDSyncTime(HAL_AddressableLEDHandle handle,
int32_t syncTimeMicroSeconds,
int32_t* status) {
int32_t syncTime, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions hal/src/main/native/systemcore/DIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ HAL_Bool HAL_GetDIODirection(HAL_DigitalHandle dioPortHandle, int32_t* status) {
}
}

void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLengthSeconds,
void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLength,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}

void HAL_PulseMultiple(uint32_t channelMask, double pulseLengthSeconds,
void HAL_PulseMultiple(uint32_t channelMask, double pulseLength,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
namespace sysid {

/**
* Calculates the track width given the left distance, right distance, and
* Calculates the trackwidth given the left distance, right distance, and
* accumulated gyro angle.
*
* @param l The distance traveled by the left side of the drivetrain.
* @param r The distance traveled by the right side of the drivetrain.
* @param accum The accumulated gyro angle.
*/
constexpr double CalculateTrackWidth(double l, double r,
constexpr double CalculateTrackwidth(double l, double r,
units::radian_t accum) {
// The below comes from solving ω = (vr − vl) / 2r for 2r.
return (gcem::abs(r) + gcem::abs(l)) / gcem::abs(accum.value());
Expand Down
Loading
Loading