CARLA
 
载入中...
搜索中...
未找到
Timestamp.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8//这个指令确保头文件只会被编译一次,避免重复包含(多重定义)的错误。
9
10#include <cstdint>
11//包含 C++ 标准库中的 头文件,提供精确宽度的整数类型
12
13namespace carla {
14namespace client {
15
16 class Timestamp {
17 public:
18
19 Timestamp() = default;
20
22 std::size_t in_frame,
23 double in_elapsed_seconds,
24 double in_delta_seconds,
25 double in_platform_timestamp)
26 : frame(in_frame),
27 elapsed_seconds(in_elapsed_seconds),
28 delta_seconds(in_delta_seconds),
29 platform_timestamp(in_platform_timestamp) {}
30 //这个构造函数接受四个参数,初始化四个成员变量。
31 //in_frame:当前帧的序号。
32 //in_elapsed_seconds:模拟自当前情境开始以来的秒数。
33 // in_delta_seconds:模拟自上一帧以来经过的秒数。
34 // in_platform_timestamp:操作系统给出的秒数(例如,Unix 时间戳)。
35
36 /// 自模拟器启动以来经过的帧数。
37 std::size_t frame = 0u;
38
39 /// 模拟自当前情境开始以来经过的秒数。
40 double elapsed_seconds = 0.0;
41
42 /// 模拟自上一帧以来经过的秒数。
43 double delta_seconds = 0.0;
44
45 /// 进行此测量的帧的时间戳,以操作系统给出的秒数为单位。
46 double platform_timestamp = 0.0;
47
48 // 判断两个时间戳是否相等(基于帧数)
49 bool operator==(const Timestamp &rhs) const {
50 return frame == rhs.frame;
51 }
52
53 // 判断两个时间戳是否不相等
54 bool operator!=(const Timestamp &rhs) const {
55 return !(*this == rhs);
56 //这个==运算符重载用于比较两个Timestamp对象是否相等,判断依据是它们的frame数值是否相同。
57 }
58 };
59
60} // namespace client
61} // namespace carla
62
63
64namespace std {
65/**
66 * \brief 标准输出流操作
67 *
68 * \param[in/out] out 要写入的输出流
69 * \param[in] timestamp 输出流的时间戳
70 *
71 * \returns The stream object.
72 *
73 */
74 //时间戳的输出流操作符重载,用于打印时间戳对象
75inline std::ostream &operator<<(std::ostream &out, const ::carla::client::Timestamp &timestamp) {
76 out << "Timestamp(frame=" << std::to_string(timestamp.frame)
77 << ",elapsed_seconds=" << std::to_string(timestamp.elapsed_seconds)
78 << ",delta_seconds=" << std::to_string(timestamp.delta_seconds)
79 << ",platform_timestamp=" << std::to_string(timestamp.platform_timestamp) << ')';
80 return out;
81}
82} // namespace std
std::size_t frame
自模拟器启动以来经过的帧数。
Definition Timestamp.h:37
Timestamp(std::size_t in_frame, double in_elapsed_seconds, double in_delta_seconds, double in_platform_timestamp)
Definition Timestamp.h:21
double delta_seconds
模拟自上一帧以来经过的秒数。
Definition Timestamp.h:43
bool operator!=(const Timestamp &rhs) const
Definition Timestamp.h:54
double platform_timestamp
进行此测量的帧的时间戳,以操作系统给出的秒数为单位。
Definition Timestamp.h:46
double elapsed_seconds
模拟自当前情境开始以来经过的秒数。
Definition Timestamp.h:40
bool operator==(const Timestamp &rhs) const
Definition Timestamp.h:49
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
包含CARLA客户端相关类和函数的命名空间。
std::ostream & operator<<(std::ostream &out, const ::carla::client::Timestamp &timestamp)
标准输出流操作
Definition Timestamp.h:75