Quote:
Originally Posted by microman1934
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
You may want to limit acceleration.
|
Quote:
Originally Posted by nighterfighter
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);