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(raw_vehicle_cmd_converter): validate map at first before run time #2152

Merged

Conversation

taikitanaka3
Copy link
Contributor

@taikitanaka3 taikitanaka3 commented Oct 25, 2022

Signed-off-by: taikitanaka3 taiki.tanaka@tier4.jp

resolve: #2151

Description

1: [==========] Running 5 tests from 1 test suite.
1: [----------] Global test environment set-up.
1: [----------] 5 tests from ConverterTests
1: [ RUN      ] ConverterTests.LoadExampleMap
1: [       OK ] ConverterTests.LoadExampleMap (1 ms)
1: [ RUN      ] ConverterTests.LoadValidPath
1: Cannot open invalid.csv
1: Cannot open invalid.csv
1: Cannot open invalid.csv
1: Cannot read /home/ros2-galatic/workspace/Universe.proj/install/raw_vehicle_cmd_converter/share/raw_vehicle_cmd_converter/test/map_data/test_1col_map.csv CSV file should have at least 2 column
1: Cannot read /home/ros2-galatic/workspace/Universe.proj/install/raw_vehicle_cmd_converter/share/raw_vehicle_cmd_converter/test/map_data/test_inconsistent_rows_map.csv. Each row should have a same number of columns
1: index around (i,j) is invalid ( 2, 1 )
1: [       OK ] ConverterTests.LoadValidPath (0 ms)
1: [ RUN      ] ConverterTests.AccelMapCalculation
1: Input throttle: vel: 20 is out of range. use closest value.
1: Input throttle: acc: 2 is out of range. use closest value.
1: [       OK ] ConverterTests.AccelMapCalculation (0 ms)
1: [ RUN      ] ConverterTests.BrakeMapCalculation
1: Input brake: vel: 11 is out of range. use closest value.
1: Input brake: acc: 1.1 is out of range. use closest value.
1: Input brake: vel: 12 is out of range. use closest value.
1: Input brake: acc: 1.1 is out of range. use closest value.
1: [       OK ] ConverterTests.BrakeMapCalculation (0 ms)
1: [ RUN      ] ConverterTests.SteerMapCalculation
1: [       OK ] ConverterTests.SteerMapCalculation (0 ms)
1: [----------] 5 tests from ConverterTests (1 ms total)
1: 
1: [----------] Global test environment tear-down
1: [==========] 5 tests from 1 test suite ran. (1 ms total)
1: [  PASSED  ] 5 tests.
1: -- run_test.py: return code 0

Related links

Tests performed

  • validation with existing acc brake sterr map
  • validate with more realistic params
  • add unit test for invalid map case

checked external cmd converter runs successful with psim
image

Notes for reviewers

see if unit tests are successful

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

  • The PR follows the pull request guidelines.
  • The PR has been properly tested.
  • The PR has been reviewed by the code owners.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.
  • The PR is ready for merge.

After all checkboxes are checked, anyone who has write access can merge the PR.

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>
@codecov
Copy link

codecov bot commented Oct 25, 2022

Codecov Report

Base: 10.76% // Head: 10.82% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (06db32f) compared to base (641b84b).
Patch coverage: 43.24% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2152      +/-   ##
==========================================
+ Coverage   10.76%   10.82%   +0.05%     
==========================================
  Files        1186     1186              
  Lines       84826    84965     +139     
  Branches    19889    19978      +89     
==========================================
+ Hits         9133     9195      +62     
- Misses      66008    66041      +33     
- Partials     9685     9729      +44     
Flag Coverage Δ *Carryforward flag
differential 7.35% <22.91%> (?)
total 10.74% <50.98%> (ø) Carriedforward from 01edb12

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

Impacted Files Coverage Δ
...r/include/raw_vehicle_cmd_converter/csv_loader.hpp 100.00% <ø> (ø)
...ehicle/raw_vehicle_cmd_converter/src/brake_map.cpp 43.18% <0.00%> (+9.84%) ⬆️
vehicle/raw_vehicle_cmd_converter/src/node.cpp 0.00% <0.00%> (ø)
..._converter/test/test_raw_vehicle_cmd_converter.cpp 37.39% <25.71%> (+9.61%) ⬆️
...hicle/raw_vehicle_cmd_converter/src/csv_loader.cpp 67.85% <70.37%> (-2.36%) ⬇️
...ehicle/raw_vehicle_cmd_converter/src/accel_map.cpp 39.39% <100.00%> (-1.35%) ⬇️
...ehicle/raw_vehicle_cmd_converter/src/steer_map.cpp 50.00% <100.00%> (+2.94%) ⬆️
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>
Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>
@taikitanaka3 taikitanaka3 marked this pull request as ready for review October 25, 2022 15:15
}
}
}
if (is_invalid) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: add output where is invalid in map

0, 1.0, 11.0, 21.0
0.5, 2.0, 22.0, 42.0
1.0, 3.0, 33.0, 46.0
default,0.0, 5.0, 10.0
Copy link
Contributor Author

@taikitanaka3 taikitanaka3 Oct 26, 2022

Choose a reason for hiding this comment

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

Note: use more realistic params for test because it's hard to tell if case "calcThrottle" should use accel map or brake map for single unit test

const auto data_path =
ament_index_cpp::get_package_share_directory("raw_vehicle_cmd_converter") + "/data/default/";
// for invalid path
EXPECT_TRUE(accel_map.readAccelMapFromCSV(data_path + "accel_map.csv"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: add test with existing accel / brake / steer map for unit test

@@ -100,10 +142,10 @@ std::vector<double> CSVLoader::getColumnIndex(const Table & table)
double CSVLoader::clampValue(
const double val, const std::vector<double> & ranges, const std::string & name)
{
const double max_value = ranges.back();
const double min_value = ranges.front();
const double max_value = *std::max_element(ranges.begin(), ranges.end());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: max = vec.back() min = vec.front() is common for current map format but I want this change for safe

         min ----> max
   min
   |
   max

@@ -148,25 +144,17 @@ double RawVehicleCommandConverterNode::calculateSteer(
double dt = (current_time - prev_time_steer_calculation_).seconds();
if (std::abs(dt) > 1.0) {
RCLCPP_WARN_EXPRESSION(get_logger(), is_debugging_, "ignore old topic");
dt = 0.0;
dt = 0.1; // set ordinaray delta time instead
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: add ordinary dt for delay case

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!

Signed-off-by: tanaka3 <ttatcoder@outlook.jp>
@taikitanaka3 taikitanaka3 enabled auto-merge (squash) October 26, 2022 02:55
@taikitanaka3 taikitanaka3 merged commit 897794a into autowarefoundation:main Oct 26, 2022
@taikitanaka3 taikitanaka3 deleted the feature/validate_acc_brake_map branch October 26, 2022 03:01
taikitanaka3 added a commit to tier4/autoware.universe that referenced this pull request Dec 2, 2022
autowarefoundation#2152)

* feat(raw_vehicle_cmd_converter): validate map at first before run time

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>

* chore: remove debug

* fix: clamp method and add more unit tests

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>

* feat: add more realistic params

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>

* chore: revert to simple map

Signed-off-by: tanaka3 <ttatcoder@outlook.jp>

* Revert "chore: revert to simple map"

This reverts commit 0350724.

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>
Signed-off-by: tanaka3 <ttatcoder@outlook.jp>
HansRobo pushed a commit to HansRobo/autoware.universe that referenced this pull request Dec 16, 2022
autowarefoundation#2152)

* feat(raw_vehicle_cmd_converter): validate map at first before run time

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>

* chore: remove debug

* fix: clamp method and add more unit tests

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>

* feat: add more realistic params

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>

* chore: revert to simple map

Signed-off-by: tanaka3 <ttatcoder@outlook.jp>

* Revert "chore: revert to simple map"

This reverts commit 0350724.

Signed-off-by: taikitanaka3 <taiki.tanaka@tier4.jp>
Signed-off-by: tanaka3 <ttatcoder@outlook.jp>
Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com>
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.

raw vehicle cmd converter might skip computation during run time
2 participants