$darkmode
simple_steering_model.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 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 namespace cloe {
25 namespace utility {
26 
35  public:
36  SimpleSteeringModel() = default;
37  explicit SimpleSteeringModel(double delta_time_s) : dt_(delta_time_s) {}
38  ~SimpleSteeringModel() = default;
39 
50  void update_model(double steering_torque, double long_velocity) {
51  // Gain depending on vehicle velocity, to reduce oscillations
52  // ^ v_gain
53  // 1|*
54  // | *
55  // | *
56  // | *
57  // |- - - - * * * * * MIN
58  // |--------|-------> velocity
59  // 0 30 m/s
60  double v_gain = -0.03 * long_velocity + 1;
61 
62  // Minimize to value
63  if (v_gain <= 0.1) {
64  v_gain = 0.1;
65  }
66 
67  // target_steering_angle = target_steering_angle (t-1) + K * K_Ego_velocity_vx * dt * torque
68  steering_angle_ = steering_angle_ + 0.1 * v_gain * dt_ * steering_torque;
69  }
70 
74  double steering_angle() const { return steering_angle_; }
75 
76  private:
77  double dt_{0.02};
78  double steering_angle_{0.0};
79 };
80 
81 } // namespace utility
82 } // namespace cloe
Definition: simple_steering_model.hpp:34
double steering_angle() const
Definition: simple_steering_model.hpp:74
void update_model(double steering_torque, double long_velocity)
Definition: simple_steering_model.hpp:50