![]() |
Moderating Acceleration / Deceleration
1 Attachment(s)
This is one of those problems that "should" be easy conceptually. For some reason though, we are really strugging with it. Yesterday we spent about 3 hours trying to write code that would moderate our acceleration and deceleration to prevent "rocking" the robot off the front and back wheels.
Here is our thought. From a dead stand-still, flooring the outputs in either forward or reverse does not cause a problem. However, if you are already moving forward or backward, flooring the outputs the opposite direction creates a "wheelie" followed by a slam as the robot comes down. (Yesterday we blew apart a muffin fan we came down so hard). So we check to see if there is a difference in joysticks of more than 50, AND we check to see if the joysticks are pointing in the direction opposite of the old motion. But it doesn't seem to work. The code we are using is attached. Aside from the fact that this doesn't work, it seems very kludgey. Can someone point us in the right direction, or perhaps take a quick look at the code and tell us where we might be going wrong? |
Re: Moderating Acceleration / Deceleration
Hi Tom, It's a be-deviling problem, isn't it :rolleyes:
Here's a thread with a plot (from last year) that may shed some light on what you are dealing with: pwm / voltage dat and just a day or 2 ago, I saw a plot of a team's wheel speeds vs joystick input that is also good data....but I'll be darned if I can find it again :rolleyes: Anyway, you might try something like a rate limiter. We've done this in the past, but just ended up in an argument among team members on robot handling qualities. You can also search on something like "exponential drivetrain" to see how some teams re-map the joystick to motor relationship. Here's a shot at some rate limit code that shows the general idea ... it ain't tested, so caveat cursor :ahh: Code:
//I'm sure there are others on this forum that can improve on these ideas. Good Luck! (not quite in panic mode)Eric PS the fighting pi's is a great name! Ha! |
Re: Moderating Acceleration / Deceleration
Look up digital low-pass filters. Low-pass filters are simple pieces of code that you can write that only allow the value to change by a certain percentage per cycle.
|
Re: Moderating Acceleration / Deceleration
There's a fairly detailed discussion of this code here:
http://www.chiefdelphi.com/forums/sh...ad.php?t=53488 We use it to minimize wear on the gearbox end plate. |
Re: Moderating Acceleration / Deceleration
A simple filter is one line of code. Here is a version that works with integer math:
Code:
out = (((n-1)*out)+in)/n;out = the filtered quantity e.g. PWM value to the wheel. n sets the filter bandwidth. Higher values, lower bandwidth. Experiment! Preserve the value of 'out' (make it global or static). Use separate variables for each wheel. That should get you started. |
Re: Moderating Acceleration / Deceleration
http://www.chiefdelphi.com/forums/sh...ad.php?t=53988
I actually posted about a problem with our code trying to achieve the same purpose....this code works, but is a little sloppy compared to others. Code:
int Incrementation_Code(int motor_curr, int motor_prev, int padd, int max_step) |
Re: Moderating Acceleration / Deceleration
1 Attachment(s)
Here's an Excel spreadsheet, illustrating a formula for moderating joystick values. With it, relatively large movements of the joystick near the centre of travel result in relatatively small movements of the output.
With it, drivers should find it less of a problem with the sudden direction change. |
Re: Moderating Acceleration / Deceleration
This might be a dumb idea, but what if you used a PID algorithm.
Use small extremely small values for P, I , D. Set your input (target) to be the joystick, the feedback/output would be the actual PWM. If the constants are small enough you should experience the same effects that you want. If the joystick is held in one place for a long time, the integral term will build up to the PWM value. You could actually change the D term to a negative value so that if the joystick is moved quickly it will have a smaller effect on changing the output. I think this approach is better than a simple re-distribution of the joystick output, because it takes into account the dynamics of the joystick movement in many dimensions (Positon of the joystick, time it was held there, how quickly it was moved there). This code should be extremely easy to implement, simply modify some existing PID code to fit these parameters You will need to tweak it significantly to get it working perfect though. |
| All times are GMT -5. The time now is 10:58. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi