Tarek Lule / CreaBotLib

Fork of CreaBotLib by CreaLab

Revision:
11:5a94af0afa12
Parent:
10:79509113310a
diff -r 79509113310a -r 5a94af0afa12 CreaBot.cpp
--- a/CreaBot.cpp	Wed Apr 17 21:48:00 2019 +0000
+++ b/CreaBot.cpp	Thu Apr 18 11:53:56 2019 +0000
@@ -29,8 +29,8 @@
     // TODO: To catch for illegal dimensions (<= 0)
     
     // Initialize wheel geometires
-    wheelLeft ->diam_cm = diameter_wheel_cm;
-    wheelRight->diam_cm = diameter_wheel_cm;
+    wheelLeft ->setDiamCM( diameter_wheel_cm );
+    wheelRight->setDiamCM( diameter_wheel_cm );
     // setup the bot parameters:
     botDiameter     = bot_diam_cm;
     ratio_wheel_bot = bot_diam_cm/diameter_wheel_cm;
@@ -243,7 +243,7 @@
 around a radius that is turn_radius_cm away from the right wheel*/
 void Creabot::moveRight(float turn_angle_deg, float turn_radius_cm)
 {   // If Center_cm is too small the right wheel has practically nothing to do ;)
-    if (abs(turn_radius_cm)<0.1) { moveRight(turn_angle_deg); } 
+    if (fabs(double(turn_radius_cm))<0.1) { moveRight(turn_angle_deg); } 
     else {
         wheelLeft ->setSpeed_cm_sec(botSpeed_cm_sec);
         wheelRight->setSpeed_cm_sec(botSpeed_cm_sec * turn_radius_cm/turn_radius_cm+botDiameter);
@@ -268,7 +268,7 @@
    around a radius equal to the bot size; = the left wheel stands still */
 void Creabot::moveLeft(float turn_angle_deg)
 {
-    wheelRight>setSpeed_cm_sec(botSpeed_cm_sec);
+    wheelRight->setSpeed_cm_sec(botSpeed_cm_sec);
     wheelRight->RunTurnAngle(turn_angle_deg,botDiameter);
     wheelsState = RWHEEL_RUNS;
 }
@@ -277,7 +277,7 @@
    around a radius that is turn_radius_cm away from the left wheel */
 void Creabot::moveLeft(float turn_angle_deg, float turn_radius_cm)
 {   // If Center_cm is too small the left wheel has practically nothing to do ;)
-    if (abs(turn_radius_cm)<0.1) { moveLeft(turn_angle_deg); } 
+    if (fabs(double(turn_radius_cm))<0.1) { moveLeft(turn_angle_deg); } 
     else {
         wheelLeft -> setSpeed_cm_sec(botSpeed_cm_sec * turn_radius_cm/(turn_radius_cm+botDiameter));
         wheelRight-> setSpeed_cm_sec(botSpeed_cm_sec);
@@ -333,13 +333,13 @@
 // *****************************************************************************
 
 void Creabot::wheelLeftStoppedCB()
-{   wheelsState = wheelsState & ! wheelLeft->StateValue;  // mask out Left Wheel status bit
+{   wheelsState = TWheelsState( wheelsState & LWHEEL_RUNS );  // mask out Left Wheel status bit
     if (wheelsState == LRWHEELS_STOP) // all wheels are now known to have stopped
         wheelsAllStoppedCB();
 }
 
 void Creabot::wheelRightStoppedCB()
-{   wheelsState = wheelsState & ! wheelRight->StateValue;  // mask out Left Wheel status bit
+{   wheelsState = TWheelsState( wheelsState & RWHEEL_RUNS );  // mask out Left Wheel status bit
     if (wheelsState == LRWHEELS_STOP) // all wheels are now known to have stopped
         wheelsAllStoppedCB();
 }
@@ -352,8 +352,8 @@
         // if wheels are still STOPed, that means no command to execute was left in the queue 
         if (wheelsState==LRWHEELS_STOP) 
           { // Turn motor power off!
-            wheelLeft->WheelOFF();
-            wheelRight->WheelOFF();
+            wheelLeft->MotorOFF();
+            wheelRight->MotorOFF();
             // Call the externall callback function to inform about the end of all movements
             if(extCallBack!=NULL) extCallBack( wheelsState );
           } // if wheelsState==LRWHEELS_STOP