semio_ros  0.10.6
humanoid_source_ros.h
Go to the documentation of this file.
1 #ifndef _SEMIO_ROS_HUMANOIDSOURCEROS_H_
2 #define _SEMIO_ROS_HUMANOIDSOURCEROS_H_
3 
5 #include <ros/node_handle.h>
6 #include <semio_msgs_ros/Humanoids.h>
7 
8 namespace semio
9 {
10 
11 namespace ros
12 {
13 
14 //! semio::HumanoidSource to source humanoids from ROS
15 /**
16 @par ROS Topics
17 <table>
18 <tr><th>Topic</th><th>Type</th><th>Description</th></tr>
19 <tr><td colspan="3" align="center">@b Subscriptions</td></tr>
20 <tr><td>variable; see @p topic param of @ref HumanoidSourceROS()</td><td>@ref semio_msgs_ros<a href=Humanoids_8msg_source.html><b>/Humanoids</b></a></td><td>#_HumanoidsMsg messages to convert to @c semio::HumanoidArray</td></tr>
21 </table>
22 */
24 {
25 public:
26  //! ROS message for a vector of humanoids
27  typedef semio_msgs_ros::Humanoids _HumanoidsMsg;
28  //! ROS message for a single humanoid
29  typedef semio_msgs_ros::Humanoid _HumanoidMsg;
30  //! ROS message for a humanoid joint
31  typedef semio_msgs_ros::HumanoidJoint _HumanoidJointMsg;
32 
33 protected:
34  //! NodeHandle copy for interfacing with ROS
35  ::ros::NodeHandle _nh_rel;
36  //! Subscriber for humanoid messages
37  ::ros::Subscriber _humanoids_sub;
38  //! ConstPtr to the last message received from ROS
39  _HumanoidsMsg::ConstPtr _last_humanoids_msg;
40 
41 public:
42  /**
43  @param nh_rel @copybrief _nh_rel
44  @param topic ROS topic on which to look for humanoids
45  */
46  HumanoidSourceROS( ::ros::NodeHandle const & nh_rel, std::string const & topic = "humanoids" );
47 
48  //! Create a semio::HumanoidJoint from a humanoid joint message
49  /**
50  @param msg ConstPtr to the humanoid joint message
51  @return A semio::HumanoidJoint initialized from the data in @p msg
52  */
53  static HumanoidJoint fromROSMsg( _HumanoidJointMsg const & msg );
54  //! Create a semio::Humanoid from a humanoid message
55  /**
56  @param msg ConstPtr to the humanoid message
57  @return A semio::Humanoid initialized from the data in @p msg
58  */
59  static Humanoid fromROSMsg( _HumanoidMsg const & msg );
60  //! Create a semio::HumanoidArray from a humanoids message
61  /**
62  @param msg ConstPtr to the humanoids message
63  @return A semio::HumanoidArray initialized from the data in @p msg
64  */
65  static HumanoidArray fromROSMsg( _HumanoidsMsg const & msg );
66 
67 protected:
68  //! Convert #_last_humanoids_msg to a semio::HumanoidArray
69  /**
70  @return #_last_humanoids_msg converted to a semio::HumanoidArray
71  @post #_last_humanoids_msg is released via _HumanoidsMsg::ConstPtr::reset()
72  @note Result will be empty if #_last_humanoids_msg is undefined (no messages have been received since last updateFromSource())
73  */
75 
76  //! ROS callback for humanoids messages
77  /**
78  @param msg ConstPtr to the humanoids message
79  @post #_last_humanoids_msg shares ownership of message data with @p msg
80  */
81  void humanoidsCB( _HumanoidsMsg::ConstPtr const & msg );
82 };
83 
84 }
85 
86 }
87 
88 #endif // _SEMIO_ROS_HUMANOIDSOURCEROS_H_
::ros::Subscriber _humanoids_sub
Subscriber for humanoid messages.
semio_msgs_ros::HumanoidJoint _HumanoidJointMsg
ROS message for a humanoid joint.
HumanoidSourceROS(::ros::NodeHandle const &nh_rel, std::string const &topic="humanoids")
::ros::NodeHandle _nh_rel
NodeHandle copy for interfacing with ROS.
void humanoidsCB(_HumanoidsMsg::ConstPtr const &msg)
ROS callback for humanoids messages.
semio_msgs_ros::Humanoids _HumanoidsMsg
ROS message for a vector of humanoids.
static HumanoidJoint fromROSMsg(_HumanoidJointMsg const &msg)
Create a semio::HumanoidJoint from a humanoid joint message.
_HumanoidsMsg::ConstPtr _last_humanoids_msg
ConstPtr to the last message received from ROS.
semio::HumanoidSource to source humanoids from ROS
HumanoidArray updateFromSource()
Convert _last_humanoids_msg to a semio::HumanoidArray.
std::vector< semio::Humanoid > HumanoidArray
semio_msgs_ros::Humanoid _HumanoidMsg
ROS message for a single humanoid.