|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
A VERY nice perl script for generating lookup tables.
well everybody, i have spent the last two days working painstakingly on this Perl script that generates a lookup table for C. Right now it generates the joystick position then a tab then the corresponding PWM value. It is easy to switch the output format to generate a series of array definitions for a C .h file. I am not completely familiar with the max and min values that can be sent to the PWM (255 or 254? and 0 or 1?) so the program protect against anything lower then 126 away from the center of the graph on either side.
The program defaults to having 127 be zero but all that needs to be done to change that is to set the x offset variable. The left side and right side curves can be independently controlled as well as up and down (in their position, not the function used to generate them). The script can graph 2 functions. There is a variable ($yOuterOffset) that controls how far from the center the first function ends and the second begins. The center of the graph is determined by ($xOffset,$yOffset). I included a .xls file of some sample data generated by the script. The other lines represent 10 and -10 (the minimum for the victors) and a line with the slope 1 to give perspective. This is my first contribution to Open Source and i would appreciate all comments/suggestions. I move that .pl be legit attachment extentions I apologies for my bad spelling and such. QBasic was my first language and i am just now learning English. Last edited by Validius : 19-03-2005 at 22:30. |
|
#2
|
|||
|
|||
|
Re: A VERY nice perl script for generating lookup tables.
We have simple Python hacked-up scripts that generate our drivecurves. The curves we usually have:
1. Quadratic, scaled to 0 - 255 2. Sine (actually, cosine) wave, scaled to 0-255 With the joysticks we got this year, #1 worked the best for us. |
|
#3
|
||||
|
||||
|
Re: A VERY nice perl script for generating lookup tables.
Quote:
|
|
#4
|
|||
|
|||
|
Re: A VERY nice perl script for generating lookup tables.
To make a drive curve, you don't need any more code than:
echo '{' for loop: print CurveFunction(x),',' echo '};' As far as the curves, a quadratic curve is simply scaling a quadratic function f(x)=x^2 such that f(127)=255. |
|
#5
|
||||
|
||||
|
Re: A VERY nice perl script for generating lookup tables.
what's a drive curve and how is it helpful? why would i want to generate a drive curve?
|
|
#6
|
||||
|
||||
|
Re: A VERY nice perl script for generating lookup tables.
A "drive curve" is just a way of saying that you want your robot to start out moving slowly, but gradually (typically in a curved way) get faster. It's just designed to make control a little easier and to prevent wear and tear from fast reverses in direction.
In many cases, your driver may do this manually (a good one does it without even realizing it), but it's typically very important for an accurate autonomous mode. |
|
#7
|
||||
|
||||
|
Re: A VERY nice perl script for generating lookup tables.
Quote:
Most people do not maneuver at high speeds. With a drive curve you can devote large amounts of your joystick swing to the lower speeds while still being able to hit the high speeds. |
|
#8
|
||||
|
||||
|
Re: A VERY nice perl script for generating lookup tables.
Quote:
|
|
#9
|
||||
|
||||
|
Re: A VERY nice perl script for generating lookup tables.
Here is an updated version. I fixed a few bugs, made it easier to edit and documented it a little better.
|
|
#10
|
|||
|
|||
|
Re: A VERY nice perl script for generating lookup tables.
Quote:
![]() |
|
#11
|
||||
|
||||
|
Re: A VERY nice perl script for generating lookup tables.
Yea, i'm going to post a bugfix in the code in a sec. I think imay work on a way to edit paramaters from command line. the hard coded ones would still be here but they would be overridable.
|
|
#12
|
||||
|
||||
|
Re: A VERY nice perl script for generating lookup tables.
BUGFIX!!!!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|