Access field in message inside a message
Hallo
Being new to ros, I´ve stumbled into a stupid problem..
Im writing a python listener, and I want to get the orientation from an Imu.
The variable I want to access can be echoed with : rostopic echo /imu/orientation/z
Here is what I have so far - which is not really working out...:
#!/usr/bin/env python
import rospy
from sensor_msgs.msg import Imu
from geometry_msgs.msg import Quaternion
def imu_callback(data):
rospy.loginfo(Imu.orientation.z)
#do something with z
def imu_listener():
rospy.init_node('listener', anonymous=True)
rospy.Subscriber("imu", Imu, imu_callback)
rospy.spin()
if __name__ == '__main__':
imu_listener()