$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 #ifndef CLOE_COMPONENT_WHEEL_SENSOR_HPP_
24 #define CLOE_COMPONENT_WHEEL_SENSOR_HPP_
25 
26 #include <cloe/component.hpp> // for Component, Json
27 #include <cloe/component/wheel.hpp> // for Wheel
28 
29 namespace cloe {
30 
31 class WheelSensor : public Component {
32  public:
33  using Component::Component;
34  WheelSensor() : Component("wheel_sensor") {}
35  virtual ~WheelSensor() noexcept = default;
36 
40  virtual Wheel wheel_fl() const = 0;
41 
45  virtual Wheel wheel_fr() const = 0;
46 
50  virtual Wheel wheel_rl() const = 0;
51 
55  virtual Wheel wheel_rr() const = 0;
56 
60  Json active_state() const override {
61  return Json{
62  {"wheel_fl", wheel_fl()},
63  {"wheel_fr", wheel_fr()},
64  {"wheel_rl", wheel_rl()},
65  {"wheel_rr", wheel_rr()},
66  };
67  }
68 };
69 
73 class NopWheelSensor : public WheelSensor {
74  public:
75  using WheelSensor::WheelSensor;
76  NopWheelSensor() : WheelSensor("nop_wheel_sensor") {}
77  virtual ~NopWheelSensor() noexcept {};
78 
79  Wheel wheel_fl() const override { return wheel_fl_; };
80  Wheel wheel_fr() const override { return wheel_fr_; };
81  Wheel wheel_rl() const override { return wheel_rl_; };
82  Wheel wheel_rr() const override { return wheel_rr_; };
83 
84  void reset() override {
85  wheel_fl_ = Wheel();
86  wheel_fr_ = Wheel();
87  wheel_rl_ = Wheel();
88  wheel_rr_ = Wheel();
89  }
90 
91  protected:
92  Wheel wheel_fl_{};
93  Wheel wheel_fr_{};
94  Wheel wheel_rl_{};
95  Wheel wheel_rr_{};
96 };
97 
98 } // namespace cloe
99 
100 #endif // CLOE_COMPONENT_WHEEL_SENSOR_HPP_
Wheel wheel_fr() const override
Definition: wheel_sensor.hpp:80
void reset() override
Definition: wheel_sensor.hpp:84
Definition: wheel_sensor.hpp:73
Definition: coordinator.hpp:36
Json active_state() const override
Definition: wheel_sensor.hpp:60
Definition: wheel.hpp:30
Definition: wheel_sensor.hpp:31
virtual Wheel wheel_rl() const =0
virtual Wheel wheel_fl() const =0
virtual Wheel wheel_fr() const =0
Definition: component.hpp:144
Wheel wheel_rr() const override
Definition: wheel_sensor.hpp:82
virtual Wheel wheel_rr() const =0
Wheel wheel_rl() const override
Definition: wheel_sensor.hpp:81
Wheel wheel_fl() const override
Definition: wheel_sensor.hpp:79