$darkmode
steering_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_STEERING_SENSOR_HPP_
24 #define CLOE_COMPONENT_STEERING_SENSOR_HPP_
25 
26 #include <cloe/component.hpp> // for Component, Json
27 
28 namespace cloe {
29 
30 class SteeringSensor : public Component {
31  public:
32  using Component::Component;
33  SteeringSensor() : Component("steering_sensor") {}
34  virtual ~SteeringSensor() noexcept = default;
35 
39  virtual double curvature() const = 0;
40 
44  Json active_state() const override {
45  return Json{
46  {"curvature", curvature()},
47  };
48  }
49 };
50 
55  public:
56  using SteeringSensor::SteeringSensor;
57  NopSteeringSensor() : SteeringSensor("nop_steering_sensor") {}
58  virtual ~NopSteeringSensor() noexcept {};
59 
60  double curvature() const override { return curvature_; }
61  void reset() override { curvature_ = 0.0; }
62 
63  protected:
64  double curvature_{0.0};
65 };
66 
67 } // namespace cloe
68 
69 #endif // CLOE_COMPONENT_STEERING_SENSOR_HPP_
virtual double curvature() const =0
double curvature() const override
Definition: steering_sensor.hpp:60
Definition: coordinator.hpp:36
Definition: steering_sensor.hpp:30
Json active_state() const override
Definition: steering_sensor.hpp:44
Definition: component.hpp:144
void reset() override
Definition: steering_sensor.hpp:61
Definition: steering_sensor.hpp:54