Skip to content

Commit f5dbeb6

Browse files
committed
v4.12.0 final push: Modify ValveDA to execute the valve moves with the slide delay in a separate thread so the delay is not incurred by the calling thread.
1 parent 9d1b6d2 commit f5dbeb6

File tree

6 files changed

+45
-23
lines changed

6 files changed

+45
-23
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ This project originally set up under Eclipse. You can use VSCode with the follow
4343
Do not let VSCode update the project automatically on a new year. This may damage the highly customized
4444
build.gradle used by this project. New year updates need to done manually.
4545
***************************************************************************************************************
46+
Version 4.12.0
47+
48+
* Modify ValveDA to execute the valve moves with the slide delay in a separate thread so the delay is
49+
not incurred by the calling thread.
50+
51+
R. Corn, March 04 2025
52+
4653
Version 4.11.0
4754

4855
* More updates to ValveDA & SA for REV PH.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LibraryVersion=4.11.0
1+
LibraryVersion=4.12.0
22
archivesGroup = com.github.ORF-4450
33
archivesBaseName = RobotLib
44
jsonFileName = robotlib.json

src/main/java/Team4450/Lib/LibraryVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class LibraryVersion
4747
* of the Jitpack compile when requested and will be automatically made available via JitPack.
4848
*/
4949

50-
public static final String version = "4.11.0 (02.20.2025) WPILib=" + WPILibVersion.Version;
50+
public static final String version = "4.12.0 (03.05.2025) WPILib=" + WPILibVersion.Version;
5151

5252
// Private constructor means this class can't be instantiated.
5353
private LibraryVersion()

src/main/java/Team4450/Lib/MonitorPDP.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ public static MonitorPDP getInstance(PowerDistribution pdp)
7474
private MonitorPDP()
7575
{
7676
Util.consoleLog();
77+
7778
pdp = new PowerDistribution();
79+
7880
this.setName("MonitorPDP");
7981

8082
SendableRegistry.addLW(this, "MonitorPDP");
@@ -83,7 +85,9 @@ private MonitorPDP()
8385
private MonitorPDP(PowerDistribution pdp)
8486
{
8587
Util.consoleLog();
88+
8689
this.pdp = pdp;
90+
8791
this.setName("MonitorPDP");
8892

8993
SendableRegistry.addLW(this, "MonitorPDP");

src/main/java/Team4450/Lib/ValveDA.java

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414
* the valve to move to the open position. Power is then turned off and the valve
1515
* stays where it is (open). Calling close applies power to the close side momentarily causing the
1616
* valve to move to the closed position. Power is then turned off and the valve
17-
* stays where it is (closed).
17+
* stays where it is (closed). Note that the actual movement of the valve which lasts for whatever
18+
* the slide time is set to is done in a separate thread so as not to delay the calling thread.
1819
*
1920
* Open and Close are arbitrary definitions, they are actually defined by the physical robot
2021
* valve piping/wiring and what you want the cylinder to do. Typically you would pipe the "open" side
2122
* of the valve to extend a cylinder and close to retract. For DA valves, our convention is to wire
2223
* the A side to the first port and pipe to open or extend the cylinder and B side to close or retract.
23-
* Again, these are conventions and the reality is what you design your valve to cylinder piping to be
24-
* and the wiring to the corresponding sides of the valve to the control module ports.
24+
* This means we pipe B side to the "at rest" or not "active" position of the cylinder. A side is piped
25+
* to the "active" or "doing the desired action" position of the cylinder. This based on the SMC manifold
26+
* and valves which have A and B sides. So for a valve you would wire the A side of the valve to the port
27+
* number on the constructor and the B side to that port + 1. Hoses go into A and B air ports to the ends
28+
* of the target cylinder corredsponding to at rest and active.
2529
*/
2630

2731
public class ValveDA implements Sendable
@@ -35,7 +39,7 @@ public class ValveDA implements Sendable
3539
* Sets the time to apply power to make sure valve slide moves correctly.
3640
* The movement takes time so power has to be applied until slide has
3741
* moved from one side to the other. In seconds, defaults to .02 sec.
38-
* This default determined using Test mode.
42+
* This default determined using Test mode.ve
3943
*/
4044
public double solenoidSlideTime = .02;
4145

@@ -93,7 +97,6 @@ public void setName(String name)
9397
this.name = String.format("%s[%d-%d]", name, canId, port);
9498

9599
SendableRegistry.setName(this, this.name);
96-
97100
}
98101

99102
/**
@@ -118,17 +121,22 @@ public void Open()
118121

119122
valveCloseSide.set(false);
120123

121-
valveOpenSide.set(true);
122-
Timer.delay(solenoidSlideTime);
123-
valveOpenSide.set(false);
124+
// valveOpenSide.set(true);
125+
// Timer.delay(solenoidSlideTime);
126+
// valveOpenSide.set(false);
124127

125-
valveOpen = true;
128+
new Thread(() -> {
129+
try {
130+
valveOpenSide.set(true);
131+
Timer.delay(solenoidSlideTime);
132+
valveOpenSide.set(false);
133+
valveOpen = true;
134+
} catch (Exception e) { }
135+
}).start();
126136
}
127137

128138
/**
129139
* Pressurize the A side of the valve.
130-
* This function delays calling thread for the valve
131-
* slide time (default 20ms).
132140
*/
133141
public void SetA()
134142
{
@@ -139,26 +147,29 @@ public void SetA()
139147

140148
/**
141149
* Close the valve (pressurize port+1. This is B side).
142-
* This function delays calling thread for the valve
143-
* slide time (default 20ms).
144150
*/
145151
public void Close()
146152
{
147153
Util.consoleLog("canid=%d, port=%d", canId, port);
148154

149155
valveOpenSide.set(false);
150156

151-
valveCloseSide.set(true);
152-
Timer.delay(solenoidSlideTime);
153-
valveCloseSide.set(false);
157+
// valveCloseSide.set(true);
158+
// Timer.delay(solenoidSlideTime);
159+
// valveCloseSide.set(false);
154160

155-
valveOpen = false;
161+
new Thread(() -> {
162+
try {
163+
valveCloseSide.set(true);
164+
Timer.delay(solenoidSlideTime);
165+
valveCloseSide.set(false);
166+
valveOpen = false;
167+
} catch (Exception e) { }
168+
}).start();
156169
}
157170

158171
/**
159172
* Pressurize the B side of the valve.
160-
* This function delays calling thread for the valve
161-
* slide time (default 20ms).
162173
*/
163174
public void SetB()
164175
{
@@ -172,7 +183,7 @@ public void SetB()
172183
* valve, which is open based on our convention. Note, this value
173184
* is not reliable until your first call to open/SetA or close/SetB to set
174185
* the initial physical state of the valve.
175-
* @return True if valve open (pressure on A side), false if closed.
186+
* @return True if valve open (pressure on A side), false if closed (pressure on B side).
176187
*/
177188
public boolean isOpen()
178189
{

src/main/resources/overview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
<body>
44
<h1 style="font-family: arial">FRC Team 4450 Robot Control Program Utility Library</h1>
55
<p style="font-family: arial">Provides utility classes and functions for FRC robot control programs.</p>
6-
<p style="font-family: arial">Version 4.11.0 (February 20 2025)</p>
6+
<p style="font-family: arial">Version 4.12.0 (March 5 2025)</p>
77
</body>

0 commit comments

Comments
 (0)