$darkmode
wheel_sensor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2022 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 <cloe/component.hpp> // for Component
25 #include <cloe/component/wheel.hpp> // for Wheel
26 #include <fable/json.hpp> // for Json
27 
28 namespace cloe {
29 
30 class WheelSensor : public Component {
31  public:
32  using Component::Component;
33  WheelSensor() : Component("wheel_sensor") {}
34  virtual ~WheelSensor() noexcept = default;
35 
39  virtual Wheel wheel_fl() const = 0;
40 
44  virtual Wheel wheel_fr() const = 0;
45 
49  virtual Wheel wheel_rl() const = 0;
50 
54  virtual Wheel wheel_rr() const = 0;
55 
59  fable::Json active_state() const override {
60  return fable::Json{
61  {"wheel_fl", wheel_fl()},
62  {"wheel_fr", wheel_fr()},
63  {"wheel_rl", wheel_rl()},
64  {"wheel_rr", wheel_rr()},
65  };
66  }
67 };
68 
72 class NopWheelSensor : public WheelSensor {
73  public:
74  using WheelSensor::WheelSensor;
75  NopWheelSensor() : WheelSensor("nop_wheel_sensor") {}
76  virtual ~NopWheelSensor() noexcept {};
77 
78  Wheel wheel_fl() const override { return wheel_fl_; };
79  Wheel wheel_fr() const override { return wheel_fr_; };
80  Wheel wheel_rl() const override { return wheel_rl_; };
81  Wheel wheel_rr() const override { return wheel_rr_; };
82 
83  void reset() override {
84  wheel_fl_ = Wheel();
85  wheel_fr_ = Wheel();
86  wheel_rl_ = Wheel();
87  wheel_rr_ = Wheel();
88  }
89 
90  protected:
91  Wheel wheel_fl_{};
92  Wheel wheel_fr_{};
93  Wheel wheel_rl_{};
94  Wheel wheel_rr_{};
95 };
96 
97 } // namespace cloe
Definition: component.hpp:143
Definition: wheel_sensor.hpp:72
Wheel wheel_rl() const override
Definition: wheel_sensor.hpp:80
void reset() override
Definition: wheel_sensor.hpp:83
Wheel wheel_fr() const override
Definition: wheel_sensor.hpp:79
Wheel wheel_fl() const override
Definition: wheel_sensor.hpp:78
Wheel wheel_rr() const override
Definition: wheel_sensor.hpp:81
Definition: wheel_sensor.hpp:30
virtual Wheel wheel_fl() const =0
virtual Wheel wheel_rr() const =0
virtual Wheel wheel_rl() const =0
fable::Json active_state() const override
Definition: wheel_sensor.hpp:59
virtual Wheel wheel_fr() const =0
nlohmann::json Json
Definition: fable_fwd.hpp:35
Definition: wheel.hpp:30