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

Add tolerance time to tolerance exit conditions #87

Merged
merged 1 commit into from
Mar 22, 2024
Merged

Conversation

AndrewLuGit
Copy link
Contributor

No description provided.

@AndrewLuGit AndrewLuGit requested a review from Rocky14683 March 21, 2024 22:36
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

@@ -41,10 +41,11 @@ ExitConditions& ExitConditions::add_timeout(int timeout) {
}

ExitConditions& ExitConditions::add_tolerance(double linear_tolerance,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 2 adjacent parameters of 'add_tolerance' of similar type ('double') are easily swapped by mistake [bugprone-easily-swappable-parameters]

ExitConditions& ExitConditions::add_tolerance(double linear_tolerance,
                                              ^
Additional context

src/VOSS/exit_conditions/ExitConditions.cpp:42: the first parameter in the range is 'linear_tolerance'

ExitConditions& ExitConditions::add_tolerance(double linear_tolerance,
                                                     ^

src/VOSS/exit_conditions/ExitConditions.cpp:43: the last parameter in the range is 'angular_tolerance'

                                              double angular_tolerance,
                                                     ^

@@ -5,14 +5,26 @@

namespace voss::controller {

ToleranceAngularExitCondition::ToleranceAngularExitCondition(double tolerance)
: tolerance(voss::to_radians(tolerance)) {
ToleranceAngularExitCondition::ToleranceAngularExitCondition(double tolerance, double tolerance_time)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: constructor does not initialize these fields: current_time [cppcoreguidelines-pro-type-member-init]

include/VOSS/exit_conditions/ToleranceAngularExitCondition.hpp:11:

-     double current_time;
+     double current_time{};

@@ -5,14 +5,26 @@

namespace voss::controller {

ToleranceAngularExitCondition::ToleranceAngularExitCondition(double tolerance)
: tolerance(voss::to_radians(tolerance)) {
ToleranceAngularExitCondition::ToleranceAngularExitCondition(double tolerance, double tolerance_time)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 2 adjacent parameters of 'ToleranceAngularExitCondition' of similar type ('double') are easily swapped by mistake [bugprone-easily-swappable-parameters]

ToleranceAngularExitCondition::ToleranceAngularExitCondition(double tolerance, double tolerance_time)
                                                             ^
Additional context

src/VOSS/exit_conditions/ToleranceAngularExitCondition.cpp:7: the first parameter in the range is 'tolerance'

ToleranceAngularExitCondition::ToleranceAngularExitCondition(double tolerance, double tolerance_time)
                                                                    ^

src/VOSS/exit_conditions/ToleranceAngularExitCondition.cpp:7: the last parameter in the range is 'tolerance_time'

ToleranceAngularExitCondition::ToleranceAngularExitCondition(double tolerance, double tolerance_time)
                                                                                      ^

if (thru) {
return true;
}
current_time += 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]

        current_time += 10;
                        ^

}
}

void ToleranceExitCondition::add_ang_exit(double angular_tolerance, double tolerance_time) {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 2 adjacent parameters of 'add_ang_exit' of similar type ('double') are easily swapped by mistake [bugprone-easily-swappable-parameters]

void ToleranceExitCondition::add_ang_exit(double angular_tolerance, double tolerance_time) {
                                          ^
Additional context

src/VOSS/exit_conditions/ToleranceExitCondition.cpp:35: the first parameter in the range is 'angular_tolerance'

void ToleranceExitCondition::add_ang_exit(double angular_tolerance, double tolerance_time) {
                                                 ^

src/VOSS/exit_conditions/ToleranceExitCondition.cpp:35: the last parameter in the range is 'tolerance_time'

void ToleranceExitCondition::add_ang_exit(double angular_tolerance, double tolerance_time) {
                                                                           ^

if (thru) {
return true;
}
current_time += 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]

        current_time += 10;
                        ^

@@ -11,12 +11,12 @@
#define RIGHT_MOTORS \
{ 10, 3, 9, -7, -15 }

auto odom = voss::localizer::IMELocalizerBuilder::new_builder()
auto odom = voss::localizer::TrackingWheelLocalizerBuilder::new_builder()
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 'odom' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

auto odom = voss::localizer::TrackingWheelLocalizerBuilder::new_builder()
     ^

@@ -11,12 +11,12 @@
#define RIGHT_MOTORS \
{ 10, 3, 9, -7, -15 }

auto odom = voss::localizer::IMELocalizerBuilder::new_builder()
auto odom = voss::localizer::TrackingWheelLocalizerBuilder::new_builder()
.with_right_motor(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]

                .with_right_motor(10)
                                  ^

@@ -50,7 +50,7 @@ auto arc = voss::controller::ArcPIDControllerBuilder(odom)
pros::Controller master(pros::E_CONTROLLER_MASTER);
auto ec = voss::controller::ExitConditions::new_conditions()
.add_settle(400, 0.5, 400)
.add_tolerance(1.0, 2.0)
.add_tolerance(1.0, 2.0, 200)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]

              .add_tolerance(1.0, 2.0, 200)
                                  ^

@@ -50,7 +50,7 @@ auto arc = voss::controller::ArcPIDControllerBuilder(odom)
pros::Controller master(pros::E_CONTROLLER_MASTER);
auto ec = voss::controller::ExitConditions::new_conditions()
.add_settle(400, 0.5, 400)
.add_tolerance(1.0, 2.0)
.add_tolerance(1.0, 2.0, 200)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 200 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers]

              .add_tolerance(1.0, 2.0, 200)
                                       ^

Copy link
Member

@Rocky14683 Rocky14683 left a comment

Choose a reason for hiding this comment

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

Rocky review says "All clean, LGTM! 👍"

@Rocky14683 Rocky14683 merged commit 4c2ea66 into master Mar 22, 2024
2 checks passed
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