public static boolean getBoolean(String key,boolean defaultValue)
{
boolean value;
try
{
value = getBoolean(key);
}
catch (TableKeyNotDefinedException e)
{
putBoolean(key,defaultValue);
value = defaultValue;
}
return value;
}
public static double getNumber(String key,double defaultValue)
{
double value;
try
{
value = getNumber(key);
}
catch (TableKeyNotDefinedException e)
{
putNumber(key,defaultValue);
value = defaultValue;
}
return value;
}
public static String getString(String key,String defaultValue)
{
String value;
try
{
value = getString(key);
}
catch (TableKeyNotDefinedException e)
{
putString(key,defaultValue);
value = defaultValue;
}
return value;
}
项目:NR-2014-CMD
文件:CheckHotGoalCommand.java
protected void execute()
{
try
{
if(SmartDashboard.getNumber("isHot") == 1 && (SmartDashboard.getNumber("isVisible") == 1))
{
new AutonomousPunchCommand(0).start();
}
else
{
new AutonomousPunchCommand(4).start();
}
}
catch(TableKeyNotDefinedException t)
{
System.err.println("ERROR DURING AUTONOMOUS HOT GOAL CHECK");
new AutonomousPunchCommand(0).start();
}
}
项目:Woodchuck-2013
文件:Vision.java
项目:Woodchuck-2013
文件:Vision.java
/**
* Find the angle that the robot is from the goal.
* Zero degrees means the robot is perfectly centered with the goal.
* @return Angle from the goal
*/
public double getAngle()
{
double angle = 0;
try
{
//angle = table.getNumber("Angle");
}
catch (TableKeyNotDefinedException e)
{
Logger.log(e);
}
return angle;
}
项目:desiree
文件:Tilter.java
/**
* Uses Smart Dashboard to update PID values.
*/
public void updatePID() {
double pVal;
double iVal;
double dVal;
try {
pVal = SmartDashboard.getNumber("Tilter P");
iVal = SmartDashboard.getNumber("Tilter I");
dVal = SmartDashboard.getNumber("Tilter D");
controller.setPID(pVal,iVal,dVal);
} catch (TableKeyNotDefinedException e) {
SmartDashboard.putNumber("Tilter P",0.0);
SmartDashboard.putNumber("Tilter I",0.0);
SmartDashboard.putNumber("Tilter D",0.0);
}
}
protected boolean updateVision() {
boolean reslt = false;
// Get the values we need from current vision results
try {
final NumberArray targetNum = new NumberArray();
ntserver.retrieveValue("BLOBS",targetNum);
if (targetNum.size() > 0) {
double blobx = targetNum.get(0);
double bloby = targetNum.get(1);
// Compute firing angle
double baseCameraAngle = Robot.arm.getRawEncoder();
double targetInclineAngle = baseCameraAngle + vFoV * (bloby - ImageH / 2) * ImageH;
double cameraHeight = CameraPivotHeight + CameraArmlength * Math.sin(Math.toradians(baseCameraAngle));
double towerRange = (TargetHeight - cameraHeight) / Math.tan(Math.toradians(targetInclineAngle));
double firingAngle = Math.todegrees(Math.atan(Vfire2 / (G * towerRange) - Math.sqrt(
Vfire2 * (Vfire2 - 2.0 * G * (TargetHeight - cameraHeight)) / (G * G * towerRange * towerRange)
- 1)));
Elevate(firingAngle);
// Compute turn angle
double targetTurnAngle = FoV * (blobx - ImageW / 2) * ImageW;
Turn(targetTurnAngle);
reslt = true;
}
} catch (TableKeyNotDefinedException exp) {
}
return reslt;
}
protected boolean updateVision() {
boolean reslt = false;
// Get the values we need from current vision results
try {
final NumberArray targetNum = new NumberArray();
ntserver.retrieveValue("BLOBS",targetNum);
if (targetNum.size() > 0) {
double blobx = targetNum.get(0);
double bloby = targetNum.get(1);
// Compute firing angle
double baseCameraAngle = Robot.arm.getRawEncoder();
double targetInclineAngle = baseCameraAngle + vFoV * (bloby - ImageH / 2) * ImageH;
double cameraHeight = CameraPivotHeight + CameraArmlength * Math.sin(Math.toradians(baseCameraAngle));
double towerRange = (TargetHeight - cameraHeight) / Math.tan(Math.toradians(targetInclineAngle));
double firingAngle = Math.todegrees(Math.atan(Vfire2 / (G * towerRange) - Math.sqrt(
Vfire2 * (Vfire2 - 2.0 * G * (TargetHeight - cameraHeight)) / (G * G * towerRange * towerRange)
- 1)));
Elevate(firingAngle);
// Compute turn angle
double targetTurnAngle = FoV * (blobx - ImageW / 2) * ImageW;
Turn(targetTurnAngle);
reslt = true;
}
} catch (TableKeyNotDefinedException exp) {
}
return reslt;
}
项目:FRCStronghold2016
文件:VisionSeek.java
private void updateCameraError() {
if (SmartDashboard.getNumber("BLOB_COUNT") > 0) {
try {
azSteer = SmartDashboard.getNumber("Az_Steer");
azSteer += CAMERA_OFFSET;
targetAngle = azSteer + Robot.sensors.getContinuousAngle();
gyroSource.setTargetAngle(targetAngle);
} catch (TableKeyNotDefinedException ex) {
DriverStation.reportError(ex.getClass().getCanonicalName() + ": " + ex.getMessage() + "\n",true);
cancel();
}
}
}
@Override
public Object getValue(String key) throws TableKeyNotDefinedException {
MockNetworkTable relevant = tableForKey(key);
String name = realKey(key);
if (relevant.containsKey(name)) {
return relevant.entries.get(name);
} else {
throw new TableKeyNotDefinedException(key);
}
}
@Override
public Object getValue(String key,Object defaultValue) {
MockNetworkTable relevant = tableForKey(key);
String name = realKey(key);
if (relevant.containsKey(name)) {
return relevant.entries.getorDefault(name,defaultValue);
} else {
throw new TableKeyNotDefinedException(key);
}
}
项目:2014-Krugelfang
文件:Driverstation.java
项目:2014-Krugelfang
文件:Driverstation.java
项目:2014-Krugelfang
文件:Driverstation.java
public static double getBlobCount() {
try {
double blobcount = laptop.getNumber("BLOB_COUNT");
// System.out.println(blobcount);
return blobcount;
}
catch (TableKeyNotDefinedException ex) {
return -1;
}
}
项目:2014-Krugelfang
文件:Driverstation.java
public static double getBlobCount() {
try {
double blobcount = laptop.getNumber("BlOB_COUNT");
return blobcount;
}
catch (TableKeyNotDefinedException ex) {
return -1;
}
}
项目:2014-Krugelfang
文件:Driverstation.java
项目:2014-Krugelfang
文件:Driverstation.java
项目:2014-Krugelfang
文件:Driverstation.java
项目:2014-Krugelfang
文件:Driverstation.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。