Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*----------------------------------------------------------------------------*/
- /* Copyright (c) 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 frc.robot.utilities;
- import edu.wpi.first.wpilibj.DriverStation;
- import edu.wpi.first.wpilibj.SerialPort;
- /**
- * Add your docs here.
- */
- public class ByteVision
- {
- SerialPort visionPortIntake;
- double lastValue = 0.0;
- int counter=0;
- public ByteVision()
- {
- try
- {
- visionPortIntake = new SerialPort(115200, SerialPort.Port.kUSB);
- }
- catch (Exception e)
- {
- DriverStation.reportError("ERROR: Vision tracking intake camera", e.getStackTrace());
- }
- }
- public double getDataIntake()
- {
- if (visionPortIntake != null)
- {
- try
- {
- counter=0;
- lastValue = Double.parseDouble(visionPortIntake.readString());
- return lastValue;
- }
- catch(Exception e)
- {
- counter++;
- if(counter<25)
- return lastValue;
- return 0.0;
- }
- }
- return 0.0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement