CARLA
载入中...
搜索中...
未找到
LibCarla
source
carla
rpc
LibCarla/source/carla/rpc/VehicleControl.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
#include "
carla/MsgPack.h
"
// 引入 MsgPack 库头文件,用于序列化
9
10
#ifdef LIBCARLA_INCLUDED_FROM_UE4
//
11
#include <
compiler/enable-ue4-macros.h
>
12
#include "
Carla/Vehicle/VehicleControl.h
"
// 引入与车辆控制相关的头文件
13
#include <
compiler/disable-ue4-macros.h
>
14
#endif
// LIBCARLA_INCLUDED_FROM_UE4 // 结束条件编译判断
15
16
namespace
carla
{
// carla 命名空间
17
namespace
rpc {
// rpc 命名空间
18
19
// 定义一个车辆控制类 VehicleControl
20
class
VehicleControl
{
21
public
:
22
23
VehicleControl
() =
default
;
// 默认构造函数,使用默认成员初始化
24
25
// 带参数的构造函数,初始化所有成员变量
26
VehicleControl
(
27
float
in_throttle,
// 油门
28
float
in_steer,
// 转向
29
float
in_brake,
// 刹车
30
bool
in_hand_brake,
// 手刹
31
bool
in_reverse,
// 倒车
32
bool
in_manual_gear_shift,
// 是否手动换挡
33
int32_t in_gear)
// 当前挡位
34
:
throttle
(in_throttle),
// 初始化油门
35
steer
(in_steer),
// 初始化转向
36
brake
(in_brake),
// 初始化刹车
37
hand_brake
(in_hand_brake),
// 初始化手刹
38
reverse
(in_reverse),
// 初始化倒车
39
manual_gear_shift
(in_manual_gear_shift),
// 初始化手动换挡
40
gear
(in_gear) {}
// 初始化挡位
41
42
// 定义所有成员变量
43
float
throttle
= 0.0f;
// 油门,默认值为 0.0
44
float
steer
= 0.0f;
// 转向,默认值为 0.0
45
float
brake
= 0.0f;
// 刹车,默认值为 0.0
46
bool
hand_brake
=
false
;
// 手刹,默认值为 false
47
bool
reverse
=
false
;
// 倒车,默认值为 false
48
bool
manual_gear_shift
=
false
;
// 是否手动换挡,默认值为 false
49
int32_t
gear
= 0;
// 当前挡位,默认值为 0
50
51
#ifdef LIBCARLA_INCLUDED_FROM_UE4
// 如果是从 UE4 环境中包含此代码
52
// 从 FVehicleControl 转换为 VehicleControl 的构造函数
53
VehicleControl
(
const
FVehicleControl
&
Control
)
54
:
throttle
(
Control
.Throttle),
// 初始化油门
55
steer
(
Control
.Steer),
// 初始化转向
56
brake
(
Control
.Brake),
// 初始化刹车
57
hand_brake
(
Control
.bHandBrake),
// 初始化手刹
58
reverse
(
Control
.bReverse),
// 初始化倒车
59
manual_gear_shift
(
Control
.bManualGearShift),
// 初始化手动换挡
60
gear
(
Control
.Gear) {}
// 初始化挡位
61
62
// 将 VehicleControl 转换为 FVehicleControl 的操作符
63
operator
FVehicleControl
()
const
{
64
FVehicleControl
Control
;
// 创建一个 FVehicleControl 对象
65
Control
.
Throttle
=
throttle
;
// 设置油门
66
Control
.
Steer
=
steer
;
// 设置转向
67
Control
.
Brake
=
brake
;
// 设置刹车
68
Control
.
bHandBrake
=
hand_brake
;
// 设置手刹
69
Control
.
bReverse
=
reverse
;
// 设置倒车
70
Control
.
bManualGearShift
=
manual_gear_shift
;
// 设置手动换挡
71
Control
.
Gear
=
gear
;
// 设置挡位
72
return
Control
;
// 返回转换后的 FVehicleControl 对象
73
}
74
75
#endif
// LIBCARLA_INCLUDED_FROM_UE4 // 结束 UE4 环境的条件编译
76
77
// 定义不等于操作符,用于比较两个 VehicleControl 对象是否不同
78
bool
operator!=
(
const
VehicleControl
&rhs)
const
{
79
return
80
throttle
!= rhs.
throttle
||
// 油门不相等
81
steer
!= rhs.
steer
||
// 转向不相等
82
brake
!= rhs.
brake
||
// 刹车不相等
83
hand_brake
!= rhs.
hand_brake
||
// 手刹不相等
84
reverse
!= rhs.
reverse
||
// 倒车不相等
85
manual_gear_shift
!= rhs.
manual_gear_shift
||
// 是否手动换挡不相等
86
gear
!= rhs.
gear
;
// 挡位不相等
87
}
88
89
// 定义等于操作符,用于比较两个 VehicleControl 对象是否相等
90
bool
operator==
(
const
VehicleControl
&rhs)
const
{
91
return
!(*
this
!= rhs);
// 如果不等于返回 false,则相等
92
}
93
94
// 定义序列化方式,使用 MsgPack 库
95
MSGPACK_DEFINE_ARRAY
(
96
throttle
,
// 序列化油门
97
steer
,
// 序列化转向
98
brake
,
// 序列化刹车
99
hand_brake
,
// 序列化手刹
100
reverse
,
// 序列化倒车
101
manual_gear_shift
,
// 序列化手动换挡
102
gear
);
// 序列化挡位
103
};
104
105
}
// namespace rpc // 结束 rpc 命名空间
106
}
// namespace carla // 结束 carla 命名空间
Control
FVehicleControl Control
Definition
ActorData.h:119
MsgPack.h
VehicleControl.h
carla::rpc::VehicleControl
Definition
LibCarla/source/carla/rpc/VehicleControl.h:20
carla::rpc::VehicleControl::operator!=
bool operator!=(const VehicleControl &rhs) const
Definition
LibCarla/source/carla/rpc/VehicleControl.h:78
carla::rpc::VehicleControl::manual_gear_shift
bool manual_gear_shift
Definition
LibCarla/source/carla/rpc/VehicleControl.h:48
carla::rpc::VehicleControl::gear
int32_t gear
Definition
LibCarla/source/carla/rpc/VehicleControl.h:49
carla::rpc::VehicleControl::steer
float steer
Definition
LibCarla/source/carla/rpc/VehicleControl.h:44
carla::rpc::VehicleControl::MSGPACK_DEFINE_ARRAY
MSGPACK_DEFINE_ARRAY(throttle, steer, brake, hand_brake, reverse, manual_gear_shift, gear)
carla::rpc::VehicleControl::operator==
bool operator==(const VehicleControl &rhs) const
Definition
LibCarla/source/carla/rpc/VehicleControl.h:90
carla::rpc::VehicleControl::VehicleControl
VehicleControl()=default
carla::rpc::VehicleControl::throttle
float throttle
Definition
LibCarla/source/carla/rpc/VehicleControl.h:43
carla::rpc::VehicleControl::VehicleControl
VehicleControl(float in_throttle, float in_steer, float in_brake, bool in_hand_brake, bool in_reverse, bool in_manual_gear_shift, int32_t in_gear)
Definition
LibCarla/source/carla/rpc/VehicleControl.h:26
carla::rpc::VehicleControl::reverse
bool reverse
Definition
LibCarla/source/carla/rpc/VehicleControl.h:47
carla::rpc::VehicleControl::VehicleControl
VehicleControl(const FVehicleControl &Control)
Definition
LibCarla/source/carla/rpc/VehicleControl.h:53
carla::rpc::VehicleControl::hand_brake
bool hand_brake
Definition
LibCarla/source/carla/rpc/VehicleControl.h:46
carla::rpc::VehicleControl::brake
float brake
Definition
LibCarla/source/carla/rpc/VehicleControl.h:45
disable-ue4-macros.h
enable-ue4-macros.h
carla
CARLA模拟器的主命名空间。
Definition
Carla.cpp:139
FVehicleControl
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:16
FVehicleControl::Steer
float Steer
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:29
FVehicleControl::Throttle
float Throttle
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:24
FVehicleControl::Brake
float Brake
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:34
FVehicleControl::Gear
int32 Gear
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:55
FVehicleControl::bManualGearShift
bool bManualGearShift
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:49
FVehicleControl::bHandBrake
bool bHandBrake
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:39
FVehicleControl::bReverse
bool bReverse
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Vehicle/VehicleControl.h:44
制作者
1.10.0