$darkmode
frustum_culling_conf.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2024 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 
24 #include <memory> // for shared_ptr<>
25 #include <random> // for default_random_engine, normal_distribution<>
26 #include <string> // for string
27 #include <utility> // for move
28 
29 #include <cloe/component.hpp> // for Component, ComponentFactory, ...
30 #include <cloe/component/frustum.hpp> // for Frustum
31 #include <cloe/core.hpp> // for Confable, Schema
32 #include <cloe/entity.hpp> // for Entity
33 #include <cloe/simulator.hpp> // for ModelError
34 #include <cloe/utility/geometry.hpp> // for quaternion_from_rpy
35 #include <fable/utility/eigen.hpp> // for to_json
36 
37 namespace cloe::frustum_culling_plugin {
38 
42 struct MountPose : public fable::Confable {
43  Eigen::Isometry3d pose;
44  double x, y, z;
45  double roll, pitch, yaw;
46 
47  void to_json(fable::Json& j) const override {
48  j = fable::Json{
49  {"pose", pose},
50  };
51  }
52 
53  void convert() {
54  Eigen::Quaterniond q = cloe::utility::quaternion_from_rpy(roll, pitch, yaw);
55  pose = cloe::utility::pose_from_rotation_translation(q, Eigen::Vector3d(x, y, z));
56  }
57 
58  protected:
60  // clang-format off
61  using namespace fable::schema; // NOLINT
62  return Struct{
63  {"x", make_schema(&x, "x-position in ego reference frame [m]").require()},
64  {"y", make_schema(&y, "y-position in ego reference frame [m]").require()},
65  {"z", make_schema(&z, "z-position in ego reference frame [m]").require()},
66  {"roll", make_schema(&roll, "roll angle relative to ego reference frame [rad]").require()},
67  {"pitch", make_schema(&pitch, "pitch angle relative to ego reference frame [rad]").require()},
68  {"yaw", make_schema(&yaw, "yaw angle relative to ego reference frame [rad]").require()},
69  };
70  // clang-format on
71  }
72 
73  CONFABLE_FRIENDS(MountPose)
74 };
75 
76 struct FrustumCullingConf : public Confable {
81 
86 
87  CONFABLE_SCHEMA(FrustumCullingConf) {
88  using namespace fable::schema;
89  return Struct{
90  {"reference_frame", make_schema(&ref_frame, "sensor frame of reference").require()},
91  {"frustum", make_schema(&frustum, "sensor frustum").require()},
92  };
93  };
94 
95  void to_json(Json& j) const override {
96  j = Json{
97  {"reference_frame", ref_frame},
98  {"frustum", frustum},
99  };
100  }
101 };
102 
103 } // namespace cloe::frustum_culling_plugin
Definition: confable.hpp:98
Json to_json() const
Definition: confable.cpp:78
Definition: schema.hpp:173
Definition: struct.hpp:70
nlohmann::json Json
Definition: fable_fwd.hpp:35
Definition: frustum.hpp:37
Definition: frustum_culling_conf.hpp:76
Frustum frustum
Definition: frustum_culling_conf.hpp:85
MountPose ref_frame
Definition: frustum_culling_conf.hpp:80
Definition: frustum_culling_conf.hpp:42
void to_json(fable::Json &j) const override
Definition: frustum_culling_conf.hpp:47
fable::Schema schema_impl() override
Definition: frustum_culling_conf.hpp:59