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