![]() |
PID loop speeds up as it gets closer to target?
Hey I'm programming a mecanum drive base and previously we used a simple function that slowed it down as we got closer to the target. However, we want to make a more complex PID loop so we can strafe and rotate at the same time more smoothly.
I am using a navx and the PIDController class. I based my changes off of the examples that the navx comes with. However, I'd rather not change too much of what we already have. All I want to do is compute the absolute speed that we want. So the problem I'm having is that the output speed that it is giving me doesn't make sense. It starts slow and gets faster in the middle and slows down at the end. This causes us to rotate much slower than we could before. Here is a link to my code: https://github.com/team2053tigertron...e/TigerDrive.h https://github.com/team2053tigertron...TigerDrive.cpp Thank you for the help, Drew |
Re: PID loop speeds up as it gets closer to target?
What motor controller are you using?
Verify that your motor controller and sensor are in-phase. In-phase means that if you apply a positive throttle to the motor controller, the sensor moves in a positive direction. If the motor controller and sensor are not in-phase, then you might want to go to setPoint = 500, but the sensor is reading -250, and when you try to go forward, the sensor shows that you are going backwards, i.e. towards -500. That could cause the PID loop to accelerate towards your setPoint, because as far as the PID loop knows, you are getting further away from the setPoint. Good luck! -Tyler |
Re: PID loop speeds up as it gets closer to target?
Im using 4 talon srxs.
But all im doing is calculating absolute speed based on absolute degrees to the angle I am rotating to. It shouldn't matter in this case, unless I am missing something. |
Re: PID loop speeds up as it gets closer to target?
Quote:
|
Re: PID loop speeds up as it gets closer to target?
We are running on the roboRIO. Have you taken a look at my code that i linked in the first post?
Relevant code: Code:
rotateToAngleRate = 0.0f;Code:
turnController->Enable(); |
Re: PID loop speeds up as it gets closer to target?
Yes, I looked over your code, but I am unfamiliar with CPP.
Try printing out your PID error to the console. Knowing where the PID loop thinks it is can be very useful for debugging. If the PID loop is speeding up towards the setpoint, it could be that the PID does not correctly understand where it is, or the PID gain constants could be tuned poorly. Seeing as you are only using a P term right now, I would suggest looking at the error that your PID loop sees. As I said earlier, the control system still needs to be in-phase. What you are seeing here could very likely be caused by a gyroscope and drive train that are out of phase. |
Re: PID loop speeds up as it gets closer to target?
Thank you for the help! I figured it out. I just changed the input and output range back to full range of the IMU. Then I let the PID loop control the direction we are rotating.
Drew |
Re: PID loop speeds up as it gets closer to target?
Quote:
|
| All times are GMT -5. The time now is 15:30. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi