Skip to content

Commit

Permalink
Update mira tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Tudela <ajtudela@gmail.com>
  • Loading branch information
ajtudela committed Apr 8, 2024
1 parent 395c08d commit 1de3a01
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
10 changes: 10 additions & 0 deletions scitos2_mira/src/mira_framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ nav2_util::CallbackReturn MiraFramework::on_configure(const rclcpp_lifecycle::St
rcl_interfaces::msg::ParameterDescriptor()
.set__description("List of the modules exposed by the node"));
this->get_parameter("module_plugins", module_ids_);

// Print the list of modules
for (size_t i = 0; i != module_ids_.size(); ++i) {
RCLCPP_INFO(get_logger(), "Module: %s", module_ids_[i].c_str());
}

for (size_t i = 0; i != default_ids_.size(); ++i) {
RCLCPP_INFO(get_logger(), "Default module: %s", default_ids_[i].c_str());
}

if (module_ids_ == default_ids_) {
for (size_t i = 0; i != default_ids_.size(); ++i) {
nav2_util::declare_parameter_if_not_declared(
Expand Down
16 changes: 12 additions & 4 deletions scitos2_mira/test/test_mira_framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include "scitos2_mira/mira_framework.hpp"
#include "scitos2_core/module.hpp"

class MiraFrameworkFixture : public scitos2_mira::MiraFramework
{
public:
MiraFrameworkFixture()
: scitos2_mira::MiraFramework(rclcpp::NodeOptions())
{}
};

class DummyModule : public scitos2_core::Module
{
public:
Expand Down Expand Up @@ -50,7 +58,7 @@ template<>
pluginlib::UniquePtr<scitos2_core::Module> pluginlib::ClassLoader<scitos2_core::Module>::
createUniqueInstance(const std::string & lookup_name)
{
if (lookup_name != "DummyModule") {
if (lookup_name != "drive") {
// original method body
if (!isClassLoaded(lookup_name)) {
loadLibraryForClass(lookup_name);
Expand All @@ -73,7 +81,7 @@ createUniqueInstance(const std::string & lookup_name)

TEST(ScitosMiraFrameworkTest, configure) {
// Create the node
auto node = std::make_shared<scitos2_mira::MiraFramework>();
auto node = std::make_shared<MiraFrameworkFixture>();

// Set an empty scitos config parameter
nav2_util::declare_parameter_if_not_declared(node, "scitos_config", rclcpp::ParameterValue(""));
Expand All @@ -92,9 +100,9 @@ TEST(ScitosMiraFrameworkTest, configure) {
"scitos_config", rclcpp::ParameterValue(std::string(pkg + "/test/scitos_config.xml"))));
nav2_util::declare_parameter_if_not_declared(
node, "module_plugins",
rclcpp::ParameterValue(std::vector<std::string>(1, "DummyModule")));
rclcpp::ParameterValue(std::vector<std::string>(1, "drive")));
nav2_util::declare_parameter_if_not_declared(
node, "DummyModule.plugin", rclcpp::ParameterValue("DummyModule"));
node, "drive.plugin", rclcpp::ParameterValue("drive"));

// Configure the node
node->configure();
Expand Down

0 comments on commit 1de3a01

Please sign in to comment.