$darkmode
pedal_actuator.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/actuator.hpp> // for Actuator
25 #include <fable/json.hpp> // for Json
26 
27 namespace cloe {
28 
29 struct PedalRequest {
30  /*
31  * Requested status of the gas pedal with no unit.
32  *
33  * The range goes from 0 (unpressed) to 1 (fully pressed).
34  */
35  double gas_pedal_position{0.0};
36 
37  /*
38  * Requested status of the brake pedal with no unit.
39  *
40  * The range goes from 0 (unpressed) to 1 (fully pressed).
41  */
42  double brake_pedal_position{0.0};
43 
44  friend void to_json(fable::Json& j, const PedalRequest& p) {
45  j = fable::Json{
46  {"gas_pedal_position", p.gas_pedal_position},
47  {"brake_pedal_position", p.brake_pedal_position},
48  };
49  }
50 };
51 
52 class PedalActuator : public Actuator<PedalRequest> {
53  public:
54  using Actuator::Actuator;
55  PedalActuator() : Actuator("pedal_actuator") {}
56  virtual ~PedalActuator() noexcept = default;
57 };
58 
59 } // namespace cloe
Definition: actuator.hpp:32
Definition: pedal_actuator.hpp:52
nlohmann::json Json
Definition: fable_fwd.hpp:35
Definition: pedal_actuator.hpp:29