9#ifndef _USE_MATH_DEFINES
10#define _USE_MATH_DEFINES
16#include <tf2/LinearMath/Quaternion.h>
24 ok = m_poly->
view(m_iThreeAxisGyroscopes);
29 ok = m_poly->view(m_iThreeAxisLinearAccelerometers);
34 ok = m_poly->view(m_iThreeAxisMagnetometers);
39 ok = m_poly->view(m_iOrientationSensors);
45 ok = m_iThreeAxisGyroscopes->getThreeAxisGyroscopeFrameName(m_sens_index, m_framename);
57 sensor_msgs::msg::Imu imu_ros_data;
62 quat.setRPY(vecrpy[0] *
M_PI / 180.0, vecrpy[1] *
M_PI / 180.0, vecrpy[2] *
M_PI / 180.0);
66 imu_ros_data.angular_velocity.x = vecgyr[0] *
M_PI / 180.0;
67 imu_ros_data.angular_velocity.y = vecgyr[1] *
M_PI / 180.0;
68 imu_ros_data.angular_velocity.z = vecgyr[2] *
M_PI / 180.0;
69 imu_ros_data.linear_acceleration.x = vecacc[0];
70 imu_ros_data.linear_acceleration.y = vecacc[1];
71 imu_ros_data.linear_acceleration.z = vecacc[2];
72 imu_ros_data.orientation.x = quat.x();
73 imu_ros_data.orientation.y = quat.y();
74 imu_ros_data.orientation.z = quat.z();
75 imu_ros_data.orientation.w = quat.w();
const yarp::os::LogComponent & GENERICSENSOR_NWS_ROS2()
builtin_interfaces::msg::Time ros2TimeFromYarp(double yarpTime)
rclcpp::Publisher< sensor_msgs::msg::Imu >::SharedPtr m_publisher
const size_t m_sens_index
IMU_nws_ros2: This wrapper connects to a device and publishes a ROS topic of type sensor_msgs::Imu.
void run() override
Loop function.
bool view(T *&x)
Get an interface to the device driver.
virtual bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double ×tamp) const =0
Get the last reading of the orientation sensor as roll pitch yaw.
virtual bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const =0
Get the last reading of the gyroscope.
virtual bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const =0
Get the last reading of the specified sensor.
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)