From 1cc74ce7d44a54ac61cb2e64259e3278d89f5e3d Mon Sep 17 00:00:00 2001 From: Diogo Duarte Date: Wed, 20 Mar 2019 12:48:12 +0000 Subject: [PATCH] Merge to new version --- AccelStepper/AccelStepper.cpp | 5 + AccelStepper/AccelStepper.h | 6 +- MMKIT/MMkit.cpp | 37 +++-- MMKIT/MMkit.h | 131 ++++-------------- .../FloodFillAlgorithm/Acceleration.ino | 18 ++- .../FloodFillAlgorithm/FloodFillAlgorithm.ino | 13 +- .../Advanced/FloodFillAlgorithm/nextMove.ino | 13 +- .../Advanced/FloodFillAlgorithm/robotMove.ino | 1 - .../MMkitSeqMotion/MMkitSeqMotion.ino | 12 +- .../Advanced/MMkitSeqMotion/nextMove.ino | 1 - .../Advanced/MMkitSeqMotion/robotMove.ino | 1 - .../RandomNextMove/RandomNextMove.ino | 9 +- .../Advanced/RightWallFollow/Acceleration.ino | 19 ++- .../RightWallFollow/RightWallFollow.ino | 4 - .../Advanced/RightWallFollow/nextMove.ino | 1 - .../Advanced/RightWallFollow/odometry.ino | 1 - .../Advanced/RightWallFollow/robotMove.ino | 1 - .../Advanced/TesteMicromouse/Acceleration.ino | 18 ++- .../TesteMicromouse/TesteMicromouse.ino | 2 - .../Basic/Button_switch/Button_switch.ino | 1 - .../Button_switch_Bin/Button_switch_Bin.ino | 1 - .../Basic/MoveFoward/Acceleration.ino | 19 ++- .../examples/Basic/MoveFoward/MoveFoward.ino | 2 - .../Basic/Test_Button/Test_Button.ino | 2 +- .../Basic/TesteIRSensors/TesteIRSensors.ino | 1 - MMKIT/examples/Basic/TurnLeft/TurnLeft.ino | 1 - MMKIT/examples/Basic/TurnRight/TurnRight.ino | 1 - 27 files changed, 110 insertions(+), 211 deletions(-) diff --git a/AccelStepper/AccelStepper.cpp b/AccelStepper/AccelStepper.cpp index c3b3f23..8517d2e 100644 --- a/AccelStepper/AccelStepper.cpp +++ b/AccelStepper/AccelStepper.cpp @@ -645,3 +645,8 @@ void AccelStepper::stop() move(-stepsToStop); } } + +bool AccelStepper::isRunning() +{ + return !(_speed == 0.0 || _targetPos == _currentPos); +} diff --git a/AccelStepper/AccelStepper.h b/AccelStepper/AccelStepper.h index 8363803..147ace4 100644 --- a/AccelStepper/AccelStepper.h +++ b/AccelStepper/AccelStepper.h @@ -456,8 +456,10 @@ class AccelStepper /// move() or moveTo() void computeNewSpeed(); void computeNewSpeed(int correction); - - + + /// Checks to see if the motor is currently running to a target + /// \return true if the speed is not zero or not at the target position + bool isRunning(); protected: /// \brief Direction indicator diff --git a/MMKIT/MMkit.cpp b/MMKIT/MMkit.cpp index bb74451..324f30f 100644 --- a/MMKIT/MMkit.cpp +++ b/MMKIT/MMkit.cpp @@ -40,8 +40,8 @@ boolean Running=false; int reading=0; -int _right_Correction=555;//-60 -int _left_Correction=555; //90 +int _right_Correction=550;//150 +int _left_Correction=550; //150 float _leftSpeed = 474.0; //default _leftSpeed 500 float _rightSpeed = 474.0; //default _rightSpeed 500 @@ -89,7 +89,17 @@ void MMkit::readIRSensors() { Serial.print(" = "); Serial.println(IRsensorsValues[i]); */ - } + } + current_cell.wall = B00000000; // clears cell values + if (isWallLeft() == 1) { // wall 0000 0 LRF checks if there is a left wall + current_cell.wall = current_cell.wall | B00000100; + } + if (isWallFront() == 1) { // wall 0000 0 LRF checks if there is a front wall + current_cell.wall = current_cell.wall | B00000001; + } + if (isWallRight() == 1) { // wall 0000 0 LRF checks if there is a right wall + current_cell.wall = current_cell.wall | B00000010; + } } void MMkit::testIRSensors() { for (int i=0;i<4;i++){ @@ -183,8 +193,8 @@ void MMkit::rotate(float deg) {//positive rotates Right, negative rotates Left _motorLeft.setCurrentPosition(0); _motorRight.setCurrentPosition(0); deg=deg/10; - _motorLeft.move(cmToSteps((deg/360.0)*3.14159265358979*(_WHEEL_SPACING+10))); - _motorRight.move(-cmToSteps((deg/360.0)*3.14159265358979*(_WHEEL_SPACING+10))); + _motorLeft.move(cmToSteps((deg/360.0)*3.14159265358979*_WHEEL_SPACING)); + _motorRight.move(-cmToSteps((deg/360.0)*3.14159265358979*_WHEEL_SPACING)); Running=true; } @@ -230,7 +240,7 @@ void MMkit::waitForStart(){ readIRSensors(); delay(100); - while(IRsensorsValues[0]<450||(6000 / (IRsensorsValues[1]- 17) - 4 )<6) { + while(IRsensorsValues[0]<150||(6000 / (IRsensorsValues[1]- 17) - 2 )<10) { readIRSensors(); digitalWrite(13,HIGH); int Diference_Between_Right_Left=abs(IRsensorsValues[1]-IRsensorsValues[2]); // get the difference between right and left sensor @@ -298,7 +308,7 @@ void MMkit::runSpeed() { case B00000010: //Right wall //Serial.println("Right Wall"); _motorRight.setSpeed(+(_rightSpeed-(_right_Correction-IRsensorsValues[1]))); - _motorLeft.setSpeed(_leftSpeed+(_right_Correction-IRsensorsValues[1])/3); + _motorLeft.setSpeed(_leftSpeed+(_right_Correction-IRsensorsValues[1])); break; default: _motorLeft.setSpeed(_leftSpeed); @@ -306,7 +316,7 @@ void MMkit::runSpeed() { break; } //Serial.println(IRsensorsValues[3]); - if(IRsensorsValues[0]>750&&IRsensorsValues[3]>750){ + if(IRsensorsValues[0]>890&&IRsensorsValues[3]>890){ if(_motorRight.distanceToGo()>1000&&_motorLeft.distanceToGo()>1000){ if(current_cell.theta=0x02)current_cell.y++; if(current_cell.theta=0x01)current_cell.x--; @@ -317,7 +327,16 @@ void MMkit::runSpeed() { _motorLeft.setCurrentPosition(0); _motorRight.setCurrentPosition(0); _motorLeft.setSpeed(+_leftSpeed); - _motorRight.setSpeed(_rightSpeed); + _motorRight.setSpeed(_rightSpeed); + // goForward(-1); + // while (_motorLeft.distanceToGo() < 0 || _motorRight.distanceToGo() < 0){ +// //while (_motorLeft.isRunning() || _motorRight.isRunning()){ + // _motorLeft.runSpeed(); + // _motorRight.runSpeed(); + // } + // readIRSensors(); + // _motorLeft.setCurrentPosition(0); + // _motorRight.setCurrentPosition(0); } _motorLeft.runSpeed(); diff --git a/MMKIT/MMkit.h b/MMKIT/MMkit.h index cd1ef53..efd1d6c 100644 --- a/MMKIT/MMkit.h +++ b/MMKIT/MMkit.h @@ -1,15 +1,7 @@ -// MMkit.h -// -/// \mainpage MMkit library for Arduino -/// -/// This is the Arduino MMkit library. -/// It provides an object-oriented interface for Micromouse Kit Robot. -/// -/// -/// MMKIT version -/// in development -/// V1.0 -///1 june 2016 +/* MMKIT version to control motors +in development +V1.0 +*/ #ifndef MMkit_h #define MMkit_h @@ -21,117 +13,56 @@ class MMkit { public: // IR thresholds - #define IR_FRONT_L_THRESHOLD 320 //38 105 - #define IR_FRONT_R_THRESHOLD 320 //38 - #define IR_LEFT_THRESHOLD 390 //18 - #define IR_RIGHT_THRESHOLD 390 + #define IR_FRONT_L_THRESHOLD 600 //38 105 + #define IR_FRONT_R_THRESHOLD 600 //38 + #define IR_LEFT_THRESHOLD 350 //18 + #define IR_RIGHT_THRESHOLD 350 - #define _WHEEL_SPACING 81 //mm 81 + #define _WHEEL_SPACING 81.0 //mm 81 #define _WHEEL_RADIUS 31.0 //mm 27.5 int IRsensorsValues[4]; - boolean Correction_ON; - boolean Front_Detection_ON; MMkit(AccelStepper leftMotor, AccelStepper rightMotor); - //!Description: The robot will try to move in its forward direction at the predefined - - ///forward motion speed. If a front wall is detected, the robot shall rotate right or left. + ///Description: The robot will try to move in its forward direction at the predefined + ///forward motion speed. If a front wall is detected, the robot shall rotate right or left. ///If walls are sensed on its left and right, it shall move parallel to them and ///in their middle. If only one wall is sensed, it shall move parallel to it. ///Input parameter: none ///Output parameter: none void goForward(float cm); - - //!Description: The robot will try to rotate over is axis positive right, negative values left - - ///Input parameter: desired angle in degrees - ///Output parameter: none + void rotate(float deg); - ///!Description: The robot shall rotate in it's axis the specified angle to the Right. - - ///Input parameter: desired angle in degrees + ///Description: The robot shall rotate in it's axis the specified angle to the Right. + ///Input parameter: desired angle in degrees ///Output parameter: none void rotateRight (float deg); - //!Description: The robot shall rotate in it's axis the specified angle to the Right. - - ///Input parameter: desired angle in degrees + ///Description: The robot shall rotate in it's axis the specified angle to the Right. + ///Input parameter: desired angle in degrees ///Output parameter: none void rotateLeft(float deg); - //!Description: Perform initial configuration - - ///Input parameter: none + ///Description: Perform initial configuration + ///Input parameter: none ///Output parameter: none void setupMMkit(); - - //!Description: This function makes the motor do a step so must be call each time we want the motor to turn 1,8 degrees - - ///Input parameter: none - ///Output parameter: none void run(); - - //!Description: This function makes the motor to stop, break. - - ///Input parameter: none - ///Output parameter: none void stop(); - - //!Description: This function Set the value of the LEFT IR sensor to the wall(default is 555. - - ///Input parameter: Value of IR_LEFT to the wall - ///Output parameter: none void setIR_LEFT(float LeftCorrection); - - //!Description: This function Set the value of the Right IR sensor to the wall(default is 555. - - ///Input parameter: Value of IR_RIGHT to the wall - ///Output parameter: none void setIR_RIGHT(float RightCorrection); - - //!Description: Continuously checks for the start signal (hand movement close to the left forward distance sensor where a sequence of high, low and high distances are detected) - - ///Input parameter: none + ///Description: Continuously checks for the start signal (hand movement close to the left forward distance sensor where a sequence of high, low and high distances are detected) + ///Input parameter: none ///Output parameter: none void waitForStart(); - - ///!Description: Checks if the dstance has been reached, if so returns false else is still moving returns true - ///Input parameter: none - ///Output parameter: True -> moving False -> Stop boolean running(); - - //!Description: Reads the values of the IRsensorsValues and stores the values in IRsensorsValues[0], IRsensorsValues[1], IRsensorsValues[2], IRsensorsValues[3] - - ///Input parameter: none - ///Output parameter: none, values are stored at IRsensorsValues[], void readIRSensors(); - - //!Description: Reads the values of the IRsensorsValues and stores the values in IRsensorsValues[0], IRsensorsValues[1], IRsensorsValues[2], IRsensorsValues[3] - - ///Input parameter: none - ///Output parameter: Reads and Prints the values stored at IRsensorsValues[], void testIRSensors(); - - //!Description: compares de treshold value to the readvalue and if this Value is Higher returns true - - ///Input parameter: none - ///Output parameter: True if there is wall present boolean isWallRight(void); - - //!Description: compares de treshold value to the readvalue and if this Value is Higher returns true - - ///Input parameter: none - ///Output parameter: True if there is wall present boolean isWallLeft(void); - - //!Description: compares de treshold value to the readvalue and if this Value is Higher returns true - - ///Input parameter: none - ///Output parameter: True if there is wall present boolean isWallFront(void); /*********************/ @@ -143,7 +74,7 @@ struct cell unsigned char y; unsigned char theta; unsigned char wall; - uint8_t weight; + unsigned char weight; }; struct cell current_cell; struct cell track[156]; @@ -159,28 +90,24 @@ struct cell /// Output parameter: none /// void setWHEEL_RADIUS(float WHEEL_RADIUS); - //! Description: Define the forward motion velocity of the robot - - /// Input parameter: desired speed in cm/s + /// Description: Define the forward motion velocity of the robot + /// Input parameter: desired speed in cm/s /// Output parameter: none /// Used by: void setForwardMotionSpeed (float speed); - //! Description: Get the configured forward motion velocity of the robot - - /// Input parameter: none + /// Description: Get the configured forward motion velocity of the robot + /// Input parameter: none /// Output parameter: speed in cm/s float getForwardMotionSpeed(void); - //!Description: Define the forward motion acceleration of the robot. - - ///Input parameter: desired acceleration in cm/s + ///Description: Define the forward motion acceleration of the robot. + ///Input parameter: desired acceleration in cm/s ///Output parameter: none void setForwardMotionAcceleration (float Acceleration); - //! Description: Get the configured forward motion acceleration of the robot. - - /// Input parameter: none + /// Description: Get the configured forward motion acceleration of the robot. + /// Input parameter: none /// Output parameter: acceleration in cm/s float getForwardMotionAcceleration(void); diff --git a/MMKIT/examples/Advanced/FloodFillAlgorithm/Acceleration.ino b/MMKIT/examples/Advanced/FloodFillAlgorithm/Acceleration.ino index 45d8b26..7a57c6a 100644 --- a/MMKIT/examples/Advanced/FloodFillAlgorithm/Acceleration.ino +++ b/MMKIT/examples/Advanced/FloodFillAlgorithm/Acceleration.ino @@ -1,12 +1,10 @@ -/**@file acceleration.ino*/ void acceleration(void) { - unsigned long currentMicros = micros(); - if (currentMicros>= previousMicros + 900) { - previousMicros = currentMicros; - if (aceleration <= velocidade) { - Grigoras.setForwardMotionSpeed((int) aceleration); - aceleration = aceleration + aceleration / 100; - } - } -} \ No newline at end of file +if (aceleration<=velocidade){ + Grigoras.setForwardMotionSpeed((int) aceleration); + aceleration=aceleration+aceleration/100; + Serial.println((int) aceleration); + }else{ + Serial.println((int) aceleration); + } +} diff --git a/MMKIT/examples/Advanced/FloodFillAlgorithm/FloodFillAlgorithm.ino b/MMKIT/examples/Advanced/FloodFillAlgorithm/FloodFillAlgorithm.ino index 6600a3c..48b8d3b 100644 --- a/MMKIT/examples/Advanced/FloodFillAlgorithm/FloodFillAlgorithm.ino +++ b/MMKIT/examples/Advanced/FloodFillAlgorithm/FloodFillAlgorithm.ino @@ -1,4 +1,3 @@ -/**@file*/ /* This example was created by Sérgio Silva on the 20th April 2015 @@ -31,7 +30,7 @@ enum statesRobotMovements { STATE_MOV_STOP }; -uint8_t Map[16][16] ={ +int Map[16][16] ={ { 16, 15, 14, 13, 12, 11, 10, 9, 9, 10, 11, 12, 13, 14, 15, 16 }, { 15, 14, 13, 12, 11, 10, 9, 8, 8, 9, 10, 11, 12, 13, 14, 15 }, { 14, 13, 12, 11, 10, 9, 8, 7, 7, 8, 9, 10, 11, 12, 13, 14 }, @@ -57,7 +56,6 @@ boolean turn=false; unsigned int Step=0; unsigned int velocidade=10; double aceleration=1; //usada para chegar a velocidade -unsigned long previousMicros=0; void setup(){ Grigoras.current_cell.x = 5; // Start x position @@ -85,7 +83,6 @@ void loop(){ else{ digitalWrite(13,LOW); turn=false; - Grigoras.readIRSensors(); toMove = nextMove(); robotMove(); @@ -134,14 +131,10 @@ void checkTrack(){ void reMap() { for (int i = Step; i >= 0; i--) { - if((Grigoras.track[i].wall==B00000101)||(Grigoras.track[i].wall==B00000110)||(Grigoras.track[i].wall==B00000011)){ Grigoras.track[i].weight++; Map[Grigoras.track[i].y][Grigoras.track[i].x] = Grigoras.track[i].weight; - }else{ - Grigoras.current_cell.weight++; - break; - } + } Grigoras.current_cell.weight++; } -} + diff --git a/MMKIT/examples/Advanced/FloodFillAlgorithm/nextMove.ino b/MMKIT/examples/Advanced/FloodFillAlgorithm/nextMove.ino index 984a148..91963b8 100644 --- a/MMKIT/examples/Advanced/FloodFillAlgorithm/nextMove.ino +++ b/MMKIT/examples/Advanced/FloodFillAlgorithm/nextMove.ino @@ -1,4 +1,3 @@ -/**@file*/ unsigned char nextMove(void) { unsigned char nMove; @@ -344,18 +343,10 @@ unsigned char nextMove(void) if (Grigoras.current_cell.wall==B00000111){ Serial.println("Beco sem saida"); nMove = STATE_MOV_UTURN; - if(75+Step<=255){ - Map[Grigoras.current_cell.y][Grigoras.current_cell.x]=75+Step; - }else{ - Map[Grigoras.current_cell.y][Grigoras.current_cell.x]=255; - } + Map[Grigoras.current_cell.y][Grigoras.current_cell.x]=100+Step; for(int i=Step;i>=0;i--){ if((Grigoras.track[i].wall==B00000101)||(Grigoras.track[i].wall==B00000110)||(Grigoras.track[i].wall==B00000011)){ - if(75+i<=255){ - Map[Grigoras.track[i].y][Grigoras.track[i].x]=75+i; - }else{ - Map[Grigoras.track[i].y][Grigoras.track[i].x]=255; - } + Map[Grigoras.track[i].y][Grigoras.track[i].x]=100+Step; } else{ Step=i; diff --git a/MMKIT/examples/Advanced/FloodFillAlgorithm/robotMove.ino b/MMKIT/examples/Advanced/FloodFillAlgorithm/robotMove.ino index 5610692..456bb75 100644 --- a/MMKIT/examples/Advanced/FloodFillAlgorithm/robotMove.ino +++ b/MMKIT/examples/Advanced/FloodFillAlgorithm/robotMove.ino @@ -1,4 +1,3 @@ -/**@file*/ void robotMove(void) { switch (stateMovement) { diff --git a/MMKIT/examples/Advanced/MMkitSeqMotion/MMkitSeqMotion.ino b/MMKIT/examples/Advanced/MMkitSeqMotion/MMkitSeqMotion.ino index eedddd9..de59d67 100644 --- a/MMKIT/examples/Advanced/MMkitSeqMotion/MMkitSeqMotion.ino +++ b/MMKIT/examples/Advanced/MMkitSeqMotion/MMkitSeqMotion.ino @@ -1,4 +1,4 @@ -/**@file*/ + /* This example was created by Sérgio Silva on the 20th April 2015 @@ -29,14 +29,10 @@ enum statesRobotMovements { unsigned char stateMovement = STATE_MOV_FRONT; unsigned char toMove = STATE_MOV_FRONT; boolean turn=false; -unsigned int velocidade=10; -double aceleration=1; //usada para chegar a velocidade -unsigned long previousMicros=0; -int a=0; void setup(){ Grigoras.setupMMkit(); // Starts the MMkit Grigoras.goForward(18.0); //distance to go forward in cm (18.0) means 18.0cm - Grigoras.setForwardMotionSpeed(1); //sets forward speed + Grigoras.setForwardMotionSpeed(6); //sets forward speed Grigoras.waitForStart(); // waits for hand passing front right sensors } @@ -44,8 +40,7 @@ void setup(){ void loop() { if(Grigoras.running()==true) { if(turn==false){ - acceleration(); - Grigoras.runSpeed(); //moves at the desired speed + Grigoras.runSpeed(); //moves at the desired speed } else{ Grigoras.run(); @@ -53,7 +48,6 @@ void loop() { } else{ turn=false; - Grigoras.readIRSensors(); stateMovement = nextMove(stateMovement); robotMove(); diff --git a/MMKIT/examples/Advanced/MMkitSeqMotion/nextMove.ino b/MMKIT/examples/Advanced/MMkitSeqMotion/nextMove.ino index 90408e6..ca5fc35 100644 --- a/MMKIT/examples/Advanced/MMkitSeqMotion/nextMove.ino +++ b/MMKIT/examples/Advanced/MMkitSeqMotion/nextMove.ino @@ -1,4 +1,3 @@ -/**@file*/ unsigned char nextMove(unsigned char State) { unsigned char nMove=State; diff --git a/MMKIT/examples/Advanced/MMkitSeqMotion/robotMove.ino b/MMKIT/examples/Advanced/MMkitSeqMotion/robotMove.ino index 8f2684b..32eaa06 100644 --- a/MMKIT/examples/Advanced/MMkitSeqMotion/robotMove.ino +++ b/MMKIT/examples/Advanced/MMkitSeqMotion/robotMove.ino @@ -1,4 +1,3 @@ -/**@file*/ void robotMove(void) { a=a+1; diff --git a/MMKIT/examples/Advanced/RandomNextMove/RandomNextMove.ino b/MMKIT/examples/Advanced/RandomNextMove/RandomNextMove.ino index f95b3ea..6cb1f2f 100644 --- a/MMKIT/examples/Advanced/RandomNextMove/RandomNextMove.ino +++ b/MMKIT/examples/Advanced/RandomNextMove/RandomNextMove.ino @@ -1,4 +1,3 @@ -/**@file*/ /* This example was created by Sérgio Silva on the 20th April 2015 @@ -29,14 +28,10 @@ enum statesRobotMovements { unsigned char stateMovement = STATE_MOV_FRONT; unsigned char toMove = STATE_MOV_FRONT; boolean turn=false; -unsigned int velocidade=10; -double aceleration=1; //usada para chegar a velocidade -unsigned long previousMicros=0; - void setup(){ Grigoras.setupMMkit(); // Starts the MMkit Grigoras.goForward(18.0); //distance to go forward in cm (18.0) means 18.0cm - Grigoras.setForwardMotionSpeed(velocidade); //sets forward speed + Grigoras.setForwardMotionSpeed(500); //sets forward speed Grigoras.waitForStart(); // waits for hand passing front right sensors } @@ -44,7 +39,6 @@ void loop(){ if(Grigoras.running()==true) { if(turn==false){ - acceleration(); Grigoras.runSpeed(); //moves at the desired speed } else{ @@ -54,7 +48,6 @@ void loop(){ else{ digitalWrite(13,HIGH); turn=false; - Grigoras.readIRSensors(); stateMovement = nextMove(stateMovement); robotMove(); diff --git a/MMKIT/examples/Advanced/RightWallFollow/Acceleration.ino b/MMKIT/examples/Advanced/RightWallFollow/Acceleration.ino index 45d8b26..b2e286f 100644 --- a/MMKIT/examples/Advanced/RightWallFollow/Acceleration.ino +++ b/MMKIT/examples/Advanced/RightWallFollow/Acceleration.ino @@ -1,12 +1,11 @@ -/**@file acceleration.ino*/ void acceleration(void) { - unsigned long currentMicros = micros(); - if (currentMicros>= previousMicros + 900) { - previousMicros = currentMicros; - if (aceleration <= velocidade) { - Grigoras.setForwardMotionSpeed((int) aceleration); - aceleration = aceleration + aceleration / 100; - } - } -} \ No newline at end of file +if (aceleration<=velocidade){ + Grigoras.setForwardMotionSpeed((int) aceleration); + aceleration=aceleration+aceleration/100; + Serial.println((int) aceleration); + }else{ + Serial.println((int) aceleration); + } +} + diff --git a/MMKIT/examples/Advanced/RightWallFollow/RightWallFollow.ino b/MMKIT/examples/Advanced/RightWallFollow/RightWallFollow.ino index 830ff48..552a4a9 100644 --- a/MMKIT/examples/Advanced/RightWallFollow/RightWallFollow.ino +++ b/MMKIT/examples/Advanced/RightWallFollow/RightWallFollow.ino @@ -1,4 +1,3 @@ -/**@file*/ /* This example was created by Sérgio Silva on the 20th April 2015 @@ -36,8 +35,6 @@ unsigned char toMove = STATE_MOV_FRONT; boolean turn=false; unsigned int velocidade=10; double aceleration=1; //usada para chegar a velocidade -unsigned long previousMicros=0; - void setup(){ //start maze size 16;14;12;10; 8; 6; 4 Grigoras.current_cell.x = 5; // Start x position 0; 1; 2; 3; 4; 5; 6 Grigoras.current_cell.y =10; // Start y position 15;14;13;12;11;10; 9 @@ -63,7 +60,6 @@ void loop(){ else{ digitalWrite(13,LOW); turn=false; - Grigoras.readIRSensors(); toMove = nextMove(stateMovement); robotMove(); } diff --git a/MMKIT/examples/Advanced/RightWallFollow/nextMove.ino b/MMKIT/examples/Advanced/RightWallFollow/nextMove.ino index b9db51c..478ec89 100644 --- a/MMKIT/examples/Advanced/RightWallFollow/nextMove.ino +++ b/MMKIT/examples/Advanced/RightWallFollow/nextMove.ino @@ -1,4 +1,3 @@ -/**@file*/ unsigned char nextMove(unsigned char State) { unsigned char nMove=State; diff --git a/MMKIT/examples/Advanced/RightWallFollow/odometry.ino b/MMKIT/examples/Advanced/RightWallFollow/odometry.ino index 60872a6..a46717d 100644 --- a/MMKIT/examples/Advanced/RightWallFollow/odometry.ino +++ b/MMKIT/examples/Advanced/RightWallFollow/odometry.ino @@ -1,4 +1,3 @@ -/**@file*/ unsigned char odometry(unsigned char THETA, unsigned char MOVE){ //Grigoras.current_cell.theta switch (MOVE){ diff --git a/MMKIT/examples/Advanced/RightWallFollow/robotMove.ino b/MMKIT/examples/Advanced/RightWallFollow/robotMove.ino index cc33481..4c48da1 100644 --- a/MMKIT/examples/Advanced/RightWallFollow/robotMove.ino +++ b/MMKIT/examples/Advanced/RightWallFollow/robotMove.ino @@ -1,4 +1,3 @@ -/**@file*/ void robotMove(void) { switch (stateMovement) { diff --git a/MMKIT/examples/Advanced/TesteMicromouse/Acceleration.ino b/MMKIT/examples/Advanced/TesteMicromouse/Acceleration.ino index 45d8b26..7a57c6a 100644 --- a/MMKIT/examples/Advanced/TesteMicromouse/Acceleration.ino +++ b/MMKIT/examples/Advanced/TesteMicromouse/Acceleration.ino @@ -1,12 +1,10 @@ -/**@file acceleration.ino*/ void acceleration(void) { - unsigned long currentMicros = micros(); - if (currentMicros>= previousMicros + 900) { - previousMicros = currentMicros; - if (aceleration <= velocidade) { - Grigoras.setForwardMotionSpeed((int) aceleration); - aceleration = aceleration + aceleration / 100; - } - } -} \ No newline at end of file +if (aceleration<=velocidade){ + Grigoras.setForwardMotionSpeed((int) aceleration); + aceleration=aceleration+aceleration/100; + Serial.println((int) aceleration); + }else{ + Serial.println((int) aceleration); + } +} diff --git a/MMKIT/examples/Advanced/TesteMicromouse/TesteMicromouse.ino b/MMKIT/examples/Advanced/TesteMicromouse/TesteMicromouse.ino index de7452a..49a9d48 100644 --- a/MMKIT/examples/Advanced/TesteMicromouse/TesteMicromouse.ino +++ b/MMKIT/examples/Advanced/TesteMicromouse/TesteMicromouse.ino @@ -1,4 +1,3 @@ -/**@file*/ /* This example was created by Sérgio Silva on the 20th April 2015 @@ -45,7 +44,6 @@ unsigned char toMove = STATE_MOV_FRONT; char value = B00; unsigned int velocidade = 10; double aceleration = 1; //usada para chegar a velocidade -unsigned long previousMicros=0; void setup() { pinMode(2, INPUT); pinMode(3, INPUT); diff --git a/MMKIT/examples/Basic/Button_switch/Button_switch.ino b/MMKIT/examples/Basic/Button_switch/Button_switch.ino index 4145b01..fcacd88 100644 --- a/MMKIT/examples/Basic/Button_switch/Button_switch.ino +++ b/MMKIT/examples/Basic/Button_switch/Button_switch.ino @@ -1,4 +1,3 @@ -/**@file*/ /* This example was created by Sérgio Silva on the 20th April 2015 diff --git a/MMKIT/examples/Basic/Button_switch_Bin/Button_switch_Bin.ino b/MMKIT/examples/Basic/Button_switch_Bin/Button_switch_Bin.ino index 9fa867f..a660f04 100644 --- a/MMKIT/examples/Basic/Button_switch_Bin/Button_switch_Bin.ino +++ b/MMKIT/examples/Basic/Button_switch_Bin/Button_switch_Bin.ino @@ -1,4 +1,3 @@ -/**@file*/ /* This example was created by Sérgio Silva on the 20th April 2015 diff --git a/MMKIT/examples/Basic/MoveFoward/Acceleration.ino b/MMKIT/examples/Basic/MoveFoward/Acceleration.ino index 45d8b26..b2e286f 100644 --- a/MMKIT/examples/Basic/MoveFoward/Acceleration.ino +++ b/MMKIT/examples/Basic/MoveFoward/Acceleration.ino @@ -1,12 +1,11 @@ -/**@file acceleration.ino*/ void acceleration(void) { - unsigned long currentMicros = micros(); - if (currentMicros>= previousMicros + 900) { - previousMicros = currentMicros; - if (aceleration <= velocidade) { - Grigoras.setForwardMotionSpeed((int) aceleration); - aceleration = aceleration + aceleration / 100; - } - } -} \ No newline at end of file +if (aceleration<=velocidade){ + Grigoras.setForwardMotionSpeed((int) aceleration); + aceleration=aceleration+aceleration/100; + Serial.println((int) aceleration); + }else{ + Serial.println((int) aceleration); + } +} + diff --git a/MMKIT/examples/Basic/MoveFoward/MoveFoward.ino b/MMKIT/examples/Basic/MoveFoward/MoveFoward.ino index 6b0c517..b854b5a 100644 --- a/MMKIT/examples/Basic/MoveFoward/MoveFoward.ino +++ b/MMKIT/examples/Basic/MoveFoward/MoveFoward.ino @@ -1,4 +1,3 @@ -/**@file*/ /* This example was created by Sérgio Silva on the 20th April 2015 @@ -30,7 +29,6 @@ unsigned char stateMovement = STATE_MOV_FRONT; unsigned char toMove = STATE_MOV_FRONT; unsigned int velocidade=10; double aceleration=1; //usada para chegar a velocidade -unsigned long previousMicros=0; void setup(){ Grigoras.setupMMkit(); // Starts the MMkit Grigoras.goForward(20.0); //distance to go forward in cm (18.0) means 18.0cm diff --git a/MMKIT/examples/Basic/Test_Button/Test_Button.ino b/MMKIT/examples/Basic/Test_Button/Test_Button.ino index 359d9f8..f01aa3c 100644 --- a/MMKIT/examples/Basic/Test_Button/Test_Button.ino +++ b/MMKIT/examples/Basic/Test_Button/Test_Button.ino @@ -1,4 +1,4 @@ -/**@file*/ + /* This example was created by Sérgio Silva on the 20th April 2015 diff --git a/MMKIT/examples/Basic/TesteIRSensors/TesteIRSensors.ino b/MMKIT/examples/Basic/TesteIRSensors/TesteIRSensors.ino index e2a4729..b1a8234 100644 --- a/MMKIT/examples/Basic/TesteIRSensors/TesteIRSensors.ino +++ b/MMKIT/examples/Basic/TesteIRSensors/TesteIRSensors.ino @@ -1,4 +1,3 @@ -/**@file*/ /* This example was created by Sérgio Silva on the 20th April 2015 diff --git a/MMKIT/examples/Basic/TurnLeft/TurnLeft.ino b/MMKIT/examples/Basic/TurnLeft/TurnLeft.ino index 5260c9c..60acd0b 100644 --- a/MMKIT/examples/Basic/TurnLeft/TurnLeft.ino +++ b/MMKIT/examples/Basic/TurnLeft/TurnLeft.ino @@ -1,4 +1,3 @@ -/**@file*/ #include #include AccelStepper motorLeft(AccelStepper::DRIVER, 9, 8); diff --git a/MMKIT/examples/Basic/TurnRight/TurnRight.ino b/MMKIT/examples/Basic/TurnRight/TurnRight.ino index ed0ec1c..278d957 100644 --- a/MMKIT/examples/Basic/TurnRight/TurnRight.ino +++ b/MMKIT/examples/Basic/TurnRight/TurnRight.ino @@ -1,4 +1,3 @@ -/**@file*/ #include #include AccelStepper motorLeft(AccelStepper::DRIVER, 9, 8);