Lodestar
An integrated real-time control package in C++
CarDemo.hpp
1 //
2 // Created by Hamza El-Kebir on 12/30/2021.
3 //
4 
5 #ifndef LODESTAR_CARDEMO_HPP
6 #define LODESTAR_CARDEMO_HPP
7 
8 
9 #include "Eigen/Dense"
10 
20 // Function automatically generated by Lodestar
21 Eigen::Matrix<double, 6, 6> jacStates(const double (&x)[6], const double (&u)[2], const double t = 0)
22 {
23  Eigen::Matrix<double, 6, 6> mat;
24  mat << 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
25  0.0, 0.0, 0.0, 0.0, -2.0 * sin(x[4]) * (u[1] + u[0]), 0.0,
26  0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
27  0.0, 0.0, 0.0, 0.0, -2.0 * cos(x[4]) * (u[1] + u[0]), 0.0,
28  0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
29  0.0, 0.0, 0.0, 0.0, 0.0, 0.0;
30 
31  return mat;
32 }
33 
34 Eigen::Matrix<double, 6, 1> dynamics(const double (&x)[6], const double (&u)[2], const double t = 0)
35 {
36  Eigen::Matrix<double, 6, 1> mat;
37  mat << x[1],
38  2 * (u[0] + u[1]) * cos(x[4]),
39  x[3],
40  -2 * (u[0] + u[1]) * sin(x[4]),
41  x[5],
42  (u[0] - u[1]);
43 
44  return mat;
45 }
46 
47 
57 // Function automatically generated by Lodestar
58 Eigen::Matrix<double, 6, 2> jacInput(const double (&x)[6], const double (&u)[2], const double t = 0)
59 {
60  Eigen::Matrix<double, 6, 2> mat;
61  mat << 0.0, 0.0,
62  2.0 * cos(x[4]), 2.0 * cos(x[4]),
63  0.0, 0.0,
64  -2.0 * sin(x[4]), -2.0 * sin(x[4]),
65  0.0, 0.0,
66  1.0, -1.0;
67 
68  return mat;
69 }
70 
71 
72 #endif //LODESTAR_CARDEMO_HPP