Skip to content

Conversation

@Versus7
Copy link
Collaborator

@Versus7 Versus7 commented Nov 3, 2023

No description provided.

Versus7 and others added 30 commits October 18, 2023 19:22
…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
@Versus7 Versus7 requested a review from linc-mvla November 3, 2023 03:44
Copy link
Contributor

@linc-mvla linc-mvla left a 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

allPaths[i] = a.path;
if (i == startPathIdx)
continue;
cueToPath[a.cue] = {i, 0.0, &a.path};
Copy link
Contributor

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

continue;
cueToPath[a.cue] = {i, 0.0, &a.path};
}
StartPath({startPathIdx, 0.0, &allPaths[startPathIdx]});
Copy link
Contributor

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

i.path->AutonomousPeriodic();
auto itr = cueToPath.lower_bound(i.index+i.lastCompletion);
double curCompletion = i.path->GetCompletionPercentage();
while (true){
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

if last element

Copy link
Contributor

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

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?)

Copy link
Contributor

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

} else break;
itr++;
}
i.lastCompletion = curCompletion;
Copy link
Contributor

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

use a tolerance

Copy link
Contributor

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

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

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

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();

Copy link
Contributor

Choose a reason for hiding this comment

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

where update completion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants