From cdd14f0199409c72626bf7e4e7af64bc1c8fb775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 20 Mar 2024 17:12:13 +0100 Subject: [PATCH 1/5] Use resource_retriever MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_bridge/CMakeLists.txt | 3 +++ .../include/ros_gz_bridge/ros_gz_bridge.hpp | 3 +++ ros_gz_bridge/package.xml | 1 + ros_gz_bridge/src/ros_gz_bridge.cpp | 26 ++++++++++++++----- ros_gz_sim/src/ros_gz_bridge_system.cpp | 9 +------ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/ros_gz_bridge/CMakeLists.txt b/ros_gz_bridge/CMakeLists.txt index 6c2d4b3e..18c3e1cf 100644 --- a/ros_gz_bridge/CMakeLists.txt +++ b/ros_gz_bridge/CMakeLists.txt @@ -13,6 +13,7 @@ endif() find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(rclcpp_components REQUIRED) +find_package(resource_retriever REQUIRED) find_package(yaml_cpp_vendor REQUIRED) if(NOT DEFINED ENV{GZ_VERSION}) @@ -120,6 +121,7 @@ add_library(${bridge_lib} target_link_libraries(${bridge_lib} ${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}::core ${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}::core + resource_retriever::resource_retriever ) ament_target_dependencies(${bridge_lib} @@ -341,6 +343,7 @@ ament_export_targets(export_${PROJECT_NAME}) # specific order: dependents before dependencies ament_export_dependencies(rclcpp) ament_export_dependencies(rclcpp_components) +ament_export_dependencies(resource_retriever) ament_export_dependencies(${GZ_TARGET_PREFIX}-msgs${GZ_MSGS_VER}) ament_export_dependencies(${GZ_TARGET_PREFIX}-transport${GZ_TRANSPORT_VER}) ament_export_dependencies(yaml_cpp_vendor) diff --git a/ros_gz_bridge/include/ros_gz_bridge/ros_gz_bridge.hpp b/ros_gz_bridge/include/ros_gz_bridge/ros_gz_bridge.hpp index 735cdecc..1e159507 100644 --- a/ros_gz_bridge/include/ros_gz_bridge/ros_gz_bridge.hpp +++ b/ros_gz_bridge/include/ros_gz_bridge/ros_gz_bridge.hpp @@ -68,6 +68,9 @@ class RosGzBridge : public rclcpp::Node /// \brief Timer to control periodic callback rclcpp::TimerBase::SharedPtr heartbeat_timer_; + + /// \brief Whether the config_file parameter was parsed or not. + bool config_file_parsed_; }; } // namespace ros_gz_bridge diff --git a/ros_gz_bridge/package.xml b/ros_gz_bridge/package.xml index cf626a38..fb32ea75 100644 --- a/ros_gz_bridge/package.xml +++ b/ros_gz_bridge/package.xml @@ -22,6 +22,7 @@ nav_msgs rclcpp rclcpp_components + resource_retriever ros_gz_interfaces rosgraph_msgs sensor_msgs diff --git a/ros_gz_bridge/src/ros_gz_bridge.cpp b/ros_gz_bridge/src/ros_gz_bridge.cpp index f542ee90..47f82365 100644 --- a/ros_gz_bridge/src/ros_gz_bridge.cpp +++ b/ros_gz_bridge/src/ros_gz_bridge.cpp @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include #include +#include +#include + #include "bridge_handle_ros_to_gz.hpp" #include "bridge_handle_gz_to_ros.hpp" @@ -24,7 +25,8 @@ namespace ros_gz_bridge { RosGzBridge::RosGzBridge(const rclcpp::NodeOptions & options) -: rclcpp::Node("ros_gz_bridge", options) +: rclcpp::Node("ros_gz_bridge", options), + config_file_parsed_(false) { gz_node_ = std::make_shared(); @@ -43,10 +45,20 @@ void RosGzBridge::spin() if (handles_.empty()) { std::string config_file; this->get_parameter("config_file", config_file); - if (!config_file.empty()) { - auto entries = readFromYamlFile(config_file); - for (const auto & entry : entries) { - this->add_bridge(entry); + if (!config_file.empty() && !config_file_parsed_) { + config_file_parsed_ = true; + resource_retriever::Retriever r; + try { + resource_retriever::MemoryResource res = r.get(config_file); + std::string str(reinterpret_cast(res.data.get()), res.size); + auto entries = readFromYamlString(str); + for (const auto & entry : entries) { + this->add_bridge(entry); + } + } catch (const resource_retriever::Exception & exc) { + RCLCPP_ERROR( + this->get_logger(), + "Unable to find: [%s]", config_file.c_str()); } } } diff --git a/ros_gz_sim/src/ros_gz_bridge_system.cpp b/ros_gz_sim/src/ros_gz_bridge_system.cpp index 04a53344..d01880a1 100644 --- a/ros_gz_sim/src/ros_gz_bridge_system.cpp +++ b/ros_gz_sim/src/ros_gz_bridge_system.cpp @@ -73,18 +73,11 @@ void ROSGzBridgeSystem::Configure( return; } - // Sanity check: Make sure that the config file exists and it's a file. std::string filename = _sdf->Get("config_file"); - std::string path = gz::common::findFile(filename); - if (!gz::common::isFile(path)) { - std::cerr << "Unable to open YAML file [" << filename - << "], check your GZ_SIM_RESOURCE_PATH settings." << std::endl; - return; - } // Create the bridge passing the parameters as rclcpp::NodeOptions(). this->dataPtr->bridge = std::make_shared( - rclcpp::NodeOptions().append_parameter_override("config_file", path)); + rclcpp::NodeOptions().append_parameter_override("config_file", filename)); // Create the executor. this->dataPtr->exec = From 24f6021dd0a338d2bc605b749a347be8b7fd8323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 20 Mar 2024 18:37:32 +0100 Subject: [PATCH 2/5] Tweak tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_bridge/src/bridge_config.cpp | 22 +++++++-------- ros_gz_bridge/src/ros_gz_bridge.cpp | 16 +++-------- ros_gz_bridge/test/bridge_config.cpp | 37 +++++++++++++++----------- ros_gz_bridge/test/config/full.yaml | 4 +-- ros_gz_bridge/test/config/invalid.yaml | 2 +- ros_gz_bridge/test/config/minimum.yaml | 8 +++--- ros_gz_sim_demos/CMakeLists.txt | 6 ----- ros_gz_sim_demos/config/full.yaml | 18 ------------- ros_gz_sim_demos/worlds/ros_gz.sdf | 2 +- 9 files changed, 43 insertions(+), 72 deletions(-) delete mode 100644 ros_gz_sim_demos/config/full.yaml diff --git a/ros_gz_bridge/src/bridge_config.cpp b/ros_gz_bridge/src/bridge_config.cpp index d15e0dd8..ac1fbb46 100644 --- a/ros_gz_bridge/src/bridge_config.cpp +++ b/ros_gz_bridge/src/bridge_config.cpp @@ -20,6 +20,7 @@ #include #include +#include #include namespace ros_gz_bridge @@ -173,31 +174,30 @@ std::vector readFromYaml(std::istream & in) std::vector readFromYamlFile(const std::string & filename) { std::vector ret; - std::ifstream in(filename); + resource_retriever::Retriever r; + resource_retriever::MemoryResource res; auto logger = rclcpp::get_logger("readFromYamlFile"); - if (!in.is_open()) { + + try { + res = r.get(filename); + } catch (const resource_retriever::Exception & exc) { RCLCPP_ERROR( logger, "Could not parse config: failed to open file [%s]", filename.c_str()); return ret; } - // Compute file size to warn on empty configuration - const auto fbegin = in.tellg(); - in.seekg(0, std::ios::end); - const auto fend = in.tellg(); - const auto fsize = fend - fbegin; - - if (fsize == 0) { + // Sanity check: Avoid empty configuration. + if (res.size == 0) { RCLCPP_ERROR( logger, "Could not parse config: file empty [%s]", filename.c_str()); return ret; } - in.seekg(0, std::ios::beg); - return readFromYaml(in); + std::string str(reinterpret_cast(res.data.get()), res.size); + return readFromYamlString(str); } std::vector readFromYamlString(const std::string & data) diff --git a/ros_gz_bridge/src/ros_gz_bridge.cpp b/ros_gz_bridge/src/ros_gz_bridge.cpp index 47f82365..3b15bcca 100644 --- a/ros_gz_bridge/src/ros_gz_bridge.cpp +++ b/ros_gz_bridge/src/ros_gz_bridge.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include "bridge_handle_ros_to_gz.hpp" @@ -47,18 +46,9 @@ void RosGzBridge::spin() this->get_parameter("config_file", config_file); if (!config_file.empty() && !config_file_parsed_) { config_file_parsed_ = true; - resource_retriever::Retriever r; - try { - resource_retriever::MemoryResource res = r.get(config_file); - std::string str(reinterpret_cast(res.data.get()), res.size); - auto entries = readFromYamlString(str); - for (const auto & entry : entries) { - this->add_bridge(entry); - } - } catch (const resource_retriever::Exception & exc) { - RCLCPP_ERROR( - this->get_logger(), - "Unable to find: [%s]", config_file.c_str()); + auto entries = readFromYamlFile(config_file); + for (const auto & entry : entries) { + this->add_bridge(entry); } } } diff --git a/ros_gz_bridge/test/bridge_config.cpp b/ros_gz_bridge/test/bridge_config.cpp index 07987865..1356d64b 100644 --- a/ros_gz_bridge/test/bridge_config.cpp +++ b/ros_gz_bridge/test/bridge_config.cpp @@ -70,7 +70,8 @@ class BridgeConfig : public ::testing::Test TEST_F(BridgeConfig, Minimum) { - auto results = ros_gz_bridge::readFromYamlFile("test/config/minimum.yaml"); + auto results = ros_gz_bridge::readFromYamlFile( + "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/minimum.yaml"); EXPECT_EQ(4u, results.size()); { @@ -78,7 +79,7 @@ TEST_F(BridgeConfig, Minimum) EXPECT_EQ("chatter", config.ros_topic_name); EXPECT_EQ("chatter", config.gz_topic_name); EXPECT_EQ("std_msgs/msg/String", config.ros_type_name); - EXPECT_EQ("ignition.msgs.StringMsg", config.gz_type_name); + EXPECT_EQ("gz.msgs.StringMsg", config.gz_type_name); EXPECT_EQ(ros_gz_bridge::kDefaultPublisherQueue, config.publisher_queue_size); EXPECT_EQ(ros_gz_bridge::kDefaultSubscriberQueue, config.subscriber_queue_size); EXPECT_EQ(ros_gz_bridge::kDefaultLazy, config.is_lazy); @@ -88,7 +89,7 @@ TEST_F(BridgeConfig, Minimum) EXPECT_EQ("chatter_ros", config.ros_topic_name); EXPECT_EQ("chatter_ros", config.gz_topic_name); EXPECT_EQ("std_msgs/msg/String", config.ros_type_name); - EXPECT_EQ("ignition.msgs.StringMsg", config.gz_type_name); + EXPECT_EQ("gz.msgs.StringMsg", config.gz_type_name); EXPECT_EQ(ros_gz_bridge::kDefaultPublisherQueue, config.publisher_queue_size); EXPECT_EQ(ros_gz_bridge::kDefaultSubscriberQueue, config.subscriber_queue_size); EXPECT_EQ(ros_gz_bridge::kDefaultLazy, config.is_lazy); @@ -98,7 +99,7 @@ TEST_F(BridgeConfig, Minimum) EXPECT_EQ("chatter_gz", config.ros_topic_name); EXPECT_EQ("chatter_gz", config.gz_topic_name); EXPECT_EQ("std_msgs/msg/String", config.ros_type_name); - EXPECT_EQ("ignition.msgs.StringMsg", config.gz_type_name); + EXPECT_EQ("gz.msgs.StringMsg", config.gz_type_name); EXPECT_EQ(ros_gz_bridge::kDefaultPublisherQueue, config.publisher_queue_size); EXPECT_EQ(ros_gz_bridge::kDefaultSubscriberQueue, config.subscriber_queue_size); EXPECT_EQ(ros_gz_bridge::kDefaultLazy, config.is_lazy); @@ -108,7 +109,7 @@ TEST_F(BridgeConfig, Minimum) EXPECT_EQ("chatter_both_ros", config.ros_topic_name); EXPECT_EQ("chatter_both_gz", config.gz_topic_name); EXPECT_EQ("std_msgs/msg/String", config.ros_type_name); - EXPECT_EQ("ignition.msgs.StringMsg", config.gz_type_name); + EXPECT_EQ("gz.msgs.StringMsg", config.gz_type_name); EXPECT_EQ(ros_gz_bridge::kDefaultPublisherQueue, config.publisher_queue_size); EXPECT_EQ(ros_gz_bridge::kDefaultSubscriberQueue, config.subscriber_queue_size); EXPECT_EQ(ros_gz_bridge::kDefaultLazy, config.is_lazy); @@ -117,7 +118,8 @@ TEST_F(BridgeConfig, Minimum) TEST_F(BridgeConfig, FullGz) { - auto results = ros_gz_bridge::readFromYamlFile("test/config/full.yaml"); + auto results = ros_gz_bridge::readFromYamlFile( + "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/full.yaml"); EXPECT_EQ(2u, results.size()); { @@ -125,7 +127,7 @@ TEST_F(BridgeConfig, FullGz) EXPECT_EQ("ros_chatter", config.ros_topic_name); EXPECT_EQ("gz_chatter", config.gz_topic_name); EXPECT_EQ("std_msgs/msg/String", config.ros_type_name); - EXPECT_EQ("ignition.msgs.StringMsg", config.gz_type_name); + EXPECT_EQ("gz.msgs.StringMsg", config.gz_type_name); EXPECT_EQ(6u, config.publisher_queue_size); EXPECT_EQ(5u, config.subscriber_queue_size); EXPECT_EQ(true, config.is_lazy); @@ -137,7 +139,7 @@ TEST_F(BridgeConfig, FullGz) EXPECT_EQ("ros_chatter", config.ros_topic_name); EXPECT_EQ("gz_chatter", config.gz_topic_name); EXPECT_EQ("std_msgs/msg/String", config.ros_type_name); - EXPECT_EQ("ignition.msgs.StringMsg", config.gz_type_name); + EXPECT_EQ("gz.msgs.StringMsg", config.gz_type_name); EXPECT_EQ(20u, config.publisher_queue_size); EXPECT_EQ(10u, config.subscriber_queue_size); EXPECT_EQ(false, config.is_lazy); @@ -195,7 +197,7 @@ TEST_F(BridgeConfig, ParseDirection) R"( - topic_name: foo ros_type_name: std_msgs/msg/String - gz_type_name: ignition.msgs.StringMsg)"; + gz_type_name: gz.msgs.StringMsg)"; auto results = ros_gz_bridge::readFromYamlString(yaml); EXPECT_EQ(ros_gz_bridge::BridgeDirection::BIDIRECTIONAL, results[0].direction); @@ -206,7 +208,7 @@ TEST_F(BridgeConfig, ParseDirection) R"( - topic_name: foo ros_type_name: std_msgs/msg/String - gz_type_name: ignition.msgs.StringMsg + gz_type_name: gz.msgs.StringMsg direction: BIDIRECTIONAL )"; @@ -219,7 +221,7 @@ TEST_F(BridgeConfig, ParseDirection) R"( - topic_name: foo ros_type_name: std_msgs/msg/String - gz_type_name: ignition.msgs.StringMsg + gz_type_name: gz.msgs.StringMsg direction: ROS_TO_GZ )"; @@ -232,7 +234,7 @@ TEST_F(BridgeConfig, ParseDirection) R"( - topic_name: foo ros_type_name: std_msgs/msg/String - gz_type_name: ignition.msgs.StringMsg + gz_type_name: gz.msgs.StringMsg direction: GZ_TO_ROS )"; @@ -246,7 +248,7 @@ TEST_F(BridgeConfig, ParseDirection) R"( - topic_name: foo ros_type_name: std_msgs/msg/String - gz_type_name: ignition.msgs.StringMsg + gz_type_name: gz.msgs.StringMsg direction: foobar )"; @@ -267,7 +269,8 @@ TEST_F(BridgeConfig, InvalidFileDoesntExist) TEST_F(BridgeConfig, InvalidTopLevel) { - auto results = ros_gz_bridge::readFromYamlFile("test/config/invalid.yaml"); + auto results = ros_gz_bridge::readFromYamlFile( + "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/invalid.yaml"); EXPECT_EQ(0u, results.size()); EXPECT_EQ( "Could not parse config: top level must be a YAML sequence", @@ -276,9 +279,11 @@ TEST_F(BridgeConfig, InvalidTopLevel) TEST_F(BridgeConfig, EmptyYAML) { - auto results = ros_gz_bridge::readFromYamlFile("test/config/empty.yaml"); + auto results = ros_gz_bridge::readFromYamlFile( + "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/empty.yaml"); EXPECT_EQ(0u, results.size()); EXPECT_EQ( - "Could not parse config: file empty [test/config/empty.yaml]", + "Could not parse config: file empty [" + "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/empty.yaml]", g_last_log_event.message); } diff --git a/ros_gz_bridge/test/config/full.yaml b/ros_gz_bridge/test/config/full.yaml index ac838101..5d473824 100644 --- a/ros_gz_bridge/test/config/full.yaml +++ b/ros_gz_bridge/test/config/full.yaml @@ -2,7 +2,7 @@ - ros_topic_name: "ros_chatter" gz_topic_name: "gz_chatter" ros_type_name: "std_msgs/msg/String" - gz_type_name: "ignition.msgs.StringMsg" + gz_type_name: "gz.msgs.StringMsg" subscriber_queue: 5 publisher_queue: 6 lazy: true @@ -11,7 +11,7 @@ - ros_topic_name: "ros_chatter" gz_topic_name: "gz_chatter" ros_type_name: "std_msgs/msg/String" - gz_type_name: "ignition.msgs.StringMsg" + gz_type_name: "gz.msgs.StringMsg" subscriber_queue: 10 publisher_queue: 20 lazy: false diff --git a/ros_gz_bridge/test/config/invalid.yaml b/ros_gz_bridge/test/config/invalid.yaml index c14740ad..d1e4cbeb 100644 --- a/ros_gz_bridge/test/config/invalid.yaml +++ b/ros_gz_bridge/test/config/invalid.yaml @@ -1,7 +1,7 @@ ros_topic_name: "ros_chatter" gz_topic_name: "gz_chatter" ros_type_name: "std_msgs/msg/String" -gz_type_name: "ignition.msgs.StringMsg" +gz_type_name: "gz.msgs.StringMsg" subscriber_queue: 5 publisher_queue: 6 lazy: true diff --git a/ros_gz_bridge/test/config/minimum.yaml b/ros_gz_bridge/test/config/minimum.yaml index e0a6b1ca..0d5ef30e 100644 --- a/ros_gz_bridge/test/config/minimum.yaml +++ b/ros_gz_bridge/test/config/minimum.yaml @@ -1,20 +1,20 @@ # Set just topic name, applies to both - topic_name: "chatter" ros_type_name: "std_msgs/msg/String" - gz_type_name: "ignition.msgs.StringMsg" + gz_type_name: "gz.msgs.StringMsg" # Set just ROS topic name, applies to both - ros_topic_name: "chatter_ros" ros_type_name: "std_msgs/msg/String" - gz_type_name: "ignition.msgs.StringMsg" + gz_type_name: "gz.msgs.StringMsg" # Set just GZ topic name, applies to both - gz_topic_name: "chatter_gz" ros_type_name: "std_msgs/msg/String" - gz_type_name: "ignition.msgs.StringMsg" + gz_type_name: "gz.msgs.StringMsg" # Set each topic name explicitly - ros_topic_name: "chatter_both_ros" gz_topic_name: "chatter_both_gz" ros_type_name: "std_msgs/msg/String" - gz_type_name: "ignition.msgs.StringMsg" + gz_type_name: "gz.msgs.StringMsg" diff --git a/ros_gz_sim_demos/CMakeLists.txt b/ros_gz_sim_demos/CMakeLists.txt index d0626157..8e0f580a 100644 --- a/ros_gz_sim_demos/CMakeLists.txt +++ b/ros_gz_sim_demos/CMakeLists.txt @@ -33,12 +33,6 @@ install( DESTINATION share/${PROJECT_NAME}/worlds ) -install( - DIRECTORY - config/ - DESTINATION share/${PROJECT_NAME}/config -) - ament_environment_hooks("${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in") ament_package() diff --git a/ros_gz_sim_demos/config/full.yaml b/ros_gz_sim_demos/config/full.yaml deleted file mode 100644 index 5d473824..00000000 --- a/ros_gz_sim_demos/config/full.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Full set of configurations -- ros_topic_name: "ros_chatter" - gz_topic_name: "gz_chatter" - ros_type_name: "std_msgs/msg/String" - gz_type_name: "gz.msgs.StringMsg" - subscriber_queue: 5 - publisher_queue: 6 - lazy: true - direction: ROS_TO_GZ - -- ros_topic_name: "ros_chatter" - gz_topic_name: "gz_chatter" - ros_type_name: "std_msgs/msg/String" - gz_type_name: "gz.msgs.StringMsg" - subscriber_queue: 10 - publisher_queue: 20 - lazy: false - direction: GZ_TO_ROS diff --git a/ros_gz_sim_demos/worlds/ros_gz.sdf b/ros_gz_sim_demos/worlds/ros_gz.sdf index d8f772fe..e8246179 100644 --- a/ros_gz_sim_demos/worlds/ros_gz.sdf +++ b/ros_gz_sim_demos/worlds/ros_gz.sdf @@ -70,7 +70,7 @@ - package://ros_gz_sim_demos/config/full.yaml + package://ros_gz_bridge/config/full.yaml From ae79fa9764897870fe87ee1cfd03ccfcaa6ba9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 20 Mar 2024 19:43:53 +0100 Subject: [PATCH 3/5] Tweak test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_bridge/CMakeLists.txt | 4 ++++ ros_gz_bridge/test/bridge_config.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ros_gz_bridge/CMakeLists.txt b/ros_gz_bridge/CMakeLists.txt index 18c3e1cf..84f6efd7 100644 --- a/ros_gz_bridge/CMakeLists.txt +++ b/ros_gz_bridge/CMakeLists.txt @@ -311,6 +311,10 @@ if(BUILD_TESTING) DESTINATION lib/${PROJECT_NAME} ) + install(DIRECTORY + test/config + DESTINATION share/${PROJECT_NAME}/test/) + add_launch_test(test/launch/test_ros_subscriber.launch.py TIMEOUT 200 ARGS "gz_msgs_ver:=${GZ_MSGS_VERSION_FULL}" diff --git a/ros_gz_bridge/test/bridge_config.cpp b/ros_gz_bridge/test/bridge_config.cpp index 1356d64b..ac192abf 100644 --- a/ros_gz_bridge/test/bridge_config.cpp +++ b/ros_gz_bridge/test/bridge_config.cpp @@ -71,7 +71,7 @@ class BridgeConfig : public ::testing::Test TEST_F(BridgeConfig, Minimum) { auto results = ros_gz_bridge::readFromYamlFile( - "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/minimum.yaml"); + "package://ros_gz_bridge/test/config/minimum.yaml"); EXPECT_EQ(4u, results.size()); { @@ -119,7 +119,7 @@ TEST_F(BridgeConfig, Minimum) TEST_F(BridgeConfig, FullGz) { auto results = ros_gz_bridge::readFromYamlFile( - "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/full.yaml"); + "package://ros_gz_bridge/test/config/full.yaml"); EXPECT_EQ(2u, results.size()); { @@ -270,7 +270,7 @@ TEST_F(BridgeConfig, InvalidFileDoesntExist) TEST_F(BridgeConfig, InvalidTopLevel) { auto results = ros_gz_bridge::readFromYamlFile( - "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/invalid.yaml"); + "package://ros_gz_bridge/test/config/invalid.yaml"); EXPECT_EQ(0u, results.size()); EXPECT_EQ( "Could not parse config: top level must be a YAML sequence", @@ -280,10 +280,10 @@ TEST_F(BridgeConfig, InvalidTopLevel) TEST_F(BridgeConfig, EmptyYAML) { auto results = ros_gz_bridge::readFromYamlFile( - "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/empty.yaml"); + "package://ros_gz_bridge/test/config/empty.yaml"); EXPECT_EQ(0u, results.size()); EXPECT_EQ( "Could not parse config: file empty [" - "file:///home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/empty.yaml]", + "package://ros_gz_bridge/test/config/empty.yaml]", g_last_log_event.message); } From 87ccac3fd094ece8a60ccafc10c04b029e0a79b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Thu, 21 Mar 2024 19:44:09 +0100 Subject: [PATCH 4/5] Update ros_gz_bridge/CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alejandro Hernández Cordero Signed-off-by: Carlos Agüero --- ros_gz_bridge/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ros_gz_bridge/CMakeLists.txt b/ros_gz_bridge/CMakeLists.txt index 84f6efd7..97e98a78 100644 --- a/ros_gz_bridge/CMakeLists.txt +++ b/ros_gz_bridge/CMakeLists.txt @@ -313,7 +313,8 @@ if(BUILD_TESTING) install(DIRECTORY test/config - DESTINATION share/${PROJECT_NAME}/test/) + DESTINATION share/${PROJECT_NAME}/test/ + ) add_launch_test(test/launch/test_ros_subscriber.launch.py TIMEOUT 200 From 9576d862e320d75253ec78457d1f4b59c00a83f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Thu, 21 Mar 2024 19:49:11 +0100 Subject: [PATCH 5/5] Tweak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_sim_demos/worlds/ros_gz.sdf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros_gz_sim_demos/worlds/ros_gz.sdf b/ros_gz_sim_demos/worlds/ros_gz.sdf index e8246179..7aa37830 100644 --- a/ros_gz_sim_demos/worlds/ros_gz.sdf +++ b/ros_gz_sim_demos/worlds/ros_gz.sdf @@ -70,7 +70,7 @@ - package://ros_gz_bridge/config/full.yaml + package://ros_gz_bridge/test/config/full.yaml