Skip to content

Commit

Permalink
ros2GH-17 Small cleanups (addressing review comments)
Browse files Browse the repository at this point in the history
  • Loading branch information
anhosi committed Nov 28, 2018
1 parent aa73556 commit 77608b5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ros2bag/ros2bag/verb/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def main(self, *, args): # noqa: D102
all=True)
elif args.topics and len(args.topics) > 0:
rosbag2_transport_py.record(
uri=uri, storage_id=args.storage,
uri=uri,
storage_id=args.storage,
serialization_format=args.serialization_format,
topics=args.topics)
else:
Expand Down
8 changes: 7 additions & 1 deletion rosbag2/include/rosbag2/converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@
namespace rosbag2
{

struct ConverterTypeSupport;
// Convenience struct to keep both type supports (rmw and introspection) together.
// Only used internally.
struct ConverterTypeSupport
{
const rosidl_message_type_support_t * cpp_type_support;
const rosidl_message_type_support_t * introspection_type_support;
};

class ROSBAG2_PUBLIC Converter
{
Expand Down
1 change: 1 addition & 0 deletions rosbag2/include/rosbag2/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ROSBAG2_PUBLIC Writer
std::make_shared<SerializationFormatConverterFactory>(),
std::unique_ptr<rosbag2_storage::MetadataIo> metadata_io =
std::make_unique<rosbag2_storage::MetadataIo>());

virtual ~Writer();

/**
Expand Down
10 changes: 2 additions & 8 deletions rosbag2/src/rosbag2/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
namespace rosbag2
{

struct ConverterTypeSupport
{
const rosidl_message_type_support_t * type_support;
const rosidl_message_type_support_t * introspection_type_support;
};

Converter::Converter(
const std::string & input_format,
const std::string & output_format,
Expand All @@ -60,7 +54,7 @@ Converter::~Converter()
std::shared_ptr<SerializedBagMessage> Converter::convert(
std::shared_ptr<const rosbag2::SerializedBagMessage> message)
{
auto ts = topics_and_types_.at(message->topic_name).type_support;
auto ts = topics_and_types_.at(message->topic_name).cpp_type_support;
auto introspection_ts = topics_and_types_.at(message->topic_name).introspection_type_support;
auto allocator = rcutils_get_default_allocator();
std::shared_ptr<rosbag2_ros2_message_t> allocated_ros_message =
Expand All @@ -76,7 +70,7 @@ std::shared_ptr<SerializedBagMessage> Converter::convert(
void Converter::add_topic(const std::string & topic, const std::string & type)
{
ConverterTypeSupport type_support;
type_support.type_support = get_typesupport(type, "rosidl_typesupport_cpp");
type_support.cpp_type_support = get_typesupport(type, "rosidl_typesupport_cpp");
type_support.introspection_type_support =
get_typesupport(type, "rosidl_typesupport_introspection_cpp");

Expand Down
1 change: 1 addition & 0 deletions rosbag2/src/rosbag2/types/ros2_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void ros2_message_set_topic_name(rosbag2_ros2_message_t * msg, const char * topi
{
if (msg->topic_name) {
msg->allocator.deallocate(msg->topic_name, msg->allocator.state);
msg->topic_name = nullptr;
}
msg->topic_name = rcutils_strdup(topic_name, msg->allocator);
}
Expand Down

0 comments on commit 77608b5

Please sign in to comment.