ObjectTransformation.cpp
Go to the documentation of this file.
1 
19 
21 
23  : mTfListener(ros::Duration(5184000.0))
24  {
25  }
26 
28  {
29  }
30 
31  void ObjectTransformation::setBaseFrame(std::string pBaseFrame)
32  {
33  mBaseFrame = pBaseFrame;
34  }
35 
37  {
38  if (mBaseFrame == pObject->header.frame_id) return; // shortcut when both frames are equal.
39 
40  // Create everything required for the transformation
41  geometry_msgs::PoseStamped input, output;
42  input.header = pObject->header;
43 
44  if(!pObject->sampledPoses.size()){
45  std::cerr << "Got a AsrObject without poses." << std::endl;
46  std::exit(1);
47  }
48  input.pose = pObject->sampledPoses.front().pose;
49 
50  // If no transformation from source to target frame possible, drop object.
51  if(!mTfListener.waitForTransform(mBaseFrame, input.header.frame_id, pObject->header.stamp, ros::Duration(1.0)))
52  throw std::runtime_error("Unable to resolve transformation in target coordinate frame.");
53 
54  // Do the transformation.
55  mTfListener.transformPose(mBaseFrame, input, output);
56 
57  // Write the results back.
58  pObject->header = output.header;
59 
60  pObject->sampledPoses.pop_back();
61  geometry_msgs::PoseWithCovariance output_pose_with_c;
62  output_pose_with_c.pose = output.pose;
63  pObject->sampledPoses.push_back(output_pose_with_c);
64  }
65 
66 }
bool waitForTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration &timeout, const ros::Duration &polling_sleep_duration=ros::Duration(0.01), std::string *error_msg=NULL) const
void transform(const boost::shared_ptr< asr_msgs::AsrObject > &pObject)
void transformPose(const std::string &target_frame, const geometry_msgs::PoseStamped &stamped_in, geometry_msgs::PoseStamped &stamped_out) const


asr_psm
Author(s): Braun Kai, Gehrung Joachim, Heizmann Heinrich, Meißner Pascal
autogenerated on Fri Nov 15 2019 03:57:54