Get IMU data (translational acceleration)


#1

Hi,

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!


#2

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

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


#3

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)
rospy.spin()

if _ name_ == ‘_ main _’:
listener()

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


#4

Hi,

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.


#5

Thanks! Its solved now!


#6

Please close this thread if your issue is resolved now.


#7