Turret code

Does anyone have an equation to set RPM by looking at the distance from the turret to the goal?

that’s going to vary wildly from robot to robot.

you’ll have to figure out how what sort of function you need to take the distance value and output a desired rpm. One way you could do this is by testing your robot at varying distances, and seeing what rpm is ideal at that distance. Plot out the curve, and make a function that fits it well.

12 Likes

Even if you have the distance, factors depend on the angle of your flywheel, compression, and position. There isn’t a straight up answer. I would recommend getting the robot on the field and testing shots from different distances from the goal, and change the rpm for each distance. Record your findings in a chart. If you’re able to get the rpms for different distances (get it for 2ft from goal, 4ft from goal, up to 16ft, which is the max distance ), you can try plotting a regression in a graphing calculator. If you don’t know how to, you can give me the values and I might be able to make a graph for it.

Edit: fixed grammar/wording

2 Likes

I believe linear regression should work, if not, try exponential regression.

2 Likes

It varies based on your flywheel but the best way is to measure how powerful your flywheel needs to be to shoot from different distances (ideally as many as possible) and create an algorithm based on your data.

Create a look up table of known rpms and distances from goal. Then use a best fit function (interpolation) for the rest. You could also use a kinematics formula to calculate the needed initial velocity of the disc, and using that you can calculate the necessary flywheel rpm.

A lot of FRC teams did this last season. I would recommend watching some of the FUN (FIRST Updates Now) Behind the Bot videos to see how different teams tackled this problem.

[Btw, no one on here is outright going to give you plug & play code for things like this. Its better to ask for guidance and ask questions if any errors pop up- after you read similar trheads of course : ) ]

5 Likes

I do, actually. I got an equation from the forums,might be the inverse kinematics formula thread, and just rearranged it to solve for velocity. Then you can figure out how to convert velocity to rpm by whatever method you choose. I have the code, it looks like it should work. It’s just that you do need the distance, meaning you do need either very accurate Odometry (near impossible) or have set points to fire from (might be a good backup for our team).

Would a GPS sensor work for the odometry?

Yes, but the GPS strip is not required on match fields so GPS is only useful for skills.

3 Likes

Yes but even still it is only required for programming skills (most events just leave it on for both). So if you were to actually use it, you would have to have another method of position tracking for match plan.

3 Likes

Is there an alternative to gps sensors for position tracking?

Odometry is an alternative.

1 Like

Literally just use Odometry, keep in mind though that it needs to be held down by rubber bands to ensure constant contact with the ground (even then, Odometry could still go off). If you really wanted to you could try to figure out a way to detect when you cross a tile, because that would be great, but I doubt someone’s gonna be able to do that with vex’s sensors.

1 Like

Couldn’t you just use your eyes and see when you cross a tile, then press a button to update your location? That’s what I’m going to do.

Maybe if you had a second driver but I don’t think it’s going to work very well due to human error.

I was able to get accurate distance data from an angled vision sensor and triangulation

I got the robot to fire accurately by just dividing the distance (my unit was inches) by a constant, then adding another constant to the production
(Pretty crude but it worked pretty well)

However vision sensors arnt the best when angled up as there are lots of things that arnt the goal it can lock onto.

1 Like

Have you… ever been in a match?

There’s no way that you’ll be able to do something like that in such a chaotic match. Only way is maybe if you make a GUI for the controller and have it so someone on a different controller just presses some buttons and it picks the tile.that will take an immense amount of practice to do, especially for strategies employed by a turret. But at that point why have a turret? You still have to do a bunch of stuff to aim correctly.

I am interested in @MobGoblin_70291E s answer though. How did you get distance? Sensors, or just guesstimation by the vision sensors?

Purely a vision sensor

No guesstimation just highschool level math

Accuracy was +/-1 inch

2 Likes

dang ok, maybe OP can try that. 1 inch is really good

Which will drift during a match (where constant defense will make it next to impossible to “reset your position”) and make your flywheel heavily inaccurate. Better to use other sensors that won’t have as much issues.

3 Likes