Commit 6dcea292 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Add arithmetic functions to the control file language.

We can now use gear ratios. This makes parameters much more readable.
parent 3a38ef44
......@@ -43,11 +43,11 @@ comment "/*".*"*/"
number [0-9]+
hexdigit [0-9a-fA-F]
doublesimple [+-]?{number}"."{number}
doubleexp [+-]?{number}"."?{number}?"e"[+-]*{number}
doublesimple {number}"."{number}
doubleexp {number}"."?{number}?"e"[+-]*{number}
double {doublesimple}|{doubleexp}
int [+-]?{number}+
int {number}+
unsignedlong ("0x"|"0X"){hexdigit}{5,}
......@@ -63,6 +63,10 @@ boolcast "("[ \t]*"bool"[ \t]*")"
"(" { return PARENTHESESOPENSYM; }
")" { return PARENTHESESCLOSESYM; }
"," { return COMMASYM; }
"*" { return STARSYM; }
"/" { return SLASHSYM; }
"+" { return PLUSSYM; }
"-" { return MINSYM; }
"frequency" { return FREQUENCYSYM; }
"blocks" { return BLOCKSSYM; }
......
......@@ -56,8 +56,6 @@ void yyerror(yyscan_t *scanner, char const *s);
%token PARAMSSYM
%token PARENTHESESOPENSYM
%token PARENTHESESCLOSESYM
%token FLOATCASTSYM
%token DOUBLECASTSYM
%token INTCASTSYM
%token BOOLCASTSYM
%token INCLUDESYM
......@@ -65,6 +63,16 @@ void yyerror(yyscan_t *scanner, char const *s);
%token FUNC_DEG2RAD_SYM
%token FUNC_RPM2RADS_SYM
%left DUMMY_DOUBLEVAR
%left DUMMY_INTVAR
%left FLOATCASTSYM DOUBLECASTSYM
%left MINSYM
%left PLUSSYM
%left SLASHSYM
%left STARSYM
%left UMINUS
%union
{
char *string;
......@@ -74,7 +82,7 @@ void yyerror(yyscan_t *scanner, char const *s);
}
%type <dbl> doublevar
%type <dbl> doublevar_casteable
%type <dbl> double_castable
%type <integer> intvar
%type <ul> unsignedlongvar
......@@ -148,9 +156,9 @@ varlist : /* varlist may be emtpy */
var : STRINGSYM
{ controller_load_var_add_str($1, scanner); }
| doublevar
| doublevar %prec DUMMY_DOUBLEVAR
{ controller_load_var_add_dbl($1, scanner); }
| intvar
| intvar %prec DUMMY_INTVAR
{ controller_load_var_add_int($1, scanner); }
| unsignedlongvar
{ controller_load_var_add_ul($1, scanner); }
......@@ -164,37 +172,50 @@ floatlist: floatlistvar
| floatlistvar COMMASYM floatlist
;
floatlistvar: doublevar
{ controller_load_var_add_flt($1, scanner); }
floatlistvar: double_castable
{ controller_load_var_add_flt($1, scanner); }
;
double_castable: doublevar
{ $$ = $1; }
| intvar
{ controller_load_var_add_flt($1, scanner); }
{ $$ = $1; }
| unsignedlongvar
{ controller_load_var_add_flt($1, scanner); }
{ $$ = $1; }
;
doublevar: DOUBLESYM
{ $$ = $1; }
| DOUBLECASTSYM doublevar_casteable
| DOUBLECASTSYM doublevar
{ $$ = $2; }
| FLOATCASTSYM doublevar
{ $$ = $2; }
| FLOATCASTSYM doublevar_casteable
| DOUBLECASTSYM intvar
{ $$ = $2; }
| FLOATCASTSYM intvar
{ $$ = $2; }
| doublevar MINSYM doublevar
{ $$ = ($1) - ($3); }
| doublevar PLUSSYM doublevar
{ $$ = ($1) + ($3); }
| doublevar SLASHSYM doublevar
{ $$ = ($1) / ($3); }
| doublevar STARSYM doublevar
{ $$ = ($1) * ($3); }
| deg2rad
{ $$ = $1; }
| rpm2rads
{ $$ = $1; }
| MINSYM doublevar %prec UMINUS
{ $$ = - $2 }
;
doublevar_casteable: doublevar
{ $$ = $1 }
| intvar
{ $$ = $1; }
;
deg2rad: FUNC_DEG2RAD_SYM PARENTHESESOPENSYM doublevar_casteable PARENTHESESCLOSESYM
deg2rad: FUNC_DEG2RAD_SYM PARENTHESESOPENSYM double_castable PARENTHESESCLOSESYM
{ $$ = ($3) * M_PI / 180.0; }
;
rpm2rads: FUNC_RPM2RADS_SYM PARENTHESESOPENSYM doublevar_casteable PARENTHESESCLOSESYM
rpm2rads: FUNC_RPM2RADS_SYM PARENTHESESOPENSYM double_castable PARENTHESESCLOSESYM
{ $$ = ($3) * 2.0 * M_PI / 60.0; }
;
......@@ -206,6 +227,8 @@ intvar: INTSYM
{ $$ = $1; }
| BOOLCASTSYM intvar
{ $$ = $2; }
| MINSYM intvar %prec UMINUS
{ $$ = - $2 }
;
unsignedlongvar: UNSIGNEDLONGSYM
......
......@@ -225,7 +225,7 @@ params {
# maximum speed and position clients input is checked against
{ "azimuth_spg", "max_x", (float) deg2rad(270) }
{ "azimuth_spg", "min_x", (float) deg2rad(-270) }
{ "azimuth_spg", "max_v", (float) rpm2rads(0.14) }
{ "azimuth_spg", "max_v", (float) rpm2rads(2100)/15006.75 }
# acceleration and jerk we use to generate a profile
{ "azimuth_spg", "max_a", (float) 0.0002 }
{ "azimuth_spg", "max_j", (float) 0.00001 }
......@@ -236,7 +236,7 @@ params {
# maximum values within we allow normal operation
{ "azimuth_servo_state", "max_x", (float) deg2rad(270) }
{ "azimuth_servo_state", "min_x", (float) deg2rad(-270) }
{ "azimuth_servo_state", "max_v", (float) rpm2rads(0.14) }
{ "azimuth_servo_state", "max_v", (float) rpm2rads(2100)/15006.75 }
{ "azimuth_servo_state", "max_a", (float) 0.0002 }
# controller factors
{ "azimuth_pid", "kp", (float) 0.20 }
......@@ -261,14 +261,14 @@ params {
{ "azimuth_pid_limit", "offset", (float) 0.0006981317007977318308 }
{ "azimuth_pid_limit", "gain", (float)-0.3 }
# speed limit on spg + pid just before we send it to the drive
{ "azimuth_speed_limit", "min", (float) rpm2rads(-0.1999) }
{ "azimuth_speed_limit", "max", (float) rpm2rads(0.1999) }
{ "azimuth_speed_limit", "min", (float) rpm2rads(-3000)/15006.75 }
{ "azimuth_speed_limit", "max", (float) rpm2rads(3000)/15006.75 }
# gear ratio between DT and servodrive
{ "azimuth_speed_servo", "gain", (float)-15006.75 }
# torque we allow the servodrive to actuate on the DT
{ "azimuth_torque", "value", (float) 10.0 }
# inverse gear ratio between DT and servodrive
{ "azimuth_position_gain", "gain", (float)-6.663668016059439919e-05 }
{ "azimuth_position_gain", "gain", (float)-1/15006.75 }
# callibration value for position
{ "azimuth_position_offset","value", (float) 0.0 }
......@@ -286,8 +286,8 @@ params {
# we do not start in recovery mode
{ "azimuth_safety", "recover", (int) 0 }
{ "elevation_input_matrix", "constants", (float) { 1.115993583036897538e-05, -1.115993583036897538e-05 },
(float) { 2.231987166073795076e-05, 2.231987166073795076e-05 } }
{ "elevation_input_matrix", "constants", (float) { 0.5/44803.125, -0.5/44803.125 },
(float) { 1.0/44803.125, 1.0/44803.125 } }
{ "elevation_output_matrix", "constants", (float) { 44803.125, 22401.5625 },
(float) { -44803.125, 22401.5625 } }
......@@ -296,7 +296,7 @@ params {
{ "elevation_spg", "t", (float) 0.004 }
{ "elevation_spg", "max_x", (float) deg2rad(90) }
{ "elevation_spg", "min_x", (float) deg2rad(-0.05) }
{ "elevation_spg", "max_v", (float) rpm2rads(0.047) }
{ "elevation_spg", "max_v", (float) rpm2rads(2100)/44803.125 }
{ "elevation_spg", "max_a", (float) 0.0003 }
{ "elevation_spg", "max_j", (float) 0.000016 }
{ "elevation_spg", "precision_x", (float) 0.000001 }
......@@ -304,7 +304,7 @@ params {
{ "elevation_spg", "precision_v", (float) 0.000001 }
{ "elevation_servo_state", "max_x", (float) deg2rad(90) }
{ "elevation_servo_state", "min_x", (float) deg2rad(-0.05) }
{ "elevation_servo_state", "max_v", (float) rpm2rads(0.047) }
{ "elevation_servo_state", "max_v", (float) rpm2rads(2100)/44803.125 }
{ "elevation_servo_state", "max_a", (float) 0.0003 }
{ "elevation_torsion_spg", "setpoint", (float) 0.0 }
{ "elevation_torsion_spg", "t", (float) 0.004 }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment