Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Limit speed of 4 chassis CIM motors (http://www.chiefdelphi.com/forums/showthread.php?t=135501)

microman1934 05-03-2015 21:24

Limit speed of 4 chassis CIM motors
 
Hi there,

I'm from team 4939 and for this year's competition, our robot turned out quite tall. 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.

Thank you,
Uday Sharma

Qmcdonn 05-03-2015 21:27

Re: Limit speed of 4 chassis CIM motors
 
You could certainly do this in software by setting a multiplier for the speed to 0.5 or something like that. I do not know of any electrical way to achieve the same result.

DanielPlotas 05-03-2015 21:30

Re: Limit speed of 4 chassis CIM motors
 
What language?

nighterfighter 05-03-2015 21:46

Re: Limit speed of 4 chassis CIM motors
 
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.

Then you have an if statement, comparing the current speed of your robot, to a predefined "maximum" speed. If you are approaching your maximum speed, lower the output of the motors by a certain amount.

I would suggest, for either solution, you have a toggle to turn it on and off. Maybe you will want to go full speed for some reason? Who knows.

Ether 05-03-2015 21:49

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by microman1934 (Post 1454217)
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.

You may want to limit acceleration.



MrRoboSteve 05-03-2015 21:52

Re: Limit speed of 4 chassis CIM motors
 
http://thinktank.wpi.edu/article/140

If you are underweight, you can also lower the center of gravity by adding ballast low in the robot.

microman1934 05-03-2015 21:56

Re: Limit speed of 4 chassis CIM motors
 
we are using java and we are underweight but by about 2 pounds

MrRoboSteve 05-03-2015 22:04

Re: Limit speed of 4 chassis CIM motors
 
http://www.chiefdelphi.com/media/papers/2211 could be translated to Java fairly straightforwardly.

Ether 05-03-2015 22:11

Re: Limit speed of 4 chassis CIM motors
 

What motor controllers are you using for your drivetrain motors? CAN or PWM?



Ether 05-03-2015 22:17

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by Ether (Post 1454224)
You may want to limit acceleration.

http://www.chiefdelphi.com/forums/sh...69&postcount=8

http://www.chiefdelphi.com/forums/sh...22&postcount=2



GeeTwo 05-03-2015 22:22

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by microman1934 (Post 1454217)
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 (Post 1454224)
You may want to limit acceleration.

Quote:

Originally Posted by nighterfighter (Post 1454223)
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);


nighterfighter 05-03-2015 22:38

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by GeeTwo (Post 1454243)
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.

I know what we used in previous years, on the cRIO using C++, we had a 2-speed transmission with automatic shifting, based on the speed, but we also used the timer class to prevent us from rapidly shifting from high to low gear within a certain period of time.

Code:

double time = GetTime();
double left_dist = leftSide.GetDistance();
double right_dist = -rightSide.GetDistance();
double left_rate = (left_dist - leftPrevDist) / (time- leftPrevTime);
double right_rate = (right_dist - rightPrevDist) / (time - rightPrevTime);
leftPrevDist = left_dist;
rightPrevDist = right_dist;
leftPrevTime = time;
rightPrevTime = time;
//printf("left: %f, right: %f, Speed! %f\n", left_rate, right_rate, absd((left_rate + right_rate) / 2));
if (!HighGear && absd((left_rate + right_rate) / 2) > 3.7) {
shift.Set(true);
HighGear = true;
} else if (HighGear && absd((left_rate + right_rate) / 2) < 2) {
shift.Set(false);
HighGear = false;
}

That's the relevant portion of what we did in 2011, and 2012. It was placed inside of our main tele-op loop.
The "shift" object was a solenoid, that shifted the pnuematic shifter in the gearbox.


While there probably isn't a library to do that, writing the code for it shouldn't be too difficult. (You could probably just modify that to do what you need it to...)

zinthorne 05-03-2015 22:45

Re: Limit speed of 4 chassis CIM motors
 
I'm driving this year and so we made a button that while held places the max output of all drive motors at 25% you could do something similar and keep you ability to use all power and the ability to go slow at the same time... The other thought I would have is possibly removing a 2 cims from your drivetrain If you are running 4 already. We dropped from 4 to 2 and still have more than enough speed. We also have a build up in acceleration and deceleration too.

GeeTwo 05-03-2015 23:05

Re: Limit speed of 4 chassis CIM motors
 
Oh, duh!

If you really want to limit acceleration, you can use the accelerometers built into the RoboRIO; just select the one oriented along the axis that you're driving, or a vector sum of them that points you that way. For example, if your RIO is laid out on a board 30 degrees from horizontal, with the USB end towards the front and elevated, your acceleration in the drive direction would be
Code:

driveAccel = accelYaxis.getAcceleration() * .866 + accelZaxis.getAcceleration() * 0.5;

jblay 05-03-2015 23:19

Re: Limit speed of 4 chassis CIM motors
 
Also, what might help is limiting deceleration. I would make sure my motor controllers are set to coast and not brake, this way you don't decelerate as rapidly so that you have less tipping issues when stopping.

Mr V 06-03-2015 00:15

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by jblay (Post 1454266)
Also, what might help is limiting deceleration. I would make sure my motor controllers are set to coast and not brake, this way you don't decelerate as rapidly so that you have less tipping issues when stopping.

Yes tipping when abruptly getting off the throttle will also likely cause tipping. With 4 motors you can set one on each side to coast and one on each side to brake for a lower braking force. We did that on the rookie team I am working with this year and it has worked good in practice.

Personally I would remove a motor per side if it can be done w/o major disassembly.

GeeTwo 06-03-2015 00:16

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by jblay (Post 1454266)
Also, what might help is limiting deceleration. I would make sure my motor controllers are set to coast and not brake, this way you don't decelerate as rapidly so that you have less tipping issues when stopping.

Absolutely. Deceleration is a form of acceleration, and I included it implicitly. The following line was intended to reduce deceleration, and putting the motor controllers in coast would prevent a sudden unintentional change.

Quote:

Originally Posted by GeeTwo (Post 1454243)
Code:

if (newSpeed < curSpeed - maxSpeedDelta)
    newspeed = curSpeed - maxSpeedDelta;



Ether 06-03-2015 13:53

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by Ether (Post 1454224)
You may want to limit acceleration.

The suggestions previously given in the post quoted above can be used to limit acceleration/deceleration without using sensors (no wheel encoders required).

If you have wheel encoders and you want to create smooth accel/decel-controlled pre-planned motion in auto, you might try something like this:

http://www.chiefdelphi.com/media/papers/download/4312



s_forbes 06-03-2015 14:10

Re: Limit speed of 4 chassis CIM motors
 
We did a quick implementation of this approach a couple of weeks back. Limiting the rate that the joystick input can increase is an easy fix in code and does the job well. You can set different rate limits for each joystick axis (we have forward/back, strafing, and turning) to match the tipping geometry of the robot too.

IronicDeadBird 06-03-2015 14:13

Re: Limit speed of 4 chassis CIM motors
 
You using Joysticks or gamepads for control?

s_forbes 06-03-2015 14:29

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by IronicDeadBird (Post 1454475)
You using Joysticks or gamepads for control?

The interface hardware doesn't get rid of the tall-tippy-robot issue; you can still inadvertently send the robot a command of "full speed ahead" whether you use a joystick, a gamepad, or a DDR dance mat.


IronicDeadBird 06-03-2015 14:33

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by s_forbes (Post 1454485)
The interface hardware doesn't get rid of the tall-tippy-robot issue; you can still inadvertently send the robot a command of "full speed ahead" whether you use a joystick, a gamepad, or a DDR dance mat.



Going to have to disagree in regards to gamepads or typical console controllers you can gain more control over movement (provided they are bound to the thumb sticks) by increasing the height of the thumbstick you need to accidentally make much larger movements. If you are using a joystick your out of luck though.

microman1934 06-03-2015 21:47

Re: Limit speed of 4 chassis CIM motors
 
Thank you so much for the help guys, I just ended up doing this:

Code:

double rot = -stick.getX();
double speed = -stick.getY();
myRobot.arcadeDrive(rot*0.5, speed*0.5);


nighterfighter 06-03-2015 21:58

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by microman1934 (Post 1454610)
Thank you so much for the help guys, I just ended up doing this:

Code:

double rot = -stick.getX();
double speed = -stick.getY();
myRobot.arcadeDrive(rot*0.5, speed*0.5);


Glad you found a solution.

I would suggest you throw that in a if-else statement though, making the half-speed your default speed:
Code:

if(stick.getRawButton(1))
{
myRobot.arcadeDrive(-stick.getX(),-stick.getY());
}
else
{
double rot = -stick.getX();
double speed = -stick.getY();
myRobot.arcadeDrive(rot*0.5, speed*0.5);
}

This way, if in the middle of a match, your driver decides that he or she needs full speed, they have the ability to do so.

Just a suggestion. Of course, you may already have it that way in the rest of your code!

microman1934 15-03-2015 21:52

Re: Limit speed of 4 chassis CIM motors
 
Thanks for the idea, would the throttle work for that as well?

nighterfighter 16-03-2015 01:16

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by microman1934 (Post 1457950)
Thanks for the idea, would the throttle work for that as well?

Yes. You could set the throttle to act as a toggle switch...

I'm on my phone so I can't format this correctly and can only give some pseudo code.

If(stick.getThrottle () > 0)
myRobot.Drive (halfSpeedValues);

else if(stick.getThrottle <= 0)
myRobot.Drive (fullSpeedValues);

Remember the throttle on the joystick ranges from -1 to 1, so 0 will be in the middle.

Knufire 16-03-2015 01:19

Re: Limit speed of 4 chassis CIM motors
 
Just remember, by implementing that throttle (we refer to it as a software shift), you lose both speed and torque. This shouldn't be an issue driving around on an open field, but things like noodles or carrying large stacks while driving with the throtte enabled could cause very poor drive performance.

JesseK 16-03-2015 09:14

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by microman1934 (Post 1454610)
Thank you so much for the help guys, I just ended up doing this:

Code:

double rot = -stick.getX();
double speed = -stick.getY();
myRobot.arcadeDrive(rot*0.5, speed*0.5);


Depending on your drive train characteristics, you may have trouble turning. This will be especially prevalent in tight spaces or next to a bump. It is just as bad (or worse, perception-wise) as flopping over on your face every match. Could you describe your drive train from a mechanical perspective?

Ozuru 16-03-2015 11:18

Re: Limit speed of 4 chassis CIM motors
 
Quote:

Originally Posted by microman1934 (Post 1454610)
Thank you so much for the help guys, I just ended up doing this:

Code:

double rot = -stick.getX();
double speed = -stick.getY();
myRobot.arcadeDrive(rot*0.5, speed*0.5);


Why not just square the magnitude? Pseudo code for example.

Code:

double rot = -stick.getX();
double speed = -stick.getRawAxis(drive axis);
myRobot.arcadeDrive(rot, speed * Math.abs(speed));

This allows finer control at lower speeds (when joystick is reading 0.5 you will send 0.25 to the motors) but still allows full speed when the joysticks are at full throttle.


All times are GMT -5. The time now is 09:56.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi