Skip to content

Commit

Permalink
[hal] Fixes for making PWM drive (#7528)
Browse files Browse the repository at this point in the history
* Increase connection timeout, fix ld path, properly initialize smart io.

* Also fix HAL_GetSystemTimeValid, so DataLogManager doesn't throw errors.
  • Loading branch information
ThadHouse authored Dec 9, 2024
1 parent b6ae9e9 commit 31d1aa6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions developerRobot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ deploy {
}
}

timeout = 7

def remote = it

artifacts {
Expand All @@ -95,7 +97,7 @@ deploy {
excludes.add('**/*.so.debug')
excludes.add('**/*.so.*.debug')
postdeploy << { ctx ->
ctx.execute("echo '/home/systemcore/developerRobotCpp' > /home/systemcore/robotCommand")
ctx.execute("echo 'LD_LIBRARY_PATH=/home/systemcore/frc/third-party/lib /home/systemcore/developerRobotCpp' > /home/systemcore/robotCommand")
ctx.execute("chmod +x /home/systemcore/robotCommand; chown systemcore /home/systemcore/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/systemcore/developerRobotCpp\"")
ctx.execute('chmod +x developerRobotCpp')
Expand All @@ -105,7 +107,7 @@ deploy {
developerRobotCppStatic(NativeExecutableArtifact) {
libraryDirectory = '/home/systemcore/frc/third-party/lib'
postdeploy << { ctx ->
ctx.execute("echo '/home/systemcore/developerRobotCppStatic' > /home/systemcore/robotCommand")
ctx.execute("echo ''LD_LIBRARY_PATH=/home/systemcore/frc/third-party/lib /home/systemcore/developerRobotCppStatic' > /home/systemcore/robotCommand")
ctx.execute("chmod +x /home/systemcore/robotCommand; chown systemcore /home/systemcore/robotCommand")
ctx.execute("sudo setcap cap_sys_nice+eip \"/home/systemcore/developerRobotCppStatic\"")
ctx.execute('chmod +x developerRobotCppStatic')
Expand Down
2 changes: 1 addition & 1 deletion hal/src/main/native/systemcore/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void InitializeHAL() {
InitializePWM();
InitializeRelay();
InitializeSerialPort();
InitializeSmartIo();
InitializeSPI();
InitializeThreads();
}
Expand Down Expand Up @@ -311,7 +312,6 @@ HAL_Bool HAL_GetRSLState(int32_t* status) {
}

HAL_Bool HAL_GetSystemTimeValid(int32_t* status) {
*status = HAL_HANDLE_ERROR;
return false;
}

Expand Down
1 change: 1 addition & 0 deletions hal/src/main/native/systemcore/HALInitializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern void InitializePower();
extern void InitializePWM();
extern void InitializeRelay();
extern void InitializeSerialPort();
extern void InitializeSmartIo();
extern void InitializeSPI();
extern void InitializeThreads();
} // namespace hal::init
6 changes: 3 additions & 3 deletions hal/src/main/native/systemcore/SmartIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int32_t SmartIo::InitializeMode(SmartIoMode mode) {
inst.GetDoubleTopic("/io/valset" + channelString).Publish(options);
setPublisher.Set(0);
pwmMinPublisher =
inst.GetDoubleTopic("/io/pwmmim" + channelString).Publish();
inst.GetDoubleTopic("/io/pwmmin" + channelString).Publish();
pwmMinPublisher.Set(0);
pwmMaxPublisher =
inst.GetDoubleTopic("/io/pwmmax" + channelString).Publish();
Expand All @@ -63,8 +63,8 @@ int32_t SmartIo::SetPwmMicroseconds(uint16_t microseconds) {

// TODO(thad) add support for always on signal

if (microseconds > 4096) {
microseconds = 4096;
if (microseconds > 4095) {
microseconds = 4095;
}

// Scale from 0-4096 to 0.0-2.0, then to -1.0-1.0
Expand Down

0 comments on commit 31d1aa6

Please sign in to comment.