ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
tf::TransformListener frame_listener;
ros::Rate rate(10.0);
while (node.ok()){ tf::StampedTransform right_hand_transform; try{ frame_listener.waitForTransform("/right_hand_1", "/openni_depth_frame", ros::Time(0), ros::Duration(3.0)); frame_listener.lookupTransform("/right_hand_1", "/openni_depth_frame", ros::Time(0), right_hand_transform); } catch (tf::TransformException &ex) { ROS_ERROR("%s",ex.what()); ros::Duration(1.0).sleep(); continue; }
right_hand_x = right_hand_transform.getOrigin().x() * 10; right_hand_y = right_hand_transform.getOrigin().y() * 10; right_hand_z = right_hand_transform.getOrigin().z() * 10;
ROS_INFO_STREAM("right_hand_x: " << right_hand_x); ROS_INFO_STREAM("right_hand_y: " << right_hand_y); ROS_INFO_STREAM("right_hand_z: " << right_hand_z);
2 | No.2 Revision |
tf::TransformListener frame_listener;
ros::Rate 3 | No.3 Revision |
tf::TransformListener frame_listener;.
tf::TransformListener frame_listener;
ros::Rate rate(10.0);
while (node.ok()){
tf::StampedTransform right_hand_transform;
try{
frame_listener.waitForTransform("/right_hand_1", "/openni_depth_frame", ros::Time(0), ros::Duration(3.0));
frame_listener.lookupTransform("/right_hand_1", "/openni_depth_frame", ros::Time(0), right_hand_transform);
}
catch (tf::TransformException &ex) {
ROS_ERROR("%s",ex.what());
ros::Duration(1.0).sleep();
continue;
}
right_hand_x = right_hand_transform.getOrigin().x() * 10;
right_hand_y = right_hand_transform.getOrigin().y() * 10;
right_hand_z = right_hand_transform.getOrigin().z() * 10;
ROS_INFO_STREAM("right_hand_x: " << right_hand_x);
ROS_INFO_STREAM("right_hand_y: " << right_hand_y);
ROS_INFO_STREAM("right_hand_z: " << right_hand_z);