15#ifndef SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_INTERFACE_HPP_
16#define SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_INTERFACE_HPP_
22#include "controller_interface/helpers.hpp"
23#include "hardware_interface/loaned_state_interface.hpp"
25namespace semantic_components
27template <
typename MessageReturnType>
32 const std::string & name,
const std::vector<std::string> & interface_names)
33 : name_(name), interface_names_(interface_names)
35 state_interfaces_.reserve(interface_names.size());
40 interface_names_.reserve(size);
41 state_interfaces_.reserve(size);
54 std::vector<hardware_interface::LoanedStateInterface> & state_interfaces)
56 return controller_interface::get_ordered_interfaces(
57 state_interfaces, interface_names_,
"", state_interfaces_);
77 if (interface_names_.empty())
79 for (
auto i = 0u; i < interface_names_.capacity(); ++i)
81 interface_names_.emplace_back(name_ +
"/" + std::to_string(i + 1));
84 return interface_names_;
95 if (values.capacity() != state_interfaces_.size())
100 for (
auto i = 0u; i < state_interfaces_.size(); ++i)
102 values.emplace_back(state_interfaces_[i].get().get_optional().value());
120 std::vector<std::string> interface_names_;
121 std::vector<std::reference_wrapper<hardware_interface::LoanedStateInterface>> state_interfaces_;
Definition semantic_component_interface.hpp:29
bool get_values(std::vector< double > &values) const
Return all values.
Definition semantic_component_interface.hpp:92
bool assign_loaned_state_interfaces(std::vector< hardware_interface::LoanedStateInterface > &state_interfaces)
Assign loaned state interfaces from the hardware.
Definition semantic_component_interface.hpp:53
bool get_values_as_message(MessageReturnType &)
Return values as MessageReturnType.
Definition semantic_component_interface.hpp:112
virtual std::vector< std::string > get_state_interface_names()
Definition of state interface names for the component.
Definition semantic_component_interface.hpp:75
void release_interfaces()
Release loaned interfaces from the hardware.
Definition semantic_component_interface.hpp:63