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

feat(autoware_external_cmd_converter): add ext cmd converter tests #9118

Conversation

danielsanchezaran
Copy link
Contributor

@danielsanchezaran danielsanchezaran commented Oct 18, 2024

Description

Add tests to increase test coverage of external cmd converter

image

Related links

Parent Issue:

  • Link

How was this PR tested?

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

@danielsanchezaran danielsanchezaran added the run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) label Oct 18, 2024
@github-actions github-actions bot added the component:vehicle Vehicle-specific implementations, drivers, packages. (auto-assigned) label Oct 18, 2024
Copy link

github-actions bot commented Oct 18, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@danielsanchezaran danielsanchezaran marked this pull request as ready for review October 18, 2024 09:08
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 70.43478% with 34 lines in your changes missing coverage. Please review.

Project coverage is 28.59%. Comparing base (8e0d40b) to head (f39fd7a).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...md_converter/tests/test_external_cmd_converter.cpp 69.91% 0 Missing and 34 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9118      +/-   ##
==========================================
+ Coverage   28.48%   28.59%   +0.10%     
==========================================
  Files        1306     1307       +1     
  Lines      101074   101196     +122     
  Branches    39234    39333      +99     
==========================================
+ Hits        28792    28934     +142     
+ Misses      69339    69277      -62     
- Partials     2943     2985      +42     
Flag Coverage Δ *Carryforward flag
differential 9.37% <70.43%> (?)
total 28.48% <ø> (ø) Carriedforward from 8e0d40b

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

std::shared_ptr<ExternalCmdConverterNode> external_cmd_converter_;
};

TEST_F(TestExternalCmdConverter, testCheckEmergencyStopTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you show a brief description of each test case?

EXPECT_DOUBLE_EQ(0.0, test_get_shift_velocity_sign(cmd));
}

TEST_F(TestExternalCmdConverter, testCalculateAcc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make test cases for boundary conditions? For example, a case with throttle = Inf (large number)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TakaHoribe thanks for your suggestions. I have added descriptions to the tests and functions used to evaluate. I also added combinations of std::numeric_limits::infinity() to the throttle and brake. Could you please check again?

Copy link
Contributor

Choose a reason for hiding this comment

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

You only check if the output is positive/negative for infinite cases. Are you sure that those outputs are not nan nor other invalid numbers?
This PR looks ok if the above concern is solved.

Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com>
Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com>
Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com>
@danielsanchezaran danielsanchezaran force-pushed the feat/add-ext-cmd-converter-tests branch from 771811c to f39fd7a Compare October 24, 2024 05:22
Comment on lines +151 to +158
if (
std::isnan(desired_throttle) || std::isnan(desired_brake) || std::isinf(desired_throttle) ||
std::isinf(desired_brake)) {
std::cerr << "Input brake or throttle is out of range. returning 0.0 acceleration."
<< std::endl;
return 0.0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if (
std::isnan(desired_throttle) || std::isnan(desired_brake) || std::isinf(desired_throttle) ||
std::isinf(desired_brake)) {
std::cerr << "Input brake or throttle is out of range. returning 0.0 acceleration."
<< std::endl;
return 0.0;
}
if (
std::isnan(desired_throttle) || std::isnan(desired_brake) || std::isinf(desired_throttle) ||
std::isinf(desired_brake)) {
std::cerr << "Input brake or throttle is out of range. returning 0.0 acceleration."
<< std::endl;
return 0.0;
}

@TakaHoribe I noticed there is no proper handling of Nan or infinite values in the external_cmd_converter so I decided to add this check, but I am wondering if returning 0 acceleration is the right answer in this case?

I have also made checks to combinations of infinity and nan inputs and checking the output to not be NaN or inf.

Copy link
Contributor

@TakaHoribe TakaHoribe left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for your nice work!

@danielsanchezaran danielsanchezaran merged commit 26f617d into autowarefoundation:main Oct 24, 2024
31 of 32 checks passed
@danielsanchezaran danielsanchezaran deleted the feat/add-ext-cmd-converter-tests branch October 24, 2024 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:vehicle Vehicle-specific implementations, drivers, packages. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants