Chun Feng Huang / STATE_FEEDBACK

Files at this revision

API Documentation at this revision

Comitter:
benson516
Date:
Tue Jan 03 15:00:01 2017 +0000
Parent:
2:0544e16ea933
Child:
4:958c25c1b151
Commit message:
Fix the dimension bugs in utilities

Changed in this revision

STATE_FEEDBACK.cpp Show annotated file Show diff for this revision Revisions of this file
STATE_FEEDBACK.h Show annotated file Show diff for this revision Revisions of this file
--- a/STATE_FEEDBACK.cpp	Thu Dec 29 16:40:52 2016 +0000
+++ b/STATE_FEEDBACK.cpp	Tue Jan 03 15:00:01 2017 +0000
@@ -113,14 +113,14 @@
     // sys_inputs = Get_VectorScalarMultiply(Mat_multiply_Vec(K_full, states),-1.0);
     //
     // With command input
-    get_Xd_ud();
+    get_inputs_compensate();
     // sys_inputs = Get_VectorPlus(inputs_d, Mat_multiply_Vec(K_full, Get_VectorPlus(states, states_d, true)), true); // minus
     sys_inputs = Get_VectorPlus(sys_inputs_compensate, Mat_multiply_Vec(K_full, states), true); // minus
 }
 
 // Private functions
 // Command (equalibrium state) related calculation
-void STATE_FEEDBACK::get_Xd_ud(void){ // Calculate the compensation variable, states_d and sys_inputs_compensate
+void STATE_FEEDBACK::get_inputs_compensate(void){ // Calculate the compensation variable, states_d and sys_inputs_compensate
     // Mat_multiply_Vec(states_d, N_xd, command);
     // Mat_multiply_Vec(inputs_d, N_ud, command);
     //
@@ -193,7 +193,7 @@
         v_c.resize(v_a.size());
     }
     //
-    for (size_t i = 0; i < n; ++i){
+    for (size_t i = 0; i < v_a.size(); ++i){
         if (is_minus){
             v_c[i] = v_a[i] - v_b[i];
         }else{
@@ -211,13 +211,13 @@
     }
     // for pure negative
     if (scale == -1.0){
-        for (size_t i = 0; i < n; ++i){
+        for (size_t i = 0; i < v_a.size(); ++i){
             v_c[i] = -v_a[i];
         }
         return v_c;
     }
     // else
-    for (size_t i = 0; i < n; ++i){
+    for (size_t i = 0; i < v_a.size(); ++i){
         v_c[i] = scale*v_a[i];
 
     }
--- a/STATE_FEEDBACK.h	Thu Dec 29 16:40:52 2016 +0000
+++ b/STATE_FEEDBACK.h	Tue Jan 03 15:00:01 2017 +0000
@@ -45,7 +45,7 @@
     vector<float> zeros_q;
 
     // Command (equalibrium state) related calculation
-    void get_Xd_ud(void); // Calculate the compensation variable, states_d and sys_inputs_compensate
+    void get_inputs_compensate(void); // Calculate the compensation variable, states_d and sys_inputs_compensate
 
     // Utilities
     void Mat_multiply_Vec(vector<float> &v_out, const vector<vector<float> > &m_left, const vector<float> &v_right); // v_out = m_left*v_right