當前位置: 首頁>>代碼示例>>Java>>正文


Java NetworkTable類代碼示例

本文整理匯總了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));
	}
	
}
 
開發者ID:2729StormRobotics,項目名稱:StormRobotics2017,代碼行數:17,代碼來源:VisionAlignment.java

示例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();
}
 
開發者ID:2729StormRobotics,項目名稱:StormRobotics2017,代碼行數:17,代碼來源:DFDSMove.java

示例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();
}
 
開發者ID:ligerbots,項目名稱:Steamworks2017Robot,代碼行數:26,代碼來源:Vision.java

示例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;
            }
        });
    }
 
開發者ID:Team334,項目名稱:R2017,代碼行數:24,代碼來源:VisionData.java

示例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.");
  }
}
 
開發者ID:flybotix,項目名稱:highfrequencyrobots,代碼行數:27,代碼來源:CodexNetworkTables.java

示例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.
  }
}
 
開發者ID:flybotix,項目名稱:highfrequencyrobots,代碼行數:29,代碼來源:CodexNetworkTables.java

示例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();
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:17,代碼來源:SplinePlannerWidget.java

示例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();
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:18,代碼來源:PlotPlannerWidget.java

示例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);
    }
  }
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:28,代碼來源:LiveWindow.java

示例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");
    }
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:25,代碼來源:Simulator.java

示例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();    
    }
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:23,代碼來源:AutonomousFactory.java

示例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();
}
 
開發者ID:ArcticWarriors,項目名稱:snobot-2017,代碼行數:17,代碼來源:AutonFactory.java

示例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();
}
 
開發者ID:first95,項目名稱:FRC2016,代碼行數:17,代碼來源:VisionHandler.java

示例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());
        }
    }
}
 
開發者ID:FRC1458,項目名稱:turtleshell,代碼行數:18,代碼來源:Main.java

示例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));
}
 
開發者ID:BadRobots1014,項目名稱:BadRobot2013,代碼行數:19,代碼來源:AimWithCamera.java


注:本文中的edu.wpi.first.wpilibj.networktables.NetworkTable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。