TF: level RPY in child frame from robot frame

asked 2021-05-18 01:41:46 -0500

abirdh gravatar image

updated 2021-05-19 03:43:39 -0500

Hi,

I have realsense d435 depth camera on my flying quad robot, I need to level the obstacle POI so i want to use the frame of the robot for the XYZ location but i want to keep the RPY flat to the map.

anyone have an idia how to make this? (I only know to use python in my code, i'm newbie :) )


Edit:

#!/usr/bin/env python
import roslib

roslib.load_manifest('imu_tf')
import rospy
import tf
from geometry_msgs.msg import PoseStamped

x = 0
y = 0
z = 0
w = 1


def camera_pose(data):
    global x
    global y
    global z
    global w
    x = data.pose.orientation.x
    y = data.pose.orientation.y
    z = data.pose.orientation.z
    w = data.pose.orientation.w


if __name__ == '__main__':
    rospy.init_node('imu_tf')
    br = tf.TransformBroadcaster()
    rate = rospy.Rate(10.0)
    while not rospy.is_shutdown():
        rospy.Subscriber("/orb_slam2_rgbd/pose", PoseStamped, camera_pose)
        br.sendTransform((0.0, 0.0, 0.0),
                         (-x, -y, -z, 1),
                         rospy.Time.now(),
                         "imu_abir_link",
                         "camera_link")
        rate.sleep()

I tried this code and it work but in some angles i have transform error:

Error: TF_DENORMALIZED_QUATERNION: Ignoring transform for child_frame_id "imu_abir_link" from authority "unknown_publisher" because of an invalid quaternion in the transform (0.014272 -0.011671 -0.358522 1.000000)

Edit 2: I found that i have to add the 'w' orientation to avoid this error.

Now I wonder if there is a simpliar way to fix the RPY orientation to be level to the "map" frame without the IMU.

edit retag flag offensive close merge delete