36 #include <interactive_marker_proxy/GetInit.h> 53 std::map<std::string, visualization_msgs::InteractiveMarker>
int_markers_;
55 Proxy(std::string target_frame, std::string topic_ns) :
56 client_(tf_, target_frame, topic_ns), topic_ns_(topic_ns), target_frame_(target_frame)
67 pub_ = nh_.
advertise<visualization_msgs::InteractiveMarkerUpdate>(topic_ns_ +
"/tunneled/update", 1000);
73 private_nh.
param<
double>(
"update_rate", update_rate, 30.0f);
77 typedef visualization_msgs::InteractiveMarkerInitConstPtr
InitConstPtr;
79 typedef visualization_msgs::InteractiveMarkerUpdatePtr
UpdatePtr;
86 bool getInit(interactive_marker_proxy::GetInit::Request& request,
87 interactive_marker_proxy::GetInit::Response& response)
90 std::vector< visualization_msgs::InteractiveMarker > markers;
91 std::map<std::string, visualization_msgs::InteractiveMarker>::iterator it;
92 for( it = int_markers_.begin(); it!=int_markers_.end(); it++ )
94 response.msg.markers.push_back(it->second);
101 const visualization_msgs::InteractiveMarkerUpdate::_erases_type& erases = up_msg->erases;
102 for (
unsigned i = 0; i < erases.size(); i++)
104 int_markers_.erase(erases[i]);
107 const visualization_msgs::InteractiveMarkerUpdate::_poses_type& poses = up_msg->poses;
108 for (
unsigned i = 0; i < poses.size(); i++)
110 int_markers_[poses[i].name].pose = poses[i].pose;
111 int_markers_[poses[i].name].header = poses[i].header;
114 const visualization_msgs::InteractiveMarkerUpdate::_markers_type& markers = up_msg->markers;
115 for (
unsigned i = 0; i < markers.size(); i++)
117 int_markers_[markers[i].name] = markers[i];
123 void initCb(
const InitConstPtr& init_msg)
125 UpdatePtr
update(
new visualization_msgs::InteractiveMarkerUpdate());
126 update->markers = init_msg->markers;
127 update->seq_num = init_msg->seq_num;
128 update->server_id = init_msg->server_id;
130 int_markers_.clear();
136 if ( status_text_.find(server_id) != status_text_.end() &&
137 status_text_[server_id] == status_text )
141 status_text_[server_id] = status_text;
142 std::string status_string[] = {
"INFO",
"WARN",
"ERROR"};
143 ROS_INFO_STREAM(
"(" << status_string[(
unsigned)status] <<
") " << server_id <<
": " << status_text);
151 int main(
int argc,
char **argv)
153 ros::init(argc, argv,
"interactive_marker_proxy");
std::string target_frame_
void updateCb(const UpdateConstPtr &up_msg)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
void statusCb(InteractiveMarkerClient::StatusT status, const std::string &server_id, const std::string &status_text)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
visualization_msgs::InteractiveMarkerInitConstPtr InitConstPtr
int main(int argc, char **argv)
std::map< std::string, std::string > status_text_
void timerCb(const ros::TimerEvent &)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
INTERACTIVE_MARKERS_PUBLIC void setInitCb(const InitCallback &cb)
tf::TransformListener tf_
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void publish(const boost::shared_ptr< M > &message) const
INTERACTIVE_MARKERS_PUBLIC void setResetCb(const ResetCallback &cb)
INTERACTIVE_MARKERS_PUBLIC void subscribe(std::string topic_ns)
INTERACTIVE_MARKERS_PUBLIC void setUpdateCb(const UpdateCallback &cb)
INTERACTIVE_MARKERS_PUBLIC void setStatusCb(const StatusCallback &cb)
void resetCb(const std::string &server_id)
Proxy(std::string target_frame, std::string topic_ns)
std::string resolveName(const std::string &name, bool remap=true) const
visualization_msgs::InteractiveMarkerUpdateConstPtr UpdateConstPtr
interactive_markers::InteractiveMarkerClient client_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
visualization_msgs::InteractiveMarkerUpdatePtr UpdatePtr
#define ROS_INFO_STREAM(args)
void initCb(const InitConstPtr &init_msg)
bool getInit(interactive_marker_proxy::GetInit::Request &request, interactive_marker_proxy::GetInit::Response &response)
ros::ServiceServer service_
INTERACTIVE_MARKERS_PUBLIC void update()
void updateCb(const UpdateConstPtr &msg)
std::map< std::string, visualization_msgs::InteractiveMarker > int_markers_