Forked from madhephaestus/LoadGameController.groovy
Last active
January 7, 2020 08:05
-
-
Save javatechs/6c2454ada6192111f4d1d2ff36b8d521 to your computer and use it in GitHub Desktop.
Adding new file from BowlerStudio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabResolver(name='nr', root='https://oss.sonatype.org/content/repositories/staging/') | |
@Grab(group='com.neuronrobotics', module='SimplePacketComsJava', version='0.12.0') | |
import edu.wpi.SimplePacketComs.*; | |
import edu.wpi.SimplePacketComs.phy.*; | |
import com.neuronrobotics.sdk.addons.kinematics.imu.*; | |
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.* | |
boolean noreturn = false | |
if(args == null){ | |
args = ["Game*"] | |
noreturn=true | |
} | |
String name=args[0] | |
if(name.contains("*")) { | |
name = name.split("\\*")[0]; | |
} | |
println "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
println "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
println "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" | |
def dev= DeviceManager.getSpecificDevice(name,{ | |
try{ | |
println "Called DeviceManager.getSpecificDevice..." | |
sleep(3000) | |
def control = GameController.get(args[0]).toArray()[0] | |
println "Got past GameController.get..." | |
if(control==null) | |
return null | |
control.connect() | |
int i=0; | |
while(control.getName().getBytes().size()==0 && i++<10){ | |
println "Waiting for device name..." | |
Thread.sleep(500)// wait for the name packet to be sent | |
//String n = control.getName(); | |
} | |
String n = control.getName(); | |
println "Device named ="+n.getBytes()+" " + n | |
return control; | |
}catch(Throwable t){ | |
return null; | |
} | |
}) | |
print "Returning device: "+dev | |
if (null!=dev) { | |
print " Name: "+dev.getName(); | |
} | |
println "" | |
return dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment