0
$\begingroup$

Rosanswers logo

I created a node and subscribe a topic (nav_msgs/Odometry Message) i want operate with the quaternion, how i can get it value? With python

i try it this way:

rospy.Subscriber('/odometry/filtered', Odometry) 
x = Odometry.pose.pose.pose.orientation.x

but not work well


Originally posted by Porti77 on ROS Answers with karma: 183 on 2015-05-20

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

First, your subscriber must use a callback, I suggest trying the ROS publisher subscriber tutorial.

I suppose you want to get the orientation in the Euler angle format (rotations around the x-y-z axis). Once you're able to receive the message through the callback, you can use the following code to access the angles.

import tf
orientation_euler = tf.transformations.euler_from_quaternion( odom_msg.pose.pose.orientation)
# use the angles with orientation_euler.x, orientation_euler.y, orientation_euler.z

Originally posted by yohtm with karma: 66 on 2015-05-20

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$