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);
53 std::vector<hardware_interface::LoanedStateInterface> & state_interfaces)
55 return controller_interface::get_ordered_interfaces(
56 state_interfaces, interface_names_,
"", state_interfaces_);
76 if (interface_names_.empty())
78 for (
auto i = 0u; i < interface_names_.capacity(); ++i)
80 interface_names_.emplace_back(name_ +
"/" + std::to_string(i + 1));
83 return interface_names_;
94 if (values.capacity() != state_interfaces_.size())
99 for (
auto i = 0u; i < state_interfaces_.size(); ++i)
101 values.emplace_back(state_interfaces_[i].get().get_optional().value());
119 std::vector<std::string> interface_names_;
120 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:91
bool assign_loaned_state_interfaces(std::vector< hardware_interface::LoanedStateInterface > &state_interfaces)
Assign loaned state interfaces from the hardware.
Definition semantic_component_interface.hpp:52
bool get_values_as_message(MessageReturnType &)
Return values as MessageReturnType.
Definition semantic_component_interface.hpp:111
virtual std::vector< std::string > get_state_interface_names()
Definition of state interface names for the component.
Definition semantic_component_interface.hpp:74
void release_interfaces()
Release loaned interfaces from the hardware.
Definition semantic_component_interface.hpp:62