-
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
Use converters when playing back files #56
Conversation
- Added mocks for storage and converters (and factories)
- Use convert only if necessary (different input and output formats), converters are only loaded if really necessary. - Allocate_ros2_message is public to enable extensive tests for this function. - Helper function to get any typesupport by name - Helper function for empty ros2_message
- Treats most messages already. - Some combinations of nested messages with arrays are still missing - Cleanup of DynamicArrayNested messages is failing - Main difficulty is the cleanup of the allocated ros2_message which needs to be done manually - The test_ros2_message is intended to be run with valgrind and there should be no leaks or problems with free!
Swapping with empty container seems more stable than deleting the data pointer of the container.
ace2d84
to
eb1d1d2
Compare
- The TODO comments have been removed because they're no longer relevant: they have been discussed in the PR review
- Big strings are not treated with small string optimization and need to be checked, too.
@Karsten1987 As discussed I added allocation tests for bigger strings (no small string optimization) and nested arrays. The cleanup actually already covered these cases. |
7e29614
to
e5d1460
Compare
msg->allocator.deallocate(msg->message, msg->allocator.state); | ||
delete msg; | ||
}; | ||
auto deleter = std::bind(&deallocate_ros2_message, std::placeholders::_1, intro_ts_members); |
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 not keeping the lambda? This change does not compile on Windows VS2017.
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.
@Karsten1987 Why did you want all these functions to be exported? They are not intended for direct use (except maybe deallocate_ros2_message
). Should we put them in a nested namespace (e.g. rosbag2::ros2_message
) instead?
This PR lays the foundations for using converters to play (and record) bagfiles with different middleware serialization formats.
Content of this PR:
rosbag2_storage::StorageFactory
for testing the new functionality. Nothing really happens here.Pointer to how the ROS message allocation/deallocation works:
rosidl_introspection_typesupport_t
.std::string
andstd::vector<bool>
the zero-allocated memory does not work correctly, so we have to overwrite the memory with a true empty string or empty vector. All other vectors seem to work correctly.As of now, the methods have a drawback in that any further dynamic memory allocation uses the free store (new). The allocator of the message is only used to allocate the bare message struct. I think that it might be possible to pass the allocator around except for nested message types, as I don't know the type of the vector to allocate.
Note: The way the converter plugins are used in the SequentialReader is not yet final and will be changed in a followup PR, which will additionally store serialization format information on a per topic basis.