adapted the environment for EnvInterfaceBase
This commit is contained in:
parent
71063b19aa
commit
18d2772cef
17 changed files with 447 additions and 74 deletions
63
env_manager/env_interface/src/env_interface_base.cpp
Normal file
63
env_manager/env_interface/src/env_interface_base.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include "env_interface/env_interface_base.hpp"
|
||||
|
||||
namespace env_interface
|
||||
{
|
||||
|
||||
CallbackReturn
|
||||
EnvInterfaceBase::init(
|
||||
const std::string& t_env_name,
|
||||
const std::string & t_namespace,
|
||||
const rclcpp::NodeOptions & t_node_options)
|
||||
{
|
||||
m_node = std::make_shared<rclcpp_lifecycle::LifecycleNode>(
|
||||
t_env_name, t_namespace, t_node_options, false);
|
||||
|
||||
if (on_init() == CallbackReturn::FAILURE)
|
||||
{
|
||||
return CallbackReturn::FAILURE;
|
||||
}
|
||||
|
||||
m_node->register_on_configure(
|
||||
std::bind(&EnvInterfaceBase::on_configure, this, std::placeholders::_1)
|
||||
);
|
||||
m_node->register_on_activate(
|
||||
std::bind(&EnvInterfaceBase::on_activate, this, std::placeholders::_1)
|
||||
);
|
||||
m_node->register_on_cleanup(
|
||||
std::bind(&EnvInterfaceBase::on_cleanup, this, std::placeholders::_1)
|
||||
);
|
||||
m_node->register_on_deactivate(
|
||||
std::bind(&EnvInterfaceBase::on_deactivate, this, std::placeholders::_1)
|
||||
);
|
||||
m_node->register_on_error(
|
||||
std::bind(&EnvInterfaceBase::on_error, this, std::placeholders::_1)
|
||||
);
|
||||
m_node->register_on_shutdown(
|
||||
std::bind(&EnvInterfaceBase::on_shutdown, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
return CallbackReturn::SUCCESS;
|
||||
}
|
||||
|
||||
const rclcpp_lifecycle::State&
|
||||
EnvInterfaceBase::configure()
|
||||
{
|
||||
return getNode()->configure();
|
||||
}
|
||||
|
||||
std::shared_ptr<rclcpp_lifecycle::LifecycleNode>
|
||||
EnvInterfaceBase::getNode()
|
||||
{
|
||||
if (!m_node.get())
|
||||
{
|
||||
throw std::runtime_error("Lifecycle node hasn't been initialized yet");
|
||||
}
|
||||
return m_node;
|
||||
}
|
||||
|
||||
const rclcpp_lifecycle::State & EnvInterfaceBase::getState() const
|
||||
{
|
||||
return m_node->get_current_state();
|
||||
}
|
||||
|
||||
} // namespace env_interface
|
Loading…
Add table
Add a link
Reference in a new issue