I see the graphs saying a good KP value shows an oscillating graph. My question is in practical terms, what data should I collect to plot a graph to see what kind of graph my robot is giving for a given KP?
I have the code ready for PID controller - I am setting KP to a non-zero value, KD = KI = 0
Now I am making my robot drive 24 inches everytime. Obviously it keeps doing different distances every time with the same KP value.
My question is, what values do I gather to get the oscillating graph I see in tutorials. That is a part I cannot figure out.
It depends on what data you are trying to graph.
For your example of moving a distance of 24 in, you would graph actual distance traveled. However, if you were trying to graph velocity and use a PID to minimize error in velocity, you’d graph your actual velocity.
To get the data off the brain you can use an SD Card or you can do a console print. To do so use the line of code below.
std::cout refers to the character out (cout) stream << is the bit shift operator, it has been overloaded to pass info into the steam pros::millis() is how you get time in milliseconds
The ’ ’ is a delimiter commonly used in space seperated values, you could use a ‘,’ instead however. actual_distance refers to variable recording the actual distance traveled. You could substitute it with a call that gets the encoder position from the motor. std::endl adds a \n character, potentially a \r character (not sure on that), and flushes the cout buffer.
Then open a brain terminal using your prefered platform. In PROS you can type pros mut (make, upload, and terminal) or pros terminal to open a brain terminal.
For any questions about how to get certian sensor data take a look at the APIs.