My Version of CreaBotLib
Fork of CreaBotLib by
Revision 11:5a94af0afa12, committed 2019-04-18
- Comitter:
- sepp_nepp
- Date:
- Thu Apr 18 11:53:56 2019 +0000
- Parent:
- 10:79509113310a
- Child:
- 12:530772639065
- Commit message:
- Compiles;
Changed in this revision
| CreaBot.cpp | Show annotated file Show diff for this revision Revisions of this file |
| CreaBot.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
--- a/CreaBot.h Wed Apr 17 21:48:00 2019 +0000 +++ b/CreaBot.h Thu Apr 18 11:53:56 2019 +0000 @@ -3,7 +3,7 @@ * \brief File contains Creabot Library. * CreaBot.h contains the Creabot class, and required enums and structs. - * Imports "mbed.h" and "motor.h" + * Imports "mbed.h" and "CreaMot.h" * Refactorings: * All variables with suffixes "_cm_sec" = speeds in centimeters per second. @@ -25,7 +25,7 @@ #define CREABOT_H #include "mbed.h" -#include "motor.h" +#include "CreaMot.h" #define DEFAULT_SPEED_CM_SEC 2.0f /**< Default advancement speed = 2.0cm/sec, was DEFAULT_SPEED */ #define DEPTH_Queue 256 /**< Initialize the depth of the command Queue to 256 */
