Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Drive system + encoders (http://www.chiefdelphi.com/forums/showthread.php?t=111482)

tuXguy15 17-01-2013 18:29

Drive system + encoders
 
Hey guys... I'm new to the java for FRC and i was wondering if you guys can help me out with the basic code for our iterative robot project. We have 2 jaguars on pwn 1 and 2 on the DSC and arcade drive. Also we have encoders for the drive system and i dont know how to do them either. Can you guys point me in the right direction? Thanks!

2472Programer 17-01-2013 18:59

Re: Drive system + encoders
 
Though i don't know how to use encoders, there is a first made tutorial based on them. I do however know how to program a basic arcade drive.
one joystick:
Code:

public class Main extends IterativeRobot {
    AxisCamera camera = AxisCamera.getInstance();
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    Joystick joypad = new Joystick(3);
    CriteriaCollection cc;
    RobotDrive robotDrive = new RobotDrive(1,2,3,4);
    //Encoder shooterSpeed = new Encoder(1,2);
    //float Kp = 3.f;
    //float Ki = 0.f;
    //float Kd = 0.f;
    //private final PIDController shooterPID;
 
    public void robotInit() {
       
        cc = new CriteriaCollection();
       
        cc.addCriteria(NIVision.MeasurementType.IMAQ_MT_AREA, 30, 400, false);
       
        cc.addCriteria(NIVision.MeasurementType.IMAQ_MT_AREA, 40, 400, false);

    }

    /**
    * This function is called periodically during autonomous
    */
    public void autonomousPeriodic() {
       

    }

    /**
    * This function is called periodically during operator control
    */
    public void teleopPeriodic() {
       
        robotDrive.arcadeDrive(leftStick);


2 Joysticks
Code:

public class Main extends IterativeRobot {
    AxisCamera camera = AxisCamera.getInstance();
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    Joystick joypad = new Joystick(3);
    CriteriaCollection cc;
    RobotDrive robotDrive = new RobotDrive(1,2,3,4);
    //Encoder shooterSpeed = new Encoder(1,2);
    //float Kp = 3.f;
    //float Ki = 0.f;
    //float Kd = 0.f;
    //private final PIDController shooterPID;
 
    public void robotInit() {
       
        cc = new CriteriaCollection();
       
        cc.addCriteria(NIVision.MeasurementType.IMAQ_MT_AREA, 30, 400, false);
       
        cc.addCriteria(NIVision.MeasurementType.IMAQ_MT_AREA, 40, 400, false);

    }

    /**
    * This function is called periodically during autonomous
    */
    public void autonomousPeriodic() {
       

    }

    /**
    * This function is called periodically during operator control
    */
    public void teleopPeriodic() {
       
        robotDrive.arcadeDrive(leftStick, rightStick);



All times are GMT -5. The time now is 09:51.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi