38 #include <std_msgs/Float32.h>
43 std::shared_ptr<tf2_ros::TransformListener> tf_listener)
49 std::move(tf_listener) :
93 bool should_emit =
false;
173 Ogre::Vector3& position,
174 Ogre::Quaternion& orientation)
180 position = Ogre::Vector3(9999999, 9999999, 9999999);
181 orientation = Ogre::Quaternion::IDENTITY;
191 position = it->second.position;
192 orientation = it->second.orientation;
196 geometry_msgs::Pose pose;
197 pose.orientation.w = 1.0f;
199 if (!
transform(frame, time, pose, position, orientation))
211 const geometry_msgs::Pose& pose_msg,
212 Ogre::Vector3& position,
213 Ogre::Quaternion& orientation)
217 position = Ogre::Vector3::ZERO;
218 orientation = Ogre::Quaternion::IDENTITY;
220 geometry_msgs::Pose pose = pose_msg;
221 if (pose.orientation.x == 0.0 && pose.orientation.y == 0.0 && pose.orientation.z == 0.0 &&
222 pose.orientation.w == 0.0)
223 pose.orientation.w = 1.0;
243 catch (
const std::runtime_error& e)
245 ROS_DEBUG(
"Error transforming from frame '%s' to frame '%s': %s", frame.c_str(),
250 position = Ogre::Vector3(pose.position.x, pose.position.y, pose.position.z);
252 Ogre::Quaternion(pose.orientation.w, pose.orientation.x, pose.orientation.y, pose.orientation.z);
261 error =
"Frame [" + frame +
"] does not exist";
264 error =
"Fixed " + error;
276 std::string tf_error;
278 if (transform_succeeded)
289 std::stringstream ss;
290 ss <<
"No transform to fixed frame [" <<
fixed_frame_ <<
"]. TF error: [" << tf_error <<
"]";
296 std::stringstream ss;
297 ss <<
"For frame [" << frame <<
"]: " << error;
306 std::stringstream ss;
307 ss <<
"Transform [sender=" << caller_id <<
"]";
318 std::stringstream ss;
319 ss <<
"Message removed because it is too old (frame=[" << frame_id <<
"], stamp=[" << stamp <<
"])";
331 return "Unknown reason for transform failure (frame=[" + frame_id +
"])";
336 const std::string& caller_id,
343 const std::string& status_text,