Project Paint / Mbed 2 deprecated arm_control

Dependencies:   mbed QEI biquadFilter

Committer:
ronvbree
Date:
Mon Oct 31 13:05:53 2016 +0000
Revision:
0:494acf21d3bc
Child:
2:fc869e45e672
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ronvbree 0:494acf21d3bc 1 #include "math.h"
ronvbree 0:494acf21d3bc 2
ronvbree 0:494acf21d3bc 3 /*
ronvbree 0:494acf21d3bc 4 Constants
ronvbree 0:494acf21d3bc 5 */
ronvbree 0:494acf21d3bc 6
ronvbree 0:494acf21d3bc 7 const float L_max = 50.0; // Max arm length
ronvbree 0:494acf21d3bc 8 const float L_min = 30.0; // Min arm length
ronvbree 0:494acf21d3bc 9
ronvbree 0:494acf21d3bc 10 const float d = 30.0; // Distance between arm centres of rotation
ronvbree 0:494acf21d3bc 11 const float h = 30.0; // Height of lower arm centre of rotation TODO -- Determine
ronvbree 0:494acf21d3bc 12
ronvbree 0:494acf21d3bc 13 const float reach = 2*sqrt(pow(L_max,2)-pow(L_min,2))-d; // Total length of wall that can be covered
ronvbree 0:494acf21d3bc 14
ronvbree 0:494acf21d3bc 15 const float y_max = (2*h + d)/2 + reach/2;
ronvbree 0:494acf21d3bc 16 const float y_min = (2*h + d)/2 - reach/2;
ronvbree 0:494acf21d3bc 17
ronvbree 0:494acf21d3bc 18 const float x_min = L_min;
ronvbree 0:494acf21d3bc 19 const float x_max = 0; // TODO
ronvbree 0:494acf21d3bc 20
ronvbree 0:494acf21d3bc 21 /*
ronvbree 0:494acf21d3bc 22 Methods
ronvbree 0:494acf21d3bc 23 */
ronvbree 0:494acf21d3bc 24
ronvbree 0:494acf21d3bc 25 // Sets the required arm lengths in the 'upper' and 'lower' parameters
ronvbree 0:494acf21d3bc 26 void getArmLengthsForRollerPosition(float x, float y, float &upper, float &lower) {
ronvbree 0:494acf21d3bc 27 lower = sqrt(pow(y-h,2)+pow(x,2));
ronvbree 0:494acf21d3bc 28 upper = sqrt(pow(lower,2)+pow(d,2)-2*d*sqrt(pow(lower,2)-pow(x,2)));
ronvbree 0:494acf21d3bc 29 }
ronvbree 0:494acf21d3bc 30
ronvbree 0:494acf21d3bc 31 // Sets the roller position corresponding to the current arm lengths in the x and y parameters
ronvbree 0:494acf21d3bc 32 void getRollerPositionForArmLengths(float upper, float lower, float &x, float &y) {
ronvbree 0:494acf21d3bc 33 y=(pow(lower,2)-pow(upper,2)+2*h*d+pow(d,2))/(2*d);
ronvbree 0:494acf21d3bc 34 x=sqrt(pow(upper,2)-pow(y-h,2)); //TODO
ronvbree 0:494acf21d3bc 35 }
ronvbree 0:494acf21d3bc 36
ronvbree 0:494acf21d3bc 37 /*
ronvbree 0:494acf21d3bc 38 Getters
ronvbree 0:494acf21d3bc 39 */
ronvbree 0:494acf21d3bc 40
ronvbree 0:494acf21d3bc 41 float getMaximalArmLength(){
ronvbree 0:494acf21d3bc 42 return L_max;
ronvbree 0:494acf21d3bc 43 }
ronvbree 0:494acf21d3bc 44
ronvbree 0:494acf21d3bc 45 float getMinimalArmLength(){
ronvbree 0:494acf21d3bc 46 return L_min;
ronvbree 0:494acf21d3bc 47 }
ronvbree 0:494acf21d3bc 48
ronvbree 0:494acf21d3bc 49 float getReach(){
ronvbree 0:494acf21d3bc 50 return reach;
ronvbree 0:494acf21d3bc 51 }
ronvbree 0:494acf21d3bc 52
ronvbree 0:494acf21d3bc 53 float getMaximalRollerHeight(){
ronvbree 0:494acf21d3bc 54 return y_max;
ronvbree 0:494acf21d3bc 55 }
ronvbree 0:494acf21d3bc 56
ronvbree 0:494acf21d3bc 57 float getMinimalRollerHeight(){
ronvbree 0:494acf21d3bc 58 return y_min;
ronvbree 0:494acf21d3bc 59 }
ronvbree 0:494acf21d3bc 60