Prototyp V2

Dependencies:   PM2_Libary

Revision:
51:7d165baaa646
Parent:
48:0ab6b1fd455f
Child:
52:adfcbf71be5b
--- a/main.cpp	Tue Apr 19 18:52:59 2022 +0200
+++ b/main.cpp	Wed Apr 20 08:35:02 2022 +0200
@@ -83,6 +83,7 @@
 // calculates the deg which the arm has to take to reach a certain height (the input height has to be the height of OK Gripper area)
 double calc_arm_deg_for_height(int height_mm)
 {
+    float deg_arm;
     if ((height_mm - dist_arm_ground - (dist_grappleratt_grappler_uk - gripper_area_height)) > arm_length) //check if height is reachable
     {
         printf("Error in calc_arm_deg_for_height: desired height is bigger than Wall-E arm lenght."); // error message when desired height is not reachable. 
@@ -90,10 +91,9 @@
     else 
     {
         float height_arm = height_mm - dist_arm_ground - (dist_grappleratt_grappler_uk - gripper_area_height); // calculates the height which only the arm has to cover (- attachement height (arm to robot) etc.)
-        float deg_arm = asin(height_arm / arm_length) * 180.0/pi; // calculates the absolute degrees which the arm has to reach
-        return deg_arm;
+        deg_arm = asin(height_arm / arm_length) * 180.0/pi; // calculates the absolute degrees which the arm has to reach
     }
-    return NULL; // <------ maybe error testing necessary (value deg_arm might not be returned)
+    return deg_arm;
 }
 
 //calculates the deg which the wheels have to turn in order to cover specified distance in mm