View Single Post
  #5   Spotlight this post!  
Unread 08-17-2012, 01:41 PM
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: West Coast Drive Code

@Tom

How does one determine the "gain?" Trial and error, algorithms, etc?

Would something like this be correct?

Code:
// Xbox Controller    
    Joystick Xbox = new Joystick(1);  
           
    // Drivetrain
    public double throttle = Xbox.getRawAxis(3);
    public double turn = applyDeadband(Xbox);
    public double leftMtr = throttle + turn;
    public double rightMtr = throttle + turn;
    //This will need to be tuned
    public double gain = 1;

private double applyDeadband(Joystick Xbox) {
        if(Math.abs(Xbox.getRawAxis(1)) < 0.1) return 0;
        else return Xbox.getRawAxis(1);
    }

 private double skim(double v) {
  // gain determines how much to skim off the top
  if (v > 1.0)
    return -((v - 1.0) * gain);
  else if (v < -1.0)
    return -((v + 1.0) * gain);
  return 0;
}
    
    public double getLeftMotor() {
        return leftMtr + skim(rightMtr);
    }
    
    public double getRightMotor() {
        return rightMtr + skim(leftMtr);
    }
@ Ether what are the benefits of your method vs Tom's? What would that code look like in Java?

Last edited by F22Rapture : 08-17-2012 at 01:44 PM.
Reply With Quote