 # Inertial Sensor vs PID

Hello, would using a combination of a Inertial Sensor and a PID for driving during auton. The PID would be used for Lateral Movement and using the Inertial Sensor for turning. What would be more accurate when tuned. PID only or Inertial + PID?

Well the inertial sensor is not a terrible sensor at all and the drift isn’t too bad. If you are going to use it I would recommend making a pid for turning based on the inertial sensor. The benefit of the inertial is that even with wheel slippage or other factors the robot will still turn to the correct angle. You can defiantly just use a pid that uses encoders for turning as well if you don’t want to use the inertial. Both of those options work pretty well though. To increase accuracy with the inertial sensor you can use multiple sensors and average their position too.

3 Likes

So more inertial sensors?

and how would you make a pid off of values of thr inertial sensor

Ok so I found some values, would it be possible to use acceleration? 1 Like

Integrating the acceleration from the inertial would not be very accurate as the refresh rate is 50ms but using either heading or rotation will work. You would do it just like any other pid with your current position being whatever the inertial sensor is reading. And you don’t have to use multiple sensors its just a way to help accuracy.

3 Likes

I mean if you are using acceleration solely for acceleration (And not trying to somehow calculate position which is very inaccurate if you try), nothing says a control loop has to solely contain PID. I = Absement (integral of position), P = Position, and D = Velocity (derivative of position). I am unsure of the application of this, but you can include acceleration as a derivative of velocity D(v), and if Im thinking more about this, it could technically be used to prevent whiplash maybe(?).

You know the basic algorithm but you could do:
Potential * kP + totalError * kI + Derivative * kD + Acceleration * kA assuming that you are using acceleration as a term for lateral (but im not sure if rotational acceleration exists on the internal sensor)

1 Like

I think @Cadaver_42 is trying to say that making a turn PID with the gyros from the inertial sensor with distance PID is viable. The acceleration could work with the PID (I think the slow refresh rate would seriously limit its usefulness); you would have to take the double integral of the acceleration.

2 Likes

I was able to make a fairly reliable PID this season (it was actually just a PD technically) using the Inertial.rotation() value

I though p was Proportional, as you calculate error and multiply by a constant.

Error is distance between a point of reference and current point. Delta X is distance between a point of reference and current point. Thus, error is the exact same as delta X, or position.

yes, it’s directly related to position, but the value is not how far you’ve gone, it’s how far you have left

1 Like

Although I agree that they are both directly related, I don’t think I agree with the second statement. Whenever I change the desired value within PID, all I do is change the point of reference from one area to another. To simplify, when you set desired value, you are changing distance in relivance to the sensor’s position. But when you run PID, the error changes distance in relivance to the desired value’s position.

On earth, if I say I’m on latitude x and logitude y, I am giving a position in relivance to the earth, despite the earth moving at 67,000 miles per hour (so my position will be 300 miles away from its previous position one second after). All position in this world is relative to a fixed point.

Also: What many don’t realize is instead of currentposition - desiredposition in the code, everyone swaps it to desiredposition - currentposition to make the output negative.

I don’t see how this is different from what I said. The P (before being multiplied by kP) is the distance remaining to get to the target

Yes but he is responding to my Q

Also does the Inertial Sensor have to be put on the center of the robot?

My apologies for not answering your question properly. In regards to that, the “distance remaining to get to the target” is a bit confusing. Let’s say I am -100 feet from a target. If applied on a GPS, it will always tell me my distance remaining is 100 feet (and never -100 feet). So, if that makes sense, it just seems confusing to say distance remaining. I stated what I said to more or less clarify what you’re trying to explain.

oh, ok. I did forget to clarify that distance does matter (assuming you want the bot to, you know, work) making it centered saves you a lot of math, so do it if you can (I just put mine in the bottom of the bot and vibrations from the chassis barely affected it)

I used p loops (pid would be better) based on inertial sensor reading for the 68 pt program I ran at MD states. when you don’t have tracking wheels, inertial + pid would be more consistent than pid only.

4 Likes