Skip to content
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

Fixes for tests in service recording #1

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions ros2bag/ros2bag/verb/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def _is_service_event_topic(self, topic_name, topic_type) -> bool:
return True

def main(self, *, args): # noqa: D102
m = Info().read_metadata(args.bag_path, args.storage)
if args.topic_name:
for topic_info in m.topics_with_message_count:
if not self._is_service_event_topic(topic_info.topic_metadata.name,
topic_info.topic_metadata.type):
print(topic_info.topic_metadata.name)
if args.verbose:
MichaelOrlov marked this conversation as resolved.
Show resolved Hide resolved
Info().read_metadata_and_output_service_verbose(args.bag_path, args.storage)
else:
if args.verbose:
Info().read_metadata_and_output_service_verbose(args.bag_path, args.storage)
m = Info().read_metadata(args.bag_path, args.storage)
if args.topic_name:
for topic_info in m.topics_with_message_count:
if not self._is_service_event_topic(topic_info.topic_metadata.name,
topic_info.topic_metadata.type):
print(topic_info.topic_metadata.name)
else:
print(m)
14 changes: 12 additions & 2 deletions rosbag2_test_common/include/rosbag2_test_common/client_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,17 @@ class ClientManager : public rclcpp::Node
return true;
}

bool send_request()
bool wait_for_srvice_to_be_ready(std::chrono::duration<double> timeout = std::chrono::seconds(5))
{
using clock = std::chrono::system_clock;
auto start = clock::now();
while (!check_service_ready() && (clock::now() - start) < timeout) {
std::this_thread::sleep_for(std::chrono::milliseconds(25));
}
return check_service_ready();
}

bool send_request(std::chrono::duration<double> timeout = std::chrono::seconds(5))
{
if (!check_service_ready()) {
return false;
Expand All @@ -100,7 +110,7 @@ class ClientManager : public rclcpp::Node
auto result = client->async_send_request(request);
// Wait for the result.
if (rclcpp::executors::spin_node_until_future_complete(
exec_, get_node_base_interface(), result) != rclcpp::FutureReturnCode::SUCCESS)
exec_, get_node_base_interface(), result, timeout) != rclcpp::FutureReturnCode::SUCCESS)
{
RCLCPP_INFO(
rclcpp::get_logger("service_client_manager"), "Failed to get response !");
Expand Down
17 changes: 17 additions & 0 deletions rosbag2_test_common/include/rosbag2_test_common/wait_for.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ bool wait_until_shutdown(Timeout timeout, Condition condition)
rclcpp::shutdown();
return true;
}

template<typename Condition>
bool wait_until_condition(
Condition condition,
std::chrono::duration<double> timeout = std::chrono::seconds(5))
{
using clock = std::chrono::system_clock;
auto start = clock::now();
while (!condition()) {
if ((clock::now() - start) > timeout) {
return false;
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
return true;
}

} // namespace rosbag2_test_common

#endif // ROSBAG2_TEST_COMMON__WAIT_FOR_HPP_
9 changes: 5 additions & 4 deletions rosbag2_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ if(BUILD_TESTING)
)
endif()

ament_add_gmock(test_rosbag2_info_get_service_info
test/rosbag2_tests/test_rosbag2_info_get_service_info.cpp
ament_add_gmock(test_rosbag2_cpp_get_service_info
test/rosbag2_tests/test_rosbag2_cpp_get_service_info.cpp
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(TARGET test_rosbag2_info_get_service_info)
target_link_libraries(test_rosbag2_info_get_service_info
if(TARGET test_rosbag2_cpp_get_service_info)
target_link_libraries(test_rosbag2_cpp_get_service_info
rosbag2_cpp::rosbag2_cpp
rosbag2_storage::rosbag2_storage
rosbag2_test_common::rosbag2_test_common
rosbag2_transport::rosbag2_transport
${test_msgs_TARGETS}
)
endif()
Expand Down
1 change: 1 addition & 0 deletions rosbag2_tests/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<test_depend>rosbag2_storage_default_plugins</test_depend>
<test_depend>rosbag2_storage</test_depend>
<test_depend>rosbag2_test_common</test_depend>
<test_depend>rosbag2_transport</test_depend>
<test_depend>std_msgs</test_depend>
<test_depend>test_msgs</test_depend>

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
rosbag2_bagfile_information:
version: 8
storage_identifier: mcap
duration:
nanoseconds: 70653944
starting_time:
nanoseconds_since_epoch: 1699345836270074454
message_count: 10
topics_with_message_count:
- topic_metadata:
name: /events/write_split
type: rosbag2_interfaces/msg/WriteSplitEvent
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_5ef58f7106a5cff8f5a794028c18117ee21015850ddcc567df449f41932960f8
message_count: 0
- topic_metadata:
name: /test_service1/_service_event
type: test_msgs/srv/BasicTypes_Event
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_5b9988a4805a06ae22dff12903a774ccda710e9514926b826ffc884e3a9a982e
message_count: 4
- topic_metadata:
name: /test_service2/_service_event
type: test_msgs/srv/BasicTypes_Event
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_5b9988a4805a06ae22dff12903a774ccda710e9514926b826ffc884e3a9a982e
message_count: 4
- topic_metadata:
name: /test_topic1
type: test_msgs/msg/Strings
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_eee55533636293ac7c94c62432eedb5777eb849847d2a17b4dcead8c4a20ab32
message_count: 1
- topic_metadata:
name: /test_topic2
type: test_msgs/msg/Strings
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_eee55533636293ac7c94c62432eedb5777eb849847d2a17b4dcead8c4a20ab32
message_count: 1
compression_format: ""
compression_mode: ""
relative_file_paths:
- bag_with_topics_and_service_events.mcap
files:
- path: bag_with_topics_and_service_events.mcap
starting_time:
nanoseconds_since_epoch: 1699345836270074454
duration:
nanoseconds: 70653944
message_count: 10
custom_data: ~
ros_distro: ""
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
rosbag2_bagfile_information:
version: 8
storage_identifier: sqlite3
duration:
nanoseconds: 70633730
starting_time:
nanoseconds_since_epoch: 1699345836023194036
message_count: 10
topics_with_message_count:
- topic_metadata:
name: /events/write_split
type: rosbag2_interfaces/msg/WriteSplitEvent
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_5ef58f7106a5cff8f5a794028c18117ee21015850ddcc567df449f41932960f8
message_count: 0
- topic_metadata:
name: /test_service1/_service_event
type: test_msgs/srv/BasicTypes_Event
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_5b9988a4805a06ae22dff12903a774ccda710e9514926b826ffc884e3a9a982e
message_count: 4
- topic_metadata:
name: /test_service2/_service_event
type: test_msgs/srv/BasicTypes_Event
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_5b9988a4805a06ae22dff12903a774ccda710e9514926b826ffc884e3a9a982e
message_count: 4
- topic_metadata:
name: /test_topic1
type: test_msgs/msg/Strings
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_eee55533636293ac7c94c62432eedb5777eb849847d2a17b4dcead8c4a20ab32
message_count: 1
- topic_metadata:
name: /test_topic2
type: test_msgs/msg/Strings
serialization_format: cdr
offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false"
type_description_hash: RIHS01_eee55533636293ac7c94c62432eedb5777eb849847d2a17b4dcead8c4a20ab32
message_count: 1
compression_format: ""
compression_mode: ""
relative_file_paths:
- bag_with_topics_and_service_events.db3
files:
- path: bag_with_topics_and_service_events.db3
starting_time:
nanoseconds_since_epoch: 1699345836023194036
duration:
nanoseconds: 70633730
message_count: 10
custom_data: ~
ros_distro: ""
Loading
Loading