本文整理汇总了C++中tf::Transformer::transformPose方法的典型用法代码示例。如果您正苦于以下问题:C++ Transformer::transformPose方法的具体用法?C++ Transformer::transformPose怎么用?C++ Transformer::transformPose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tf::Transformer
的用法示例。
在下文中一共展示了Transformer::transformPose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: detectObject
// detected object = checkerboard, target = plug
bool RosDetector::detectObject(const sensor_msgs::ImageConstPtr& image_msg,
const sensor_msgs::CameraInfoConstPtr& info_msg,
const tf::Stamped<tf::Pose>& target_prior, const tf::Transformer& transformer,
tf::Stamped<tf::Pose>& target_pose)
{
// Convert image message
cv_bridge::CvImageConstPtr cv_image = cv_bridge::toCvShare(image_msg, "mono8");
cv::Mat image = cv_image->image;
// Detect the checkerboard
std::vector<cv::Point2f> corners;
if (!detector_.detect(image, corners)) {
ROS_DEBUG("%s: Failed to detect checkerboard", name_.c_str());
publishDisplayImage(image, corners, false);
/// @todo Publish feedback?
return false;
}
// Estimate its pose
cam_model_.fromCameraInfo(info_msg);
tf::Stamped<tf::Pose> target_prior_in_camera;
try {
transformer.transformPose(cam_model_.tfFrame(), target_prior, target_prior_in_camera);
}
catch (tf::TransformException& ex) {
ROS_WARN("%s: TF exception\n%s", name_.c_str(), ex.what());
return false;
}
tf::Pose detected_object_prior = target_prior_in_camera * target_in_detected_object_.inverse();
tf::Pose detected_object_pose = pose_estimator_.solveWithPrior(corners, cam_model_, detected_object_prior);
target_pose = tf::Stamped<tf::Pose>(detected_object_pose * target_in_detected_object_,
image_msg->header.stamp, cam_model_.tfFrame());
// Publish visualization messages
tf_broadcaster_.sendTransform(tf::StampedTransform(detected_object_prior, image_msg->header.stamp,
cam_model_.tfFrame(), "checkerboard_prior_frame"));
tf_broadcaster_.sendTransform(tf::StampedTransform(target_prior, target_prior.stamp_,
target_prior.frame_id_, "plug_prior_frame"));
tf_broadcaster_.sendTransform(tf::StampedTransform(detected_object_pose, image_msg->header.stamp,
cam_model_.tfFrame(), "checkerboard_frame"));
tf_broadcaster_.sendTransform(tf::StampedTransform(target_pose, image_msg->header.stamp,
cam_model_.tfFrame(), "plug_frame"));
publishDisplayImage(image, corners, true);
return true;
}