single_client.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Author: David Gossow
30  *//*
31  * single_client.h
32  *
33  * Created on: Jul 17, 2012
34  * Author: gossow
35  */
36 
37 #ifndef SINGLE_CLIENT_H_
38 #define SINGLE_CLIENT_H_
39 
40 #include <visualization_msgs/InteractiveMarkerInit.h>
41 #include <visualization_msgs/InteractiveMarkerUpdate.h>
42 
43 #include <boost/scoped_ptr.hpp>
44 #include <boost/thread/thread.hpp>
45 #include <boost/thread/recursive_mutex.hpp>
46 
47 #include <boost/function.hpp>
48 #include <boost/unordered_map.hpp>
49 
50 #include <tf/tf.h>
51 
52 #include <deque>
53 
54 #include "message_context.h"
55 #include "state_machine.h"
56 #include "../interactive_marker_client.h"
57 
58 
59 namespace interactive_markers
60 {
61 
63 {
64 public:
65 
67  const std::string& server_id,
69  const std::string& target_frame,
70  const InteractiveMarkerClient::CbCollection& callbacks );
71 
72  ~SingleClient();
73 
74  // Process message from the update channel
75  void process(const visualization_msgs::InteractiveMarkerUpdate::ConstPtr& msg, bool enable_autocomplete_transparency = true);
76 
77  // Process message from the init channel
78  void process(const visualization_msgs::InteractiveMarkerInit::ConstPtr& msg, bool enable_autocomplete_transparency = true);
79 
80  // true if INIT messages are not needed anymore
81  bool isInitialized();
82 
83  // transform all messages with missing transforms
84  void update();
85 
86 private:
87 
88  // check if we can go from init state to normal operation
89  void checkInitFinished();
90 
91  void checkKeepAlive();
92 
93  enum StateT
94  {
98  };
99 
101 
102  // updateTf implementation (for one queue)
103  void transformInitMsgs( );
104  void transformUpdateMsgs( );
105 
106  void pushUpdates();
107 
108  void errorReset( std::string error_msg );
109 
110  // sequence number and time of first ever received update
112 
113  // sequence number and time of last received update
116 
117  // true if the last outgoing update is too long ago
118  // and we've already sent a notification of that
120 
123 
124  // Queue of Updates waiting for tf and numbering
125  typedef std::deque< UpdateMessageContext > M_UpdateMessageContext;
126  typedef std::deque< InitMessageContext > M_InitMessageContext;
127 
128  // queue for update messages
129  M_UpdateMessageContext update_queue_;
130 
131  // queue for init messages
132  M_InitMessageContext init_queue_;
133 
135  std::string target_frame_;
136 
138 
139  std::string server_id_;
140 
142 };
143 
144 }
145 
146 #endif /* SINGLE_CLIENT_H_ */
MessageContext< visualization_msgs::InteractiveMarkerInit > InitMessageContext
MessageContext< visualization_msgs::InteractiveMarkerUpdate > UpdateMessageContext
std::deque< InitMessageContext > M_InitMessageContext
M_UpdateMessageContext update_queue_
std::string target_frame
Definition: client_test.cpp:74
M_InitMessageContext init_queue_
void errorReset(std::string error_msg)
void process(const visualization_msgs::InteractiveMarkerUpdate::ConstPtr &msg, bool enable_autocomplete_transparency=true)
std::deque< UpdateMessageContext > M_UpdateMessageContext
const InteractiveMarkerClient::CbCollection & callbacks_
StateMachine< StateT > state_
SingleClient(const std::string &server_id, tf::Transformer &tf, const std::string &target_frame, const InteractiveMarkerClient::CbCollection &callbacks)


interactive_markers
Author(s): David Gossow, William Woodall
autogenerated on Mon Feb 28 2022 22:33:22