View Single Post
  #11   Spotlight this post!  
Unread 17-02-2015, 22:27
JacobD's Avatar
JacobD JacobD is offline
Registered User
AKA: Jacob
FRC #1672 (Mahwah Robo T-Birds)
Team Role: Leadership
 
Join Date: Jan 2015
Rookie Year: 2013
Location: New Jersey
Posts: 90
JacobD is an unknown quantity at this point
Re: Acceleration Curve java help

Code:
package org.usfirst.frc.team4640.robot;


import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;



public class Robot extends SampleRobot {
    RobotDrive myRobot;  // class that handles basic drive operations
    Joystick leftStick = new Joystick(0);  // set to ID 0 in DriverStation
    Joystick rightStick = new Joystick(1); // set to ID 1 in DriverStation
    CameraServer server;
    double leftStickVal,rightStickVal;
    
    public Robot() {
        myRobot = new RobotDrive(0, 1);
        myRobot.setExpiration(0.1);
        leftStick = new Joystick(0);
        rightStick = new Joystick(1);
        server = CameraServer.getInstance();
        server.setQuality(50);
        //the camera name (ex "cam0") can be found through the roborio web interface
        server.startAutomaticCapture("cam0");
            
    }

    
    /**
     * Runs the motors with tank steering.
     */
    public void operatorControl() {
        myRobot.setSafetyEnabled(true);
        while (isOperatorControl() && isEnabled()) {

                leftStickVal = Math.pow(leftStick.getY(),3);
                rightStickVal= Math.pow(rightStick.getY(),3);
 
        	myRobot.tankDrive(leftStickVal, rightStickVal);
            Timer.delay(0.005);		// wait for a motor update time
           
           
            }
        
        }
    }
Use this code exactly and your problem should be solved.
Reply With Quote