-
Notifications
You must be signed in to change notification settings - Fork 251
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
Make recorder node composable by inheritance #1093
Make recorder node composable by inheritance #1093
Conversation
Signed-off-by: Bernardo Taveira <taveira@student.chalmers.se>
40d7a5d
to
b2d7851
Compare
If this is approved I would also like to make a pull request to the Humble branch to have this change in there as well. Unfortunately, this had only been merged to the galactic branch before |
985b53c
to
d03c781
Compare
@@ -48,7 +48,6 @@ Recorder::Recorder( | |||
// TODO(karsten1987): Use this constructor later with parameter parsing. | |||
// The reader, storage_options as well as record_options can be loaded via parameter. | |||
// That way, the recorder can be used as a simple component in a component manager. | |||
throw rclcpp::exceptions::UnimplementedError(); |
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.
@bertaveira Nop. At least not so easy..
Will need to:
- Create default objects for
storage_options
andrecord options
- Create writer object and pass all these arguments to the next constructor the same way as it's made here
rosbag2/rosbag2_py/src/rosbag2_py/_transport.cpp
Lines 211 to 221 in 50e28cb
void record( const rosbag2_storage::StorageOptions & storage_options, RecordOptions & record_options) { if (record_options.rmw_serialization_format.empty()) { record_options.rmw_serialization_format = std::string(rmw_get_serialization_format()); } auto writer = rosbag2_transport::ReaderWriterFactory::make_writer(record_options); auto recorder = std::make_shared<rosbag2_transport::Recorder>( std::move(writer), storage_options, record_options); - Create setter methods for
storage_options
andrecord options
- Add coverage in unit tests
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 was the same merge acceptable in the Galactic branch but not in Humble or Rolling? It is blocking us from going to Humble right now and this does not break anything for anyone. Simply enables classes that inherit this to have some extra access that allows it to setup and start recording internally.
- As I can see
record_options
andstorage_options
already have default values of initialisation I think. The structures have default values so it should be initialised with those already right? - What do you mean by setter methods?
If I go back on the change of the throw error removal would it be acceptable? Basically would just change the writer and option structures to protected instead of private?
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.
@bertaveira setters
means methods which provides API to assign record_options
and storage_options
after calling default constructor.
e.g.
set_record_options(const RecordOptions & record_options)
and
set_storage_options(const rosbag2_storage::StorageOptions & storage_options)
Anyway just removing throw rclcpp::exceptions::UnimplementedError();
is not acceptable since need to create default writer
and pass it to the another constructor.
Also since writer
constructor accept record_options
as parameter need to provide "setter" method for writer interface to be able to setup record_options
after calling writer constructor.
Signed-off-by: Bernardo Taveira <taveira@student.chalmers.se>
Signed-off-by: Bernardo Taveira <taveira@student.chalmers.se>
I am not very familiar with this repo and the structure it has. I am totally ok with adding back the How should we proceed? |
@bertaveira If we will not do changes in constructor, i.e. only move some variable from private to protected scope. Then, yes it's ok to proceed without unit test and extra effort for taking care about dependencies. |
Signed-off-by: Bernardo Taveira <taveira@student.chalmers.se>
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
Gist: https://gist.githubusercontent.com/MichaelOrlov/f63c462dbace9542864e5f7dbe09f94e/raw/6a5743834463552d23bfb7bb6ab0c4839fd6cadd/ros2.repos |
Failure on Linux CI job is flakiness in tests and unrelated to the changes in this PR |
Thanks @bertaveira for pushing those changes, they will really come in handy! |
Recreate changes made in #892 for the Galactic branch on the Rolling branch.
This basically enables users to write their own recording nodes by inheriting the rosbag2_transport::Recorder node and keep access to the options and writer.
Very useful for writing a node that starts recording and stops recording on a service call or on a topic value change.