Robowflex  v0.1
Making MoveIt Easy
broadcaster.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef ROBOWFLEX_IO_ROBOTBROADCASTER_
4 #define ROBOWFLEX_IO_ROBOTBROADCASTER_
5 
6 #include <thread>
7 
10 #include <tf2_ros/transform_broadcaster.h>
11 
12 namespace robowflex
13 {
14  /** \cond IGNORE */
17  /** \endcond */
18 
19  namespace IO
20  {
21  /** \brief Helper class to broadcast transform information on TF and joint states
22  */
24  {
25  public:
26  /** \brief Constructor. Sets up TF2 broadcaster.
27  * \param[in] robot Robot to broadcast.
28  * \param[in] base_frame Base frame to use for robot transforms.
29  * \param[in] name Namespace to use.
30  */
31  RobotBroadcaster(const RobotConstPtr &robot, const std::string &base_frame = "world",
32  const std::string &name = "robowflex");
33 
34  /** \brief Destructor.
35  */
37 
38  /** \brief Begin publishing TF and joint information.
39  */
40  void start();
41 
42  /** \brief Stop publishing TF and joint information.
43  */
44  void stop();
45 
46  /** \brief Add a new static transform to the broadcaster.
47  * \param[in] name Name of transform (used for removal)
48  * \param[in] base Base frame of transform.
49  * \param[in] target Target frame of transform.
50  * \param[in] tf The transform from \a base to \a target.
51  */
52  void addStaticTransform(const std::string &name, const std::string &base,
53  const std::string &target, const RobotPose &tf = RobotPose::Identity());
54 
55  /** \brief Remove a named static transform
56  * \param[in] name Name of transform to remove.
57  */
58  void removeStaticTransform(const std::string &name);
59 
60  private:
61  /** \brief Send out the TF and joint information.
62  */
63  void update();
64 
65  RobotConstPtr robot_; ///< Robot being published.
66  const std::string base_; ///< Base frame to use.
67  bool active_{false}; ///< Is thread active?
68  bool done_{false}; ///< Is thread done?
69  unsigned int rate_{10}; ///< Times per second to send out.
71  ros::NodeHandle nh_; ///< Handle for publishing.
72  tf2_ros::TransformBroadcaster tf2br_; ///< TF2 broadcaster
73  ros::Publisher state_pub_; ///< State publisher.
74 
75  /** \brief Information for a static transform.
76  */
78  {
79  std::string base; ///< Base frame
80  std::string target; ///< Target frame
81  RobotPose tf; ///< Transform
82  };
83 
85  };
86  } // namespace IO
87 } // namespace robowflex
88 
89 #endif
#define ROBOWFLEX_CLASS_FORWARD(C)
Macro that forward declares a class and defines two shared ptrs types:
Definition: class_forward.h:16
Helper class to broadcast transform information on TF and joint states.
Definition: broadcaster.h:24
RobotConstPtr robot_
Robot being published.
Definition: broadcaster.h:65
bool active_
Is thread active?
Definition: broadcaster.h:67
std::unique_ptr< std::thread > thread_
Worker thread.
Definition: broadcaster.h:70
void addStaticTransform(const std::string &name, const std::string &base, const std::string &target, const RobotPose &tf=RobotPose::Identity())
Add a new static transform to the broadcaster.
Definition: broadcaster.cpp:60
RobotBroadcaster(const RobotConstPtr &robot, const std::string &base_frame="world", const std::string &name="robowflex")
Constructor. Sets up TF2 broadcaster.
Definition: broadcaster.cpp:20
ros::NodeHandle nh_
Handle for publishing.
Definition: broadcaster.h:71
unsigned int rate_
Times per second to send out.
Definition: broadcaster.h:69
void stop()
Stop publishing TF and joint information.
Definition: broadcaster.cpp:55
std::map< std::string, StaticTransform > static_
Static transforms.
Definition: broadcaster.h:84
void start()
Begin publishing TF and joint information.
Definition: broadcaster.cpp:37
ros::Publisher state_pub_
State publisher.
Definition: broadcaster.h:73
void update()
Send out the TF and joint information.
Definition: broadcaster.cpp:85
const std::string base_
Base frame to use.
Definition: broadcaster.h:66
tf2_ros::TransformBroadcaster tf2br_
TF2 broadcaster.
Definition: broadcaster.h:72
bool done_
Is thread done?
Definition: broadcaster.h:68
void removeStaticTransform(const std::string &name)
Remove a named static transform.
Definition: broadcaster.cpp:76
A const shared pointer wrapper for robowflex::Robot.
Functions for loading and animating robots in Blender.
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
std::decay< decltype(std::declval< moveit::core::Transforms >().getTransform("")) >::type RobotPose
A pose (point in SE(3)) used in various functions. Defined from what MoveIt! uses.
Definition: adapter.h:24
Information for a static transform.
Definition: broadcaster.h:78