apollo icon indicating copy to clipboard operation
apollo copied to clipboard

question about dynamic models used in LQR controller

Open ImCabbage opened this issue 8 years ago • 14 comments

Hi, I am new to Apollo and have several questions about the dynamic models used in the LQR controller. It origins from that I find the lines in lat_controller.cc are different from what is said in the book "Vehicle Dynamics and Control". This book is also recommended in the Apollo docs. Below are my questions:

  1. On page 30 of the book I mentioned (Chapter 2), I believe Apollo used the same dynamic model described as Equation (2.31). But I found the A matrix is a little bit different, for example, the (1,3) element of the matrix should have a term -Vx. However, I did not find anything similar in the code.
  2. Did Apollo put the value of 2 times of Cf in one Cf since there is always a 2 in the matrix used? By the way, if it is convenient, could anyone told me how to measure the cornering stiffness of a vehicle.

Thanks.

ImCabbage avatar Feb 11 '18 03:02 ImCabbage

Q1: I guess the state space model lat_controller used refers to equation (2.45), but there is still some differences between the equation and the implementation such as coefficient '2' and another one.

Q2.1: I did not find coefficient '2'

Q2.2: I also have this problem, maybe we can obtain the cornering stiffness from vehicle's manual?

turinglife avatar Feb 11 '18 04:02 turinglife

Hi, turinglife, Thanks for your reply. I agree with you. Apollo uses the dynamic models in (2.45), but still, there are some differences, such as (2.45) has values in column 3 which is not reflected anywhere in the code.

For the coefficient problem, I think Apollo put 2 times Cf as one. The value cited in the book for a sedan is 80000, but in Apollo, they give is 155494, around two times. So I believe they did this trick.

I am totally confused how to measure the corning stiffness right now. They seem not giving out any method for that.

ImCabbage avatar Feb 11 '18 05:02 ImCabbage

@ImCabbage

Q1: Yes, they did not consider the desired yaw angle rate in the third term (2.45)

Q2: Where did you find the reference cornering stiffness '80000'? I did not find it in the reference book.

turinglife avatar Feb 11 '18 05:02 turinglife

@turinglife chapter 3, page 48 top line

ImCabbage avatar Feb 11 '18 06:02 ImCabbage

@turinglife I think they dod not consider the desired yaw angle since the yaw angle error cannot converge to zero no matter which control law you use according to chapter 3.3.2 and 3.3.3. "All we need is that the heading angle converges to the desired angle." I do not fully understand this sentence, but at least I think Apollo did not have terms for this specific reason.

ImCabbage avatar Feb 11 '18 06:02 ImCabbage

@ImCabbage 'The following values of vehicle parameters will be used for all the simulations in this chapter.'

for all the simulations maybe I guess 155494 used by Apollo does not mean two times of 80000, since '80000' is a value for simulation in this book.

"All we need is that the heading angle converges to the desired angle." From my perspective, both lateral error and heading error converging to zero will cause a good ref trajectory tracking fit, however, the heading error is just the difference between heading angle and desired angle.

turinglife avatar Feb 11 '18 07:02 turinglife

@turinglife I have an automotive theory book at my hand. This book says that usually for a sedan, the cornering stiffness ranges from -28000 to - 80000 N/rad. I mean '80000' is a practical value. Even if the vehicle model is different (Apollo uses MKZ), the value should not change too much. Obviously, the number applied by Apollo is two times of actual cornering stiffness. It is how I understand this.

I agree with you that both the lateral error and the heading error should go to zero if we'd like a good ref trajectory fit. But I still concern about why this book says that yaw angle does not matter. And obviously, Apollo does not have the corresponding terms for the lateral heading error elimination. This may be why (2.45) is not fully used in Apollo.

ImCabbage avatar Feb 11 '18 07:02 ImCabbage

@ImCabbage

  1. for cornering stiffness, You've convinced me.

  2. for (2.45), I think Apollo considered the lateral error, lateral error rate, heading error(vehicle's current yaw angle - the desired yaw angle), heading error rate. They just did not consider the third term for the desired yaw angle rate. So I think they have considered the lateral heading error elimination.

turinglife avatar Feb 11 '18 07:02 turinglife

Most of the discussion above are right. For the cornering stiffness, it is calculated via statistical fitting, and relative accurate for a large range of velocity.

Capri2014 avatar Feb 13 '18 21:02 Capri2014

@Capri2014 Is there a script for performing this statistical fitting? I looked through the code base, but couldn't seem to find it. I may have been looking in the wrong location.

drliebe avatar Jul 13 '18 22:07 drliebe

@drliebe I don't believe this exists in the Apollo codebase. I believe since you have a linear state space model it can be done with a simple least squares estimation. However, you need to be sure you are not attributing other sources of model misspecification to uncertainty in the cornering stiffness parameter.

berthu avatar Dec 11 '18 02:12 berthu

Hello, the conclusion from the above discussion is, in the code, cf_ = image , cr_ = image

However, the feed-forward term responds to equation 3.12 in the book Vehicle Dynamics and Control, image const double kv = lr_ * mass_ / 2 / cf_ / wheelbase_ - lf_ * mass_ / 2 / cr_ / wheelbase_; const double steer_angle_feedforwardterm = (wheelbase_ * ref_curvature + kv * v * v * ref_curvature - matrix_k_(0, 2) * (lr_ * ref_curvature - lf_ * mass_ * v * v * ref_curvature / 2 / cr_ / wheelbase_)) * 180 / M_PI * steer_ratio_ / steer_single_direction_max_degree_ * 100; Here it appears to assume cf_ =image, cr_ =image. I'm confused here, how would you explain this? @Capri2014

Freiheit1992 avatar Apr 30 '19 05:04 Freiheit1992

I have the same question about it! could anyone tell me why? Thanks very much!

quuen avatar Jun 17 '19 12:06 quuen

hello For first question i saw the equation (2.31) it is a vehicle dynamics equation with state variables y dy phi dphi. however the code in apollo is using state variable e1 de1 e2 de2. e1 is latitude error and e2 is heading error.so you need further formula derivation.——Reply reference comes from the Apollo developer community issue master contest https://apollo.auto/developer/questiondata_cn.html?target=699

apollodevcommunity avatar Feb 07 '21 06:02 apollodevcommunity