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

Open
wants to merge 1 commit into
base: 2027
Choose a base branch
from
Open
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 @@ -120,31 +120,31 @@ jobs:
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
# 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 @@ -56,29 +56,25 @@ public class AddressableLEDJNI extends JNIWrapper {
* <p>By default, the driver is set up to drive WS2812Bs, so nothing needs to be set for 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.
*
* @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
9 changes: 4 additions & 5 deletions hal/src/main/java/edu/wpi/first/hal/DMAJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public class DMAJNI extends JNIWrapper {
* <p>This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param periodSeconds the period to trigger in seconds
* @param period the period to trigger in seconds
* @see "HAL_SetDMATimedTrigger"
*/
public static native void setTimedTrigger(int handle, double periodSeconds);
public static native void setTimedTrigger(int handle, double period);

/**
* Sets DMA transfers to occur at a specific timed interval in FPGA cycles.
Expand Down Expand Up @@ -229,14 +229,13 @@ public static native int setExternalTrigger(
* Reads a DMA sample from the queue.
*
* @param handle the dma handle
* @param timeoutSeconds the time to wait for data to be queued before timing out
* @param timeout the time in seconds to wait for data to be queued before timing out
* @param buffer the sample object to place data into
* @param sampleStore index 0-21 channelOffsets, index 22: capture size, index 23: triggerChannels
* (bitflags), index 24: remaining, index 25: read status
* @return timestamp of the DMA Sample
*/
public static native long readDMA(
int handle, double timeoutSeconds, int[] buffer, int[] sampleStore);
public static native long readDMA(int handle, double timeout, int[] buffer, int[] sampleStore);

/**
* Get the sensor DMA sample.
Expand Down
4 changes: 2 additions & 2 deletions hal/src/main/java/edu/wpi/first/hal/DMAJNISample.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ static class BaseStore {
/** Default constructor. */
public DMAJNISample() {}

public int update(int dmaHandle, double timeoutSeconds) {
m_timeStamp = DMAJNI.readDMA(dmaHandle, timeoutSeconds, m_dataBuffer, m_storage);
public int update(int dmaHandle, double timeout) {
m_timeStamp = DMAJNI.readDMA(dmaHandle, timeout, m_dataBuffer, m_storage);
return m_storage[25];
}

Expand Down
19 changes: 8 additions & 11 deletions hal/src/main/native/athena/AddressableLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,33 +211,30 @@ 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) {
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}

led->led->writeLowBitTickTiming(0, highTime0NanoSeconds / 25, status);
led->led->writeLowBitTickTiming(1, lowTime0NanoSeconds / 25, status);
led->led->writeHighBitTickTiming(0, highTime1NanoSeconds / 25, status);
led->led->writeHighBitTickTiming(1, lowTime1NanoSeconds / 25, status);
led->led->writeLowBitTickTiming(0, highTime0 / 25, status);
led->led->writeLowBitTickTiming(1, lowTime0 / 25, status);
led->led->writeHighBitTickTiming(0, highTime1 / 25, status);
led->led->writeHighBitTickTiming(1, lowTime1 / 25, status);
}

void HAL_SetAddressableLEDSyncTime(HAL_AddressableLEDHandle handle,
int32_t syncTimeMicroSeconds,
int32_t* status) {
int32_t syncTime, int32_t* status) {
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}

led->led->writeSyncTiming(syncTimeMicroSeconds, status);
led->led->writeSyncTiming(syncTime, status);
}

void HAL_StartAddressableLEDOutput(HAL_AddressableLEDHandle handle,
Expand Down
20 changes: 8 additions & 12 deletions hal/src/main/native/athena/DIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,18 +433,17 @@ 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) {
auto port = digitalChannelHandles->Get(dioPortHandle, HAL_HandleEnum::DIO);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}

uint32_t pulseLengthMicroseconds =
static_cast<uint32_t>(pulseLengthSeconds * 1e6);
uint32_t pulseLengthUs = static_cast<uint32_t>(pulseLength * 1e6); // μs
calcmogul marked this conversation as resolved.
Show resolved Hide resolved

if (pulseLengthMicroseconds <= 0 || pulseLengthMicroseconds > 0xFFFF) {
if (pulseLengthUs <= 0 || pulseLengthUs > 0xFFFF) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(status,
"Length must be between 1 and 65535 microseconds");
Expand All @@ -461,17 +460,15 @@ void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLengthSeconds,
pulse.MXP = 1u << remapMXPChannel(port->channel);
}

digitalSystem->writePulseLength(
static_cast<uint16_t>(pulseLengthMicroseconds), status);
digitalSystem->writePulseLength(static_cast<uint16_t>(pulseLengthUs), status);
digitalSystem->writePulse(pulse, status);
}

void HAL_PulseMultiple(uint32_t channelMask, double pulseLengthSeconds,
void HAL_PulseMultiple(uint32_t channelMask, double pulseLength,
int32_t* status) {
uint32_t pulseLengthMicroseconds =
static_cast<uint32_t>(pulseLengthSeconds * 1e6);
uint32_t pulseLengthUs = static_cast<uint32_t>(pulseLength * 1e6); // μs
calcmogul marked this conversation as resolved.
Show resolved Hide resolved

if (pulseLengthMicroseconds <= 0 || pulseLengthMicroseconds > 0xFFFF) {
if (pulseLengthUs <= 0 || pulseLengthUs > 0xFFFF) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(status,
"Length must be between 1 and 65535 microseconds");
Expand All @@ -483,8 +480,7 @@ void HAL_PulseMultiple(uint32_t channelMask, double pulseLengthSeconds,
pulse.MXP = (channelMask & 0xFFFF) >> 10;
pulse.SPIPort = (channelMask & 0x1F) >> 26;

digitalSystem->writePulseLength(
static_cast<uint16_t>(pulseLengthMicroseconds), status);
digitalSystem->writePulseLength(static_cast<uint16_t>(pulseLengthUs), status);
digitalSystem->writePulse(pulse, status);
}

Expand Down
Loading
Loading