I'm building an ROV as a capstone project for a mechanical engineering technology program and I wanted to posit this question to the community about how to interpret the pot data from our PS3 controller. We're trying to figure out how to control the thrusters but we're not sure how to go about the math. The pot returns data in cartesian coordinates (x = 0 -> 255, y = 0 -> 255) and we can plot that point anywhere within a circle. We would like to control forward and backward, and left and right strafe (for now). What follows this intro is what I've thought of so far; if there is a better way to go please do feel free to tell me to look at other directions. So anyway...
The controller transmits pot data to our Uno and ranges from 0 - 255 with 127 as the neutral point in the middle. Imagine the total range of the pots as a circle (scribed by the cartesian resultant of the x & y pot data) with the point (127,127) as the centre coordinate. I would like to be able to tell which quadrant of the circle the resultant point from the pot coordinates is in. My original thought was a check something like this:
if (x < 127){
qx = -1}
else {
qx = 1}
if (y < 127){
qu = -1
}
else {
qy = 1
}
Then check to see what quadrant the pot coordinates are in by referencing:
Quadrant x y
Q1 1 1
Q2 -1 1
Q3 -1 -1
Q4 1 -1
Knowing what quadrant we're in will make the code range the two vectored thrusters that affect rotation away from 45 degrees much easier to figure out. For example, if we're going 45 degrees forward and to the right, the 2/4 thruster pair (T2 & T4) is running full bore (or at least whatever the intensity of the resultant vector of the pot coordinates) and whatever deviation from exactly 45 degrees the pot picks up the program will interpret as adding forward or reverse thrust from the other thruster pair (T1 & T3).
That's all I have for now, but I'm going to have more to work with tomorrow when I present this thought to my group. Any and all help is appreciated to get this idea either fleshed out or flushed down the toilet. I can clarify anything that I didn't explain well enough but it's the end of a long day and right now all I want is some dinner and a beer
Cheers friends