View Single Post
  #10   Spotlight this post!  
Unread 05-03-2015, 22:22
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,653
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Limit speed of 4 chassis CIM motors

Quote:
Originally Posted by microman1934 View Post
So in order to decrease tipping of the robot, I was wondering if it was possible to limit the speed of the 4 chassis CIM motors.
Quote:
Originally Posted by Ether View Post
You may want to limit acceleration.
Quote:
Originally Posted by nighterfighter View Post
You have a few ways to do this:

One way would to just multiply your inputs from the joystick by a constant, less than 1, and pass that value to your motor.Set() function.

Another way, would be to limit the actual speed of your robot. For this to work, you would need encoders on each side of the robot, to monitor your speed.
Limiting acceleration using encoders would require writing some code to calculate the acceleration from the speed (just the change in speed divided by the elapsed time). I don't know of any libraries to do this, so unless you have some experienced programmers, you probably wouldn't want to attempt it at this late date.

On the other, hand, limiting the maximum value you send to the motors will reduce acceleration by itself. You can improve stability a bit more by combining this with a throttle change limiter - and that's rather easier. All you have to do is to determine what the maximum acceptable change in the throttle is for each poll of the joysticks and update of the motors. In java it would look like:

Code:
//in initializer
double maxSpeedDelta = 0.05; // larger values allow faster changes




// inside loop

//assumes that your current call looks like:
//     motor.set(joystick.getY())
newSpeed = joystick.getY(); // or your original argument to motor.set()
curSpeed = motor.getSpeed();
if (newSpeed > curSpeed + maxSpeedDelta)
     newspeed = curSpeed + maxSpeedDelta;
if (newSpeed < curSpeed - maxSpeedDelta)
     newspeed = curSpeed - maxSpeedDelta;
motor.set(newSpeed);
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.