controller.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 // Using ublas for vector/matrix multiplication
00004 #include <boost/numeric/ublas/vector.hpp>
00005 typedef boost::numeric::ublas::vector <double> ublas_vector;
00006 #include <boost/numeric/ublas/matrix.hpp>
00007 
00008 // Using to check for NaN
00009 #include <boost/math/special_functions/fpclassify.hpp>
00010 
00011 #include "ros/ros.h"
00012 #include "lyap_control/plant_msg.h"
00013 #include "lyap_control/controller_msg.h"
00014 #include "lyap_control/controller_globals.h"
00015 
00016 
00018 // User-defined parameters - MAKE YOUR CHANGES HERE
00020 
00021 // 'Aggressiveness' of the controller, in dB
00022 static const double V_dot_target_initial_dB= -100.0;
00023 
00024 static const double high_saturation_limit [] = {10.0, 10.0};
00025 static const double low_saturation_limit []= {-10.0, -10.0};
00026 
00027 // Parameter for V2 step location, gamma
00028 static const double g = 1.0;
00029 
00030 // Threshold for switching to the alternative Lyapunov function
00031 static const double switching_threshold = 0.01;
00032 
00033 // The state space definition-- the dynamic equations of the model.
00034 // Calculates dx/dt
00035 // model_definition sees u b/c it's a global variable, it can't be an argument
00036 void model_definition(const ublas_vector &x, ublas_vector &dxdt, const double t)
00037 {
00038   dxdt[0] = 0.1*x[0]+u[0];
00039   dxdt[1] = 2.*x[1]+u[1];
00040 }
00041 
00043 // Functions
00045 
00046 // The main callback to calculate u
00047 void chatterCallback(const lyap_control::plant_msg& msg);
00048 
00049 void initial_error_check(const lyap_control::plant_msg& msg);
00050 
00051 // Calculate dx_dot_du and open_loop_dx_dt
00052 void calculate_dx_dot_du(boost::numeric::ublas::matrix<double> &dx_dot_du, ublas_vector & open_loop_dx_dt);
00053 
00054 // Calculate V_initial, V, and V_dot_target
00055 void calculate_V_and_damping(double &V_dot_target);
00056 
00057 // Calculate a stabilizing control effort
00058 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);


lyap_control
Author(s): Andy Zelenak
autogenerated on Wed Mar 2 2016 12:14:43