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 <SpaceVecAlg/SpaceVecAlg>
12 
13 #include <Eigen/Geometry>
14 #include <map>
15 #include <memory>
16 #include <string>
17 #include <vector>
18 
19 #ifdef MC_RTC_ROS_IS_ROS2
20 namespace rclcpp
21 {
22 class Node;
23 }
24 #else
25 namespace ros
26 {
27 class NodeHandle;
28 }
29 #endif
30 
31 namespace mc_rbdyn
32 {
33 struct Robot;
34 }
35 
36 namespace mc_control
37 {
38 struct MCGlobalController;
39 } // namespace mc_control
40 
41 namespace mc_rtc
42 {
43 
44 struct ROSBridgeImpl;
45 
46 #ifdef MC_RTC_ROS_IS_ROS2
47 using NodeHandlePtr = std::shared_ptr<rclcpp::Node>;
48 #else
49 using NodeHandlePtr = std::shared_ptr<ros::NodeHandle>;
50 #endif
51 
54 {
61  static NodeHandlePtr get_node_handle();
62 
68  static void set_publisher_timestep(double timestep);
69 
81  static void init_robot_publisher(const std::string & publisher,
82  double dt,
83  const mc_rbdyn::Robot & robot,
84  bool use_real = false);
85 
95  static void update_robot_publisher(const std::string & publisher, double dt, const mc_rbdyn::Robot & robot);
96 
101  static void stop_robot_publisher(const std::string & publisher);
102 
104  static void shutdown();
105 
106 private:
107  static ROSBridgeImpl & impl_();
108 };
109 
110 struct RobotPublisherImpl;
111 
119 {
120 public:
132  RobotPublisher(const std::string & prefix, double rate, double dt);
133 
135  ~RobotPublisher();
136 
138  void init(const mc_rbdyn::Robot & robot, bool use_real = false);
139 
141  void update(double dt, const mc_rbdyn::Robot & robot);
142 
144  void set_rate(double rate);
145 
146 private:
147  std::unique_ptr<RobotPublisherImpl> impl;
148 };
149 
150 } // namespace mc_rtc
ros
Definition: ros.h:25
mc_rbdyn::Robot
Definition: Robot.h:62
api.h
mc_rtc::NodeHandlePtr
std::shared_ptr< ros::NodeHandle > NodeHandlePtr
Definition: ros.h:49
mc_rtc::ROSBridge
Allows to access ROS functionalities within mc_rtc without explicit ROS dependencies.
Definition: ros.h:53
MC_RTC_ROS_DLLAPI
#define MC_RTC_ROS_DLLAPI
Definition: api.h:50
mc_rtc::RobotPublisher
This structure is able to publish a Robot's state to ROS.
Definition: ros.h:118
mc_control
Definition: CompletionCriteria.h:10
mc_rbdyn
Definition: generic_gripper.h:14
mc_rtc::gui::Robot
auto Robot(const std::string &name, GetT get_fn)
Definition: Robot.h:56
mc_rtc
Definition: Contact.h:87