View Single Post
  #3   Spotlight this post!  
Unread 17-03-2014, 23:22
cad321 cad321 is online now
Jack of all trades, Master of none
AKA: Brian Wagg
FRC #2386 (Trojans)
Team Role: Alumni
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Burlington, Ontario
Posts: 319
cad321 is just really nicecad321 is just really nicecad321 is just really nicecad321 is just really nice
Re: trying to get encoders working

Quote:
Originally Posted by Joe Ross View Post

You are calling these methods before creating the leftEncoder and rightEncoder objects, which is causing the code to crash. If you scroll up in the output window, you will see a stack trace which would point to those lines.
So changing the code to this should in theory stop causing the code to crash:
Code:
public void robotInit() {
        driveStick  = new Joystick(1);
        mainDrive = new RobotDrive(1,2,3,4);
        
        rightEncoder = new Encoder(1,2);
        leftEncoder = new Encoder(3,4);
        
        leftEncoder.setDistancePerPulse(0.000623);
        rightEncoder.setDistancePerPulse(0.000623);
        
        RDistance = rightEncoder.getDistance();
        LDistance = leftEncoder.getDistance();
        
        DB1 = driveStick.getRawButton(1);
    }
Unfortunately I don't have the output from the Crio anymore but I understand how that would cause a problem.
Reply With Quote