Complete burgerboy3000 code with commentary
Dependencies: HIDScope MODSERIAL QEI mbed
Fork of Burgerboy3000code by
Revision 33:db4fc2f642f0, committed 2016-11-07
- Comitter:
- WterVeldhuis
- Date:
- Mon Nov 07 12:42:58 2016 +0000
- Parent:
- 32:952f3f30a0cd
- Commit message:
- really really final code with commentary
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 07 12:21:12 2016 +0000 +++ b/main.cpp Mon Nov 07 12:42:58 2016 +0000 @@ -23,8 +23,8 @@ PwmOut M3_Speed(D6); // encoder side pot 1 spatel rotation //Booleans for simplifying the EMG control -bool links; -bool rechts; +bool left; +bool right; //EMG related inputs and outputs HIDScope scope( 2 ); @@ -45,7 +45,7 @@ float wheel1 = 16; float wheel2 = 31; float wheel3 = 41; -float overbrenging = ((wheel2/wheel1)*(wheel3/wheel1)); +float transmission = ((wheel2/wheel1)*(wheel3/wheel1)); float pi = 3.14159265359; //Global filter variables @@ -95,7 +95,7 @@ //setpoints volatile float setpointRotation; volatile float setpointTranslation; -const double Setpoint_Translation = -200; +const double Setpoint_Translation = -300; const double Setpoint_Back = 0; const double Setpoint_Rotation = pi; double M3_ControlSpeed = 0; @@ -170,7 +170,7 @@ float pulses2 = motor2.getPulses(); float degrees2 = (pulses2/Puls_degree); float radians2 = (degrees2/360)*2*pi; - float translation = ((radians2/overbrenging)*32.25); + float translation = ((radians2/transmission)*32.25); return translation; } @@ -259,7 +259,7 @@ M2_ControlSpeed = 0; } - if ((theta_translation < -192) && (M2_ControlSpeed == 0)) + if ((theta_translation < -292) && (M2_ControlSpeed == 0)) booltranslate = true; if ((theta_translation > -8) && (M2_ControlSpeed == 0)) booltranslate = false; @@ -317,52 +317,52 @@ //booleans based on EMG input if (lowpassFilterRight < threshold_Right) - rechts = 0; + right = 0; if (lowpassFilterRight > threshold_Right) - rechts = 1; + right = 1; if (lowpassFilterLeft < threshold_Left) - links = 0; + left = 0; if (lowpassFilterLeft > threshold_Left) - links = 1; + left = 1; pc.baud(115200); //based on the EMG inputs and the boolean 'turn' (which is a go flag for the burger flip action) turnLeft and turnRight are set. //turnLeft and turnRight control the base motor which rotates the entire robot. - if ((rechts == 1) && (links == 1) && (turn == 0)) { + if ((right == 1) && (left == 1) && (turn == 0)) { turnLeft = 0; turnRight = 0; turn = 1; - pc.printf("begin de actie \n \r "); + pc.printf("start action \n \r "); wait(waiter); - } else if ((rechts == 1) && (links == 1) && (turn == 1)) { + } else if ((right == 1) && (left == 1) && (turn == 1)) { turnLeft = 0; turnRight = 0; turn = 0; - pc.printf("breek de actie af \n \r "); + pc.printf("cancel action \n \r "); GoBack(); wait(waiter); - } else if ((rechts == 0) && (links == 0)&& (turn == 0)) { + } else if ((right == 0) && (left == 0)&& (turn == 0)) { - } else if ((rechts == 1) && (turnLeft == 0)&& (turn == 0)) { + } else if ((right == 1) && (turnLeft == 0)&& (turn == 0)) { /* if the right button is pressed and the motor isn't rotating to the left, then start rotating to the right etc*/ turnRight = !turnRight; - pc.printf("draai naar rechts \n \r "); + pc.printf("turn right \n \r "); wait(waiter); - } else if ((rechts == 1) && (turnLeft == 1)&& (turn == 0)) { + } else if ((right == 1) && (turnLeft == 1)&& (turn == 0)) { turnLeft = 0; turnRight = !turnRight; - pc.printf("draai naar rechts na links \n \r "); + pc.printf("turn right after left \n \r "); wait(waiter); - } else if ((links == 1) && (turnRight == 0)&& (turn == 0)) { + } else if ((left == 1) && (turnRight == 0)&& (turn == 0)) { turnLeft = !turnLeft; - pc.printf("draai naar links \n \r "); + pc.printf("turn left \n \r "); wait(waiter); - } else if ((links == 1) && (turnRight == 1) && (turn == 0)) { + } else if ((left == 1) && (turnRight == 1) && (turn == 0)) { turnRight = 0; turnLeft = !turnLeft; - pc.printf("draai naar links na rechts \n \r "); + pc.printf("turn left after right \n \r "); wait(waiter); } wait(2*waiter);