So We’ve been thinking of changing our catapult to a clawbot. I need some tips:

1. What’s PID? I’ve asked in the Discord Server but I don’t seem to understand. With calculus terms like derivative and integral, it may be too hard for my team (middle school) to meddle with it, and I can’t find any good video explaining it in layman’s layman’s layman’s terms.
2. What’s the optimal gear ratio for a claw? Pictures would help.
3. Our club can’t afford pneumatics, so we use motors for everything. For a motorized claw, which type of motor (Torque, Hi-speed, Turbo) is best?
4. People say if we use a claw, we should probably use PID tuning to help us accurately pick them up (or something like that), which loops back to my first question.

Thanks!

1. PID is a control algorithm that uses one input and a target to produce one output. First, it takes the difference between the target and the input, called error. It uses three terms to do so: Proportional, Integral, and Derivative. Proportional is the error multiplied by a number. Integral is the accumulation of the error multiplied by another number. To calculate the integral, you add the error to the previous integral value. Derivative is the change in error from one cycle to the next (like the slope of a line).

RobotC Code:

``````
float kP,
kI,
kD,
integ;
int inputLast;

int pid(int input, int target) {
int error = target - input;
float prop = error * kP;
integ = integ + (error * kI);
float deriv = (input - inputLast) * kD;
return prop + integ + deriv;
}

``````

What’s error? And is like Derivative like an average of both to make it as even as possible?

the error is what what degree the pot is at - what you want it to be, or the difference between the two

MartinMaVexForever’s series called “Let’s make a PID loop” was pretty good. Though I didn’t understand it when I was in middle school so…

EDIT: that series is on Youtube btw.

The error is the difference between the measurement you want (target) and the measurement you have (input).
The derivative is the change in error. Think of that as the slope of the error.

Here is a video for an explanation:

I started learning the code from Martin Ma:

1. Previous posts explain PID pretty well

2. I encourage your team to play around with gear ratios, finding something, even if it may be the same result as if it were given to you, will usually result in better learning. That being said, for a starter, a 1-1 ratio is far to weak ( and overkill in speed) for a claw. Many people are having great success with a 1:5 gear ratio (with torque motors). Also, you’ll find some difficulty with claw alignment unless you gear your two claw arms together.

3. Depends on the external gear ratio. High speed motors with an external 1:7 gear ratio works out to be a 1:4.375 compared to torque. Don’t restrict the team to one motor, play around with a combination of external and internal ratios to find your “ideal” gear setup.

4. True PID is pretty complicated and honestly not necessarily required for most situations. Assuming you have your claw geared together, you shouldn’t have too many problems with your claw. To keep the claw closed under significant load (lots of stars) use elastics or a separate button that runs the claw closed at a low power (like 20) so the claw will stay closed without burning out the motors.

Hope that helps!

Here is yet another resource on PID. It also addresses how to determine the constants that work best for your scenario. It is technically for FRC, but really the only thing to be aware of is that we don’t have hall effect sensors in VEX.

Honestly, we (ACP Robotics) usually just use P (proportional) or PI (proportional-integral) loops (just omit the remaining parts of the full PID loop). They tend to work well enough, and using the D (derivative) part can easily yield worse results than just P or PI.

…If you don’t know what you are doing .

But, all jokes aside, a P or a PI is what you should go for most of the time. The only time that I have used all three is for a drive base (Some bonafide code if I do say so myself). If you honestly don’t know what you are doing and you’re trying PID, you’ll probably skew your results more than the original robot’s results. That is why I recommend that you research it a lot before trying it.

To be fair, it generally comes down to available time… A P or PI takes less time than a full PID and generally works well enough when you have a competition in less than 2 weeks…