feat: env_monitor_core package with detector plugins

EnvMonitor moves out of move_base2 into its own package. stall, unreachable and
contact become boost::dll detector plugins loaded from env_monitor/detectors,
each with its own recovery route (route, route_mode step|sequence,
on_exhausted lock|abort). Golden test replays the pre-split verdicts bit for bit.
This commit is contained in:
2026-11-27 10:08:30 +07:00
commit 93d3996629
22 changed files with 11423 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
/*********************************************************************
*
* Software License Agreement (BSD License)
*
* env_monitor_core tests — detectors that EnvMonitor must REFUSE to load:
* - StaleAbiDetector : `_abi` returns a version the runtime does not match;
* - NoAbiDetector : no `_abi` symbol at all (plain BOOST_DLL_ALIAS).
*
* Author: DuongTD
*********************************************************************/
#include <memory>
#include <string>
#include <boost/dll/alias.hpp>
#include <env_monitor_core/env_detector.h>
#include <env_monitor_core/env_detector_abi.h>
namespace env_monitor_core
{
namespace testing
{
class StaleAbiDetector final : public EnvDetector
{
public:
static EnvDetector::Ptr create()
{
return std::make_shared<StaleAbiDetector>();
}
bool initialize(const std::string& /*name*/, robot::NodeHandle& /*nh*/, std::string& /*error*/) override
{
return true;
}
std::string describe() const override
{
return "stale";
}
bool armed() const override
{
return true;
}
EnvRouteSpec defaultRoute() const override
{
EnvRouteSpec spec;
spec.route = "stale";
return spec;
}
EnvNeeds needs() const override
{
return EnvNeeds();
}
void reset() override
{
}
void update(const EnvFrame& /*frame*/, EnvDetectorOutput& out, EnvVerdict& /*verdict*/) override
{
out.brake = true; // would be visible if the monitor ever ran it
}
};
/// ABI version "from the future": never equal to the runtime's.
int staleAbiVersion()
{
return kEnvDetectorAbiVersion + 1;
}
} // namespace testing
} // namespace env_monitor_core
BOOST_DLL_ALIAS(env_monitor_core::testing::StaleAbiDetector::create, StaleAbiDetector)
BOOST_DLL_ALIAS(env_monitor_core::testing::staleAbiVersion, StaleAbiDetector_abi)
BOOST_DLL_ALIAS(env_monitor_core::testing::StaleAbiDetector::create, NoAbiDetector)