15#ifndef SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_INTERFACE_HPP_
16#define SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_INTERFACE_HPP_
21#include "controller_interface/helpers.hpp"
22#include "hardware_interface/loaned_state_interface.hpp"
24namespace semantic_components
26template <
typename MessageReturnType>
31 const std::string & name,
const std::vector<std::string> & interface_names)
32 : name_(name), interface_names_(interface_names)
34 state_interfaces_.reserve(interface_names.size());
39 interface_names_.reserve(size);
40 state_interfaces_.reserve(size);
52 std::vector<hardware_interface::LoanedStateInterface> & state_interfaces)
54 return controller_interface::get_ordered_interfaces(
55 state_interfaces, interface_names_,
"", state_interfaces_);
72 if (interface_names_.empty())
74 for (
auto i = 0u; i < interface_names_.capacity(); ++i)
76 interface_names_.emplace_back(name_ +
"/" + std::to_string(i + 1));
79 return interface_names_;
89 if (values.capacity() != state_interfaces_.size())
94 for (
auto i = 0u; i < state_interfaces_.size(); ++i)
96 values.emplace_back(state_interfaces_[i].get().get_value());
109 std::vector<std::string> interface_names_;
110 std::vector<std::reference_wrapper<hardware_interface::LoanedStateInterface>> state_interfaces_;
Definition semantic_component_interface.hpp:28
bool get_values(std::vector< double > &values) const
Return all values.
Definition semantic_component_interface.hpp:86
bool assign_loaned_state_interfaces(std::vector< hardware_interface::LoanedStateInterface > &state_interfaces)
Assign loaned state interfaces from the hardware.
Definition semantic_component_interface.hpp:51
bool get_values_as_message(MessageReturnType &)
Return values as MessageReturnType.
Definition semantic_component_interface.hpp:105
virtual std::vector< std::string > get_state_interface_names()
Definition of state interface names for the component.
Definition semantic_component_interface.hpp:70
void release_interfaces()
Release loaned interfaces from the hardware.
Definition semantic_component_interface.hpp:59