Environment manager base architecture implemented
This commit is contained in:
parent
2019e7db41
commit
9f27ad0af3
30 changed files with 1555 additions and 1 deletions
39
env_manager/include/component_manager/service_component.hpp
Normal file
39
env_manager/include/component_manager/service_component.hpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef ENV_MANAGER__COMPONENT_MANAGER__SERVICE_COMPONENT_HPP_
|
||||
#define ENV_MANAGER__COMPONENT_MANAGER__SERVICE_COMPONENT_HPP_
|
||||
|
||||
#include "component_manager/visibility_control.h"
|
||||
|
||||
#include <rclcpp/node.hpp>
|
||||
|
||||
namespace env_manager
|
||||
{
|
||||
namespace component_manager
|
||||
{
|
||||
|
||||
const std::string DEFAULT_SERVICE_NDOE_NAME = "env_manager_service_node";
|
||||
const std::string DEFAULT_SERVICE_NAME = "service";
|
||||
|
||||
template <typename ServiceT>
|
||||
class ServiceComponent: public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
explicit ServiceComponent(const rclcpp::NodeOptions& options)
|
||||
: Node(DEFAULT_SERVICE_NDOE_NAME, options)
|
||||
{
|
||||
_service = create_service<ServiceT>(
|
||||
DEFAULT_SERVICE_NAME, std::bind(
|
||||
&ServiceComponent::callback, this,
|
||||
std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
virtual void callback(std::shared_ptr<typename ServiceT::Request> request,
|
||||
std::shared_ptr<typename ServiceT::Response> response) = 0;
|
||||
|
||||
private:
|
||||
typename rclcpp::Service<ServiceT>::SharedPtr _service;
|
||||
};
|
||||
|
||||
} // namespace component_manager
|
||||
} // namespace env_manager
|
||||
|
||||
#endif // ENV_MANAGER__COMPONENT_MANAGER__SERVICE_COMPONENT_HPP_
|
Loading…
Add table
Add a link
Reference in a new issue