controller.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Using ublas for vector/matrix multiplication
4 #include <boost/numeric/ublas/vector.hpp>
5 typedef boost::numeric::ublas::vector <double> ublas_vector;
6 #include <boost/numeric/ublas/matrix.hpp>
7 
8 // Using to check for NaN
9 #include <boost/math/special_functions/fpclassify.hpp>
10 
11 #include "ros/ros.h"
12 #include "lyap_control/plant_msg.h"
13 #include "lyap_control/controller_msg.h"
15 
16 
18 // User-defined parameters - MAKE YOUR CHANGES HERE
20 
21 // 'Aggressiveness' of the controller, in dB
22 static const double V_dot_target_initial_dB= -100.0;
23 
24 static const double high_saturation_limit [] = {10.0, 10.0};
25 static const double low_saturation_limit []= {-10.0, -10.0};
26 
27 // Parameter for V2 step location, gamma
28 static const double g = 1.0;
29 
30 // Threshold for switching to the alternative Lyapunov function
31 static const double switching_threshold = 0.01;
32 
33 // The state space definition-- the dynamic equations of the model.
34 // Calculates dx/dt
35 // model_definition sees u b/c it's a global variable, it can't be an argument
36 void model_definition(const ublas_vector &x, ublas_vector &dxdt, const double t)
37 {
38  dxdt[0] = 0.1*x[0]+u[0];
39  dxdt[1] = 2.*x[1]+u[1];
40 }
41 
43 // Functions
45 
46 // The main callback to calculate u
47 void chatterCallback(const lyap_control::plant_msg& msg);
48 
49 void initial_error_check(const lyap_control::plant_msg& msg);
50 
51 // Calculate dx_dot_du and open_loop_dx_dt
52 void calculate_dx_dot_du(boost::numeric::ublas::matrix<double> &dx_dot_du, ublas_vector & open_loop_dx_dt);
53 
54 // Calculate V_initial, V, and V_dot_target
55 void calculate_V_and_damping(double &V_dot_target);
56 
57 // Calculate a stabilizing control effort
58 void calculate_u(ublas_vector &D, ublas_vector &open_loop_dx_dt, const double &V_dot_target, boost::numeric::ublas::matrix<double> &dx_dot_du);
static double t
void calculate_u(ublas_vector &D, ublas_vector &open_loop_dx_dt, const double &V_dot_target, boost::numeric::ublas::matrix< double > &dx_dot_du)
Definition: controller.cpp:189
static const double low_saturation_limit[]
Definition: controller.h:25
void chatterCallback(const lyap_control::plant_msg &msg)
Definition: controller.cpp:41
boost::numeric::ublas::vector< double > ublas_vector
Definition: controller.h:5
static const double high_saturation_limit[]
Definition: controller.h:24
ublas_vector x(num_states)
ublas_vector u(num_inputs)
void calculate_V_and_damping(double &V_dot_target)
Definition: controller.cpp:170
static const double g
Definition: controller.h:28
void initial_error_check(const lyap_control::plant_msg &msg)
Definition: controller.cpp:104
void model_definition(const ublas_vector &x, ublas_vector &dxdt, const double t)
Definition: controller.h:36
void calculate_dx_dot_du(boost::numeric::ublas::matrix< double > &dx_dot_du, ublas_vector &open_loop_dx_dt)
Definition: controller.cpp:138
static const double switching_threshold
Definition: controller.h:31
static const double V_dot_target_initial_dB
Definition: controller.h:22


lyap_control
Author(s): Andy Zelenak
autogenerated on Mon Jun 10 2019 13:50:32