-
Notifications
You must be signed in to change notification settings - Fork 0
Review: Auto stages #37
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: auto-ff-testing
Are you sure you want to change the base?
Conversation
…mplements basic functions in respective cpp file
…reqs of autopaths also moved johnathans old autopaths into auto folder and renamed it. there is still 1 error i cant figure out about the map but ill fix it l8r
…ude files but no actual code errors
…s code to SwerveAutoPath and elsewhere
…-robot into auto-stages
…-robot into auto-stages
linc-mvla
left a comment
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.
get back to work
src/main/cpp/Auto/AutoStage.cpp
Outdated
| allPaths[i] = a.path; | ||
| if (i == startPathIdx) | ||
| continue; | ||
| cueToPath[a.cue] = {i, 0.0, &a.path}; |
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.
check index isn't a.cue + i
src/main/cpp/Auto/AutoStage.cpp
Outdated
| continue; | ||
| cueToPath[a.cue] = {i, 0.0, &a.path}; | ||
| } | ||
| StartPath({startPathIdx, 0.0, &allPaths[startPathIdx]}); |
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.
missing m_startIDx = start, prolly should put it in StartPath
src/main/cpp/Auto/AutoStage.cpp
Outdated
| i.path->AutonomousPeriodic(); | ||
| auto itr = cueToPath.lower_bound(i.index+i.lastCompletion); | ||
| double curCompletion = i.path->GetCompletionPercentage(); | ||
| while (true){ |
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.
Will run into out of bounds error
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.
if last element
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.
also this check should be done outside the for loop, where you just store the maximum index within the loop
| while (true){ | ||
| double curCue = itr->first; | ||
| if (curCue <= i.index + curCompletion){ | ||
| StartPath(itr->second); |
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.
this will start paths already started (is that ok?)
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.
also might cause infinite adding to the set if the equals operator is not working
src/main/cpp/Auto/AutoStage.cpp
Outdated
| } else break; | ||
| itr++; | ||
| } | ||
| i.lastCompletion = curCompletion; |
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.
Sorta unnecessary because of prolly less than 20ms delay, doesn't hurt tho
| double y_completion = calcGenericCompletion(previous_waypoint.getPos().at(1), curr_y, current_waypoint.getPos().at(1)); | ||
| double averaged = (x_completion + y_completion) / 2.0; | ||
|
|
||
| if (averaged == 1.0) { |
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.
bro's not reaching target ever
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.
use a tolerance
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.
I would also recommend using the time to figure out what segment you're on, instead of incrementing whenever it reaches the target. (your choice)
| } | ||
|
|
||
| double SwerveAutoPath::calcGenericCompletion(double start, double current, double end) { | ||
| double frac = abs(current_distance - start) / abs(end - start); |
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.
don't use absolute value (you don't need it). Also do the math correctly: (end - current)/(end - start), don't return 1.0 - that
| // double y_completion = curr_y / current_waypoint.getPos().at(1); | ||
| double x_completion = calcGenericCompletion(previous_waypoint.getPos().at(0), curr_x, current_waypoint.getPos().at(0)); | ||
| double y_completion = calcGenericCompletion(previous_waypoint.getPos().at(1), curr_y, current_waypoint.getPos().at(1)); | ||
| double averaged = (x_completion + y_completion) / 2.0; |
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.
Might want to use geometric average
| * @param ang Current angle | ||
| */ | ||
| void AutoPath::UpdateOdom(vec::Vector2D curPos, double curAng) { | ||
| void SwerveAutoPath::UpdateOdom(vec::Vector2D curPos, double curAng) { |
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.
Remember to call this
| void SwerveAutoPath::AutonomousPeriodic() { | ||
| // does the calculations | ||
| Periodic(); | ||
|
|
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.
where update completion
No description provided.