9#ifndef _USE_MATH_DEFINES
10#define _USE_MATH_DEFINES
16#include <tf2/LinearMath/Quaternion.h>
20void
Imu_nwc_ros2::subscription_callback(const
std::shared_ptr<sensor_msgs::msg::Imu> msg)
22 std::lock_guard<std::mutex> dataGuard(m_dataMutex);
41 accelerations[0] = m_currentData.linear_acceleration.x;
42 accelerations[1] = m_currentData.linear_acceleration.y;
43 accelerations[2] = m_currentData.linear_acceleration.z;
68 frameName = m_currentData.header.frame_id;
98 angularVelocities[0] = m_currentData.angular_velocity.x * 180.0 /
M_PI;
99 angularVelocities[1] = m_currentData.angular_velocity.y * 180.0 /
M_PI;
100 angularVelocities[2] = m_currentData.angular_velocity.z * 180.0 /
M_PI;
102 out = angularVelocities;
117 std::lock_guard<std::mutex> dataGuard(
m_dataMutex);
125 frameName = m_currentData.header.frame_id;
144 std::lock_guard<std::mutex> dataGuard(
m_dataMutex);
153 tf2Scalar roll, pitch, yaw;
154 tf2::Quaternion tempQuat;
155 tempQuat.setX(m_currentData.orientation.x);
156 tempQuat.setY(m_currentData.orientation.y);
157 tempQuat.setZ(m_currentData.orientation.z);
158 tempQuat.setW(m_currentData.orientation.w);
159 tf2::Matrix3x3 tempMat(tempQuat);
160 tempMat.getRPY(roll, pitch, yaw);
164 orient[0] = roll * 180.0 /
M_PI;
165 orient[1] = pitch * 180.0 /
M_PI;
166 orient[2] = yaw * 180.0 /
M_PI;
183 std::lock_guard<std::mutex> dataGuard(
m_dataMutex);
191 frameName = m_currentData.header.frame_id;
const yarp::os::LogComponent & GENERICSENSOR_NWC_ROS2()
const yarp::os::LogComponent & GENERICSENSOR_NWC_ROS2()
double yarpTimeFromRos2(builtin_interfaces::msg::Time ros2Time)
std::string m_sensor_name
yarp::dev::MAS_status m_internalStatus
IMU_nwc_ros2: This wrapper connects to a device and publishes a ROS topic of type sensor_msgs::Imu.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double ×tamp) const override
Get the last reading of the orientation sensor as roll pitch yaw.
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
size_t getNrOfThreeAxisGyroscopes() const override
Get the number of three axis gyroscopes exposed by this sensor.
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the gyroscope.
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
@ MAS_WAITING_FOR_FIRST_READ
The sensor is read through the network, and the device is waiting to receive the first measurement.
@ MAS_OK
The sensor is working correctly.