ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I would guess that it's this line:

odom.pose.pose.orientation = odom_quat

odom.pose.pose.orientation is a quaternion message, but odom_quat is a numpy array (which is what transformations.py uses natively) You need to convert the data type before assigning it. The numpy array uses index notation, while the message uses .x .y .z and .w

click to hide/show revision 2
updated with specific code as requested

I would guess that it's this line:

odom.pose.pose.orientation = odom_quat

odom.pose.pose.orientation is a quaternion message, but odom_quat is a numpy array (which is what transformations.py uses natively) You need to convert the data type before assigning it. The numpy array uses index notation, while the message uses .x .y .z and .w

To do this you would need to do it like this:

odom.pose.pose.orientation.x = odom_quat[0]
odom.pose.pose.orientation.y = odom_quat[1]
odom.pose.pose.orientation.z = odom_quat[2]
odom.pose.pose.orientation.w = odom_quat[3]

You could collapse it into one line with list comprehension but this is likely easier to read and understand.

I would guess that it's this line:

odom.pose.pose.orientation = odom_quat

odom.pose.pose.orientation is a quaternion message, but odom_quat is a numpy array (which is what transformations.py uses natively) You need to convert the data type before assigning it. The numpy array uses index notation, while the message uses .x .y .z and .w

To do this you would need to do it like this:

odom.pose.pose.orientation.x = odom_quat[0]
odom.pose.pose.orientation.y = odom_quat[1]
odom.pose.pose.orientation.z = odom_quat[2]
odom.pose.pose.orientation.w = odom_quat[3]

You could collapse it into one line with list comprehension but this is likely easier to read and understand.