CARLA
 
载入中...
搜索中...
未找到
LibCarla/source/carla/rpc/VehicleTelemetryData.h
浏览该文件的文档.
1// Copyright (c) 2022 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"
11
12#include <vector>
13
14namespace carla {
15namespace rpc {
17 public:
18
20
22 float speed,
23 float steer,
24 float throttle,
25 float brake,
26 float engine_rpm,
27 int32_t gear,
28 float drag,
29 std::vector<WheelTelemetryData> wheels)
30 : speed(speed),
31 steer(steer),
33 brake(brake),
35 gear(gear),
36 drag(drag),
37 wheels(wheels) {}
38
39 const std::vector<WheelTelemetryData> &GetWheels() const {
40 return wheels;
41 }
42
43 void SetWheels(std::vector<WheelTelemetryData> &in_wheels) {
44 wheels = in_wheels;
45 }
46
47 float speed = 0.0f;
48 float steer = 0.0f;
49 float throttle = 0.0f;
50 float brake = 0.0f;
51 float engine_rpm = 0.0f;
52 int32_t gear = 0.0f;
53 float drag = 0.0f;
54 std::vector<WheelTelemetryData> wheels;
55
56 bool operator!=(const VehicleTelemetryData &rhs) const {
57 return
58 speed != rhs.speed ||
59 steer != rhs.steer ||
60 throttle != rhs.throttle ||
61 brake != rhs.brake ||
62 engine_rpm != rhs.engine_rpm ||
63 gear != rhs.gear ||
64 drag != rhs.drag ||
65 wheels != rhs.wheels;
66 }
67
68 bool operator==(const VehicleTelemetryData &rhs) const {
69 return !(*this != rhs);
70 }
71
72#ifdef LIBCARLA_INCLUDED_FROM_UE4
73
75 speed = TelemetryData.Speed;
76 steer = TelemetryData.Steer;
77 throttle = TelemetryData.Throttle;
78 brake = TelemetryData.Brake;
79 engine_rpm = TelemetryData.EngineRPM;
80 gear = TelemetryData.Gear;
81 drag = TelemetryData.Drag;
82
83 // Wheels Setup
84 wheels = std::vector<WheelTelemetryData>();
85 for (const auto &Wheel : TelemetryData.Wheels) {
86 wheels.push_back(WheelTelemetryData(Wheel));
87 }
88 }
89
90 operator FVehicleTelemetryData() const {
91 FVehicleTelemetryData TelemetryData;
92
93 TelemetryData.Speed = speed;
94 TelemetryData.Steer = steer;
95 TelemetryData.Throttle = throttle;
96 TelemetryData.Brake = brake;
97 TelemetryData.EngineRPM = engine_rpm;
98 TelemetryData.Gear = gear;
99 TelemetryData.Drag = drag;
100
101 TArray<FWheelTelemetryData> Wheels;
102 for (const auto &wheel : wheels) {
103 Wheels.Add(FWheelTelemetryData(wheel));
104 }
105 TelemetryData.Wheels = Wheels;
106
107 return TelemetryData;
108 }
109
110#endif
111
113 steer,
114 throttle,
115 brake,
117 gear,
118 drag,
119 wheels);
120 };
121
122} // namespace rpc
123} // namespace carla
const std::vector< WheelTelemetryData > & GetWheels() const
void SetWheels(std::vector< WheelTelemetryData > &in_wheels)
MSGPACK_DEFINE_ARRAY(speed, steer, throttle, brake, engine_rpm, gear, drag, wheels)
bool operator==(const VehicleTelemetryData &rhs) const
VehicleTelemetryData(float speed, float steer, float throttle, float brake, float engine_rpm, int32_t gear, float drag, std::vector< WheelTelemetryData > wheels)
bool operator!=(const VehicleTelemetryData &rhs) const
VehicleTelemetryData(const FVehicleTelemetryData &TelemetryData)
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133