pose_correction_tf_publisher.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_CORE_POSE_CORRECTION_TF_PUBLISHER_H
2 #define SLAM_CTOR_CORE_POSE_CORRECTION_TF_PUBLISHER_H
3 
4 #include <thread>
5 #include <mutex>
6 #include <utility>
7 #include <ros/ros.h>
9 
10 #include "topic_with_transform.h"
11 #include "../core/states/world.h"
12 
13 template <typename ObservationType>
14 class PoseCorrectionTfPublisher : public TopicObserver<ObservationType>,
15  public WorldPoseObserver {
16 public: //methods
18  const std::string &tf_odom_frame_id,
19  bool is_async = false) :
20  _tf_map_frame_id{tf_map_frame_id},
24  if (!is_async) {
25  return;
26  }
28  _transform_publisher = std::move(std::thread{loop_f, this});
29  }
30 
31  virtual void handle_transformed_msg(
33  const tf::StampedTransform& t) override {
34  // work with 2D pose
35  _last_odom2base = t;
37  }
38 
39  virtual void on_pose_update(const RobotPose &pose) override {
40  tf::Transform base2map = tf::Transform{
42  tf::Vector3(pose.x, pose.y, 0.0)}.inverse();
43  {
44  std::lock_guard<std::mutex> lock{_map2odom_mutex};
45  _map2odom = (_last_odom2base * base2map).inverse();
46  }
48  }
49 
50 private: //methods
51 
52  void publishing_loop() {
53  ros::Rate rate(1.0 / 0.05);
54  while (ros::ok()) {
56  rate.sleep();
57  }
58  }
59 
61  _map2odom_mutex.lock();
65  _map2odom_mutex.unlock();
66  }
67 private: // fields
72  std::mutex _map2odom_mutex;
73  std::thread _transform_publisher;
74 };
75 
76 #endif
static tf::Quaternion createQuaternionFromRPY(double roll, double pitch, double yaw)
double theta
Definition: robot_pose.h:131
tf::TransformBroadcaster _tf_brcst
TFSIMD_FORCE_INLINE void setZ(tfScalar z)
std::string tf_odom_frame_id(const PropertiesProvider &props)
Definition: init_utils.h:29
virtual void handle_transformed_msg(const boost::shared_ptr< ObservationType >, const tf::StampedTransform &t) override
TFSIMD_FORCE_INLINE Quaternion inverse(const Quaternion &q)
ROSCPP_DECL bool ok()
void sendTransform(const StampedTransform &transform)
PoseCorrectionTfPublisher(const std::string &tf_map_frame_id, const std::string &tf_odom_frame_id, bool is_async=false)
TFSIMD_FORCE_INLINE Vector3 & getOrigin()
bool sleep()
virtual void on_pose_update(const RobotPose &pose) override
double y
Definition: robot_pose.h:131
static Time now()
std::string tf_map_frame_id()
Definition: init_utils.h:33
double x
Definition: robot_pose.h:131


slam_constructor
Author(s): JetBrains Research, OSLL team
autogenerated on Mon Jun 10 2019 15:08:25