Get IMU data (translational acceleration)



I am trying to get IMU data from Pixhawk. I was wondering if any of the APIs provide translational acceleration data. I am using get_attitude_euler to get the rotational velocities for now.
Thank you!


Checkout the ~/imu/data_raw API as mentioned over here.

If you face any issue consuming this API, feel free to post further.


Hi! Thanks for your response! I tried to write a subscriber for the imu data using the following script in flytsim. I ran it both through the “userapps/onboard_user/install” location as well as from the ros package I initially wrote it in. It shows the message ‘protobuf message implementation not found. Using pickle based protocol’ after which it just freezes.

#!/usr/bin/env python
import rospy
from sensor_msgs.msg import Imu

def callback(data):
rospy.loginfo(rospy.get_caller_id() + “\nlinear acceleration:\nx: [{}]\ny: [{}]\nz: [{}]”
.format(data.linear_acceleration.x, data.linear_acceleration.y, data.linear_acceleration.z))

def listener():
rospy.init_node(‘listener’, anonymous=True)
rospy.Subscriber("/mavros/imu/data", Imu, callback)

if _ name_ == ‘_ main _’:

Any suggestions on what I can do to make it work? Thank you!



You are missing the namespace that must go before the topic name when you subscribe.
It should be -> rospy.Subscriber("/<namespace>/mavros/imu/data", Imu, callback)

You must fetch the current namespace, using the /get_global_namespace API.


Thanks! Its solved now!


Please close this thread if your issue is resolved now.