View Single Post
  #2   Spotlight this post!  
Unread 30-01-2014, 09:18
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: How to grdually speed up the robot?

Quote:
Originally Posted by Mubtasim View Post
We are trying to make it so that when the joystick signals to seed up, there has to be several milliseconds delays in order to gradually increase the speed. Is there any simple way to do this? [ using simple robot template ]

Thanks
You can keep track of an output variable and add a percentage of the error between it and the desired output each loop. Something like:

Code:
float output = 0.0;

while(true)
{
    float desired = joystick.getY();

    float error = desired - output;

    output += error * 0.1;

    motor.set(output);
}
Reply With Quote