Example project for the Line Follower robot.

Dependencies:   PM2_Libary Eigen

Revision:
47:5ce234723e3a
Parent:
46:fd580fa68618
Child:
48:3ae406d7554a
--- a/main.cpp	Fri May 13 20:53:37 2022 +0000
+++ b/main.cpp	Sat May 14 09:56:31 2022 +0200
@@ -56,10 +56,10 @@
     SpeedController* speedControllers[1];
     speedControllers[0] = new SpeedController(counts_per_turn, kn, max_voltage, pwm_M1, encoder_M1);
     //speedControllers[1] = new SpeedController(counts_per_turn, kn, max_voltage, pwm_M2, encoder_M2);
-    speedControllers[0]->setMaxAccelerationRPM(22.0f * max_voltage * kn * 0.05f);
+    speedControllers[0]->setMaxAccelerationRPS(0.36f * max_voltage * kn * 0.1f);
     //speedControllers[1]->setMaxAccelerationRPM(22.0f * max_voltage * kn * 0.1f);
     PositionController* positionController = new PositionController(counts_per_turn, kn, max_voltage, pwm_M2, encoder_M2);
-    positionController->setMaxAccelerationRPM(22.0f * max_voltage * kn * 0.05f);
+    positionController->setMaxAccelerationRPS(0.36f * max_voltage * kn * 0.1f);
     positionController->setMaxVelocityRPS(2.0f);
     //std::vector<SpeedController*> speedControllers;
     //speedControllers.push_back( new SpeedController(counts_per_turn, kn, max_voltage, pwm_M1, encoder_M1) );
@@ -76,10 +76,10 @@
     Eigen::Matrix2f Crobot2wheel; // transform robot to wheel
     Eigen::Vector2f robot_coord;  // contains v and w (robot translational and rotational velocities)
     Eigen::Vector2f wheel_speed;  // w1 w2 (wheel speed)
-    Cwheel2robot << r_wheel / 2.0f,  r_wheel / 2.0f,
-                 r_wheel / L_wheel, -r_wheel / L_wheel;
+    Cwheel2robot << r_wheel / 2.0f   ,  r_wheel / 2.0f   ,
+                    r_wheel / L_wheel, -r_wheel / L_wheel;
     Crobot2wheel << 1.0f / r_wheel,  L_wheel / (2.0f * r_wheel),
-                 1.0f / r_wheel, -L_wheel / (2.0f * r_wheel);
+                    1.0f / r_wheel, -L_wheel / (2.0f * r_wheel);
     robot_coord.setZero();
     wheel_speed.setZero();
 
@@ -105,6 +105,8 @@
 
         if (do_execute_main_task) {
 
+            
+
             // read SensorBar
             static float sensor_bar_avgAngleRad = 0.0f; // by making this static it will not be overwritten (only fist time set to zero)
             if (sensor_bar.isAnyLedActive()) {