Converting vector to orientation in sensor_msgs/Imu
I'm using the Lego Control+ Technic Hub as an IMU using the node-poweredup library. I am getting the imu data from the hub into ROS just fine but I am having trouble knowing how to correctly publish the orientation data in the sensor_msgs/imu message.
The data I'm getting from the hub is:
- Gyro: This is coming from the hub as [x, y, z] in degrees per second. I am converting this to radians per second and publishing it on the angular_velocity property of the imu message.
- Accel: This is the linear acceleration coming from the hub as [x, y, z] in milli-Gs. I am converting this to m/s^2 and publishing it on the linear_velocity property of the imu message.
- Tilt: This is coming from the hub as [x, y, z] where each value is in (-180, 180]. This is the one I'm not sure how to use. It seems like this is the orientation of the hub but the sensor_msgs/imu message expects a quaternion for the orientation.
If I convert the 'tilt' vector to a quaternion via this method would that work? My understanding of quaternions isn't very strong, but I think it represents a rotation from another position. Is there some information not represented in that vector that would be necessary to accurately track the robot?