14#ifndef SEMANTIC_COMPONENTS__POSE_SENSOR_HPP_
15#define SEMANTIC_COMPONENTS__POSE_SENSOR_HPP_
22#include "geometry_msgs/msg/pose.hpp"
23#include "semantic_components/semantic_component_interface.hpp"
25namespace semantic_components
36 name, {{name +
'/' +
"position.x"},
37 {name +
'/' +
"position.y"},
38 {name +
'/' +
"position.z"},
39 {name +
'/' +
"orientation.x"},
40 {name +
'/' +
"orientation.y"},
41 {name +
'/' +
"orientation.z"},
42 {name +
'/' +
"orientation.w"}})
54 update_data_from_interfaces();
55 std::array<double, 3> position;
56 std::copy(data_.begin(), data_.begin() + 3, position.begin());
69 update_data_from_interfaces();
70 std::array<double, 4> orientation;
71 std::copy(data_.begin() + 3, data_.end(), orientation.begin());
85 update_data_from_interfaces();
87 message.position.x = data_[0];
88 message.position.y = data_[1];
89 message.position.z = data_[2];
90 message.orientation.x = data_[3];
91 message.orientation.y = data_[4];
92 message.orientation.z = data_[5];
93 message.orientation.w = data_[6];
105 void update_data_from_interfaces()
const
107 for (
auto i = 0u; i < data_.size(); ++i)
109 const auto data = state_interfaces_[i].get().get_optional();
110 if (data.has_value())
112 data_[i] = data.value();
120 mutable std::array<double, 7> data_{{0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}};
Definition pose_sensor.hpp:29
std::array< double, 4 > get_orientation() const
Update and return orientation.
Definition pose_sensor.hpp:67
PoseSensor(const std::string &name)
Constructor for a standard pose sensor with interface names set based on sensor name.
Definition pose_sensor.hpp:34
std::array< double, 3 > get_position() const
Update and return position.
Definition pose_sensor.hpp:52
bool get_values_as_message(geometry_msgs::msg::Pose &message) const
Fill pose message with current values.
Definition pose_sensor.hpp:83
Definition semantic_component_interface.hpp:28