CARLA
载入中...
搜索中...
未找到
LibCarla
source
carla
ros2
listeners
CarlaListener.cpp
浏览该文件的文档.
1
#define _GLIBCXX_USE_CXX11_ABI 0
2
3
#include "
CarlaListener.h
"
4
#include <iostream>
5
6
#include <fastdds/dds/publisher/DataWriterListener.hpp>
7
#include <fastdds/dds/core/status/PublicationMatchedStatus.hpp>
8
9
namespace
carla
{
10
namespace
ros2 {
11
12
namespace
efd = eprosima::fastdds::dds;
13
14
class
CarlaListenerImpl
:
public
efd::DataWriterListener
{
15
public
:
16
void
on_publication_matched
(
17
efd::DataWriter* writer,
18
const
efd::PublicationMatchedStatus& info)
override
;
19
20
21
int
_matched
{0};
22
bool
_first_connected
{
false
};
23
};
24
25
void
CarlaListenerImpl::on_publication_matched
(efd::DataWriter* writer,
const
efd::PublicationMatchedStatus& info)
26
{
27
if
(info.current_count_change == 1) {
28
_matched
= info.total_count;
29
_first_connected
=
true
;
30
}
else
if
(info.current_count_change == -1) {
31
_matched
= info.total_count;
32
}
else
{
33
std::cerr << info.current_count_change
34
<<
" is not a valid value for PublicationMatchedStatus current count change"
<< std::endl;
35
}
36
}
37
38
CarlaListener::CarlaListener
() :
39
_impl(
std
::make_unique<
CarlaListenerImpl
>()) { }
40
41
CarlaListener::~CarlaListener
() {}
42
43
}}
CarlaListener.h
carla::ros2::CarlaListenerImpl
Definition
CarlaListener.cpp:14
carla::ros2::CarlaListenerImpl::_matched
int _matched
Definition
CarlaListener.cpp:21
carla::ros2::CarlaListenerImpl::on_publication_matched
void on_publication_matched(efd::DataWriter *writer, const efd::PublicationMatchedStatus &info) override
Definition
CarlaListener.cpp:25
carla::ros2::CarlaListenerImpl::_first_connected
bool _first_connected
Definition
CarlaListener.cpp:22
carla::ros2::CarlaListener::~CarlaListener
~CarlaListener()
Definition
CarlaListener.cpp:41
carla::ros2::CarlaListener::CarlaListener
CarlaListener()
Definition
CarlaListener.cpp:38
eprosima::fastdds::dds::DataWriterListener
carla
This file contains definitions of common data structures used in traffic manager.
Definition
Carla.cpp:133
std
Definition
CarlaRecorderCollision.h:31
制作者
1.10.0