mc_rtc  2.15.0
ros.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_rtc_ros/api.h>
8 
9 #include <mc_rtc/config.h>
10 
11 #include <mc_rbdyn/Robots.h>
12 
13 #include <SpaceVecAlg/SpaceVecAlg>
14 
15 #include <Eigen/Geometry>
16 #include <map>
17 #include <memory>
18 #include <string>
19 #include <vector>
20 
21 namespace rclcpp
22 {
23 class Node;
24 }
25 
26 namespace mc_rbdyn
27 {
28 struct Robot;
29 }
30 
31 namespace mc_control
32 {
33 struct MCGlobalController;
34 } // namespace mc_control
35 
36 namespace mc_rtc
37 {
38 struct ROSBridgeImpl;
39 
40 using NodeHandlePtr = std::shared_ptr<rclcpp::Node>;
41 
44 {
52 
58  static void set_publisher_timestep(double timestep);
59 
65  static double get_publisher_timestep();
66 
80  static void init_robot_publisher(const std::string & publisher,
81  double dt,
82  const mc_rbdyn::Robot & robot,
83  bool use_real = false);
84 
96  static void update_robot_publisher(const std::string & publisher, double dt, const mc_rbdyn::Robot & robot);
97 
102  static void stop_robot_publisher(const std::string & publisher);
103 
108  static size_t nb_robot_publisher();
109 
114  static bool has_publisher(const std::string & topic);
115 
116  static void remove_extra_robot_publishers(const mc_rbdyn::Robots & robots);
117 
119  static void shutdown();
120 
121 private:
122  static ROSBridgeImpl & impl_();
123 };
124 
125 struct RobotPublisherImpl;
126 
134 {
135 public:
147  RobotPublisher(const std::string & prefix, double rate, double dt);
148 
151 
153  void init(const mc_rbdyn::Robot & robot, bool use_real = false);
154 
156  void update(double dt, const mc_rbdyn::Robot & robot);
157 
159  void set_rate(double rate);
160 
161 private:
162  std::unique_ptr<RobotPublisherImpl> impl;
163 };
164 
165 } // namespace mc_rtc
Definition: CompletionCriteria.h:11
Definition: generic_gripper.h:15
auto Robot(const std::string &name, GetT get_fn)
Definition: Robot.h:56
Definition: Contact.h:88
std::shared_ptr< rclcpp::Node > NodeHandlePtr
Definition: ros.h:40
Definition: ros.h:22
#define MC_RTC_ROS_DLLAPI
Definition: api.h:50
Definition: Robot.h:63
Definition: Robots.h:17
Allows to access ROS functionalities within mc_rtc without explicit ROS dependencies.
Definition: ros.h:44
static void update_robot_publisher(const std::string &publisher, double dt, const mc_rbdyn::Robot &robot)
static NodeHandlePtr get_node_handle()
Get a ros::NodeHandle/rclcpp::Node.
static void stop_robot_publisher(const std::string &publisher)
static void remove_extra_robot_publishers(const mc_rbdyn::Robots &robots)
static void init_robot_publisher(const std::string &publisher, double dt, const mc_rbdyn::Robot &robot, bool use_real=false)
static double get_publisher_timestep()
static bool has_publisher(const std::string &topic)
static void shutdown()
Stop ROS.
static void set_publisher_timestep(double timestep)
static size_t nb_robot_publisher()
This structure is able to publish a Robot's state to ROS.
Definition: ros.h:134
void init(const mc_rbdyn::Robot &robot, bool use_real=false)
Initialize the publisher.
void set_rate(double rate)
Reset the publishing rate.
~RobotPublisher()
Destructor.
RobotPublisher(const std::string &prefix, double rate, double dt)
void update(double dt, const mc_rbdyn::Robot &robot)
Update the publisher.