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

Add unit tests for rclcpp Rate objects #182

Merged
merged 5 commits into from
Dec 18, 2015
Merged

Add unit tests for rclcpp Rate objects #182

merged 5 commits into from
Dec 18, 2015

Conversation

tfoote
Copy link
Contributor

@tfoote tfoote commented Dec 15, 2015

Connects to #181

First adding unit tests for coverage. Next debug problem.

The problem from 181 is reproduced in these unit tests:

CI: http://ci.ros2.org/job/ci_osx/602/

08:42:55 In file included from /Users/osrf/jenkins/workspace/ci_osx/ws/src/ros2/rclcpp/rclcpp/test/test_rate.cpp:19:
08:42:55 /Users/osrf/jenkins/workspace/ci_osx/ws/src/ros2/rclcpp/rclcpp/include/rclcpp/rate.hpp:74:20: error: no viable overloaded '+='
08:42:55     last_interval_ += period_;
08:42:55     ~~~~~~~~~~~~~~ ^  ~~~~~~~
08:42:55 /Users/osrf/jenkins/workspace/ci_osx/ws/src/ros2/rclcpp/rclcpp/test/test_rate.cpp:32:5: note: in instantiation of member function 'rclcpp::rate::GenericRate<std::__1::chrono::system_clock>::sleep' requested here
08:42:55   r.sleep();
08:42:55     ^
08:42:55 /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/chrono:782:79: note: candidate function not viable: no known conversion from 'duration<[...], ratio<[...], 1000000000>>' to 'const duration<[...], ratio<[...], 1000000>>' for 1st argument
08:42:55     __attribute__ ((__visibility__("hidden"), __always_inline__)) time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
08:42:55                                                                               ^
08:42:55 In file included from /Users/osrf/jenkins/workspace/ci_osx/ws/src/ros2/rclcpp/rclcpp/test/test_rate.cpp:19:
08:42:55 /Users/osrf/jenkins/workspace/ci_osx/ws/src/ros2/rclcpp/rclcpp/include/rclcpp/rate.hpp:81:24: error: no viable overloaded '='
08:42:55         last_interval_ = now + period_;
08:42:55         ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
08:42:55 /Users/osrf/jenkins/workspace/ci_osx/ws/src/ros2/rclcpp/rclcpp/test/test_rate.cpp:32:5: note: in instantiation of member function 'rclcpp::rate::GenericRate<std::__1::chrono::system_clock>::sleep' requested here
08:42:55   r.sleep();
08:42:55     ^
08:42:55 /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/chrono:750:56: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'time_point<[...], duration<[...], ratio<[...], 1000000000>>>' to 'const time_point<[...], duration<[...], ratio<[...], 1000000>>>' for 1st argument
08:42:55 class __attribute__ ((__type_visibility__("default"))) time_point
08:42:55                                                        ^
08:42:55 /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/chrono:750:56: note: candidate function (the implicit move assignment operator) not viable: no known conversion from 'time_point<[...], duration<[...], ratio<[...], 1000000000>>>' to 'time_point<[...], duration<[...], ratio<[...], 1000000>>>' for 1st argument
08:42:55 class __attribute__ ((__type_visibility__("default"))) time_point

@tfoote tfoote self-assigned this Dec 15, 2015
@tfoote tfoote added the in progress Actively being worked on (Kanban column) label Dec 15, 2015
@tfoote tfoote force-pushed the rate_tests branch 5 times, most recently from ee1129e to ca229a1 Compare December 16, 2015 10:31
@tfoote
Copy link
Contributor Author

tfoote commented Dec 16, 2015

CI is passing:

http://ci.ros2.org/job/ci_linux/737/
http://ci.ros2.org/job/ci_osx/619/
http://ci.ros2.org/job/ci_windows/809/

However the fix is not optimal as it pulls all durations to the lowest common denominator. Clang uses microseconds whereas gcc uses nanoseconds for the high resolution clock. https://stackoverflow.com/questions/22205290/cast-from-time-point-duration-to-duration-fails-on-clang

Does anyone have a better suggestion for this?

@gerkey
Copy link
Member

gerkey commented Dec 16, 2015

It does seem a shame to throw away resolution, but if that is how clang is doing it, then it doesn't seem that we have much choice. We'll likely end up using clang eventually on Linux, too.

Also, would we really be losing any capabilities? I.e., do we expect to run on a system that supports better-than-microsecond resolution timers? Looking around a bit, it seems that Linux + RT-PREEMPT can only get down to ~10us.

@wjwwood
Copy link
Member

wjwwood commented Dec 16, 2015

I proposed a different way to fix this in #185.

Basically, you force the time point object stored by the class to be nanosecond precision, but reuse the representation that the clock uses. This works fine since time_point<..., Ratio=nano> = time_point<..., Ration=micro> is allowed, and that's different from the original problem which was time_point<..., Ratio=micro> = time_point<..., Ration=micro> + duration<..., Ration=nano> which is not allowed due to implicit loss of precision.

@tfoote
Copy link
Contributor Author

tfoote commented Dec 17, 2015

This is close, however I'm having trouble getting osx to link the unit tests correctly.

Windows is happy: http://ci.ros2.org/job/ci_windows/817/

Initially I was getting this error:

dyld: Library not loaded: @rpath/librosidl_typesupport_introspection_c.dylib
  Referenced from: /Users/osrf/jenkins/workspace/ci_osx/ws/install/rcl_interfaces/lib/librcl_interfaces__rosidl_typesupport_introspection_c.dylib
  Reason: image not found

Adding an explicit linking to rmw_implementation_LIBRARIES fixed that but I only got a little farther to

-- run_test.py: invoking following command in '/Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp':
 - /Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp/test_rate --gtest_output=xml:/Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp/test_results/rclcpp/test_rate.gtest.xml
dyld: Library not loaded: @rpath/librosidl_typesupport_introspection_c.dylib
  Referenced from: /Users/osrf/jenkins/workspace/ci_osx/ws/install/rcl_interfaces/lib/librcl_interfaces__rosidl_typesupport_introspection_c.dylib
  Reason: image not found
-- run_test.py: return code -5
-- run_test.py: generate result file '/Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp/test_results/rclcpp/test_rate.gtest.xml' with failed test
-- run_test.py: verify result file '/Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp/test_results/rclcpp/test_rate.gtest.xml'

From there I tried adding rcl_interfaces as a run dependency as well as a built time one to make sure the package is available for the tests. And that didn't work either:

-- run_test.py: invoking following command in '/Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp':
 - /Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp/test_rate --gtest_output=xml:/Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp/test_results/rclcpp/test_rate.gtest.xml
dyld: Library not loaded: @rpath/librosidl_typesupport_introspection_c.dylib
  Referenced from: /Users/osrf/jenkins/workspace/ci_osx/ws/install/rcl_interfaces/lib/librcl_interfaces__rosidl_typesupport_introspection_c.dylib
  Reason: image not found
-- run_test.py: return code -5
-- run_test.py: generate result file '/Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp/test_results/rclcpp/test_rate.gtest.xml' with failed test
-- run_test.py: verify result file '/Users/osrf/jenkins/workspace/ci_osx/ws/build/rclcpp/test_results/rclcpp/test_rate.gtest.xml'

I'm trying one more iteration with an explicit test_depend but I'm not sure where to look next. Does anyone have a suggestion?

@dirk-thomas
Copy link
Member

Without more context it is difficult to suggest anything but the usual:

  • have you checked if these libraries exist?
  • what does ldd output for the executable / the libraries?
  • if it doesn't use absolute path how is the environment variable for looking up libraries when the test is being run?

@tfoote
Copy link
Contributor Author

tfoote commented Dec 17, 2015

The libraries exist where I would expect them. Looking at the output of otool -L there are a bunch of @rpath symbols which appear to be the problem. I commented out all my additional attempts to link additional libraries and just linked against the needed rclcpp library.

I still had all the rpaths and looking at librclcpp it itself has the rpaths. (oddly including an rpath to link against itself?

https://gist.github.com/tfoote/b2a693ae2f19aa5c203b

tfoote added a commit to ros2/rmw_connext that referenced this pull request Dec 17, 2015
on rosidl_typesupport_introspection_c necessary for ros2/rclcpp#182
@tfoote
Copy link
Contributor Author

tfoote commented Dec 17, 2015

CI kickedoff but backlogged:

CI linux is diabled? @dirk-thomas
http://ci.ros2.org/job/ci_windows/830
http://ci.ros2.org/job/ci_osx/650

@tfoote
Copy link
Contributor Author

tfoote commented Dec 18, 2015

@tfoote
Copy link
Contributor Author

tfoote commented Dec 18, 2015

Our assumptions about sleep's behavior were incorrect. updated new CI:
http://ci.ros2.org/job/ci_linux/794/
http://ci.ros2.org/job/ci_osx/662
http://ci.ros2.org/job/ci_windows/843/

@tfoote
Copy link
Contributor Author

tfoote commented Dec 18, 2015

@tfoote tfoote added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Dec 18, 2015

/*
Tests that funcion_traits calculates arity of several functors.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Docblock seems to be unrelated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, not quite accurate.

@gerkey
Copy link
Member

gerkey commented Dec 18, 2015

+1

We can hopefully tighten up the underrun bounds after addressing #190.

tfoote added a commit that referenced this pull request Dec 18, 2015
Add unit tests for rclcpp Rate objects
@tfoote tfoote merged commit 4d47ef3 into master Dec 18, 2015
@tfoote tfoote removed the in review Waiting for review (Kanban column) label Dec 18, 2015
@tfoote tfoote deleted the rate_tests branch December 18, 2015 19:20
${rosidl_generator_cpp_INCLUDE_DIRS}
)
target_link_libraries(test_rate
${PROJECT_NAME}${target_suffix}
Copy link
Member

@dirk-thomas dirk-thomas Apr 27, 2016

Choose a reason for hiding this comment

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

What is this line supposed to do? There is no target_suffix in this scope. It will have a random value depending on how call_for_each_rmw_implementation above has iterated through the rmw implementations.

Fixed in #213.

nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
* Remove error msg from valid case

* Document RCL_RET_{CLIENT/SERVICE}_TAKE_FAILED
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
* Add support for specifying max bagfile size in storage_options

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>

* Add helper functions in Writer required for bagfile splitting

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>

* Store max_bagfile_size when Writer is opened

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>

* Uncrustify

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>

* Apply suggestions from PR

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>

* Add ROSBAG2_STORAGE_PUBLIC to MAX_BAGFILE_SIZE_NO_SPLIT

This should fix the issue on Windows

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>

* Renamed private function in Writer to not end in `_`

Signed-off-by: Zachary Michaels <zmichaels11@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.

None yet

4 participants