$darkmode
object.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Robert Bosch GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  */
22 #pragma once
23 #ifndef CLOE_COMPONENT_OBJECT_HPP_
24 #define CLOE_COMPONENT_OBJECT_HPP_
25 
26 #include <memory> // for shared_ptr<>
27 #include <vector> // for vector<>
28 
29 #include <Eigen/Geometry> // for Isometry3d, Vector3d
30 #include <fable/json/with_eigen.hpp> // for to_json
31 
32 #include <cloe/core.hpp> // for Json
33 
34 namespace cloe {
35 
51 struct Object {
52  enum class Type { Unknown, Static, Dynamic };
53 
54  enum class Class { Unknown, Pedestrian, Bike, Motorbike, Car, Truck, Trailer };
55 
57  int id{-1};
58 
60  double exist_prob{1.0};
61 
63  Type type{Type::Unknown};
64 
66  Class classification{Class::Unknown};
67 
69  Eigen::Isometry3d pose{Eigen::Isometry3d()};
70 
72  Eigen::Vector3d dimensions{Eigen::Vector3d::Zero()};
73 
75  Eigen::Vector3d cog_offset{Eigen::Vector3d::Zero()};
76 
78  Eigen::Vector3d velocity{Eigen::Vector3d::Zero()};
79 
81  Eigen::Vector3d acceleration{Eigen::Vector3d::Zero()};
82 
84  Eigen::Vector3d angular_velocity{Eigen::Vector3d::Zero()};
85 
86  Object() = default;
87 
88  friend void to_json(Json& j, const Object& o) {
89  j = Json{
90  {"id", o.id},
91  {"exist_prob", o.exist_prob},
92  {"type", o.type},
93  {"class", o.classification},
94  {"pose", o.pose},
95  {"dimensions", o.dimensions},
96  {"cog_offset", o.cog_offset},
97  {"velocity", o.velocity},
98  {"velocity_norm", static_cast<double>(o.velocity.norm())},
99  {"acceleration", o.acceleration},
100  {"angular_velocity", o.angular_velocity},
101  };
102  }
103 };
104 
111 using Objects = std::vector<std::shared_ptr<Object>>;
112 
113 inline void to_json(Json& j, const Objects& os) {
114  j = Json::array();
115  for (const auto& o : os) {
116  assert(o != nullptr);
117  j.push_back(*o);
118  }
119 }
120 
121 // clang-format off
122 ENUM_SERIALIZATION(Object::Type, ({
123  {Object::Type::Static, "static"},
124  {Object::Type::Dynamic, "dynamic"},
125  {Object::Type::Unknown, "unknown"},
126 }))
127 
128 ENUM_SERIALIZATION(Object::Class, ({
129  {Object::Class::Unknown, "unknown"},
130  {Object::Class::Pedestrian, "pedestrian"},
131  {Object::Class::Bike, "bicycle"},
132  {Object::Class::Motorbike, "motorcycle"},
133  {Object::Class::Car, "car"},
134  {Object::Class::Truck, "truck"},
135  {Object::Class::Trailer, "trailer"},
136 }))
137 // clang-format on
138 
139 } // namespace cloe
140 
141 #endif // CLOE_COMPONENT_OBJECT_HPP_
Eigen::Vector3d cog_offset
Center of geometry offset in [m].
Definition: object.hpp:75
Eigen::Isometry3d pose
Pose in [m] and [rad].
Definition: object.hpp:69
Type type
Type of object.
Definition: object.hpp:63
Eigen::Vector3d angular_velocity
Angular velocity in [rad/s].
Definition: object.hpp:84
double exist_prob
Object existence probability.
Definition: object.hpp:60
int id
ID of object, should be unique.
Definition: object.hpp:57
Definition: object.hpp:51
Eigen::Vector3d acceleration
Absolute acceleration in [m/(s*s)].
Definition: object.hpp:81
std::vector< std::shared_ptr< Object > > Objects
Definition: object.hpp:111
Definition: coordinator.hpp:36
#define ENUM_SERIALIZATION(xType, xMap)
Definition: enum.hpp:52
Eigen::Vector3d dimensions
Dimensions in [m].
Definition: object.hpp:72
Eigen::Vector3d velocity
Absolute velocity in [m/s].
Definition: object.hpp:78
Class classification
Classification of object.
Definition: object.hpp:66