-
Notifications
You must be signed in to change notification settings - Fork 67
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 policy to store the latest messages #38
Conversation
Could you provide some docs to explain the motivation of this policy? or more info about why, when and how we should use this policy? |
Hi @ZhenshengLee, it's been a long while since I came up with the proposal, so I lack the exact context. I can say that, back then, there was no mechanism in
Meaning in our robot we had a fixed 25 ms control loop such that, every 25 ms, a node would fetch all its messages and act accordingly. |
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 know this is really old, so sorry for the long delay in looking at it. If you'd like to give up on getting this in, I'd totally understand.
If you'd still like to move forward, I've left some stuff inline to fix. Also, I'm not a huge fan of the terminology "latest" to describe this policy. While it is accurate, I don't think it will be hugely meaningful to people, and seems too close to "latest_time" (which we already have). Maybe we can rename it to "user controlled", or something like that.
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.
Could you please rename this header file to .hpp
? I know that isn't consistent with everything else that is in here, but I'd like to move the rest of these headers to .hpp
, so for new things we should probably just do that now.
@@ -108,6 +108,11 @@ if(BUILD_TESTING) | |||
target_link_libraries(${PROJECT_NAME}-test_approximate_time_policy ${PROJECT_NAME}) | |||
endif() | |||
|
|||
ament_add_gtest(${PROJECT_NAME}-test_latest_policy test/test_latest_policy.cpp) | |||
if(TARGET ${PROJECT_NAME}-test_latest_policy) | |||
target_link_libraries(${PROJECT_NAME}-test_latest_policy ${PROJECT_NAME}) |
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.
target_link_libraries(${PROJECT_NAME}-test_latest_policy ${PROJECT_NAME}) | |
target_link_libraries(${PROJECT_NAME}-test_latest_policy ${PROJECT_NAME} rclcpp::rclcpp) |
#ifndef MESSAGE_FILTERS__SYNC_Latest_H_ | ||
#define MESSAGE_FILTERS__SYNC_Latest_H_ | ||
|
||
#include <vector> |
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.
#include <vector> | |
#include <mutex> | |
#include <tuple> |
#ifndef MESSAGE_FILTERS__SYNC_Latest_H_ | ||
#define MESSAGE_FILTERS__SYNC_Latest_H_ |
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.
#ifndef MESSAGE_FILTERS__SYNC_Latest_H_ | |
#define MESSAGE_FILTERS__SYNC_Latest_H_ | |
#ifndef MESSAGE_FILTERS__SYNC_POLICIES__LATEST_H_ | |
#define MESSAGE_FILTERS__SYNC_POLICIES__LATEST_H_ |
#ifndef MESSAGE_FILTERS__SYNC_LatestStamped_H_ | ||
#define MESSAGE_FILTERS__SYNC_LatestStamped_H_ | ||
|
||
#include <vector> |
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.
#include <vector> | |
#include <mutex> | |
#include <tuple> |
#ifndef MESSAGE_FILTERS__SYNC_LatestStamped_H_ | ||
#define MESSAGE_FILTERS__SYNC_LatestStamped_H_ |
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.
#ifndef MESSAGE_FILTERS__SYNC_LatestStamped_H_ | |
#define MESSAGE_FILTERS__SYNC_LatestStamped_H_ | |
#ifndef MESSAGE_FILTERS__SYNC_LATESTSTAMPED_H_ | |
#define MESSAGE_FILTERS__SYNC_LATESTSTAMPED_H_ |
bool has_old = (bool)evt_old.getMessage(); | ||
if (has_old) |
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.
bool has_old = (bool)evt_old.getMessage(); | |
if (has_old) | |
if (evt_old.getMessage() != nullptr) |
if (stamp_new > stamp_old) | ||
evt_old = evt; |
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 (stamp_new > stamp_old) | |
evt_old = evt; | |
if (stamp_new > stamp_old) { | |
evt_old = evt; | |
} |
else | ||
evt_old = evt; |
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.
else | |
evt_old = evt; | |
else { | |
evt_old = evt; | |
} |
|
||
|
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.
@jcmonteiro Friendly ping for updates. |
@jcmonteiro Would you agree that I continue to work with your branch and complete with the PR? I'll begin with following the change requests in this PR, then create a new PR with the forked branch with my commits. |
Hi @ZhenshengLee. I've been out of the loop of the robotics and ROS communities for a while now. Please feel free to take this PR in the direction that you see fit. |
Close this and continue with #107 |
Add policies to store the most recent received messages (based on their timestamp or on the order of arrival); These policies do not call any callback automatically. It is up to the programmer to call the
call
method when it is time to process the information.These policies are meant to be used in networks where information is processed periodically.