Skip to content
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

Limit lin_speed, scale ang_speed in PIDController and BoomerangController #95

Merged
merged 2 commits into from
Apr 17, 2024

Conversation

AndrewLuGit
Copy link
Contributor

Limit lin_speed in PIDController and Boomerang controller so it scales better in DiffChassis
Scale ang_speed for a smoother transition between being outside of min_error and being within min_error.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@@ -50,24 +49,18 @@ BoomerangController::get_command(bool reverse, bool thru,
}
lin_speed *= dir;

double pose_error = voss::norm_delta(target.theta.value() - current_angle);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'pose_error' is not initialized [cppcoreguidelines-init-variables]

Suggested change
double pose_error = voss::norm_delta(target.theta.value() - current_angle);
double pose_error = NAN = voss::norm_delta(target.theta.value() - current_angle);

// reduce the linear speed if the bot is tangent to the target
ang_speed = angular_pid.update(pose_error);
} else if (distance_error < 2 * min_error) {
double scale_factor = (distance_error - min_error) / min_error;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'scale_factor' of type 'double' can be declared 'const' [misc-const-correctness]

Suggested change
double scale_factor = (distance_error - min_error) / min_error;
double const scale_factor = (distance_error - min_error) / min_error;

ang_speed = angular_pid.update(pose_error);
} else if (distance_error < 2 * min_error) {
double scale_factor = (distance_error - min_error) / min_error;
double scaled_angle_error = voss::norm_delta(scale_factor * angle_error + (1 - scale_factor) * pose_error);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'scaled_angle_error' of type 'double' can be declared 'const' [misc-const-correctness]

Suggested change
double scaled_angle_error = voss::norm_delta(scale_factor * angle_error + (1 - scale_factor) * pose_error);
double const scaled_angle_error = voss::norm_delta(scale_factor * angle_error + (1 - scale_factor) * pose_error);

@AndrewLuGit AndrewLuGit merged commit 471f866 into master Apr 17, 2024
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.

2 participants