CARLA
 
载入中...
搜索中...
未找到
LibCarla/source/carla/rpc/WalkerControl.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#include "carla/MsgPack.h"
10
11#ifdef LIBCARLA_INCLUDED_FROM_UE4
15#endif // LIBCARLA_INCLUDED_FROM_UE4
16
17namespace carla {
18namespace rpc {
19// 定义 WalkerControl 类
21 public:
22// 默认构造函数
23 WalkerControl() = default;
24// 带参数的构造函数,接收方向、速度和是否跳跃的参数
26 geom::Vector3D in_direction,
27 float in_speed,
28 bool in_jump)
29 : direction(in_direction),
30 speed(in_speed),
31 jump(in_jump) {}
32// 代表行人方向的三维向量,默认值为 {1.0f, 0.0f, 0.0f}
33 geom::Vector3D direction = {1.0f, 0.0f, 0.0f};
34
35 float speed = 0.0f;
36
37 bool jump = false;
38
39#ifdef LIBCARLA_INCLUDED_FROM_UE4
40// 从虚幻引擎中的 FWalkerControl 类型转换为当前的 WalkerControl 类型的构造函数
42 : direction(Control.Direction.X, Control.Direction.Y, Control.Direction.Z),
43 speed(1e-2f * Control.Speed),
44 jump(Control.Jump) {}
45 // 重载类型转换运算符,将当前的 WalkerControl 类型转换为虚幻引擎中的 FWalkerControl 类型
46 operator FWalkerControl() const {
48 Control.Direction = {direction.x, direction.y, direction.z};
49 Control.Speed = 1e2f * speed;
50 Control.Jump = jump;
51 return Control;
52 }
53
54#endif // LIBCARLA_INCLUDED_FROM_UE4
55// 重载不等于运算符,用于比较两个 WalkerControl 对象是否不同
56 bool operator!=(const WalkerControl &rhs) const {
57 return direction != rhs.direction || speed != rhs.speed || jump != rhs.jump;
58 }
59
60 bool operator==(const WalkerControl &rhs) const {
61 return !(*this != rhs);
62 }
63// 使用 MsgPack 进行序列化定义
65 };
66
67} // namespace rpc
68} // namespace carla
FVehicleControl Control
Definition ActorData.h:119
bool operator!=(const WalkerControl &rhs) const
WalkerControl(geom::Vector3D in_direction, float in_speed, bool in_jump)
bool operator==(const WalkerControl &rhs) const
MSGPACK_DEFINE_ARRAY(direction, speed, jump)
CARLA模拟器的主命名空间。
Definition Carla.cpp:139