Repository Summary
Checkout URI | https://github.com/ros-misc-utilities/flex_sync.git |
VCS Type | git |
VCS Version | release |
Last Updated | 2024-06-28 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Packages
Name | Version |
---|---|
flex_sync | 2.0.0 |
README
flex_sync
This ROS2 package with headers-only library that implements a message synchronization filter. It is similar to the well-known message_filters package, but is more flexible in that the number of topics to be synchronized does not have to be known at compile time, just their message types. This can be useful when you don’t know beforehand how many sensors of a given type will be on the robot.
Just like message_filters, flex_sync
offers
exact and approximate synchronization policies.
How to use
Here is code snippet that shows how to perform an exact synchronization between two Image messages and one Imu message:
using sensor_msg::msg::Image;
using sensor_msg::msg::Imu;
using CallbackType = std::function<void(const std::vector<Image::ConstSharedPtr> &,
const std::vector<Imu::ConstSharedPtr> &)>;
class MyTest { // define class to handle callbacks
public:
void callback(const std::vector<Image::ConstSharedPtr> & msgvec1,
const std::vector<Imu::ConstSharedPtr> & msgvec2) {
// should print out "got msgs: 2 + 1"
std::cout << "got msgs: " << msgvec1.size() << " + " << msgvec2.size() << std::endl;
}
};
MyTest my_test; // instantiate object to handle synchronized callbacks
// synchronize two Image topics and one Imu topic
const std::vector<std::vector<std::string>> topics =
{{"image_topic_1", "image_topic_2"}, {"imu_topic_1"}};
const size_t q_size = 10; // depth of sync queue
flex_sync::ExactSync<Image, Imu> sync(topics,
std::bind(&MyTest::callback, &my_test, std::placeholders::_1, std::placeholders::_2),
q_size);
// now feed images and IMU messages into the sync. If
// the sync is successful there will be callbacks to MyTest::callback()
sync->process("image_topic_1", std::make_shared<Image>()); // replace with valid message
sync->process("image_topic_2", std::make_shared<Image>());
sync->process("imu_topic_1", std::make_shared<Imu>());
Note that the number of topics does not have to be known at compile time, but it cannot change during the life time of the sync object.
Special note from the author
The code in this repo is absolutely hideous. The template syntax is cryptic to begin with, and I don’t use templates often enough to become good at them. Don’t ask me any questions on how this code works, I no longer understand it myself. It certainly could use some cleaning up by somebody who knows templates better. Having that said, I have not discovered any obvious bugs so far and I use it in two projects.
If you want to understand better how the sync code works, look at the ROS1 documentation and in particular the adaptive algorithm for the approximate time sync.
License
This software and any future contributions to it are licensed under the Apache License 2.0.
CONTRIBUTING
Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
Contributors must sign-off each commit by adding a Signed-off-by: ...
line to commit messages to certify that they have the right to submit
the code they are contributing to the project according to the
Developer Certificate of Origin (DCO).
Repository Summary
Checkout URI | https://github.com/ros-misc-utilities/flex_sync.git |
VCS Type | git |
VCS Version | release |
Last Updated | 2024-06-28 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Packages
Name | Version |
---|---|
flex_sync | 2.0.0 |
README
flex_sync
This ROS2 package with headers-only library that implements a message synchronization filter. It is similar to the well-known message_filters package, but is more flexible in that the number of topics to be synchronized does not have to be known at compile time, just their message types. This can be useful when you don’t know beforehand how many sensors of a given type will be on the robot.
Just like message_filters, flex_sync
offers
exact and approximate synchronization policies.
How to use
Here is code snippet that shows how to perform an exact synchronization between two Image messages and one Imu message:
using sensor_msg::msg::Image;
using sensor_msg::msg::Imu;
using CallbackType = std::function<void(const std::vector<Image::ConstSharedPtr> &,
const std::vector<Imu::ConstSharedPtr> &)>;
class MyTest { // define class to handle callbacks
public:
void callback(const std::vector<Image::ConstSharedPtr> & msgvec1,
const std::vector<Imu::ConstSharedPtr> & msgvec2) {
// should print out "got msgs: 2 + 1"
std::cout << "got msgs: " << msgvec1.size() << " + " << msgvec2.size() << std::endl;
}
};
MyTest my_test; // instantiate object to handle synchronized callbacks
// synchronize two Image topics and one Imu topic
const std::vector<std::vector<std::string>> topics =
{{"image_topic_1", "image_topic_2"}, {"imu_topic_1"}};
const size_t q_size = 10; // depth of sync queue
flex_sync::ExactSync<Image, Imu> sync(topics,
std::bind(&MyTest::callback, &my_test, std::placeholders::_1, std::placeholders::_2),
q_size);
// now feed images and IMU messages into the sync. If
// the sync is successful there will be callbacks to MyTest::callback()
sync->process("image_topic_1", std::make_shared<Image>()); // replace with valid message
sync->process("image_topic_2", std::make_shared<Image>());
sync->process("imu_topic_1", std::make_shared<Imu>());
Note that the number of topics does not have to be known at compile time, but it cannot change during the life time of the sync object.
Special note from the author
The code in this repo is absolutely hideous. The template syntax is cryptic to begin with, and I don’t use templates often enough to become good at them. Don’t ask me any questions on how this code works, I no longer understand it myself. It certainly could use some cleaning up by somebody who knows templates better. Having that said, I have not discovered any obvious bugs so far and I use it in two projects.
If you want to understand better how the sync code works, look at the ROS1 documentation and in particular the adaptive algorithm for the approximate time sync.
License
This software and any future contributions to it are licensed under the Apache License 2.0.
CONTRIBUTING
Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
Contributors must sign-off each commit by adding a Signed-off-by: ...
line to commit messages to certify that they have the right to submit
the code they are contributing to the project according to the
Developer Certificate of Origin (DCO).
Repository Summary
Checkout URI | https://github.com/ros-misc-utilities/flex_sync.git |
VCS Type | git |
VCS Version | release |
Last Updated | 2024-06-28 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Packages
Name | Version |
---|---|
flex_sync | 2.0.0 |
README
flex_sync
This ROS2 package with headers-only library that implements a message synchronization filter. It is similar to the well-known message_filters package, but is more flexible in that the number of topics to be synchronized does not have to be known at compile time, just their message types. This can be useful when you don’t know beforehand how many sensors of a given type will be on the robot.
Just like message_filters, flex_sync
offers
exact and approximate synchronization policies.
How to use
Here is code snippet that shows how to perform an exact synchronization between two Image messages and one Imu message:
using sensor_msg::msg::Image;
using sensor_msg::msg::Imu;
using CallbackType = std::function<void(const std::vector<Image::ConstSharedPtr> &,
const std::vector<Imu::ConstSharedPtr> &)>;
class MyTest { // define class to handle callbacks
public:
void callback(const std::vector<Image::ConstSharedPtr> & msgvec1,
const std::vector<Imu::ConstSharedPtr> & msgvec2) {
// should print out "got msgs: 2 + 1"
std::cout << "got msgs: " << msgvec1.size() << " + " << msgvec2.size() << std::endl;
}
};
MyTest my_test; // instantiate object to handle synchronized callbacks
// synchronize two Image topics and one Imu topic
const std::vector<std::vector<std::string>> topics =
{{"image_topic_1", "image_topic_2"}, {"imu_topic_1"}};
const size_t q_size = 10; // depth of sync queue
flex_sync::ExactSync<Image, Imu> sync(topics,
std::bind(&MyTest::callback, &my_test, std::placeholders::_1, std::placeholders::_2),
q_size);
// now feed images and IMU messages into the sync. If
// the sync is successful there will be callbacks to MyTest::callback()
sync->process("image_topic_1", std::make_shared<Image>()); // replace with valid message
sync->process("image_topic_2", std::make_shared<Image>());
sync->process("imu_topic_1", std::make_shared<Imu>());
Note that the number of topics does not have to be known at compile time, but it cannot change during the life time of the sync object.
Special note from the author
The code in this repo is absolutely hideous. The template syntax is cryptic to begin with, and I don’t use templates often enough to become good at them. Don’t ask me any questions on how this code works, I no longer understand it myself. It certainly could use some cleaning up by somebody who knows templates better. Having that said, I have not discovered any obvious bugs so far and I use it in two projects.
If you want to understand better how the sync code works, look at the ROS1 documentation and in particular the adaptive algorithm for the approximate time sync.
License
This software and any future contributions to it are licensed under the Apache License 2.0.
CONTRIBUTING
Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
Contributors must sign-off each commit by adding a Signed-off-by: ...
line to commit messages to certify that they have the right to submit
the code they are contributing to the project according to the
Developer Certificate of Origin (DCO).
Repository Summary
Checkout URI | https://github.com/ros-misc-utilities/flex_sync.git |
VCS Type | git |
VCS Version | release |
Last Updated | 2024-06-28 |
Dev Status | DEVELOPED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Packages
Name | Version |
---|---|
flex_sync | 2.0.0 |
README
flex_sync
This ROS2 package with headers-only library that implements a message synchronization filter. It is similar to the well-known message_filters package, but is more flexible in that the number of topics to be synchronized does not have to be known at compile time, just their message types. This can be useful when you don’t know beforehand how many sensors of a given type will be on the robot.
Just like message_filters, flex_sync
offers
exact and approximate synchronization policies.
How to use
Here is code snippet that shows how to perform an exact synchronization between two Image messages and one Imu message:
using sensor_msg::msg::Image;
using sensor_msg::msg::Imu;
using CallbackType = std::function<void(const std::vector<Image::ConstSharedPtr> &,
const std::vector<Imu::ConstSharedPtr> &)>;
class MyTest { // define class to handle callbacks
public:
void callback(const std::vector<Image::ConstSharedPtr> & msgvec1,
const std::vector<Imu::ConstSharedPtr> & msgvec2) {
// should print out "got msgs: 2 + 1"
std::cout << "got msgs: " << msgvec1.size() << " + " << msgvec2.size() << std::endl;
}
};
MyTest my_test; // instantiate object to handle synchronized callbacks
// synchronize two Image topics and one Imu topic
const std::vector<std::vector<std::string>> topics =
{{"image_topic_1", "image_topic_2"}, {"imu_topic_1"}};
const size_t q_size = 10; // depth of sync queue
flex_sync::ExactSync<Image, Imu> sync(topics,
std::bind(&MyTest::callback, &my_test, std::placeholders::_1, std::placeholders::_2),
q_size);
// now feed images and IMU messages into the sync. If
// the sync is successful there will be callbacks to MyTest::callback()
sync->process("image_topic_1", std::make_shared<Image>()); // replace with valid message
sync->process("image_topic_2", std::make_shared<Image>());
sync->process("imu_topic_1", std::make_shared<Imu>());
Note that the number of topics does not have to be known at compile time, but it cannot change during the life time of the sync object.
Special note from the author
The code in this repo is absolutely hideous. The template syntax is cryptic to begin with, and I don’t use templates often enough to become good at them. Don’t ask me any questions on how this code works, I no longer understand it myself. It certainly could use some cleaning up by somebody who knows templates better. Having that said, I have not discovered any obvious bugs so far and I use it in two projects.
If you want to understand better how the sync code works, look at the ROS1 documentation and in particular the adaptive algorithm for the approximate time sync.
License
This software and any future contributions to it are licensed under the Apache License 2.0.
CONTRIBUTING
Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
Contributors must sign-off each commit by adding a Signed-off-by: ...
line to commit messages to certify that they have the right to submit
the code they are contributing to the project according to the
Developer Certificate of Origin (DCO).