Autoware.Auto
kinematic_bicycle.snippet.hpp
Go to the documentation of this file.
1 // Copyright 2019 Christopher Ho
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef COMMON__MOTION_COMMON__SCRIPTS__AUTOGENERATION_CODE_SNIPPETS__KINEMATIC_BICYCLE_SNIPPET_HPP_ // NOLINT
16 #define COMMON__MOTION_COMMON__SCRIPTS__AUTOGENERATION_CODE_SNIPPETS__KINEMATIC_BICYCLE_SNIPPET_HPP_ // NOLINT
17 
18 // For help on getting random weird models to work, see:
19 // https://sourceforge.net/p/acado/discussion/general
20 // and
21 // https://github.com/acado/acado/issues
22 
23 // Note: Order of variable declaration specifies order in C-arrays
24 //
25 // Variables
26 //
27 
28 DifferentialState x, y, yaw; // pose
29 DifferentialState u;
30 Control ax; // acceleration
31 Control delta; // wheel angle
32 
33 // Vehicle parameters
34 OnlineData L_f, L_r; // front, rear wheelbase length
35 //
36 // Differential algebraic equation
37 //
38 
39 // Kinematic bicycle model:
40 // https://borrelli.me.berkeley.edu/pdfpub/IV_KinematicMPC_jason.pdf
41 // Intermediate variables
42 IntermediateState beta = atan((L_r * tan(delta)) / (L_f + L_r));
43 
44 DifferentialEquation f;
45 
46 f << dot(x) == u * cos(yaw + beta);
47 f << dot(y) == u * sin(yaw + beta);
48 f << dot(yaw) == (u * sin(beta)) / L_r;
49 f << dot(u) == ax;
50 #endif // COMMON__MOTION_COMMON__SCRIPTS__AUTOGENERATION_CODE_SNIPPETS__KINEMATIC_BICYCLE_SNIPPET_HPP_ // NOLINT
Control ax
Definition: kinematic_bicycle.snippet.hpp:30
DifferentialEquation f
Definition: kinematic_bicycle.snippet.hpp:44
DifferentialState u
Definition: kinematic_bicycle.snippet.hpp:29
Control delta
Definition: kinematic_bicycle.snippet.hpp:31
DifferentialState yaw
Definition: kinematic_bicycle.snippet.hpp:28
IntermediateState beta
Definition: kinematic_bicycle.snippet.hpp:42
DifferentialState x
Definition: kinematic_bicycle.snippet.hpp:28
OnlineData L_r
Definition: kinematic_bicycle.snippet.hpp:34
DifferentialState y
Definition: kinematic_bicycle.snippet.hpp:28
OnlineData L_f
Definition: kinematic_bicycle.snippet.hpp:34