cnoid_ros_utils
PosePublisherItem.h
Go to the documentation of this file.
1 /* Author: Masaki Murooka */
2 
3 #pragma once
4 
5 #include <cnoid/Archive>
6 #include <cnoid/Item>
7 #include <cnoid/SimulatorItem>
8 #include <cnoid/WorldItem>
9 
10 #include <ros/ros.h>
11 #include <tf2_ros/transform_broadcaster.h>
12 #include <eigen_conversions/eigen_msg.h>
13 
14 namespace CnoidRosUtils
15 {
30 class PosePublisherItem : public cnoid::Item
31 {
32 public:
33  static void initialize(cnoid::ExtensionManager * ext);
34 
35  inline static bool initialized_ = false;
36 
37 public:
39 
41 
43 
44 protected:
45  virtual cnoid::Item * doDuplicate() const override;
46 
47  virtual void doPutProperties(cnoid::PutPropertyFunction & putProperty) override;
48 
49  virtual bool store(cnoid::Archive & archive) override;
50 
51  virtual bool restore(const cnoid::Archive & archive) override;
52 
53  void setup();
54 
55  bool start();
56 
57  void stop();
58 
59  void onPostDynamics();
60 
61  int getPubSkip() const;
62 
63 protected:
64  cnoid::WorldItemPtr world_;
65  cnoid::SimulatorItemPtr sim_;
66 
67  std::set<std::string> hooked_sims_;
68 
70 
71  cnoid::BodyItem * body_item_;
72 
73  std::string link_name_ = "";
74 
75  bool output_tf_ = false;
76 
77  std::shared_ptr<ros::NodeHandle> nh_;
78  std::string frame_id_ = "";
79  std::string pose_topic_name_ = "";
80  std::string vel_topic_name_ = "";
81  std::string tf_child_frame_id_ = "";
82  double pub_rate_ = 30.0;
83  ros::Publisher pose_pub_;
84  ros::Publisher vel_pub_;
85  std::shared_ptr<tf2_ros::TransformBroadcaster> tf_br_;
86 
87  int sim_cnt_ = 0;
88  int pub_skip_ = 0;
89 };
90 } // namespace CnoidRosUtils
CnoidRosUtils::PosePublisherItem::vel_topic_name_
std::string vel_topic_name_
Definition: PosePublisherItem.h:80
CnoidRosUtils::PosePublisherItem::doDuplicate
virtual cnoid::Item * doDuplicate() const override
Definition: PosePublisherItem.cpp:53
CnoidRosUtils::PosePublisherItem::post_dynamics_func_id_
int post_dynamics_func_id_
Definition: PosePublisherItem.h:69
CnoidRosUtils::PosePublisherItem::initialized_
static bool initialized_
Definition: PosePublisherItem.h:35
CnoidRosUtils::PosePublisherItem::nh_
std::shared_ptr< ros::NodeHandle > nh_
Definition: PosePublisherItem.h:77
CnoidRosUtils::PosePublisherItem::frame_id_
std::string frame_id_
Definition: PosePublisherItem.h:78
CnoidRosUtils::PosePublisherItem
Plugin item to publish topics and broadcast TF of pose and velocity of the model.
Definition: PosePublisherItem.h:30
CnoidRosUtils::PosePublisherItem::hooked_sims_
std::set< std::string > hooked_sims_
Definition: PosePublisherItem.h:67
CnoidRosUtils::PosePublisherItem::output_tf_
bool output_tf_
Definition: PosePublisherItem.h:75
CnoidRosUtils::PosePublisherItem::store
virtual bool store(cnoid::Archive &archive) override
Definition: PosePublisherItem.cpp:77
CnoidRosUtils::PosePublisherItem::stop
void stop()
Definition: PosePublisherItem.cpp:173
CnoidRosUtils::PosePublisherItem::pub_skip_
int pub_skip_
Definition: PosePublisherItem.h:88
CnoidRosUtils::PosePublisherItem::vel_pub_
ros::Publisher vel_pub_
Definition: PosePublisherItem.h:84
CnoidRosUtils::PosePublisherItem::setup
void setup()
Definition: PosePublisherItem.cpp:103
CnoidRosUtils::PosePublisherItem::~PosePublisherItem
~PosePublisherItem()
Definition: PosePublisherItem.cpp:48
CnoidRosUtils::PosePublisherItem::body_item_
cnoid::BodyItem * body_item_
Definition: PosePublisherItem.h:71
CnoidRosUtils::PosePublisherItem::start
bool start()
Definition: PosePublisherItem.cpp:126
CnoidRosUtils::PosePublisherItem::pose_topic_name_
std::string pose_topic_name_
Definition: PosePublisherItem.h:79
CnoidRosUtils::PosePublisherItem::tf_child_frame_id_
std::string tf_child_frame_id_
Definition: PosePublisherItem.h:81
CnoidRosUtils::PosePublisherItem::onPostDynamics
void onPostDynamics()
Definition: PosePublisherItem.cpp:183
CnoidRosUtils::PosePublisherItem::getPubSkip
int getPubSkip() const
Definition: PosePublisherItem.cpp:253
CnoidRosUtils::PosePublisherItem::sim_cnt_
int sim_cnt_
Definition: PosePublisherItem.h:87
CnoidRosUtils::PosePublisherItem::pose_pub_
ros::Publisher pose_pub_
Definition: PosePublisherItem.h:83
CnoidRosUtils::PosePublisherItem::world_
cnoid::WorldItemPtr world_
Definition: PosePublisherItem.h:64
CnoidRosUtils::PosePublisherItem::tf_br_
std::shared_ptr< tf2_ros::TransformBroadcaster > tf_br_
Definition: PosePublisherItem.h:85
CnoidRosUtils::PosePublisherItem::PosePublisherItem
PosePublisherItem()
Definition: PosePublisherItem.cpp:35
CnoidRosUtils::PosePublisherItem::restore
virtual bool restore(const cnoid::Archive &archive) override
Definition: PosePublisherItem.cpp:90
CnoidRosUtils::PosePublisherItem::initialize
static void initialize(cnoid::ExtensionManager *ext)
Definition: PosePublisherItem.cpp:18
CnoidRosUtils::PosePublisherItem::doPutProperties
virtual void doPutProperties(cnoid::PutPropertyFunction &putProperty) override
Definition: PosePublisherItem.cpp:58
CnoidRosUtils::PosePublisherItem::pub_rate_
double pub_rate_
Definition: PosePublisherItem.h:82
CnoidRosUtils::PosePublisherItem::sim_
cnoid::SimulatorItemPtr sim_
Definition: PosePublisherItem.h:65
CnoidRosUtils::PosePublisherItem::link_name_
std::string link_name_
Definition: PosePublisherItem.h:73
CnoidRosUtils
Definition: ClockPublisherItem.h:13