Skip to content

Conversation

@riftEmber
Copy link

Closes #109

@riftEmber riftEmber force-pushed the add-trapezoidcontroller branch from 9f6e5fc to 9d33ab5 Compare October 8, 2016 20:01
private double maxVelocity;
private double accelerationEnd;
private double decelerationStart;
private double decelerationEnd;
Copy link
Contributor

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...

Copy link
Contributor

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are config values

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add getters and setters

@riftEmber riftEmber force-pushed the add-trapezoidcontroller branch from 9d33ab5 to c3856fe Compare October 13, 2016 01:03
private double maxVelocity;
private double accelerationEnd;
private double decelerationStart;
private double decelerationEnd;
Copy link
Contributor

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);
Copy link
Contributor

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

@riftEmber
Copy link
Author

I don't know how to fix it

@riftEmber riftEmber closed this Oct 14, 2016
@amikhalev
Copy link
Contributor

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)
Initial speed
Final speed.
Max speed.
Max acceleration
From here, you should be able to calculate speed based on current time from start of movement. Then you would need to add code which adjusts the current time based on what the current distance is and what it should be

@riftEmber riftEmber reopened this Oct 15, 2016
@riftEmber riftEmber force-pushed the add-trapezoidcontroller branch 2 times, most recently from 0b8c0ca to bf2ff81 Compare October 15, 2016 04:36
private double maxAcceleration;
private double maxDeceleration;
private double time;
private boolean isTrapezoidal;
Copy link
Contributor

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);
Copy link
Contributor

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));
}
}
}
Copy link
Contributor

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

@riftEmber riftEmber force-pushed the add-trapezoidcontroller branch 2 times, most recently from 39e02f3 to 5ed2ba6 Compare October 15, 2016 22:55
@J-J-Chen J-J-Chen force-pushed the add-trapezoidcontroller branch from 5ed2ba6 to 1139b2e Compare October 16, 2016 01:28
@amikhalev amikhalev force-pushed the add-trapezoidcontroller branch from 1139b2e to 66c0941 Compare October 17, 2016 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants