Apollo  6.0
Open source self driving car software
leadlag_controller.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 The Apollo Authors. All Rights Reserved.
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 
22 #pragma once
23 
24 #include "modules/control/proto/leadlag_conf.pb.h"
25 
30 namespace apollo {
31 namespace control {
32 
39  public:
45  void Init(const LeadlagConf &leadlag_conf, const double dt);
46 
51  void SetLeadlag(const LeadlagConf &leadlag_conf);
52 
58  void TransformC2d(const double dt);
59 
63  void Reset();
64 
72  virtual double Control(const double error, const double dt);
73 
78  int InnerstateSaturationStatus() const;
79 
80  protected:
81  // Control coefficients in contiouous-time domain
82  double alpha_ = 0.0;
83  double beta_ = 0.0;
84  double tau_ = 0.0;
85  double Ts_ = 0.01; // By default, control sampling time is 0.01 sec
86  // Control coefficients in discrete-time domain
87  double kn1_ = 0.0;
88  double kn0_ = 0.0;
89  double kd1_ = 0.0;
90  double kd0_ = 0.0;
91  // Inner (intermedia) state in discrete-time domain at Direct Form II
92  double previous_output_ = 0.0;
93  double previous_innerstate_ = 0.0;
94  double innerstate_ = 0.0;
98  bool transfromc2d_enabled_ = false;
99 };
100 
101 } // namespace control
102 } // namespace apollo
void TransformC2d(const double dt)
transfer lead/lag controller coefficients to the discrete-time form, with the bilinear transform (tra...
virtual double Control(const double error, const double dt)
compute control value based on the error
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
double tau_
Definition: leadlag_controller.h:84
bool transfromc2d_enabled_
Definition: leadlag_controller.h:98
double kn1_
Definition: leadlag_controller.h:87
void SetLeadlag(const LeadlagConf &leadlag_conf)
void Init(const LeadlagConf &leadlag_conf, const double dt)
initialize lead/lag controller
double kd0_
Definition: leadlag_controller.h:90
double alpha_
Definition: leadlag_controller.h:82
double previous_output_
Definition: leadlag_controller.h:92
double kd1_
Definition: leadlag_controller.h:89
double innerstate_saturation_high_
Definition: leadlag_controller.h:95
void Reset()
reset variables for lead/leg controller
double innerstate_
Definition: leadlag_controller.h:94
double beta_
Definition: leadlag_controller.h:83
double innerstate_saturation_low_
Definition: leadlag_controller.h:96
A lead/lag controller for speed and steering using defualt integral hold.
Definition: leadlag_controller.h:38
int innerstate_saturation_status_
Definition: leadlag_controller.h:97
double kn0_
Definition: leadlag_controller.h:88
double previous_innerstate_
Definition: leadlag_controller.h:93
int InnerstateSaturationStatus() const
get saturation status
double Ts_
Definition: leadlag_controller.h:85