Skip to content

Added real frequency to log #3076

Closed
tonynajjar wants to merge 5 commits intoros-navigation:mainfrom
pixel-robotics:Add-real-frequency
Closed

Added real frequency to log #3076
tonynajjar wants to merge 5 commits intoros-navigation:mainfrom
pixel-robotics:Add-real-frequency

Conversation

@tonynajjar
Copy link
Contributor


Basic Info

Info Please fill out this column
Ticket(s) this addresses N/A
Primary OS tested on Ubuntu
Robotic platform tested on Own gazebo simulation

Description of contribution in a few bullet points

  • I added logging of the real achieved frequency when the target is not reached. Context: we were getting the "Control loop missed" warning but wanted to know at what rate we are running to know over time if this gets worse.

It's unfortunate that rclcpp::WallRate doesn't offer a way to get the achieved period/frequency when sleep returns fals

Description of documentation updates required from your changes


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

@mergify
Copy link
Contributor

mergify bot commented Jul 14, 2022

@tonynajjar, please properly fill in PR template in the future. @SteveMacenski, use this instead.

  • 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

@tonynajjar
Copy link
Contributor Author

image

I sometimes get frequencies higher than the target one. Any idea why? Maybe because I'm using a separate clock?

@tonynajjar tonynajjar force-pushed the Add-real-frequency branch from 2abe01c to 8588e28 Compare July 14, 2022 09:14
@SteveMacenski
Copy link
Member

Thanks for the addition, I agree, this is useful information!

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.

LGTM, just some sanity checking from the linters

@SteveMacenski
Copy link
Member

Just waiting on CI

@tonynajjar
Copy link
Contributor Author

tonynajjar commented Jul 14, 2022

I believe I fixed the linting issues, but before merging, do you have any idea why it sometimes print frequencies higher than the target frequency? If we are in that condition, the frequency shouldn't be higher... See above screenshot in case you missed it

@SteveMacenski
Copy link
Member

SteveMacenski commented Jul 14, 2022

I'd say first try nanoseconds rather than microseconds to give you more resolution, then try the high resolution clock[1], if that doesn't work, the ROS Steady Clock[2]. If it doesn't work by then, I can take a look. ROS Clock is probably the right move, but its worth trying those other options first to see if its a resolution issue, but it might be a time source issue.

[1] https://en.cppreference.com/w/cpp/chrono/high_resolution_clock

[2] https://github.com/ros-planning/navigation2/blob/f1d58abacc5b97a3398e805635c89f2312f469f7/nav2_planner/include/nav2_planner/planner_server.hpp#L241

@tonynajjar
Copy link
Contributor Author

on it

@tonynajjar
Copy link
Contributor Author

I applied all your suggestions but still same result...
image

I commited the version with the ROS clock. I'm still investigating

@tonynajjar
Copy link
Contributor Author

I give up 🤷‍♂️ I can't find anything wrong with the PR, maybe that's really the achieved rate. This could be related https://answers.ros.org/question/244688/frequency-of-c-while-loop-higher-than-desired/?

@SteveMacenski
Copy link
Member

It doesn't seem like this is something we should merge if it doesn't strictly speaking... work 😦

@tonynajjar
Copy link
Contributor Author

I actually agree, unless the wallrate is actually unstable and this only exposes that. I doubt it though, will investigate a bit more tomorrow

@tonynajjar
Copy link
Contributor Author

I can't find what's wrong and can't spend more time on it. I'm fine to close this PR if you want

@SteveMacenski
Copy link
Member

OK ☹️ I understand.

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