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

Use portable version for string-to-double conversion #1257

Merged
merged 7 commits into from Jan 4, 2024

Conversation

christophfroehlich
Copy link
Contributor

@christophfroehlich christophfroehlich commented Dec 29, 2023

As raised with #949 the current code is not portable to compilers not fully supporting c++17 (like on Debian 11,..) since #921

I propose using the solution of urdfdom_headers, srdfdom and MoveIt2, which fixes #949.

I created a new file and moved also the parse_bool function.

Maybe we should use this only for humble+iron, and leave the "modern" std::from_chars in rolling and for future distros? Edit: we want to keep that and add the std::from_chars with build-macros for newer compiler.

Once this is merged, I'd fix also with the then-decided solutions

@christophfroehlich christophfroehlich added the backport-iron This label should be used by maintaines only! Label triggers PR backport to ROS2 Iron. label Dec 29, 2023
Copy link

codecov bot commented Dec 29, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (e149646) 47.82% compared to head (560605c) 47.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1257      +/-   ##
==========================================
- Coverage   47.82%   47.66%   -0.16%     
==========================================
  Files          40       41       +1     
  Lines        3448     3451       +3     
  Branches     1869     1876       +7     
==========================================
- Hits         1649     1645       -4     
  Misses        455      455              
- Partials     1344     1351       +7     
Flag Coverage Δ
unittests 47.66% <33.33%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...e_interface/src/mock_components/generic_system.cpp 55.01% <0.00%> (-0.09%) ⬇️
hardware_interface/src/component_parser.cpp 43.64% <37.50%> (-1.74%) ⬇️
...rface/include/hardware_interface/lexical_casts.hpp 40.00% <40.00%> (ø)

... and 1 file with indirect coverage changes

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

Niceeee. Great job!

hardware_interface/include/hardware_interface/tools.hpp Outdated Show resolved Hide resolved
@christophfroehlich
Copy link
Contributor Author

@saikishor what do you think, which version should we use from ROS-J on? std::from_chars or this version with the std::locale::classic?

@saikishor
Copy link
Member

@saikishor what do you think, which version should we use from ROS-J on? std::from_chars or this version with the std::locale::classic?

@christophfroehlich Thanks for bringing up this. I think std::from_chars is recommended from the C++17 onwards, however, looking at the some of the main ROS repos, they are still using this locale approach in their rolling branches. For this reason, it is better to maintain this approach even in the upcoming releases. Moreover, this way we won't loose support for Debian11.

What do you think?

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

LGTM

destogl
destogl previously approved these changes Jan 3, 2024
Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

Happy, just one small comment

@@ -26,22 +26,12 @@
#include <vector>

#include "hardware_interface/component_parser.hpp"
#include "hardware_interface/helpers.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

Can we add something like this?

Suggested change
#include "hardware_interface/helpers.hpp"
#if CPP_VER<=17
#include "hardware_interface/helpers.hpp"
#endif

Copy link
Member

Choose a reason for hiding this comment

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

#if __cplusplus > 201402L

Copy link
Member

Choose a reason for hiding this comment

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

...in a follow-up ticket

Copy link
Member

Choose a reason for hiding this comment

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

The goal is to add the old code of parsing with std::from_chars protected by CPP version protection. If a higher version then C++17 (this flag #if __cplusplus > 201402L) is used then we should you this standard; otherwise we use the here implemented version.

bmagyar
bmagyar previously approved these changes Jan 3, 2024
@christophfroehlich christophfroehlich marked this pull request as draft January 3, 2024 19:49
@christophfroehlich christophfroehlich marked this pull request as ready for review January 3, 2024 19:53
Copy link
Contributor

@olivier-stasse olivier-stasse left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this !
LGTM

Copy link
Member

@saikishor saikishor left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-iron This label should be used by maintaines only! Label triggers PR backport to ROS2 Iron.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't build with GCC < 11 (RHEL CI build, Ubuntu 20.04...)
6 participants