Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.usfirst.frc.team224.robot;
- import java.util.Arrays;
- //SingleDriver
- import edu.wpi.first.wpilibj.*;
- import edu.wpi.first.wpilibj.RobotDrive.MotorType;
- import edu.wpi.first.wpilibj.image.NIVisionException;
- import edu.wpi.first.wpilibj.networktables.NetworkTable;
- import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
- import edu.wpi.first.wpilibj.vision.AxisCamera;
- /**
- * The VM is configured to automatically run this class, and to call the
- * functions corresponding to each mode, as described in the IterativeRobot
- * documentation. If you change the name of this class or the package after
- * creating this project, you must also update the manifest file in the resource
- * directory.
- */
- public class Robot extends IterativeRobot {
- RobotDrive drive;
- Servo servo;
- Joystick joystick;
- NetworkTable table;
- AxisCamera ac;
- boolean currentButtonState=false;
- String test="";
- /**
- * This function is run when the robot is first started up and should be
- * used for any initialization code.
- */
- //
- public Robot(){
- // table = NetworkTable.getTable("GRIP/myCountoursReport");
- }
- public void robotInit() {
- NetworkTable.initialize();
- System.out.println("HI");
- ac = new AxisCamera("cam1");
- drive = new RobotDrive(1, 2);
- servo = new Servo(3);
- joystick = new Joystick(1);
- table = NetworkTable.getTable("GRIP/myCountoursReport");
- //while(true){
- double[] areas=table.getNumberArray("area",new double[0]);
- for(double area:areas){
- SmartDashboard.putDouble("Area",area);
- // }
- }
- }
- public void autonomousInit() {
- }
- /**
- * This function is called periodically during autonomous
- */
- public void autonomousPeriodic() {
- }
- public void teleopInit() {
- }
- /**
- * This function is called periodically during operator control
- */
- public void teleopPeriodic() {
- test="Keys: ";
- if (joystick.getThrottle() > 0) {
- servo.set(2.4);
- } else
- servo.set(1);
- currentButtonState=joystick.getRawButton(5);
- SmartDashboard.putBoolean("Button5", currentButtonState);
- SmartDashboard.putNumber("CurrentTime", System.currentTimeMillis());
- SmartDashboard.putNumber("Framerate", NetworkTable.getTable("GRIP").getNumber("myNumber", Double.NaN));
- SmartDashboard.putBoolean("HasArea", table.containsKey("area"));
- for (String i: NetworkTable.getTable("GRIP").getKeys())
- test+=i+", ";
- test+="\n";
- SmartDashboard.putString("Keys", test);
- if (currentButtonState) {
- try {
- SmartDashboard.putString("Area: ", Arrays.toString(table.getNumberArray("area", new double[0])));
- SmartDashboard.putBoolean("Errored", false);
- SmartDashboard.putString("CenterX: ", Arrays.toString(table.getNumberArray("centerX", new double[0])));
- SmartDashboard.putString("CenterY", Arrays.toString(table.getNumberArray("centerY",new double[0])));
- } catch (Exception e) {
- SmartDashboard.putBoolean("Errored", true);
- }
- }
- drive.arcadeDrive(joystick.getTwist(), joystick.getY());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment