$darkmode
object_sensor.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  */
23 #pragma once
24 
25 #include <cloe/component.hpp> // for Component
26 #include <cloe/component/frustum.hpp> // for Frustum
27 #include <cloe/component/object.hpp> // for Object, Isometry3d
28 #include <fable/json.hpp> // for Json
29 #include <fable/utility/eigen.hpp>
30 
31 namespace cloe {
32 
33 class ObjectSensor : public Component {
34  public:
35  using Component::Component;
36  ObjectSensor() : Component("object_sensor") {}
37  virtual ~ObjectSensor() noexcept = default;
38 
47  virtual const Objects& sensed_objects() const = 0;
48 
52  virtual const Frustum& frustum() const = 0;
53 
57  virtual const Eigen::Isometry3d& mount_pose() const = 0;
58 
62  fable::Json active_state() const override {
63  return fable::Json{
64  {"mount_pose", this->mount_pose()},
65  {"frustum", this->frustum()},
66  {"sensed_objects", this->sensed_objects()},
67  };
68  }
69 };
70 
71 class NopObjectSensor : public ObjectSensor {
72  public:
73  using ObjectSensor::ObjectSensor;
74  NopObjectSensor() : ObjectSensor("nop_object_sensor") {}
75  virtual ~NopObjectSensor() noexcept = default;
76 
77  const Objects& sensed_objects() const override { return objects_; }
78 
79  const Frustum& frustum() const override { return frustum_; }
80 
81  const Eigen::Isometry3d& mount_pose() const override { return mount_; }
82 
83  void reset() override {
85  objects_.clear();
86  }
87 
88  protected:
89  Frustum frustum_;
90  Objects objects_;
91  Eigen::Isometry3d mount_ = Eigen::Isometry3d::Identity();
92 };
93 
94 } // namespace cloe
Definition: component.hpp:143
void reset() override
Definition: component.hpp:186
Definition: object_sensor.hpp:71
const Eigen::Isometry3d & mount_pose() const override
Definition: object_sensor.hpp:81
void reset() override
Definition: object_sensor.hpp:83
const Frustum & frustum() const override
Definition: object_sensor.hpp:79
const Objects & sensed_objects() const override
Definition: object_sensor.hpp:77
Definition: object_sensor.hpp:33
fable::Json active_state() const override
Definition: object_sensor.hpp:62
virtual const Objects & sensed_objects() const =0
virtual const Eigen::Isometry3d & mount_pose() const =0
virtual const Frustum & frustum() const =0
nlohmann::json Json
Definition: fable_fwd.hpp:35
std::vector< std::shared_ptr< Object > > Objects
Definition: object.hpp:128
Definition: frustum.hpp:37