-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRobot.java
More file actions
56 lines (46 loc) · 1.96 KB
/
Robot.java
File metadata and controls
56 lines (46 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package org.usfirst.frc.team4026.robot;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
public class Robot extends IterativeRobot {
boolean value;
//Declare your Instances/Tables/Entries
static NetworkTableInstance inst;
NetworkTable operatorTable;
NetworkTableEntry gotCubeEntry;
@Override
public void robotInit() {
/*
Initialize your Instances/Tables/Entries
You can usually get away with using the Default Instance created with SmartDashboard
Remember the keys you set here as that is how you access them later in the Python script
*/
inst = NetworkTableInstance.getDefault();
operatorTable = inst.getTable("operator");
gotCubeEntry = operatorTable.getEntry("gotCube");
}
@Override
public void robotPeriodic() {
SmartDashboard.putBoolean("connected", inst.isConnected());
SmartDashboard.putBoolean("gotCube", gotCubeEntry.getBoolean(false));
}
@Override
public void teleopPeriodic() {
//Use forceSetBoolean to force the entry to be a boolean and overwrite whatever it was before
gotCubeEntry.forceSetBoolean(true);
// Retrieve the value from then entry using getBoolean or whatever applicable data type like getDouble
value = gotCubeEntry.getBoolean(false);
}
@Override
public void disabledPeriodic() {
gotCubeEntry.forceSetBoolean(false);
}
}