Functie Inverse Kinematica
Dependencies: HIDScope MODSERIAL
main.cpp
- Committer:
- LennartvanHoorne
- Date:
- 2018-10-30
- Revision:
- 1:f3afd35a7188
- Parent:
- 0:4fc925102d99
- Child:
- 2:5abed9475e52
File content as of revision 1:f3afd35a7188:
#include "mbed.h" #include "math.h" #include "HIDScope.h" // Constantes const double L1 = 0.35; const double L2 = 0.30; const double T = 3; //Variables double q1; double q2; double vx; double vy; //Hoe werken de variabls? // q1 en q2 komen uit de Encoder dus die worden geleverd // This is the function for the Inverse Kinematics We start with a inverse Jacobian so we can determine q_dot (rotation speed of the motors) double Inverse_Kinetmatics(&q1 &q2 &q1_new &q2_new){ double invj[2][2] = { {sin(q1 + q2)/(L1*cos(q1 + q2)*sin(q1) - L1*sin(q1 + q2)*cos(q1)), -cos(q1 + q2)/(L1*cos(q1 + q2)*sin(q1) - L1*sin(q1 + q2)*cos(q1))}, {-(L2*sin(q1 + q2) + L1*sin(q1))/(L1*L2*cos(q1 + q2)*sin(q1) - L1*L2*sin(q1 + q2)*cos(q1)), (L2*cos(q1 + q2) + L1*cos(q1))/(L1*L2*cos(q1 + q2)*sin(q1) - L1*L2*sin(q1 + q2)*cos(q1))} }; double V_q1 = invj[1][1]*vx + invj[1][2]*vy; double V_q2 = invj[2][1]*vx + invj[2][2]*vy; // Numerical Integral to make it position controlled double q1_new = q1 + V_q1*T; q1 = q1_new; double q2_new = q2 + V_q2*T; q2 = q2_new; }