Prototyp V2
Dependencies: PM2_Libary
Diff: main.cpp
- Revision:
- 48:0ab6b1fd455f
- Parent:
- 47:8963ca9829b9
- Child:
- 51:7d165baaa646
--- a/main.cpp Tue Apr 19 18:45:43 2022 +0200 +++ b/main.cpp Tue Apr 19 18:52:59 2022 +0200 @@ -2,7 +2,7 @@ #include "PM2_Libary.h" #include <cmath> #include <cstdint> -#include "mapping.cpp" +//#include "mapping.cpp" #include <cstdio> #include "math.h" //******************************************************************************************************************************************************************* @@ -32,6 +32,7 @@ // 78:1, 100:1, ... Metal Gearmotor 20Dx44L mm 12V CB DigitalOut enable_motors(PB_15); // create DigitalOut object to enable dc motors float pwm_period_s = 0.00005f; // define pwm period time in seconds and create FastPWM objects to command dc motors + //motor pin declaration FastPWM pwm_M_right (PB_13); //motor pin decalaration for wheels right side FastPWM pwm_M_left (PA_9); //motor pin decalaration for wheels left side @@ -52,7 +53,6 @@ float k_gear = 100.0f / 78.125f; // define additional ratio in case you are using a dc motor with a different gear box, e.g. 100:1 (DC with 100:1 has 2'000 turns for 360°) float kp = 0.1f; // define custom kp, this is the default speed controller gain for gear box 78.125:1 - //motors for tracks PositionController positionController_M_right(counts_per_turn_wheels * k_gear, kn / k_gear, kp * k_gear, max_voltage, pwm_M_right, encoder_M_right); // parameters adjusted to 100:1 gear, we need a different speed controller gain here PositionController positionController_M_left(counts_per_turn_wheels * k_gear, kn / k_gear, kp * k_gear, max_voltage, pwm_M_left, encoder_M_left); // parameters adjusted to 100:1 gear, we need a different speed controller gain here @@ -77,8 +77,8 @@ float current_deg_arm = start_deg_arm; // saves the current degree the arm has. // import functions from file mapping -extern double powerx(double base, double pow2); -extern double mapping (float adc_value_mV); +//extern double powerx(double base, double pow2); +//extern double mapping (float adc_value_mV); // 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) @@ -118,7 +118,6 @@ } //Drives forward into the next step -// calculatioin of acctual distance with wheels is needed int drive_straight(float distance) { float deg_to_turn = wheel_dist_to_deg(distance); @@ -162,8 +161,6 @@ switch (ToNextFunction) { - case 0: - break; case 1: start_position();