#define LEG_R1 80.0f // Thigh length#define LEG_R2 82.0f // Calf length#define LEG_R3 22.0f // Calf fulcrum length#define LEG_R4 80.0f // Calf link length#define LEG_R5 24.0832f // Linkage bracket radius#define LEG_A5 96.73f // Linkage bracket arc angle#define LEG_R6 30.0f // Thigh link length#define LEG_R7 20.6f // Servo arm radius#define SERVO_DIST_V 20.0f // AB servo axis vertical distance#define SERVO_DIST_H 21.2f // AB servo axis horizontal distance#define SERVO_DIST_D sqrt((SERVO_DIST_V * SERVO_DIST_V) + (SERVO_DIST_H * SERVO_DIST_H))#define DEG_TO_RAD(A) ((A) * M_PI / 180.0)#define RAD_TO_DEG(A) ((A) * 180.0 / M_PI)void inverse(struct Point_t p, double* output) {double d2 = px * px + py * py;double d = sqrt(d2);double a = (d2 + ((LEG_R1 * LEG_R1) - (LEG_R2 * LEG_R2))) / (2.0 * d);double o1 = acos(a / LEG_R1);double o2 = acos(py / d);double o3 = o1 + acos((d - a) / LEG_R2);double k2 = ((LEG_R1 * LEG_R1) + (LEG_R3 * LEG_R3)) - (2.0 * LEG_R1 * LEG_R3) * cos(o3);double k = sqrt(k2);double m1 = acos((k2 + ((LEG_R1 * LEG_R1) - (LEG_R3 * LEG_R3))) / ((2.0 * LEG_R1) * k));double m2 = acos((k2 + ((LEG_R5 * LEG_R5) - (LEG_R4 * LEG_R4))) / ((2.0 * LEG_R5) * k));double m3 = px > 0.0 ? o1 - o2 : o1 + o2;double m4 = (2.0 * M_PI - DEG_TO_RAD(LEG_A5) - acos(SERVO_DIST_V / SERVO_DIST_D)) - m1 - m2 - m3;double g2 = ((LEG_R5 * LEG_R5) + (SERVO_DIST_D * SERVO_DIST_D)) - (2.0 * LEG_R5 * SERVO_DIST_D) * cos(m4);double g = sqrt(g2);double t1 = acos((g2 + ((SERVO_DIST_D * SERVO_DIST_D) - (LEG_R5 * LEG_R5))) / ((2.0 * SERVO_DIST_D) * g));double t2 = acos((g2 + ((LEG_R7 * LEG_R7) - (LEG_R6 * LEG_R6))) / ((2.0 * LEG_R7) * g));double t3 = acos(SERVO_DIST_H / SERVO_DIST_D);double servo_A = 45.0 - RAD_TO_DEG(m3);double servo_B = 135.0 - RAD_TO_DEG(t1 + t2 + t3);output[0] = servo_A;output[1] = servo_B;}
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet