项目:Steamworks2017Robot
文件:Vision.java
@Override
public void sendDataToSmartDashboard() {
// phone handles vision data for us
SmartDashboard.putBoolean("LED_On",isLedRingOn());
boolean gearLiftPhone = false;
boolean boilerPhone = false;
ConnectionInfo[] connections = NetworkTablesJNI.getConnections();
for (ConnectionInfo connInfo : connections) {
if (System.currentTimeMillis() - connInfo.last_update < 100) {
if (connInfo.remote_id.equals("Android_GEAR_LIFT")) {
gearLiftPhone = true;
} else if (connInfo.remote_id.equals("Android_BOILER")) {
boilerPhone = true;
}
}
}
SmartDashboard.putBoolean("VisionGearLift",gearLiftPhone);
SmartDashboard.putBoolean("VisionGearLift_data",isGearVisionDataValid());
SmartDashboard.putBoolean("VisionBoiler",boilerPhone);
SmartDashboard.putBoolean("VisionBoiler_data",isBoilerVisionDataValid());
}
private void addListener() {
entryListenerFunctionUid = NetworkTablesJNI.addEntryListener(path,(uid,key,value,flags) -> {
object = value;
listeners.forEach(c -> c.accept(object));
},ITable.NOTIFY_IMMEDIATE
| ITable.NOTIFY_NEW
| ITable.NOTIFY_UPDATE
| ITable.NOTIFY_DELETE
| ITable.NOTIFY_LOCAL);
}
@Override
public void close() {
NetworkTablesJNI.removeEntryListener(entryListenerFunctionUid);
synchronized (NetworkTable.class) {
// This receiver is no longer used.
if (NTManager.count.addAndGet(-1) == 0) {
// We are the last resource using NetworkTables so shut it down
NetworkTable.shutdown();
}
}
}
项目:FB2016
文件:Vision.java
public double getAngle() {
double offs = (NetworkTablesJNI.getDouble(NT_ANGLE,0) + 30);
double getting = ANGLE_MULTIPLIER * offs;
movingAvg = (movingAvg + getting) / 2.;
return movingAvg;
}
项目:FB2016
文件:Vision.java
@Inject
NTManager() {
// We may have another instance of this method lying around
NetworkTable.shutdown();
// Redirect NetworkTables log messages to our own log files. This gets rid of console spam,// and it also lets
// us grep through NetworkTables messages just like any other messages.
NetworkTablesJNI.setLogger((level,file,line,msg) -> {
String filename = new File(file).getName();
logger.log(ntLogLevels.get(level),String.format("NetworkTables: %s:%d %s",filename,msg));
},0);
NetworkTable.setClientMode();
// When in headless mode,start and stop the pipeline based on the "grip/run" key. This
// allows robot programs
// to control grip without actually restarting the process.
NetworkTable.getTable("grip").addTableListener("run",(source,isNew) -> {
if (gripMode == gripMode.HEADLESS) {
if (!(value instanceof Boolean)) {
logger.warning("NetworkTables value grip/run should be a boolean!");
return;
}
if ((Boolean) value) {
if (!pipelineRunner.isRunning()) {
logger.info("Starting grip from NetworkTables");
pipelineRunner.startAsync();
}
} else if (pipelineRunner.isRunning()) {
logger.info("Stopping grip from NetworkTables");
pipelineRunner.stopAsync();
}
}
},true);
NetworkTable.shutdown();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。