/********************************************************************* * * Software License Agreement (BSD License) * * move_base2 tests — an EnvMonitor (env_monitor_core) built from an EnvMonitorConfig through the real YAML path: * the struct becomes the `env_monitor` block under a fresh namespace, the three built-in detectors are loaded as * .so from devel/lib, exactly as NavigationRuntime does. * * Author: DuongTD *********************************************************************/ #ifndef MOVE_BASE2_TEST_ENV_MONITOR_FIXTURE_H_ #define MOVE_BASE2_TEST_ENV_MONITOR_FIXTURE_H_ #include #include #include #include #include #ifndef MOVE_BASE2_TEST_LIBRARY_DIR #error "MOVE_BASE2_TEST_LIBRARY_DIR must be defined by CMake" #endif namespace move_base2 { namespace testing { inline bool initEnvMonitor(env_monitor_core::EnvMonitor& monitor, const env_monitor_core::EnvMonitorConfig& config, std::string& error) { static int counter = 0; // devel/lib must win over a PNKX_NAV_CORE_LIBRARY_PATH left in the user's shell. setenv("PNKX_NAV_CORE_LIBRARY_PATH", MOVE_BASE2_TEST_LIBRARY_DIR, 1); robot::NodeHandle nh("move_base2_env_monitor_test_" + std::to_string(++counter)); const char* const kLibraries[][2] = { { "ContactDetector", "libenv_monitor_core_contact_detector" }, { "StallDetector", "libenv_monitor_core_stall_detector" }, { "UnreachableDetector", "libenv_monitor_core_unreachable_detector" }, }; for (const auto& lib : kLibraries) { YAML::Node node; node["library_path"] = lib[1]; nh.setParam(lib[0], node); } nh.setParam("env_monitor", env_monitor_core::toYaml(config)); return monitor.initialize(nh, error); } } // namespace testing } // namespace move_base2 #endif // MOVE_BASE2_TEST_ENV_MONITOR_FIXTURE_H_