entity_properties.h 5.24 KB
Newer Older
Arun Das's avatar
Arun Das committed
1
/*******************************************************************************
Arun Das's avatar
Arun Das committed
2
3
4
5
6
7
8
9
 * Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
Arun Das's avatar
Arun Das committed
10
11
12
13
14
15
16
17

//-----------------------------------------------------------------------------
/** @file  entity_properties.h */
//-----------------------------------------------------------------------------

#ifndef MANTLEAPI_TRAFFIC_ENTITYPROPERTIES_H
#define MANTLEAPI_TRAFFIC_ENTITYPROPERTIES_H

Arun Das's avatar
Arun Das committed
18
#include <MantleAPI/Common/bounding_box.h>
Arun Das's avatar
Arun Das committed
19
20
21
#include <MantleAPI/Common/floating_point_helper.h>
#include <MantleAPI/Common/vector.h>

22
#include <map>
Arun Das's avatar
Arun Das committed
23
24
25
26
27
28
#include <string>

namespace mantle_api
{
enum class EntityType
{
29
  // Other (unspecified but known)
René Paris's avatar
René Paris committed
30
31
32
33
34
35
  kOther = 1,
  // Object is a vehicle.
  kVehicle = 2,
  // Object is a pedestrian.
  kPedestrian = 3,
  // Object is an animal.
36
37
38
  kAnimal = 4,
  // Object is static and does not move
  kStatic = 5
Arun Das's avatar
Arun Das committed
39
40
41
42
43
};

/// Basic properties that describe scenario entities.
struct EntityProperties
{
René Paris's avatar
René Paris committed
44
  virtual ~EntityProperties() = default;
Arun Das's avatar
Arun Das committed
45

46
  BoundingBox bounding_box{Vec3<units::length::meter_t>{}, Dimension3{}};
René Paris's avatar
René Paris committed
47
48
49
  EntityType type{EntityType::kOther};
  std::string model{};
  std::map<std::string, std::string> properties{};
Arun Das's avatar
Arun Das committed
50
51
52
53
};

inline bool operator==(const EntityProperties& lhs, const EntityProperties& rhs) noexcept
{
René Paris's avatar
René Paris committed
54
  return lhs.bounding_box == rhs.bounding_box && lhs.type == rhs.type && lhs.model == rhs.model;
Arun Das's avatar
Arun Das committed
55
56
57
58
}

enum class VehicleClass
{
René Paris's avatar
René Paris committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  kOther = 1,  // Other (unspecified but known) type of vehicle.
  // Vehicle is a small car.
  // Definition: Hatchback car with maximum length 4 m.
  kSmall_car = 2,
  // Vehicle is a compact car.
  // Definition: Hatchback car with length between 4 and 4.5 m.
  kCompact_car = 3,
  // Vehicle is a medium car.
  // Definition: Hatchback or sedan with length between 4.5 and 5 m.
  kMedium_car = 4,
  // Vehicle is a luxury car.
  // Definition: Sedan or coupe that is longer then 5 m.
  kLuxury_car = 5,
  // Vehicle is a delivery van.
  // Definition: A delivery van.
  kDelivery_van = 6,
  // Vehicle is a heavy truck.
  kHeavy_truck = 7,
  // Vehicle is a truck with semitrailer.
  kSemitrailer = 8,
  // Vehicle is a trailer (possibly attached to another vehicle).
  kTrailer = 9,
  // Vehicle is a motorbike or moped.
  kMotorbike = 10,
  // Vehicle is a bicycle (without motor and specific lights).
  kBicycle = 11,
  // Vehicle is a bus.
  kBus = 12,
  // Vehicle is a tram.
  kTram = 13,
  // Vehicle is a train.
  kTrain = 14,
  // Vehicle is a wheelchair.
  kWheelchair = 15,
  // Vehicle type not specified properly.
  kInvalid = -1
Arun Das's avatar
Arun Das committed
95
96
97
98
};

enum class IndicatorState
{
René Paris's avatar
René Paris committed
99
100
101
102
103
104
105
106
107
108
109
110
  // Indicator state is unknown (must not be used in ground truth).
  kUnknown = 0,
  // Other (unspecified but known) state of indicator.
  kOther = 1,
  // Indicators are off.
  kOff = 2,
  // Left indicator is on.
  kLeft = 3,
  // Right indicator is on.
  kRight = 4,
  // Hazard/warning light, i.e. both indicators, are on.
  kWarning = 5
Arun Das's avatar
Arun Das committed
111
112
};

Arun Das's avatar
Arun Das committed
113
114
enum class ExternalControlState
{
René Paris's avatar
René Paris committed
115
116
117
118
  kOff = 0,
  kFull = 1,
  kLateralOnly = 2,
  kLongitudinalOnly = 3
Arun Das's avatar
Arun Das committed
119
120
};

121
122
struct Performance
{
René Paris's avatar
René Paris committed
123
124
125
  units::velocity::meters_per_second_t max_speed{0.0};
  units::acceleration::meters_per_second_squared_t max_acceleration{0.0};
  units::acceleration::meters_per_second_squared_t max_deceleration{0.0};
126
127
128
129
};

inline bool operator==(const Performance& lhs, const Performance& rhs) noexcept
{
René Paris's avatar
René Paris committed
130
131
132
  return IsEqual(lhs.max_speed, rhs.max_speed) &&
         IsEqual(lhs.max_acceleration, rhs.max_acceleration) &&
         IsEqual(lhs.max_deceleration, rhs.max_deceleration);
133
134
135
136
}

struct Axle
{
René Paris's avatar
René Paris committed
137
138
139
140
  units::angle::radian_t max_steering{0.0};
  units::length::meter_t wheel_diameter{0.0};
  units::length::meter_t track_width{0.0};
  Vec3<units::length::meter_t> bb_center_to_axle_center{};
141
142
143
144
};

inline bool operator==(const Axle& lhs, const Axle& rhs) noexcept
{
René Paris's avatar
René Paris committed
145
146
147
148
  return IsEqual(lhs.max_steering, rhs.max_steering) &&
         IsEqual(lhs.wheel_diameter, rhs.wheel_diameter) &&
         IsEqual(lhs.track_width, rhs.track_width) &&
         lhs.bb_center_to_axle_center == rhs.bb_center_to_axle_center;
149
150
}

Arun Das's avatar
Arun Das committed
151
152
struct VehicleProperties : public EntityProperties
{
René Paris's avatar
René Paris committed
153
  VehicleClass classification{VehicleClass::kOther};
154

René Paris's avatar
René Paris committed
155
  Performance performance{};
156

René Paris's avatar
René Paris committed
157
158
  Axle front_axle{};
  Axle rear_axle{};
159

René Paris's avatar
René Paris committed
160
161
162
  bool is_host{false};
  // TODO: remove, once external control for traffic is implemented through controllers
  bool is_controlled_externally{false};
Arun Das's avatar
Arun Das committed
163
164
165
166
};

inline bool operator==(const VehicleProperties& lhs, const VehicleProperties& rhs) noexcept
{
René Paris's avatar
René Paris committed
167
168
169
170
  return lhs.bounding_box == rhs.bounding_box && lhs.type == rhs.type && lhs.model == rhs.model &&
         lhs.classification == rhs.classification && lhs.performance == rhs.performance &&
         lhs.front_axle == rhs.front_axle && lhs.rear_axle == rhs.rear_axle &&
         lhs.is_host == rhs.is_host;
Arun Das's avatar
Arun Das committed
171
172
173
174
175
176
177
178
}

struct PedestrianProperties : public EntityProperties
{
};

struct StaticObjectProperties : public EntityProperties
{
179
  units::length::meter_t z_placement_offset{0.0};
Arun Das's avatar
Arun Das committed
180
181
182
183
184
};

}  // namespace mantle_api

#endif  // MANTLEAPI_TRAFFIC_ENTITYPROPERTIES_H