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

provide message validation check API #4206

Closed
wants to merge 39 commits into from
Closed

provide message validation check API #4206

wants to merge 39 commits into from

Conversation

GoesM
Copy link
Contributor

@GoesM GoesM commented Mar 22, 2024


Basic Info

Info Please fill out this column
Ticket(s) this addresses #4177
Primary OS tested on Ubuntu
Robotic platform tested on gazebo
Does this PR contain AI generated software? No

Description of contribution in a few bullet points

Description of documentation updates required from your changes

  • new file named validate_message.hpp, which provide a structure of message-validation-check in nav2_util
  • add a validation check for map message of nav2_amcl

Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in navigation.ros.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

Copy link
Contributor

mergify bot commented Mar 22, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

Looks good for a first go! I think it has some linting issues and needs to add unit tests for each of the functions, but overall with a few trivial changes this looks like a good starting point!

nav2_util/include/nav2_util/validate_messages.hpp Outdated Show resolved Hide resolved
nav2_util/include/nav2_util/validate_messages.hpp Outdated Show resolved Hide resolved
nav2_util/include/nav2_util/validate_messages.hpp Outdated Show resolved Hide resolved
nav2_util/include/nav2_util/validate_messages.hpp Outdated Show resolved Hide resolved
nav2_util/include/nav2_util/validate_messages.hpp Outdated Show resolved Hide resolved
nav2_util/include/nav2_util/validate_messages.hpp Outdated Show resolved Hide resolved
nav2_util/include/nav2_util/validate_messages.hpp Outdated Show resolved Hide resolved
nav2_util/include/nav2_util/validate_messages.hpp Outdated Show resolved Hide resolved
Copy link
Contributor

mergify bot commented Mar 23, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@GoesM
Copy link
Contributor Author

GoesM commented Mar 23, 2024

I've updated some conditions in validateMsg(), but I've encountered a few details that need addressing. I'll take some time to figure out how to resolve them. However, I'll go ahead and update my current code to share my progress here~ ^_^

@SteveMacenski
Copy link
Member

SteveMacenski commented Mar 25, 2024

Great, thanks! I'm giving it a once over but only thing that is clearly missing is just the unit tests / linting so that it meets our quality specs for Nav2 contributions! Thanks for this!

After this is done, I think this would make a really nice, short, confined undergraduate / jr graduate student project to finish this up with other messages and use it across the stack. It would let them think about some of the important needs for production systems and be able to touch alot of places in Nav2 to learn and grow. If you had any students in mind, let me know! Else, I'm sure I can find one.

Copy link
Contributor

mergify bot commented Mar 28, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

1 similar comment
Copy link
Contributor

mergify bot commented Mar 28, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@GoesM
Copy link
Contributor Author

GoesM commented Apr 6, 2024

About the time-stamp of map message

current code for updating the time-stamp

https://github.com/ros-planning/navigation2/blob/0be2f25782413677fedc58ea090c6ecfa8b9a6b8/nav2_map_server/src/map_server/map_server.cpp#L243-L248

in this way, we would NOT update the stamp successfully.

Though I'm not very clear about the reson , but we can prove it by following inserted code:

//goes insert
  updateMsgHeader();
  std::cout <<
    "[GOES|DEBUG] [map_io]: msg.header.stamp.sec: " << msg_.header.stamp.sec << std::endl
        << "msg_.header.stamp.nanosec" << msg_.header.stamp.nanosec << std::endl; 
  std::cout <<
    "[GOES|DEBUG] [map_io]: msg_.info.map_load_time.sec : " << msg_.info.map_load_time.sec << std::endl
        << "msg_.header.msg_.info.map_load_time.nanosec" << msg_.info.map_load_time.nanosec << std::endl; 
// insert end

then , we could catch the log as following:

[map_server-6] [GOES|DEBUG] [map_io]: msg.header.stamp.sec: 0
[map_server-6] msg_.header.stamp.nanosec0
[map_server-6] [GOES|DEBUG] [map_io]: msg_.info.map_load_time.sec : 0
[map_server-6] msg_.header.msg_.info.map_load_time.nanosec0

suggested way to update the time-stamp

I've tried to update the stamp in another way, like following:

void MapServer::updateMsgHeader()
{
  rclcpp::Clock clock(RCL_SYSTEM_TIME);
  msg_.info.map_load_time = clock.now();
  msg_.header.frame_id = frame_id_;
  msg_.header.stamp = clock.now();
}

then , we could catch the log as following, which shows a successful result.

[map_server-6] [GOES|DEBUG] [map_io]: msg.header.stamp.sec: 1712391915
[map_server-6] msg_.header.stamp.nanosec28685368
[map_server-6] [GOES|DEBUG] [map_io]: msg_.info.map_load_time.sec : 1712391915
[map_server-6] msg_.header.msg_.info.map_load_time.nanosec28684872

In addition, the message received by ros2 topic echo would have a correct time-stamp:

header:
  stamp:
    sec: 1712393583
    nanosec: 750836020
  frame_id: map
info:
  map_load_time:
    sec: 1712393583
    nanosec: 750835026
  resolution: 0.05000000074505806

Copy link
Contributor

mergify bot commented Apr 6, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@SteveMacenski
Copy link
Member

SteveMacenski commented Apr 8, 2024

That's not a solution unfortunately since we don't always run in ROS (i.e. simulation) time. The clock of the node should be set to the right time source. Does the timestamp not get populated from the service call as well or just on the on_configure first go? That is really odd

Copy link
Contributor

mergify bot commented Apr 23, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@GoesM
Copy link
Contributor Author

GoesM commented Apr 23, 2024

I fix some typo this time.

the reason why time-stamp of message from map-server is (zero,zero)

After some experiments, it seems clear for me that updateMsgHeader as following would bring non-zero time ONLY after on_activate() finished.
Because the node->now() would not start its time until it's activated.

void MapServer::updateMsgHeader() 
 { 
   msg_.info.map_load_time = now(); 
   msg_.header.frame_id = frame_id_; 
   msg_.header.stamp = now(); 
 } 

SO, here's still the trouble that :

map_server only send map-message once during on_activate() but NOT after activated, so that the time-stamp would be zero and rejected by our validation_message check, then nav2_amcl would not start its work.
(how map_server send map-message shown as following:

https://github.com/ros-planning/navigation2/blob/677e6accb3aea9380678da7d623b3387578d3549/nav2_map_server/src/map_server/map_server.cpp#L128-L144

Here's some different ways I come up with to solve the trouble:

  • send the map-message first time after on_activate() (for example let nav2_amcl call the service "/nav2_map_server/load_map" provided by nav2_map_server)
  • remove validation check for zero-time-stamp
  • using the following way to update header:
void MapServer::updateMsgHeader()
{
  rclcpp::Clock clock(RCL_SYSTEM_TIME);
  msg_.info.map_load_time = clock.now();
  msg_.header.frame_id = frame_id_;
  msg_.header.stamp = clock.now();
}

I'm not very sure if there are any better methods available, or which one among these methods is most suitable. I should primarily rely on your advice regarding which direction to proceed with modifications. : )

@SteveMacenski
Copy link
Member

remove validation check for zero-time-stamp

Lets do that.

Also please pull in main or rebase so CI can run. you also have a couple linting problems that the Actions job identified. After that, this should be good to merge!

if (!validateMsg(msg.w)) {return false;}

// logic check
// 1> the quaternion should be normalized:
Copy link
Member

Choose a reason for hiding this comment

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

No need for the comments -- checking the normalization is the same as any distance calculation sqrt(componentA*componentA + componentB*componentA + ...)

goes and others added 15 commits April 24, 2024 14:41
add validation check for map-message in `nav2_amcl`

Signed-off-by: goes <[email protected]>
Signed-off-by: goes <[email protected]>
Signed-off-by: goes <[email protected]>
Signed-off-by: goes <[email protected]>
Signed-off-by: goes <[email protected]>
* Let BtActionServer overwrite xml

Co-authored-by: Johannes Huemer <[email protected]>
Signed-off-by: Johannes Huemer <[email protected]>
Signed-off-by: Christoph Froehlich <[email protected]>

* Make a ROS parameter for it

Signed-off-by: Christoph Froehlich <[email protected]>

* Rename flag to always reload BT xml file

Signed-off-by: Johannes Huemer <[email protected]>

---------

Signed-off-by: Johannes Huemer <[email protected]>
Signed-off-by: Christoph Froehlich <[email protected]>
Co-authored-by: Christoph Froehlich <[email protected]>
Signed-off-by: goes <[email protected]>
* Set smaller timeout for service node

Signed-off-by: Christoph Froehlich <[email protected]>

* Fix timeout calculation for service node

Signed-off-by: Christoph Froehlich <[email protected]>

* Add a feasible timeout also for action node

Signed-off-by: Christoph Froehlich <[email protected]>

---------

Signed-off-by: Christoph Froehlich <[email protected]>
Signed-off-by: goes <[email protected]>
* 18.5% performance improvement in MPPI

* adding in path angle update

* path align improvements

* adding views

* more updates with some TODOs

* massive improvements to cost critic

* remove TODOs

* removing some jitter

* updates

* use fabs

* 1ms saved baby!

* completed optimizations

* remove TODO

* linting

* fixing test failure

* indexing fix

* fix bug

* make MPPI default for Jazzy

* Adding higher velocity limits

---------

Signed-off-by: Steve Macenski <[email protected]>
Signed-off-by: goes <[email protected]>
SteveMacenski and others added 16 commits April 24, 2024 14:41
* attempt to fix 22.04 CI

* adding inline comment reminder

Signed-off-by: goes <[email protected]>
* Add API to gracefully cancel a controller

Signed-off-by: Ramon Wijnands <[email protected]>

* Add `cancel_deceleration` to RegulatedPurePursuitController

Signed-off-by: Ramon Wijnands <[email protected]>

* Update nav2_regulated_pure_pursuit_controller/src/parameter_handler.cpp

Co-authored-by: Steve Macenski <[email protected]>
Signed-off-by: Ramon Wijnands <[email protected]>

---------

Signed-off-by: Ramon Wijnands <[email protected]>
Signed-off-by: Ramon Wijnands <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
Signed-off-by: goes <[email protected]>
* Refactor the plugin names for bt_navigator to use double colons

Signed-off-by: Alan Xue <[email protected]>

* Refactor the plugin names for planner_server to use double colons

Signed-off-by: Alan Xue <[email protected]>

* Refactor the plugin names for behavior_server to use double colons

Signed-off-by: Alan Xue <[email protected]>

---------

Signed-off-by: Alan Xue <[email protected]>
Signed-off-by: goes <[email protected]>
* remove unused header

Signed-off-by: Ignacio Vizzo <[email protected]>

* First step. Return an optional value instead of user provided output.

Signed-off-by: Ignacio Vizzo <[email protected]>

* Second step, update the consumers of this utility function

Signed-off-by: Ignacio Vizzo <[email protected]>

* Third step: swap source/target to make it consistent with tf lookups

Otherwise is very confusing for any user who is user to the
tf2::Buffer::lookupTransform method

Signed-off-by: Ignacio Vizzo <[email protected]>

* transform tolerance -> transform timeout

I find this "transform tolerance" to specify something else. Once
again, I believe that sticking to tf2 name conventions is better and
improve readability for users already used to the tf2 API

Signed-off-by: Ignacio Vizzo <[email protected]>

* Last step, convert functions to template functions

This allow us to also query for the TransformStamped message from the
lookupTransform method.

Signed-off-by: Ignacio Vizzo <[email protected]>

* Add nodiscard to avoid confusiong API calls

Signed-off-by: Ignacio Vizzo <[email protected]>

* Update docs

Signed-off-by: Ignacio Vizzo <[email protected]>

* Revert "transform tolerance -> transform timeout"

This reverts commit ca7d06b.

Signed-off-by: Ignacio Vizzo <[email protected]>

* Fix linter 🤦

Signed-off-by: Ignacio Vizzo <[email protected]>

* reset to main

Signed-off-by: Ignacio Vizzo <[email protected]>

* Add 2 new utils functions to query transforms using messages

Signed-off-by: Ignacio Vizzo <[email protected]>

* Move utility function to base class to reuse implementation

Signed-off-by: Ignacio Vizzo <[email protected]>

* Fix Typo

Signed-off-by: Ignacio Vizzo <[email protected]>

---------

Signed-off-by: Ignacio Vizzo <[email protected]>
Signed-off-by: goes <[email protected]>
…ult migration (#4236)

* Adding config file for DWB to exercise in system tests from MPPI default migration

* adding collision monitor

* EOF line

* correct plugin names

* removing excess plugin defs

Signed-off-by: goes <[email protected]>
* Scale cost critic's weight when dynamically updated

Signed-off-by: pepisg <[email protected]>

* sign off

Signed-off-by: pepisg <[email protected]>

---------

Signed-off-by: pepisg <[email protected]>
Signed-off-by: goes <[email protected]>
…map yaml. (#4258)

* Add user home expander of home sequence

Signed-off-by: Wiktor Bajor <[email protected]>

* Add passing home dir as string instead of const char*

Signed-off-by: Wiktor Bajor <[email protected]>

* Add docs

Signed-off-by: Wiktor Bajor <[email protected]>

* Fix function declaration

Signed-off-by: Wiktor Bajor <[email protected]>

* Fix linter issues

Signed-off-by: Wiktor Bajor <[email protected]>

* Uncrustify linter

Signed-off-by: Wiktor Bajor <[email protected]>

* Uncrustify linter

Signed-off-by: Wiktor Bajor <[email protected]>

* Uncrustify linter: remove remove whitespace

Signed-off-by: Wiktor Bajor <[email protected]>

---------

Signed-off-by: Wiktor Bajor <[email protected]>
Signed-off-by: goes <[email protected]>
* optimizations

* Update test_nodehybrid.cpp

Signed-off-by: Steve Macenski <[email protected]>

---------

Signed-off-by: Steve Macenski <[email protected]>
Signed-off-by: goes <[email protected]>
* Set start and goal as float

Signed-off-by: Brice <[email protected]>

* fix worldToMapContinuous type

Signed-off-by: Brice <[email protected]>

* add static_cast<float>

Signed-off-by: Brice <[email protected]>

* fix linting

Signed-off-by: Brice <[email protected]>

* floor float to check start = goal

Signed-off-by: Brice <[email protected]>

---------

Signed-off-by: Brice <[email protected]>
Signed-off-by: goes <[email protected]>
* Adding new velocity deadband critic.

- add some tests
- cast double to float
- add new features from "main" branch

- fix formating

- add cost test
- fix linting issue
- add README

Signed-off-by: Denis Sokolov <[email protected]>

* Remove velocity deadband critic from defaults

Signed-off-by: Denis Sokolov <[email protected]>

* remove old weight

Signed-off-by: Denis Sokolov <[email protected]>

* fix velocity deadband critic tests

Signed-off-by: Denis Sokolov <[email protected]>

---------

Signed-off-by: Denis Sokolov <[email protected]>
Signed-off-by: goes <[email protected]>
* changed slam launch file according to the comments for the PR #4211

Signed-off-by: Ibrahim Özcan <[email protected]>

* Fixing litning problems

---------

Signed-off-by: Ibrahim Özcan <[email protected]>
Co-authored-by: Ibrahim Özcan <[email protected]>
Signed-off-by: goes <[email protected]>
Signed-off-by: goes <[email protected]>
Copy link
Contributor

mergify bot commented Apr 24, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

Copy link
Contributor

mergify bot commented Apr 24, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

Copy link
Contributor

mergify bot commented Apr 24, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@GoesM
Copy link
Contributor Author

GoesM commented Apr 24, 2024

Oops, I noticed that the CI test failed due to the spin_behavior_test, which doesn't seem to be caused by the validation_message.

Copy link
Contributor

mergify bot commented Apr 24, 2024

This pull request is in conflict. Could you fix it @GoesM?

@SteveMacenski
Copy link
Member

SteveMacenski commented Apr 24, 2024

Dont worry about the spin test - its flaky. You do though have a conflict you need to resolve before we can merge & I see that there's a collision checker test that failed, that is not known to be flaky but I restarted CI to see if it comes back. If so, then you should look into that.

Also, your pull / rebase did not work correctly, you have all of the commits from the work where this should only contain your commits by rebasing the branch on main or pulling in changes. Please fix this so that we only have your contributions in this PR 😄

Edit: It looks like that test was also flaky, you may ignore.

Copy link

codecov bot commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 80.96886% with 110 lines in your changes are missing coverage. Please review.

Project coverage is 89.64%. Comparing base (d509fbf) to head (9517883).
Report is 44 commits behind head on main.

❗ Current head 9517883 differs from pull request most recent head 8322fe2. Consider uploading reports for the commit 8322fe2 to get more accurate results

Files Patch % Lines
..._mppi_controller/src/critics/constraint_critic.cpp 48.83% 22 Missing ⚠️
...ontroller/src/critics/velocity_deadband_critic.cpp 52.27% 21 Missing ⚠️
...ntroller/src/regulated_pure_pursuit_controller.cpp 25.00% 12 Missing ⚠️
nav2_mppi_controller/src/critics/cost_critic.cpp 84.21% 6 Missing ⚠️
nav2_mppi_controller/src/critics/goal_critic.cpp 60.00% 4 Missing ⚠️
...2_mppi_controller/src/critics/obstacles_critic.cpp 71.42% 4 Missing ⚠️
nav2_smac_planner/src/smac_planner_hybrid.cpp 60.00% 4 Missing ⚠️
nav2_util/src/base_footprint_publisher.cpp 0.00% 4 Missing ⚠️
...oller/include/nav2_mppi_controller/tools/utils.hpp 90.32% 3 Missing ⚠️
..._mppi_controller/src/critics/goal_angle_critic.cpp 62.50% 3 Missing ⚠️
... and 16 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4206      +/-   ##
==========================================
- Coverage   90.01%   89.64%   -0.37%     
==========================================
  Files         432      435       +3     
  Lines       19406    19738     +332     
==========================================
+ Hits        17469    17695     +226     
- Misses       1937     2043     +106     

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

Copy link
Contributor

mergify bot commented Apr 25, 2024

@GoesM, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@GoesM
Copy link
Contributor Author

GoesM commented Apr 25, 2024

I think my rebase did not work correctly and I believe it's more wise for me to open another PR #4276

@GoesM GoesM closed this Apr 25, 2024
@GoesM GoesM mentioned this pull request Apr 25, 2024
7 tasks
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.