Gazebo Sim
API Reference
9.0.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-sim
include
gz
sim
comms
MsgManager.hh
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
18
#ifndef GZ_SIM_MSGMANAGER_HH_
19
#define GZ_SIM_MSGMANAGER_HH_
20
21
#include <gz/msgs/dataframe.pb.h>
22
#include <gz/msgs/stringmsg_v.pb.h>
23
24
#include <deque>
25
#include <memory>
26
#include <string>
27
#include <unordered_map>
28
29
#include <
gz/transport/Node.hh
>
30
#include <gz/utils/ImplPtr.hh>
31
#include "gz/sim/config.hh"
32
#include "
gz/sim/Entity.hh
"
33
#include "
gz/sim/System.hh
"
34
35
namespace
gz
36
{
37
namespace
sim
38
{
39
// Inline bracket to help doxygen filtering.
40
inline
namespace
GZ_SIM_VERSION_NAMESPACE {
41
namespace
comms
42
{
44
using
DataQueue
=
std::deque<msgs::DataframeSharedPtr>
;
45
48
using
SubscriptionHandler
=
49
std::unordered_map<std::string, transport::Node::Publisher>
;
50
52
struct
AddressContent
53
{
55
public
:
DataQueue
inboundMsgs
;
56
58
public
:
DataQueue
outboundMsgs
;
59
61
public
:
SubscriptionHandler
subscriptions
;
62
64
public
:
std::string
modelName
;
65
67
public
:
sim::Entity
entity
;
68
};
69
72
using
Registry
=
std::unordered_map<std::string, AddressContent>
;
73
75
class
GZ_SIM_VISIBLE
MsgManager
76
{
78
public
:
MsgManager
();
79
88
public
:
bool
AddSubscriber
(
const
std::string
&_address,
89
const
std::string
&_modelName,
90
const
std::string
&_topic);
91
95
public
:
void
AddInbound
(
const
std::string
&_address,
96
const
msgs::DataframeSharedPtr &_msg);
97
101
public
:
void
AddOutbound
(
const
std::string
&_address,
102
const
msgs::DataframeSharedPtr &_msg);
103
108
public
:
bool
RemoveSubscriber
(
const
std::string
&_address,
109
const
std::string
&_topic);
110
115
public
:
bool
RemoveInbound
(
const
std::string
&_address,
116
const
msgs::DataframeSharedPtr &_msg);
117
122
public
:
bool
RemoveOutbound
(
const
std::string
&_address,
123
const
msgs::DataframeSharedPtr &_msg);
124
127
public
:
void
DeliverMsgs
();
128
132
public
:
const
Registry
&
DataConst
()
const
;
133
137
public
:
Registry
&
Data
();
138
142
public
:
Registry
Copy
()
const
;
143
146
public
:
void
Set
(
const
Registry
&_newContent);
147
149
GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
150
};
151
}
152
}
153
}
154
}
155
156
#endif