00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */ 00002 00003 #include <ros/ros.h> 00004 #include <visualization_msgs/Marker.h> 00005 #include <iostream> 00006 00007 class RvizMarkerStub 00008 { 00009 private: 00010 ros::NodeHandle nh_; 00011 ros::Subscriber marker_sub_; 00012 00013 int count_; 00014 visualization_msgs::Marker last_msg_; 00015 void marker_received_callback(const visualization_msgs::Marker & marker); 00016 00017 public: 00018 RvizMarkerStub(); 00019 00020 visualization_msgs::Marker get_last_marker(); 00021 int count_markers_received(); 00022 }; 00023 00024 RvizMarkerStub::RvizMarkerStub() : 00025 count_(0) 00026 { 00027 marker_sub_ = nh_.subscribe("visualization_marker", 1, & RvizMarkerStub::marker_received_callback, this); 00028 } 00029 00030 void 00031 RvizMarkerStub::marker_received_callback(const visualization_msgs::Marker & marker) 00032 { 00033 count_++; 00034 last_msg_ = marker; 00035 } 00036 00037 visualization_msgs::Marker 00038 RvizMarkerStub::get_last_marker() 00039 { 00040 return last_msg_; 00041 } 00042 00043 int 00044 RvizMarkerStub::count_markers_received() 00045 { 00046 return count_; 00047 }