15 #ifndef SEMANTIC_COMPONENTS__IMU_SENSOR_HPP_
16 #define SEMANTIC_COMPONENTS__IMU_SENSOR_HPP_
22 #include "semantic_components/semantic_component_interface.hpp"
23 #include "sensor_msgs/msg/imu.hpp"
25 namespace semantic_components
30 explicit IMUSensor(
const std::string & name)
32 name, {{name +
"/" +
"orientation.x"},
33 {name +
"/" +
"orientation.y"},
34 {name +
"/" +
"orientation.z"},
35 {name +
"/" +
"orientation.w"},
36 {name +
"/" +
"angular_velocity.x"},
37 {name +
"/" +
"angular_velocity.y"},
38 {name +
"/" +
"angular_velocity.z"},
39 {name +
"/" +
"linear_acceleration.x"},
40 {name +
"/" +
"linear_acceleration.y"},
41 {name +
"/" +
"linear_acceleration.z"}})
52 std::array<double, 4> orientation;
53 for (
auto i = 0u; i < orientation.size(); ++i)
55 orientation[i] = state_interfaces_[i].get().get_value();
68 std::array<double, 3> angular_velocity;
69 const std::size_t interface_offset{4};
70 for (
auto i = 0u; i < angular_velocity.size(); ++i)
72 angular_velocity[i] = state_interfaces_[interface_offset + i].get().get_value();
74 return angular_velocity;
85 std::array<double, 3> linear_acceleration;
86 const std::size_t interface_offset{7};
87 for (
auto i = 0u; i < linear_acceleration.size(); ++i)
89 linear_acceleration[i] = state_interfaces_[interface_offset + i].get().get_value();
91 return linear_acceleration;
101 const auto [orientation_x, orientation_y, orientation_z, orientation_w] =
get_orientation();
102 const auto [angular_velocity_x, angular_velocity_y, angular_velocity_z] =
104 const auto [linear_acceleration_x, linear_acceleration_y, linear_acceleration_z] =
107 message.orientation.x = orientation_x;
108 message.orientation.y = orientation_y;
109 message.orientation.z = orientation_z;
110 message.orientation.w = orientation_w;
112 message.angular_velocity.x = angular_velocity_x;
113 message.angular_velocity.y = angular_velocity_y;
114 message.angular_velocity.z = angular_velocity_z;
116 message.linear_acceleration.x = linear_acceleration_x;
117 message.linear_acceleration.y = linear_acceleration_y;
118 message.linear_acceleration.z = linear_acceleration_z;
Definition: imu_sensor.hpp:28
std::array< double, 3 > get_angular_velocity() const
Return angular velocity.
Definition: imu_sensor.hpp:66
bool get_values_as_message(sensor_msgs::msg::Imu &message) const
Return Imu message with orientation, angular velocity and linear acceleration.
Definition: imu_sensor.hpp:99
std::array< double, 3 > get_linear_acceleration() const
Return linear acceleration.
Definition: imu_sensor.hpp:83
std::array< double, 4 > get_orientation() const
Return orientation.
Definition: imu_sensor.hpp:50
Definition: semantic_component_interface.hpp:28