Thread: Encoder Issues
View Single Post
  #3   Spotlight this post!  
Unread 16-01-2016, 12:27
feoniks4505 feoniks4505 is offline
Registered User
FRC #4505 (MECHDonogh Eagles)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Maryland
Posts: 6
feoniks4505 is an unknown quantity at this point
Re: Encoder Issues

Here is our execute method in our sensor-reading command:
Code:
protected void execute() {
    	SmartDashboard.putNumber("Encoder Raw", Robot.sensors.getRaw());
    	SmartDashboard.putNumber("Encoder Rate", Robot.sensors.getRate());
    	SmartDashboard.putNumber("Encoder Distance" ,Robot.sensors.getDistance());
    }
Here are the definitions for those methods in our sensor subclass:
Code:
public double getRate() {
    	return canEncoder.getRate();
    }

    public double getDistance() {
    	return canEncoder.getDistance();
    }
    
    public double getRaw() {
    	return canEncoder.getRaw();
    }
And here is where we define our Talon and Encoder:
Code:
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        motorsCANTalon = new CANTalon(0);
        LiveWindow.addActuator("Motors", "CAN Talon", motorsCANTalon);
        
        sensorscanEncoder = new Encoder(0, 1, false, EncodingType.k4X);
        LiveWindow.addSensor("Sensors", "canEncoder", sensorscanEncoder);
        sensorscanEncoder.setDistancePerPulse(1.0);
        sensorscanEncoder.setPIDSourceType(PIDSourceType.kRate);

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
        motorsCANTalon.reverseSensor(true);
        motorsCANTalon.setFeedbackDevice(FeedbackDevice.QuadEncoder);
        motorsCANTalon.configEncoderCodesPerRev(360);
        motorsCANTalon.setPosition(0);
        motorsCANTalon.setForwardSoftLimit(15.0);
        motorsCANTalon.setReverseSoftLimit(-15);
Is there something we are doing wrong? Anything we need to initialize so that we'll get values off the breakout?
Reply With Quote