

if you need a hammer you use a hammer and not an oscilloscope.  Andrew Schreiber [more] 




Thread Tools  Rate Thread  Display Modes 

#1




Curve Driving Generator
Ok, I've run into a great problem for all you math and programming guys. I've been working at it since December but I have made no progress. Any help would be so very appreciated. Here goes:
I am trying to create a code that will give the robot the ability to drive curves. Essentially I want to give the function a coordinate  namely a polar vector  and have it spit out the left and right speeds that the robot needs to travel to drive in a smooth curve. If there is any way possible to integrate a starting tangent line to the curve  as in say "I want a curve that crosses x and x+dx such that dy/dx @ x is equal to some number say b"  that would be very advantageous in that I could link two curves together to have the robot not only drive in a smooth curve but also face a certain direction when it reaches its final point. So far I have figured that we would need to consider a). the currents current speed, b). the robots current direction that it is facing and c). the arc length that the curve would need to be. I have also figured that the distance that right wheel would travel (Rd), the distance the left wheel would travel (Ld) and the speeds of the wheels (Rv and Lv) are related in this manner: Ld/Rd = Lv/Rv. > this relationship was based on assuming that the time for each wheel to travel a distance would be the same (and thus the velocities are different). Note: I'm trying to keep the curves as simple as possible. For now I just want to deal with curves going to the 1st and 2nd quadrants  assuming the current robot's position is at the origin. I DO NOT want to deal with the robot driving to points to where it has to turn past (+)PI/2 (90 degrees). PS: Lets not discuss why we would or would not do this but instead, focus on how. Thanks! Last edited by theNerd : 03292012 at 09:30 PM. 
#2




Re: Curve Driving Generator
Um... what kind of drive configuration are you using? If you are using swerve, I could probably help.

#3




Re: Curve Driving Generator
We are using a tank drive.

#4




Re: Curve Driving Generator
If you have coordinates and tangents at each endpoint, you can fit a cubic polynomial to those constraints. The result will be a smooth curve which connects the endpoints and has the desired tangent at each end. Last edited by Ether : 03302012 at 01:22 AM. 
#5




Re: Curve Driving Generator
I worked on a control scheme for a vex robot that assumes the robot is always traveling in a curve with radius R. The difference in power between the sides of the skid steer then becomes K(1/R), thus as the radius of the curve goes to infinity the difference between wheel speeds approaches 0. R had a realistic minimum in my setup (navigating a black tape maze with a light sensor) and so the algorithm worked well. For FRC it would need modification for points where R approached 0.
To achieve smooth controll I would use a PID loop where the direct control was how far side to side the robot was off course. This would control the path, planned such that the arc would cross the intended path at some fraction of the remaining distance to travel. By controlling the average of the two wheel speeds in skid steer, as wheel as the radius of the turn one could achieve any possible path. This would require closed loop motor control, as well as some method to determine where the robot actually was, as opposed to where it needed to be. Last edited by Hawiian Cadder : 03302012 at 12:51 AM. Reason: Additional info on the aplication to this probelm 
#6




Re: Curve Driving Generator
Quote:
Last edited by Ether : 03302012 at 01:08 AM. 
#7




Re: Curve Driving Generator
Ether is right that the first thing you need to do is plan a path. A polynomial will work find for many situations  you need a 4th order polynomial (y= ax^3+bx^2+cx+d) to fit position and slope at both ends. However, polynomials can give you weird behavior in some situations and can't handle others  you can't get a semicircle for example.
The math is more complex, but I would recommend looking into splines as a more versatile tool for path planning. Alternately, you could try composing your trajectories entirely of circular arcs and straight segments. Once you have a path, you can compute the curvature of the path everywhere along it. From the path curvature and the speed, you can compute angular rotation rate (degrees/second). From the rotation rate and the speed, you can get your wheel velocities (using the geometry of your robot). 
#8




Re: Curve Driving Generator
Quote:
and a finish point = (3,9) with a slope of 2. The blue line is the path and the red line is the reciprocal of the radius at each point along the curve. If you download and install Maxima, you can play with the endpoints and see the curve that results. For the record, that's a thirdorder polynomial (cubic). Quote:
Quote:
Last edited by Ether : 03302012 at 02:25 AM. 
#9




Re: Curve Driving Generator
I personally think that Bezier curves are the easiest to deal with, especially if you want a particular tangent on the endpoints. I would recommend reading this.
Once you understand that, programming them in shouldn't be too difficult, you would just advance the t value as the robot goes along to get the next direction you need to drive. The only challenge I really see is converting the coordinates given by the Bezier curve into drive commands, but it shouldn't be too difficult. 
#10




Re: Curve Driving Generator
Quote:
@Ether: Your idea is great! I like its simplicity, however, I do have a question: What if I don't want the robot to move in a cubic curve? Can this method still be used to create a path that looks similar to x^(1/2)  except with a bit more curve. Also, what if the current heading angle was a slope of infinity? And, instead of using matrices (as my knowledge is extremely rustic and could use some brushing up ) could I use a Taylor polynomial instead and achieve the same result  what I mean is I have no idea how to solve for the parameters using matrices. Last edited by theNerd : 03302012 at 12:15 PM. 
#11




Re: Curve Driving Generator
You don't have to use matrix math if you don't want to. You can use plain ole algebra.
Attached PDF has the cookbook formulas for computing a, b, c, d. a=(2*y2+2*y1+(m2+m1)*x2+(m2m1)*x1)/(x2^3+3*x1*x2^23*x1^2*x2+x1^3); b=(3*x2*y2+x1*((m2m1)*x23*y2)+(3*x2+3*x1)*y1+(m2+2*m1)*x2^2+(2*m2m1)*x1^2)/(x2^3+3*x1*x2^23*x1^2*x2+x1^3); c=(x1*((2*m2+m1)*x2^26*x2*y2)+6*x1*x2*y1+m1*x2^3+(m22*m1)*x1^2*x2m2*x1^3)/(x2^3+3*x1*x2^23*x1^2*x2+x1^3); d=(x1^2*((m2m1)*x2^23*x2*y2)+x1^3*(y2m2*x2)+(3*x1*x2^2x2^3)*y1+m1*x1*x2^3)/(x2^3+3*x1*x2^23*x1^2*x2+x1^3); Last edited by Ether : 03302012 at 07:29 PM. 
#12




Re: Curve Driving Generator
Pick a coordinate system whose origin is the starting point and whose positive X axis aligns with the starting direction of motion.
Compute the ending point (X_{2},Y_{2}) and slope m_{2} in that coordinate system. Then the cubic becomes simply Y = aX^{3} + bX^{2} and the formulas for a and b are simply a = (m_{2}X_{2}  2Y_{2})/X_{2}^{3} b = (3Y_{2}  m_{2}X_{2})/X_{2}^{2} 
#13




Re: Curve Driving Generator
Why not use tank control mode? That way, you can drive curves, but it takes a little more practice to use. It's just a matter of willingness to learn, but will save a lot of time programming. So it's kind of a doubleedged sword.
Last edited by Whippet : 03302012 at 09:38 PM. 
#14




Re: Curve Driving Generator
Quote:

#15




Re: Curve Driving Generator
I agree. One of the reasons that a lowered center drive(I'm assuming not 4 wheel or treads, as I would not try these maneuvers with those drivetrains) is so competitive, is because it needs very little programming. Sure, some teams have more complex code(I'm thinking 254 with their physics engine for turn radius) that is really nice, it is not worth the effort for the negligible gain, unless you have extra time(like maybe getting a camera working and shooting accurately).

Thread Tools  
Display Modes  Rate This Thread 

