-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunGame.groovy
78 lines (70 loc) · 2.26 KB
/
RunGame.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import com.neuronrobotics.bowlerstudio.creature.MobileBaseLoader
import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine
import com.neuronrobotics.sdk.addons.kinematics.MobileBase
import com.neuronrobotics.sdk.common.DeviceManager
import edu.wpi.SimplePacketComs.BytePacketType;
import edu.wpi.SimplePacketComs.FloatPacketType;
import edu.wpi.SimplePacketComs.*;
import edu.wpi.SimplePacketComs.phy.UDPSimplePacketComs;
import edu.wpi.SimplePacketComs.device.gameController.*;
import edu.wpi.SimplePacketComs.device.*
import java.util.Arrays;
// test comment
MobileBase base=DeviceManager.getSpecificDevice( "zoltar",{
//If the device does not exist, prompt for the connection
MobileBase m = MobileBaseLoader.fromGit(
"https://github.com/Halloween2020TheChild/Zoltar.git",
"zoltar.xml"
)
if(m==null)
throw new RuntimeException("Arm failed to assemble itself")
println "Connecting new device robot arm "+m
regen=true;
return m
})
class Manager{
UDPSimplePacketComs myDevice
int IDOcCommand = 1811
Manager(def device){
myDevice=(UDPSimplePacketComs)device
setGPIO(false,true)
PacketType p = myDevice.getPacket(IDOcCommand)
p.pollingMode()
}
def setGPIO(boolean value, boolean val2) {
def down = new byte[4]
down[2]=value?1:0
down[3]=val2?1:0
myDevice.writeBytes(IDOcCommand, down)
}
def getGPIO(int index) {
PacketType p = myDevice.getPacket(IDOcCommand)
return (p.getUpstream()[index].byteValue()>0)
}
}
// remove this and the script faults out BowlerStudio... wtf...
ScriptingEngine.gitScriptRun("https://github.com/Halloween2020TheChild/Zoltar.git", "ResnetWithCamera.groovy")
def buttonManager = DeviceManager.getSpecificDevice("Zoltar");
if(buttonManager==null)
throw new RuntimeException("Zoltar Device Missing!")
Manager manager = new Manager(buttonManager)
try {
manager.setGPIO(false,true)
while(!Thread.interrupted()) {
Thread.sleep(100);
try{
if(manager.getGPIO(1)==false) {
println "Running Zoltar Script"
manager.setGPIO(false,false)
ScriptingEngine.gitScriptRun("https://github.com/Halloween2020TheChild/Zoltar.git", "ZoltarController.groovy")
manager.setGPIO(false,true)
good
}
}catch(Throwable tr){
Bowlerstudio.printStackTrace(tr);
}
}
}catch(Throwable t) {
}
manager.setGPIO(false,true)
return null