pose_helper.cpp
Go to the documentation of this file.
1 
4 /*****************************************************************************
5 ** Includes
6 *****************************************************************************/
7 
8 #include <ecl/linear_algebra.hpp>
10 #include "../../include/yocs_navi_toolkit/pose_helper.hpp"
11 
12 /*****************************************************************************
13 ** Namespaces
14 *****************************************************************************/
15 
16 namespace yocs_navi_toolkit {
17 
18 /*****************************************************************************
19 ** Implementation
20 *****************************************************************************/
21 
22 PoseHelper::PoseHelper(const std::string& pose_topic_name)
23 {
24  ros::NodeHandle nodehandle;
25  pose_subscriber_ = nodehandle.subscribe<geometry_msgs::PoseWithCovarianceStamped>(pose_topic_name, 1, boost::bind(&PoseHelper::poseCallback, this, _1));
26 }
27 
29 
30 void PoseHelper::poseCallback(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& msg)
31 {
32  std::lock_guard<std::mutex> lock(data_mutex_);
33  pose_ = *msg;
34 }
35 
36 geometry_msgs::PoseWithCovarianceStamped PoseHelper::pose()
37 {
38  std::lock_guard<std::mutex> lock(data_mutex_);
39  geometry_msgs::PoseWithCovarianceStamped msg = pose_;
40  return msg;
41 }
42 
43 void PoseHelper::yaw(float& angle) {
44  std::lock_guard<std::mutex> lock(data_mutex_);
45  angle = tf::getYaw(pose_.pose.pose.orientation);
46 }
47 
48 void PoseHelper::position(Eigen::Vector3f& position)
49 {
50  std::lock_guard<std::mutex> lock(data_mutex_);
51  position << pose_.pose.pose.position.x, pose_.pose.pose.position.y, pose_.pose.pose.position.z;
52 }
53 
54 /*****************************************************************************
55  ** Trailers
56  *****************************************************************************/
57 
58 } // namespace yocs_navi_toolkit
void yaw(float &angle)
Heading angle for mobile robot 2d use cases.
Definition: pose_helper.cpp:43
geometry_msgs::PoseWithCovarianceStamped pose_
Definition: pose_helper.hpp:65
PoseHelper(const std::string &pose_topic_name)
Definition: pose_helper.cpp:22
void position(Eigen::Vector3f &position)
3d position of the robot in eigen format.
Definition: pose_helper.cpp:48
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
static double getYaw(const Quaternion &bt_q)
geometry_msgs::PoseWithCovarianceStamped pose()
Definition: pose_helper.cpp:36
void poseCallback(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr &msg)
Definition: pose_helper.cpp:30
ros::Subscriber pose_subscriber_
Definition: pose_helper.hpp:63


yocs_navi_toolkit
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 15:53:55