forked from gazebosim/gazebo-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgz_topic.hh
108 lines (86 loc) · 3.45 KB
/
gz_topic.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* Copyright (C) 2014 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GZ_TOPIC_HH_
#define _GZ_TOPIC_HH_
#include <string>
#include <vector>
#include "gz.hh"
namespace gazebo
{
/// \brief Topic command
class TopicCommand : public Command
{
/// \brief Constructor
public: TopicCommand();
// Documentation inherited
public: virtual void HelpDetailed();
// Documentation inherited
protected: virtual bool RunImpl();
/// \brief Output the topic list.
private: void List();
/// \brief Output information about a topic.
/// \param[in] _topic Topic to print info about.
private: void Info(const std::string &_topic);
/// \brief Output messages from a topic.
/// \param[in] _topic Topic to print messages from.
private: void Echo(const std::string &_topic);
/// \brief Get a TopicInfo message from a topic.
/// \param[in] _topic Topic to get info about.
/// \return The TopicInfo message about the _topic.
private: msgs::TopicInfo GetInfo(const std::string &_topic);
/// \brief Callback used by Echo() to receive topic messages.
/// \param[in] _data Data message from a topic.
private: void EchoCB(const std::string &_data);
/// \brief Callback used by Hz() to receive topic messages.
/// \param[in] _data Data message from a topic (unused).
private: void HzCB(const std::string &_data);
/// \brief Output Hz rate for a topic.
/// \param[in] _topic Topic name.
private: void Hz(const std::string &_topic);
/// \brief Subscription callback used by Bw().
/// \param[in] _data Message data.
private: void BwCB(const std::string &_data);
/// \brief Output bandwidth data for a topic.
/// \param[in] _topic Topic name.
private: void Bw(const std::string &_topic);
/// \brief View topic information using QT.
/// \param[in] _topic Name of the topic to view. Empty will bring up
/// a topic selector.
private: void View(const std::string &_topic);
/// \brief Publish message on to a topic.
/// \param[in] _topic Topic to publish message to.
/// \return True on success
private: bool Publish(const std::string &_topic);
/// \brief Send a request.
/// \param[in] _space Namespace of all topics.
/// \param[in] _requestType Type of request.
/// \return True on success
private: bool Request(const std::string &_space,
const std::string &_requestType);
/// \brief Message used to hold data received from EchoCB().
private: boost::shared_ptr<google::protobuf::Message> echoMsg;
/// \brief Node pointer.
private: transport::NodePtr node;
/// \brief Prev time a message was received.
private: common::Time prevMsgTime;
/// \brief Buffer of message sizes, used by Bw().
private: std::vector<int> bwBytes;
/// \brief Buffer of message publish times, used by Bw().
private: std::vector<common::Time> bwTime;
};
}
#endif