CARLA
 
载入中...
搜索中...
未找到
CarlaClockPublisher.h
浏览该文件的文档.
1// Copyright (c) 2022 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB).
2// This work is licensed under the terms of the MIT license.
3// For a copy, see <https://opensource.org/licenses/MIT>.
4
5#pragma once
6#define _GLIBCXX_USE_CXX11_ABI 0
7
8#include <memory>
9#include <vector>
10
11#include "CarlaPublisher.h"
12/**
13 * @namespace carla::ros2
14 * @brief 命名空间carla::ros2,包含了与CARLA和ROS 2集成相关的类和函数。
15 */
16namespace carla {
17namespace ros2 {
18 /**
19 * @struct CarlaClockPublisherImpl
20 * @brief CarlaClockPublisher的内部实现结构体,用于隐藏实现细节。
21 */
22 struct CarlaClockPublisherImpl;
23 /**
24 * @class CarlaClockPublisher
25 * @brief 用于发布CARLA时钟信息的ROS 2发布者类。
26 *
27 * 此类继承自CarlaPublisher,并专门用于发布时钟信息(如秒和纳秒)。
28 */
30 public:
31 /**
32 * @brief 构造函数,初始化CarlaClockPublisher。
33 *
34 * @param ros_name ROS 2节点的名称,默认为空字符串。
35 * @param parent 父节点的名称,默认为空字符串。
36 */
37 CarlaClockPublisher(const char* ros_name = "", const char* parent = "");
38 /**
39 * @brief 析构函数,清理资源并释放内部实现。
40 */
42 /**
43 * @brief 拷贝构造函数。
44 *
45 * @param other 要拷贝的CarlaClockPublisher对象。
46 */
48 /**
49 * @brief 赋值运算符。
50 *
51 * @param other 要赋值的CarlaClockPublisher对象。
52 * @return 引用到当前对象。
53 */
55 /**
56 * @brief 移动构造函数。
57 *
58 * @param other 要移动的CarlaClockPublisher对象。
59 */
61 /**
62 * @brief 移动赋值运算符。
63 *
64 * @param other 要移动赋值的CarlaClockPublisher对象。
65 * @return 引用到当前对象。
66 */
68 /**
69 * @brief 初始化发布者。
70 *
71 * @return 如果初始化成功,则返回true;否则返回false。
72 */
73 bool Init();
74 /**
75 * @brief 发布时钟信息。
76 *
77 * @return 如果发布成功,则返回true;否则返回false。
78 */
79 bool Publish();
80 /**
81 * @brief 设置要发布的时钟数据。
82 *
83 * @param sec 秒数。
84 * @param nanosec 纳秒数。
85 */
86 void SetData(int32_t sec, uint32_t nanosec);
87 /**
88 * @brief 重写基类中的type函数,返回此发布者的类型。
89 *
90 * @return 指向类型名称的常量字符指针,此处为"clock"。
91 */
92 const char* type() const override { return "clock"; }
93
94 private:
95 /**
96 * @brief 指向内部实现结构体的智能指针。
97 *
98 * 使用shared_ptr来管理CarlaClockPublisherImpl的生命周期,允许多个对象共享同一个实现。
99 */
100 std::shared_ptr<CarlaClockPublisherImpl> _impl;
101 };
102}
103}
用于发布CARLA时钟信息的ROS 2发布者类。
CarlaClockPublisher(const char *ros_name="", const char *parent="")
构造函数,初始化CarlaClockPublisher。
~CarlaClockPublisher()
析构函数,清理资源并释放内部实现。
const char * type() const override
重写基类中的type函数,返回此发布者的类型。
CarlaClockPublisher & operator=(const CarlaClockPublisher &)
赋值运算符。
std::shared_ptr< CarlaClockPublisherImpl > _impl
指向内部实现结构体的智能指针。
bool Init()
初始化发布者。
void SetData(int32_t sec, uint32_t nanosec)
设置要发布的时钟数据。
bool Publish()
发布时钟信息。
const std::string & parent() const
CARLA模拟器的主命名空间。
Definition Carla.cpp:139