# Autonomous using Sine curve

How would I use two encoders (one on each side of the DT) to follow a sine curve when driving x amount of distance?

Do you really want to trace a sine curve or just want pretty much any S-shape path?

What range of phases should the sine go through (0-360deg, 90-270, something else?)

What would be your scale (amplitude vs. distance of the start and end point).

Will your robot start facing the target point or actually properly rotated according to your target path slope at start (c.f. phase above)?

Trace a sine curve as in terms of velocity. And I would want it to go from 0-180 because the value of some at 0 is 0, at 90 is 1(the max velocity), and at 180 is 0 as well(meaning the robot has come to a stop. I am not sure whay scale to use and it would be facing the target in this case the mobile goal .

Unless I misunderstand, you intend to have a robot follow a velocity curve of the positive portion of sin [0-pi] to a target? You could accomplish that like this:

``````
int getSpeed() {
float distanceFromStart = encoderTicks/360 * wheelCircumference; //in inches
float targetDistance = 72; //or whatever your target distance in inches
return (int) (127.0 * sin(pi/targetDistance * distanceFromStart));
}

``````

I’ve attached a graph also. Much easier to work in radians in this case. Equation has an amplitude of 127 to scale to vex motor speeds and period of D/2 so the coeffient on x (distance From Start) becomes 1/2(2pi/d).

However, entirely I’m not sure why you’d want to do this, it wont be very accurate in reaching the position depending on how far the target due to sin curve steepness at around pi.

If you’re going for accuracy in your auton, a sine curve seems good, but as quoted here, it won’t be perfect. For autonomous movements, I would suggest a control loop like P or PID. It’s a bit advanced, but here are some resources. It’ll be more accurate than simple timed movements.
http://www.aura.org.nz/archives/1869
http://georgegillard.com/documents/2-introduction-to-pid-controllers

This will take time, so if you don’t have much time, then you could make sure your base is built well enough and the robot should be able to get the mogo most of the time with just timed movements.

I know I am bringing more questions than answers, but my next question is: Why?