本文整理汇总了Java中edu.wpi.first.wpilibj.networktables.NetworkTable类的典型用法代码示例。如果您正苦于以下问题:Java NetworkTable类的具体用法?Java NetworkTable怎么用?Java NetworkTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NetworkTable类属于edu.wpi.first.wpilibj.networktables包,在下文中一共展示了NetworkTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VisionAlignment
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public VisionAlignment() {
table = NetworkTable.getTable("Vision");
double dist = table.getNumber("est_distance", 0);
double incr = 0.5;
int reps = (int) (dist / incr);
for(int i = 0; i<reps; i++) {
addSequential(new VisionGyroAlign(), 1.5);
addSequential(new WaitCommand(0.7));
addSequential(new DriveForwardDistance(-.2,-.2, -incr/1.5, -incr/1.5, true));
addSequential(new WaitCommand(0.5));
}
}
示例2: DFDSMove
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public DFDSMove(double speedL, double speedR, double distanceL, double distanceR) {
requires(Robot.driveTrain);
_initLeftSpeed = speedL;
_initRightSpeed = speedR;
_initDistanceL = distanceL*TICKSPERMETER;
_initDistanceR = distanceR*TICKSPERMETER;
table = NetworkTable.getTable("Console");
if(speedL > 0)
table.putString("Message", "Backwards DFD Speed");
else
table.putString("Message", "Forwards DFD Speed");
Robot.driveTrain.resetEnc();
Robot.driveTrain.resetGyro();
Robot.driveTrain.speedControl();
Robot.driveTrain.setBrakeMode();
}
示例3: Vision
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
/**
* Creates the instance of VisionSubsystem.
*/
public Vision() {
logger.trace("Initialize");
ledRing0 = new Relay(RobotMap.RELAY_LED_RING_0);
ledRing1 = new Relay(RobotMap.RELAY_LED_RING_1);
gearVision.table = NetworkTable.getTable("Vision_Gear");
boilerVision.table = NetworkTable.getTable("Vision_Boiler");
initPhoneVars(gearVision, DEFAULT_GEAR_TARGET_WIDTH, DEFAULT_GEAR_TARGET_HEIGHT);
initPhoneVars(boilerVision, DEFAULT_BOILER_TARGET_WIDTH, DEFAULT_BOILER_TARGET_HEIGHT);
Thread forwardThread = new Thread(this::packetForwardingThread);
forwardThread.setDaemon(true);
forwardThread.setName("Packet Forwarding Thread");
forwardThread.start();
Thread dataThread = new Thread(this::dataThread);
dataThread.setDaemon(true);
dataThread.setName("Vision Data Thread");
dataThread.start();
}
示例4: init
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public static void init() {
nt = NetworkTable.getTable("vision");
nt.addTableListener((source, key, value, isNew) -> {
// System.out.println("Value changed. Key = " + key + ", Value = " + value);
switch (key) {
case FOUND_TARGET_KEY:
foundTarget = (Boolean) value;
break;
case AREA_KEY:
area = (Double) value;
break;
case OFFSET_KEY:
offset = (Double) value;
break;
case SKEW_KEY:
skew = (Double) value;
break;
case ANGLE_KEY:
angle = (Double) value;
break;
}
});
}
示例5: registerCodex
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
/**
* Initializes a few items related to writing elements of a codex to a network table.
* Do this ahead of time to prevent issues with timing on the first cycle.
* @param pEnum
*/
public <V, E extends Enum<E> & CodexOf<V>> void registerCodex(Class<E> pEnum) {
Integer hash = EnumUtils.hashOf(pEnum);
String tablename = pEnum.getSimpleName().toUpperCase();
mLog.debug("Registering codex " + tablename + " with hash " + hash);
mTables.put(hash, NetworkTable.getTable(tablename));
mLog.info(tablename + " is connected: " + mTables.get(hash).isConnected());
Class<V> type = CodexMagic.getTypeOfCodex(pEnum);
if(type.equals(Double.class)) {
mWriters.put(hash, ((nt, key, val) -> nt.putNumber(key, (double)val)));
} else if(type.equals(Integer.class)) {
mWriters.put(hash, ((nt, key, val) -> nt.putNumber(key, (int)val)));
} else if(type.equals(Boolean.class)) {
mWriters.put(hash, ((nt, key, val) -> nt.putBoolean(key, (boolean)val)));
} else if(type.equals(Float.class)) {
mWriters.put(hash, ((nt, key, val) -> nt.putNumber(key, (float)val)));
} else {
throw new IllegalArgumentException("Type " + type.getSimpleName() + " is not supported by CodexNetworkTables.");
}
}
示例6: send
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
/**
* Writes the elements and metadata values of the codex to the NetworkTables that
* corresponds to the Codex's enum class name.s
* @param pCodex
*/
public <V, E extends Enum<E> & CodexOf<V>> void send(Codex<V,E> pCodex) {
int hash = EnumUtils.hashOf(pCodex.meta().getEnum());
if(!mWriters.containsKey(hash) || !mTables.containsKey(hash)) {
mLog.warn("Cannot send codex " + pCodex.meta().getEnum().getSimpleName() + " because it has not been registered.");
return;
}
@SuppressWarnings("unchecked")
Put<V> writer = (Put<V>)mWriters.get(hash);
NetworkTable nt = mTables.get(hash);
nt.putNumber("ID", pCodex.meta().id());
nt.putNumber("KEY", pCodex.meta().key());
nt.putNumber("TIME_NS", pCodex.meta().timestamp());
for(E e : EnumSet.allOf(pCodex.meta().getEnum())) {
if(pCodex.isSet(e)) {
writer.write(nt, e.name().toUpperCase(), pCodex.get(e));
}
// grumble grumble.... NT doesn't have a way to clear a field.
}
}
示例7: SplinePlannerWidget
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public SplinePlannerWidget()
{
super(false, 10);
setLayout(new BorderLayout());
mPanel = new SplinePlotterPanel();
add(mPanel);
mTable = NetworkTable.getTable(SmartDashBoardNames.sSPLINE_NAMESPACE);
mLastIndex = 0;
mIdealSplineName = SmartDashBoardNames.sSPLINE_IDEAL_POINTS;
mRealSplineName = SmartDashBoardNames.sSPLINE_REAL_POINT;
addPathListener();
}
示例8: PlotPlannerWidget
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public PlotPlannerWidget()
{
super(false, 10);
setLayout(new BorderLayout());
mPanel = new PathPlotterPanel();
add(mPanel);
mLastIndex = 0;
mTableNamespace = SmartDashBoardNames.sPATH_NAMESPACE;
mSDIdealPathName = SmartDashBoardNames.sPATH_IDEAL_POINTS;
mSDRealPathname = SmartDashBoardNames.sPATH_POINT;
mTable = NetworkTable.getTable(mTableNamespace);
addPathListener();
}
示例9: initializeLiveWindowComponents
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
/**
* Initialize all the LiveWindow elements the first time we enter LiveWindow mode. By holding off
* creating the NetworkTable entries, it allows them to be redefined before the first time in
* LiveWindow mode. This allows default sensor and actuator values to be created that are replaced
* with the custom names from users calling addActuator and addSensor.
*/
private static void initializeLiveWindowComponents() {
System.out.println("Initializing the components first time");
livewindowTable = NetworkTable.getTable("LiveWindow");
statusTable = livewindowTable.getSubTable("~STATUS~");
for (Enumeration e = components.keys(); e.hasMoreElements(); ) {
LiveWindowSendable component = (LiveWindowSendable) e.nextElement();
LiveWindowComponent liveWindowComponent = (LiveWindowComponent) components.get(component);
String subsystem = liveWindowComponent.getSubsystem();
String name = liveWindowComponent.getName();
System.out.println("Initializing table for '" + subsystem + "' '" + name + "'");
livewindowTable.getSubTable(subsystem).putString("~TYPE~", "LW Subsystem");
ITable table = livewindowTable.getSubTable(subsystem).getSubTable(name);
table.putString("~TYPE~", component.getSmartDashboardType());
table.putString("Name", name);
table.putString("Subsystem", subsystem);
component.initTable(table);
if (liveWindowComponent.isSensor()) {
sensors.addElement(component);
}
}
}
示例10: loadConfig
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
private void loadConfig(String aFile)
{
try
{
if (!Files.exists(Paths.get(aFile)))
{
System.err.println("Could not read properties file, will use defaults and will overwrite the file if it exists");
Files.copy(Paths.get("_default_properties.properties"), Paths.get(aFile));
}
Properties p = new Properties();
p.load(new FileInputStream(new File(aFile)));
mClassName = p.getProperty("robot_class");
mSimulatorClassName = p.getProperty("simulator_class");
NetworkTable.setPersistentFilename(sUSER_CONFIG_DIR + mClassName + ".preferences.ini");
}
catch (Exception e)
{
e.printStackTrace();
System.err.println("Could not read properties file");
}
}
示例11: AutonomousFactory
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public AutonomousFactory(Snobot2017 aSnobot, IDriverJoystick aDriverJoystick)
{
mPositionChooser = new SendableChooser<StartingPositions>();
mCommandParser = new CommandParser(aSnobot, mPositionChooser);
mAutoModeTable = NetworkTable.getTable(SmartDashBoardNames.sAUTON_TABLE_NAME);
mPositioner = aSnobot.getPositioner();
mAutonModeChooser = new SnobotAutonCrawler(Properties2017.sAUTON_FILE_FILTER.getValue())
.loadAutonFiles(Properties2017.sAUTON_DIRECTORY.getValue() + "/", Properties2017.sAUTON_DEFAULT_FILE.getValue());
SmartDashboard.putData(SmartDashBoardNames.sAUTON_CHOOSER, mAutonModeChooser);
for (StartingPositions pos : StartingPositions.values())
{
mPositionChooser.addObject(pos.toString(), pos);
}
SmartDashboard.putData(SmartDashBoardNames.sPOSITION_CHOOSER, mPositionChooser);
addListeners();
}
示例12: AutonFactory
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public AutonFactory(IPositioner aPositioner, Snobot aSnobot)
{
mSelectStartPosition = new SelectStartPosition(aPositioner);
mDefenseInFront = new DefenseInFront();
mSelectAutonomous = new SelectAutonomous();
mDefenseTable = NetworkTable.getTable(SmartDashBoardNames.sDEFENSE_AUTON_TABLE);
mPostDefenseTable = NetworkTable.getTable(SmartDashBoardNames.sPOST_DEFENSE_AUTON_TABLE);
mDefenseCommandParser = new CommandParser(aSnobot, mDefenseTable, mSelectStartPosition, "Defense");
mPostDefenseCommandParser = new CommandParser(aSnobot, mPostDefenseTable, "PostDefense", mSelectStartPosition, mDefenseCommandParser, mDefenseInFront);
this.putOnDash();
addListeners();
}
示例13: init
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public void init() { // This sets everything up to listen!
try {
new ProcessBuilder(CLEAR_TMP_CMD).inheritIO().start();
// new ProcessBuilder(GRIP_CMD).inheritIO().start();
} catch (IOException e) {
System.out.println(e);
}
time.reset();
time.start();
GRIPTable = NetworkTable.getTable("GRIP/myLinesReport");
GRIPTable.addTableListener(updater);
// new Thread(crashCheck).start();
}
示例14: main
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
NetworkTable.setClientMode();
InetAddress address = InetAddress.getByName("roborio-1458-frc.local");
NetworkTable.setIPAddress(address.getHostAddress());
NetworkTable SmartDashboard = NetworkTable.getTable("SmartDashboard");
Scanner s = new Scanner(System.in);
//SmartDashboard.putNumber("TestValueJetson", 42);
while(true) {
if(s.hasNextInt()) {
SmartDashboard.putNumber("TestValueJetson", s.nextInt());
}
}
}
示例15: AimWithCamera
import edu.wpi.first.wpilibj.networktables.NetworkTable; //导入依赖的package包/类
public AimWithCamera()
{
requires((Subsystem) driveTrain);
requires((Subsystem) shooterArticulator);
if (CommandBase.lightSystem != null)
requires((Subsystem) lightSystem);
table = NetworkTable.getTable("IMGPROC");
TOLERANCE = Double.parseDouble(BadPreferences.getValue(toleranceKey, "" + TOLERANCE));
TURN_SPEED = Double.parseDouble(BadPreferences.getValue(turnKey, "" + TURN_SPEED));
NUMBER_CYCLES_TO_VERIFY = Integer.parseInt(
BadPreferences.getValue(neededCyclesKey, "" + NUMBER_CYCLES_TO_VERIFY));
SWEET_SPOT_X = Double.parseDouble(BadPreferences.getValue(sweetXKey, "" + SWEET_SPOT_X));
SWEET_SPOT_Y = Double.parseDouble(BadPreferences.getValue(sweetYKey, "" + SWEET_SPOT_Y));
}