-
Notifications
You must be signed in to change notification settings - Fork 420
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
Rclcpp time #311
Rclcpp time #311
Conversation
85f2217
to
ded0ac4
Compare
ded0ac4
to
b2fc67b
Compare
A few question, I'd like to have sorted out before merging:
|
FYI: added a connects to, assigned you on the corresponding issue and cross referenced this on the high level ticket |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment otherwise lgtm
rclcpp/include/rclcpp/rclcpp.hpp
Outdated
@@ -130,6 +130,7 @@ | |||
#include "rclcpp/parameter_client.hpp" | |||
#include "rclcpp/parameter_service.hpp" | |||
#include "rclcpp/rate.hpp" | |||
//#include "rclcpp/time.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why added with a comment?
We've used time 0 in the past to indicate time uninitialized. Keeping that behavior seems reasonable for backwards compatibility. Though since we're starting from scratch an exception might be something we could consider. For realtime optimization might we want to simply recommend using the rcl api? |
I changed the code to throw exceptions now, changed the test accordingly and also include this header directly into @tfoote if you could quickly verify these changes again, then i'd merge. |
If |
What's wrong with that? Do the packages in |
No, but consider it valuable to keep dependencies which need to be released before a package can be released as small as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, except the changes I requested in the cmake code.
rclcpp/CMakeLists.txt
Outdated
include_directories(include) | ||
include_directories( | ||
include | ||
${builtin_interfaces_INCLUDE_DIRS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you really just want the include directories then please use target_include_directories
, but you probably should just use ament_target_dependencies
on the targets that need these headers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean on the packages which use this header file? As this is a header-only implementation, there is no target inside rclcpp which uses this header file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean on the packages which use this header file?
No I mean on the targets which use the header file.
As this is a header-only implementation, there is no target inside rclcpp which uses this header file.
If no target needs these header files then it doesn't need to be in the include_directories()
. I would have thought a test used this header file in a compilation unit in this package.
rclcpp/CMakeLists.txt
Outdated
ament_export_include_directories(include) | ||
ament_export_include_directories( | ||
include | ||
${builtin_interfaces_INCLUDE_DIRS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ament_export_dependencies
instead.
rclcpp/CMakeLists.txt
Outdated
if(TARGET test_time) | ||
target_include_directories(test_time PUBLIC | ||
${rcl_INCLUDE_DIRS} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need the rcl include directories you will also need the library (perhaps). I recommend using ament_target_dependencies
here as well.
rclcpp/include/rclcpp/time.hpp
Outdated
|
||
class Time | ||
{ | ||
rcl_time_point_value_t rcl_time_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put member variables at the end of the class definition in its own private section.
If you want the constructors to be private, please mark them explicitly. See: https://google.github.io/styleguide/cppguide.html#Declaration_Order
rclcpp/test/test_time.cpp
Outdated
TEST(TestTime, rate_basics) { | ||
using builtin_interfaces::msg::Time; | ||
try { | ||
rclcpp::Time::now<RCL_ROS_TIME>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be RCLCPP_*_TIME
classes to avoid this mixing of rclcpp and rcl things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, as there is no real implementation, I could typedef them for now?
rclcpp/test/test_time.cpp
Outdated
FAIL(); | ||
} catch (const std::exception &) { | ||
// test succeeded, ROStime not implemented yet | ||
// TODO(karsten1987): Fix this test when ROStime is implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can assert this case with these gtest macros:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh that's great. Thanks for the link.
I think that I agree with @dirk-thomas, low level interfaces used by the core would fit well in another repo. What do you guys think of |
I haven't followed the conversations around time related stuff so likely this has been mentioned before. Why do we use a custom time type in rcl ( |
I am fine with whatever solution for the message packages. I have not enough insight about the build/package process to give qualified feedback on that one. @dirk-thomas The idea here was to provide a real c++ object for time, which gives the opportunity to have handy helper functions or operators. That would leave the generated message struct a POD. |
@wjwwood I hope to have addressed all your points. But could you quickly verify that I did it the correct way? |
rclcpp/include/rclcpp/time.hpp
Outdated
#ifndef RCLCPP__TIME_HPP_ | ||
#define RCLCPP__TIME_HPP_ | ||
|
||
#include <chrono> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this chrono include is necessary anymore. There are no calls to std::chrono visible in this diff.
My intention was to eventually write up some stuff about the time representation and advocate for a change in the structure of the In the future, if we decide to update the structure of the However, for the time being, I think it's functional enough to have this conversion constructor handle the conversion to the message generated type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but I agree with @tfoote that the #include <chrono>
can be removed.
rclcpp/test/test_time.cpp
Outdated
|
||
TEST(TestTime, rate_basics) { | ||
using builtin_interfaces::msg::Time; | ||
EXPECT_ANY_THROW(rclcpp::Time::now<RCL_ROS_TIME>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODO(karsten1987)
that was here before still applies right?
RE: RE: moving the builtin_interfaces I think it makes sense to move it to rcl_interfaces repo makes sense at some point. Possibly into rcl_interfaces package too. |
I'm actually surprised that no messages in |
While I think that putting these in the rcl_interfaces repo makes a lot of sense. I think it should stay a package on it's own. How I see it is that |
So I'll merge this now if nobody has any outstanding comments. I propose we open another issue/PR for moving the |
Looks like there is a new warning on Linux from |
* Fix buggy if-conditions in transition functions. * Bugfix: incease number of states by one * Cleanup CMakeLists.txt and package.xml * Move goal state machine implementation details from header to C file
* Add compression factory stubs Signed-off-by: Anas Abou Allaban <aabouallaban@pm.me>
connects to #310
prototype of
rclcpp::Time::now()
For now it's mainly a convenience function, but may be object to further helper classes.
I introduced a new c++ class called Time, which by itself has a static member function
now
which returns basically a wrapper aroundrcl_time_point_value_t
. In order to assign it to a message header, the same function can be called, but gets converter via the casting operator.