Ask Your Question
0

how to calculate transform for two geometry_msgs/poseStamped messages

asked 2016-08-03 10:38:00 -0500

gk gravatar image

updated 2016-08-08 03:39:38 -0500

Hi,

I am new to ROS and RTT.

I want to calculate the transformation (relative position) for two geometry_msgs/poseStamped messages so that I can get the absolute position of my object if the position of other object is changed.

The first task is clearly to calculate the transform and then to use that transform also..

Please guide

============================================================================

Updated on August 8, 2016

CODE

void Rtt_apc::updateHook(){ if(input_port_obj.read(msg_obj) == RTT::NewData){

input_port_hand.read(msg_hand);

// calculate the transform from the object Pose this way we have the frame in which the object is lying

tf::Transform transform;
transform.setOrigin(tf::Vector3(msg_obj.pose.position.x, msg_obj.pose.position.y, msg_obj.pose.position.z));
transform.setRotation(tf::Quaternion( msg_obj.pose.orientation.x, msg_obj.pose.orientation.y, msg_obj.pose.orientation.z, msg_obj.pose.orientation.w));
tf::StampedTransform stf = tf::StampedTransform(transform,ros::Time(),"world","object");
std::cout<<stf.frame_id_<<"\n";
// Calculate the relative position of hand WRT this frame

std::string target_frame = "world";
geometry_msgs::PoseStamped& rel_hand_pos = msg_hand;
tf::TransformListener tl;

try{
  tl.transformPose(target_frame, msg_hand, rel_hand_pos);
}
catch (tf::TransformException ex){
  ROS_ERROR("%s",ex.what());
  ros::Duration(1.0).sleep();
}

output_port.write(rel_hand_pos);

} else{ std::cout << "Rtt_apc executes updateHook!! No New Data !!"<<std::endl; }="" }<="" p="">

ERROR

world ERROR "world" passed to lookupTransform argument target_frame does not exist. listener: I heard : [ 0.25,0.25,0.25,0,0,0,1 ]

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-04 14:49:05 -0500

Chrissi gravatar image

Use transformPose(). Exists for python and cpp. That of course requires that your tf tree is correct. See this tutorial.

edit flag offensive delete link more

Comments

However after using this i see an error and i am not sure if i am using the right frame for transformPose function.. Can you have a look at the code.

gk gravatar image gk  ( 2016-08-08 03:36:48 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-03 10:38:00 -0500

Seen: 4,259 times

Last updated: Aug 08 '16