From e9f7268509e45fcb9c7e969cff63c7d71ba2a3b3 Mon Sep 17 00:00:00 2001 From: tas Date: Fri, 9 Feb 2024 14:06:10 +0100 Subject: [PATCH] =?UTF-8?q?sketch=5Fnov29b.ino=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sketch_nov29b.ino | 73 ----------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 sketch_nov29b.ino diff --git a/sketch_nov29b.ino b/sketch_nov29b.ino deleted file mode 100644 index 277d33a..0000000 --- a/sketch_nov29b.ino +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include - -Servo s6,s5,s4,s3,s2; -int v6,v5,v4,v3,v2; - -void setup() { - - //s6.attach(6); - s5.attach(5); - s4.attach(4); - s3.attach(3); - // s2.attach(2); - - Serial.begin(9600); - // Setup the lengths and rotation limits for each link - Link base, upperarm, forearm, hand; - - base.init(16, b2a(0), b2a(180.0)); - upperarm.init(74, b2a(0.0), b2a(180.0)); - forearm.init(42, b2a(0.0), b2a(180.0)); - hand.init(40, b2a(0.0), b2a(180.0)); - - InverseK.attach(base, upperarm, forearm, hand); - - float a0, a1, a2, a3; - - if(InverseK.solve(120, 0, 70, a0, a1, a2, a3)) { - Serial.print(a2b(a0)); Serial.print(','); - Serial.print(a2b(a1)); Serial.print(','); - Serial.print(a2b(a2)); Serial.print(','); - Serial.println(a2b(a3)); - } else { - Serial.println("No solution found!"); - } - //s6.write(a0); - s5.write(a2b(a1)); - s4.write(a2b(a2)); - s3.write(a2b(convertServo(a3))); - - - //s3.write(90); - //writeZero(); -} - -void writeZero(){ - s5.write(90); - s4.write(10); - s3.write(convertServo(90)); -} - -void loop() { - // put your main code here, to run repeatedly: - - -} - -float b2a(float b){ - return b / 180.0 * PI - HALF_PI; -} - -// Quick conversion from radians to the Braccio angle system -float a2b(float a) { - return (a + HALF_PI) * 180 / PI; -} - -long convertServo(long l){ - - long ret = map(l, 0, 170 , 180 , 10); - - return ret; - -}