Skip to content

Commit

Permalink
Composition tests working
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Roncagliolo <[email protected]>
  • Loading branch information
roncapat committed Nov 14, 2023
1 parent 6287cd6 commit 0aa4cd5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
3 changes: 1 addition & 2 deletions rosbag2_transport/test/resources/params_player.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
player_params_node:
ros__parameters:
test: true
read_ahead_queue_size: 3
node_prefix: "test"
rate: 13.0
topics_to_filter: ["/foo", "/bar"]
topics_regex_to_filter: "[xyz]/topic"
topics_regex_to_exclude: "[abc]/topic"
loop: true
loop: false
clock_publish_frequency: 19.0
clock_publish_on_topic_publish: true
clock_trigger_topics: ["/triggers/clock"]
Expand Down
30 changes: 27 additions & 3 deletions rosbag2_transport/test/rosbag2_transport/test_load_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,24 @@ TEST_F(TestComponentManager, test_load_components)
}

{

rclcpp::parameter_map_from_yaml_file();
std::string path{_SRC_RESOURCES_DIR_PATH "/params_player.yaml"};
auto pm = rclcpp::parameter_map_from_yaml_file(path);
auto pl = rclcpp::parameters_from_map(pm, "/player_params_node");
auto request = std::make_shared<composition_interfaces::srv::LoadNode::Request>();
request->package_name = "rosbag2_transport";
request->plugin_name = "rosbag2_transport::Player";
for (auto p: pl){
request->parameters.push_back(p.to_parameter_msg());
}

rclcpp::Parameter qos_profile_overrides_path("qos_profile_overrides_path",
rclcpp::ParameterValue(_SRC_RESOURCES_DIR_PATH "/overrides.yaml"));

rclcpp::Parameter uri("uri",
rclcpp::ParameterValue(_SRC_RESOURCES_DIR_PATH "//sqlite3/test_bag_for_seek"));

request->parameters.push_back(qos_profile_overrides_path.to_parameter_msg());
request->parameters.push_back(uri.to_parameter_msg());

auto future = composition_client->async_send_request(request);
auto ret = exec->spin_until_future_complete(future, 5s); // Wait for the result.
Expand All @@ -72,9 +85,20 @@ TEST_F(TestComponentManager, test_load_components)
}

{
std::string path{_SRC_RESOURCES_DIR_PATH "/params_recorder.yaml"};
auto pm = rclcpp::parameter_map_from_yaml_file(path);
auto pl = rclcpp::parameters_from_map(pm, "/recorder_params_node");
auto request = std::make_shared<composition_interfaces::srv::LoadNode::Request>();
request->package_name = "rosbag2_transport";
request->plugin_name = "rosbag2_transport::Recorder";
for (auto p: pl){
request->parameters.push_back(p.to_parameter_msg());
}

rclcpp::Parameter qos_profile_overrides_path("qos_profile_overrides_path",
rclcpp::ParameterValue(_SRC_RESOURCES_DIR_PATH "/overrides.yaml"));

request->parameters.push_back(qos_profile_overrides_path.to_parameter_msg());

auto future = composition_client->async_send_request(request);
auto ret = exec->spin_until_future_complete(future, 5s); // Wait for the result.
Expand All @@ -83,6 +107,6 @@ TEST_F(TestComponentManager, test_load_components)
EXPECT_EQ(result->success, true);
EXPECT_EQ(result->error_message, "");
EXPECT_EQ(result->full_node_name, "/rosbag2_recorder");
EXPECT_EQ(result->unique_id, 1u);
EXPECT_EQ(result->unique_id, 2u);
}
}

0 comments on commit 0aa4cd5

Please sign in to comment.