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 <tf2_ros/buffer.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,
68  tf2_ros::Buffer& tf,
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
130 
131  // queue for init messages
133 
135  std::string target_frame_;
136 
138 
139  std::string server_id_;
140 
142 };
143 
144 }
145 
146 #endif /* SINGLE_CLIENT_H_ */
interactive_markers::SingleClient
Definition: single_client.h:62
interactive_markers::SingleClient::warn_keepalive_
bool warn_keepalive_
Definition: single_client.h:141
interactive_markers::SingleClient::state_
StateMachine< StateT > state_
Definition: single_client.h:100
interactive_markers::SingleClient::first_update_seq_num_
uint64_t first_update_seq_num_
Definition: single_client.h:111
interactive_markers::SingleClient::process
void process(const visualization_msgs::InteractiveMarkerUpdate::ConstPtr &msg, bool enable_autocomplete_transparency=true)
Definition: single_client.cpp:88
buffer.h
interactive_markers::StateMachine
Definition: state_machine.h:48
interactive_markers::SingleClient::checkInitFinished
void checkInitFinished()
Definition: single_client.cpp:190
interactive_markers::SingleClient::update_queue_
M_UpdateMessageContext update_queue_
Definition: single_client.h:129
interactive_markers::SingleClient::StateT
StateT
Definition: single_client.h:93
interactive_markers::SingleClient::UpdateMessageContext
MessageContext< visualization_msgs::InteractiveMarkerUpdate > UpdateMessageContext
Definition: single_client.h:121
interactive_markers::SingleClient::init_queue_
M_InitMessageContext init_queue_
Definition: single_client.h:132
interactive_markers::SingleClient::INIT
@ INIT
Definition: single_client.h:95
interactive_markers::SingleClient::update_time_ok_
bool update_time_ok_
Definition: single_client.h:119
interactive_markers::SingleClient::transformInitMsgs
void transformInitMsgs()
Definition: single_client.cpp:235
interactive_markers::SingleClient::M_UpdateMessageContext
std::deque< UpdateMessageContext > M_UpdateMessageContext
Definition: single_client.h:125
interactive_markers::SingleClient::last_update_seq_num_
uint64_t last_update_seq_num_
Definition: single_client.h:114
tf2_ros::Buffer
interactive_markers::SingleClient::TF_ERROR
@ TF_ERROR
Definition: single_client.h:97
state_machine.h
interactive_markers::MessageContext
Definition: message_context.h:49
interactive_markers::SingleClient::~SingleClient
~SingleClient()
Definition: single_client.cpp:61
interactive_markers::SingleClient::M_InitMessageContext
std::deque< InitMessageContext > M_InitMessageContext
Definition: single_client.h:126
interactive_markers::SingleClient::tf_
tf2_ros::Buffer & tf_
Definition: single_client.h:134
interactive_markers::SingleClient::transformUpdateMsgs
void transformUpdateMsgs()
Definition: single_client.cpp:256
interactive_markers::SingleClient::last_update_time_
ros::Time last_update_time_
Definition: single_client.h:115
interactive_markers::SingleClient::checkKeepAlive
void checkKeepAlive()
Definition: single_client.cpp:173
interactive_markers::SingleClient::SingleClient
SingleClient(const std::string &server_id, tf2_ros::Buffer &tf, const std::string &target_frame, const InteractiveMarkerClient::CbCollection &callbacks)
Definition: single_client.cpp:43
ros::Time
interactive_markers::SingleClient::update
void update()
Definition: single_client.cpp:143
interactive_markers::SingleClient::target_frame_
std::string target_frame_
Definition: single_client.h:135
target_frame
std::string target_frame
Definition: client_test.cpp:72
interactive_markers::InteractiveMarkerClient::CbCollection
Definition: interactive_marker_client.h:174
interactive_markers
Definition: message_context.h:45
interactive_markers::SingleClient::pushUpdates
void pushUpdates()
Definition: single_client.cpp:295
message_context.h
interactive_markers::SingleClient::isInitialized
bool isInitialized()
Definition: single_client.cpp:309
interactive_markers::SingleClient::RECEIVING
@ RECEIVING
Definition: single_client.h:96
interactive_markers::SingleClient::callbacks_
const InteractiveMarkerClient::CbCollection & callbacks_
Definition: single_client.h:137
interactive_markers::SingleClient::errorReset
void errorReset(std::string error_msg)
Definition: single_client.cpp:281
interactive_markers::SingleClient::InitMessageContext
MessageContext< visualization_msgs::InteractiveMarkerInit > InitMessageContext
Definition: single_client.h:122
interactive_markers::SingleClient::server_id_
std::string server_id_
Definition: single_client.h:139


interactive_markers
Author(s): David Gossow, William Woodall
autogenerated on Fri Oct 27 2023 02:31:54