SMACC
Loading...
Searching...
No Matches
cp_pose.h
Go to the documentation of this file.
1/*****************************************************************************************************************
2 * ReelRobotix Inc. - Software License Agreement Copyright (c) 2018-2020
3 * Authors: Pablo Inigo Blasco, Brett Aldrich
4 *
5 ******************************************************************************************************************/
6#pragma once
7
8#include <smacc/component.h>
10
11#include <geometry_msgs/Pose.h>
12#include <tf/transform_listener.h>
13#include <tf/transform_datatypes.h>
14#include <mutex>
15
16namespace cl_move_base_z
17{
19{
20public:
21 Pose(std::string poseFrameName = "base_link", std::string referenceFrame = "odom");
22
23 virtual void update() override;
24
25 void waitTransformUpdate(ros::Rate r = ros::Rate(20));
26
27 inline geometry_msgs::Pose toPoseMsg()
28 {
29 std::lock_guard<std::mutex> guard(m_mutex_);
30 return this->pose_.pose;
31 }
32
33 inline geometry_msgs::PoseStamped toPoseStampedMsg()
34 {
35 std::lock_guard<std::mutex> guard(m_mutex_);
36 return this->pose_;
37 }
38
39 inline const std::string &getReferenceFrame() const
40 {
41 return referenceFrame_;
42 }
43
44 inline const std::string &getFrameId() const
45 {
46 return poseFrameName_;
47 }
48
50
51private:
52 geometry_msgs::PoseStamped pose_;
53
54 static std::shared_ptr<tf::TransformListener> tfListener_;
55 static std::mutex listenerMutex_;
56
57 std::string poseFrameName_;
58 std::string referenceFrame_;
59
60 std::mutex m_mutex_;
61};
62} // namespace cl_move_base_z
static std::shared_ptr< tf::TransformListener > tfListener_
Definition: cp_pose.h:54
std::string poseFrameName_
Definition: cp_pose.h:57
void waitTransformUpdate(ros::Rate r=ros::Rate(20))
Definition: cp_pose.cpp:32
geometry_msgs::PoseStamped toPoseStampedMsg()
Definition: cp_pose.h:33
std::string referenceFrame_
Definition: cp_pose.h:58
const std::string & getFrameId() const
Definition: cp_pose.h:44
std::mutex m_mutex_
Definition: cp_pose.h:60
geometry_msgs::PoseStamped pose_
Definition: cp_pose.h:52
geometry_msgs::Pose toPoseMsg()
Definition: cp_pose.h:27
virtual void update() override
Definition: cp_pose.cpp:64
static std::mutex listenerMutex_
Definition: cp_pose.h:55
const std::string & getReferenceFrame() const
Definition: cp_pose.h:39