001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.wpilibj.xrp; 006 007import edu.wpi.first.wpilibj.AnalogInput; 008 009/** This class represents the reflectance sensor pair on an XRP robot. */ 010public class XRPReflectanceSensor { 011 private final AnalogInput m_leftSensor = new AnalogInput(0); 012 private final AnalogInput m_rightSensor = new AnalogInput(1); 013 014 /** 015 * Constructs an XRPReflectanceSensor. 016 * 017 * <p>Only one instance of a XRPReflectanceSensor is supported. 018 */ 019 public XRPReflectanceSensor() {} 020 021 /** 022 * Returns the reflectance value of the left sensor. 023 * 024 * @return value between 0.0 (white) and 1.0 (black). 025 */ 026 public double getLeftReflectanceValue() { 027 return m_leftSensor.getVoltage() / 5.0; 028 } 029 030 /** 031 * Returns the reflectance value of the right sensor. 032 * 033 * @return value between 0.0 (white) and 1.0 (black). 034 */ 035 public double getRightReflectanceValue() { 036 return m_rightSensor.getVoltage() / 5.0; 037 } 038}