当前位置: 首页>>代码示例>>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;未经允许,请勿转载。