-
Notifications
You must be signed in to change notification settings - Fork 0
Add TrapezoidController for velocity on a trapezoidal graph #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
9f6e5fc to
9d33ab5
Compare
| private double maxVelocity; | ||
| private double accelerationEnd; | ||
| private double decelerationStart; | ||
| private double decelerationEnd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should just be a max acceleration...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do none of these have getters or setters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are config values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add getters and setters
9d33ab5 to
c3856fe
Compare
| private double maxVelocity; | ||
| private double accelerationEnd; | ||
| private double decelerationStart; | ||
| private double decelerationEnd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add getters and setters
| } else if (input >= decelerationStart && input < decelerationEnd) { | ||
| return maxVelocity - (maxVelocity - endSpeed) | ||
| * (input - decelerationStart) | ||
| / (decelerationEnd - decelerationStart); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you not fix this yet? If this isn't fixed today, we're not adding it before competition
|
I don't know how to fix it |
|
I have commented on what needs to be fixed. This needs to be done today, don't close it. Things that this needs to take in as parameters: A way to get current distance (input) |
0b8c0ca to
bf2ff81
Compare
| private double maxAcceleration; | ||
| private double maxDeceleration; | ||
| private double time; | ||
| private boolean isTrapezoidal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a section for fields that are constants, and fields that are updated. The getters and setters for updated fields should be synchronized
|
|
||
| @Override | ||
| public void onEnable() { | ||
| double highestVelocity = Math.sqrt(2 * maxAcceleration * getSetpoint() / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 * ... / 2?
| return (maxVelocity - endVelocity) * (time / (2 * decelerationStart)); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my idea for the algorithm:
On enable, First check if it is trapezoidal by seeing if the intersection of the start and end acceleration lines is above the travel speed (be careful because both the start and end acceleration could theoretically be positive or negative). If it is trapezoidal, look at the start speed, end speed, and travel speed. You can figure out when you should stop the initial acceleration (positive or negative) by looking at start speed, travel speed and max acceleration. You can figure out how long from the end of the whole run to start the end acceleration the same way. You can use both of these times, plus the travel speeds and initial/end speeds to figure out the area (distance) in the initial and end acceleration periods. Then all you have to do is figure out how long the travel period has to be. Actually you might not need the initial check for trapezoidal, because if the distances combined are greater than the total travel distance then you know you have to do something different. Also you have to be careful because it is possible for the start and end speed to be too far apart to work in a particular distance. You would need to extend this to work for very short movements where you don't reach the travel speed
39e02f3 to
5ed2ba6
Compare
5ed2ba6 to
1139b2e
Compare
1139b2e to
66c0941
Compare
Closes #109