robot code for summer school

Dependencies:   PM2_Libary Eigen

Fork of PM2_Example_Summer_School by Alex Hawkins

Branch:
distance-sensor
Revision:
73:667d568da72a
Parent:
72:9325748d2d02
Child:
74:76c7a805f63d
--- a/Robot_Library/robot.h	Mon May 30 15:08:21 2022 +0200
+++ b/Robot_Library/robot.h	Mon May 30 17:02:27 2022 +0200
@@ -37,14 +37,13 @@
 
         //PID
 
-        void PID_Move(std::uint8_t s_binary);
+        void PID_Move(float position);
         void PID_Delay(int ms);
         bool IsSharpTurn(int b);
 
-        const float k_prop = 0.5f;
-        const float t_int = 0.5f;
-        const float t_deriv = 0.5f;
-        const float error_angles[4] = {0, 1, 2, 3};
+        const float k_prop = 3.0f;
+        const float k_int = 0.0f;
+        const float k_deriv = 0.0f;
 
         float previous_error_value;
         float integral_error;
@@ -52,12 +51,11 @@
         /* CONSTANTS */
 
         const float DISTANCE_THRESHOLD = 0.2f;        // minimum allowed distance to obstacle in [m]
-        const float TRANSLATIONAL_VELOCITY = 0.4f;    // translational velocity in [m/s]
-        const float ROTATIONAL_VELOCITY = 1.6f;       // rotational velocity in [rad/s]
+        const float TRANSLATIONAL_VELOCITY = 0.1f;    // translational velocity in [m/s]
         const float VELOCITY_THRESHOLD = 0.05;        // velocity threshold before switching off, in [m/s] and [rad/s]
 
-        const float WHEEL_RADIUS = 1.0f;
-        const float DISTANCE_BETWEEN_WHEELS = 1.0f;
+        const float WHEEL_RADIUS = 0.0306f;
+        const float DISTANCE_BETWEEN_WHEELS = 0.14794f;
 
         const float MAX_MOTOR_VOLTAGE = 12.0f; // define maximum motor voltage
         const float COUNTS_PER_TURN = 64.0f * 19.0f;    // define counts per turn at gearbox end: counts/turn * gearratio