Project Paint / Mbed 2 deprecated arm_control

Dependencies:   mbed QEI biquadFilter

Committer:
ronvbree
Date:
Thu Nov 03 13:08:44 2016 +0000
Revision:
12:8295c02d740f
Parent:
7:a80cb6b06320
Child:
18:1c9dc6caab9d
update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ronvbree 7:a80cb6b06320 1 #include "robot.h"
ronvbree 0:494acf21d3bc 2
ronvbree 12:8295c02d740f 3 // Maximum y value the roller can reach
ronvbree 12:8295c02d740f 4 //const float maxY = h + 0.5 * d + 0.5 * reach;
ronvbree 12:8295c02d740f 5 // Minimum y value the roller can reach
ronvbree 12:8295c02d740f 6 //const float minY = h + 0.5 * d - 0.5 * reach;
ronvbree 12:8295c02d740f 7 // Max x value for which the robot can paint a straight line
ronvbree 12:8295c02d740f 8 //const float maxX =
ronvbree 12:8295c02d740f 9 // Min x value for which the robot can paint a straight line
ronvbree 12:8295c02d740f 10 //const float minX = L_min;
ronvbree 12:8295c02d740f 11
ronvbree 12:8295c02d740f 12 const float topY = h + 0.5 * d + 0.3 * reach;
ronvbree 12:8295c02d740f 13 const float topX = 35;
ronvbree 12:8295c02d740f 14
ronvbree 12:8295c02d740f 15 const float bottomY = h + 0.5 * d - 0.3 * reach;
ronvbree 12:8295c02d740f 16 const float bottomX = 35;
ronvbree 12:8295c02d740f 17
ronvbree 7:a80cb6b06320 18 class RobotController {
ronvbree 7:a80cb6b06320 19 private:
ronvbree 7:a80cb6b06320 20 // Robot
ronvbree 7:a80cb6b06320 21 Robot robot;
ronvbree 7:a80cb6b06320 22 // Serial communication for debugging purposes
ronvbree 7:a80cb6b06320 23 Serial debug;
ronvbree 7:a80cb6b06320 24 // Ticker
ronvbree 7:a80cb6b06320 25 Ticker ticker;
ronvbree 7:a80cb6b06320 26 // Controllers
ronvbree 12:8295c02d740f 27 // -- Controls direct movement for the upper arm
ronvbree 7:a80cb6b06320 28 PIDController upperArmController;
ronvbree 12:8295c02d740f 29 // -- Controls direct movement for the lower arm
ronvbree 7:a80cb6b06320 30 PIDController lowerArmController;
ronvbree 12:8295c02d740f 31 // -- Controls the velocity at which the upper arm compensates for the dx induced by the lower arm
ronvbree 12:8295c02d740f 32 PIDController upperXController;
ronvbree 12:8295c02d740f 33 // -- Controls the velocity at which the lower arm compensates for the dx induced by the upper arm
ronvbree 12:8295c02d740f 34 PIDController lowerXController;
ronvbree 12:8295c02d740f 35
ronvbree 7:a80cb6b06320 36 // Reference arm lengths
ronvbree 7:a80cb6b06320 37 volatile float upperArmLengthReference;
ronvbree 7:a80cb6b06320 38 volatile float lowerArmLengthReference;
ronvbree 12:8295c02d740f 39 // Reference coordinates for straight movement
ronvbree 12:8295c02d740f 40 volatile float referenceX;
ronvbree 12:8295c02d740f 41 volatile float referenceY;
ronvbree 7:a80cb6b06320 42
ronvbree 7:a80cb6b06320 43 // Control state flags
ronvbree 7:a80cb6b06320 44 volatile bool MOVE_BY_REFERENCE;
ronvbree 7:a80cb6b06320 45 volatile bool PAINT_MOVE_UP;
ronvbree 7:a80cb6b06320 46 volatile bool PAINT_MOVE_DOWN;
ronvbree 7:a80cb6b06320 47
ronvbree 12:8295c02d740f 48 // Set all flags to false
ronvbree 12:8295c02d740f 49 void clearFlags();
ronvbree 12:8295c02d740f 50
ronvbree 7:a80cb6b06320 51 void doTick();
ronvbree 7:a80cb6b06320 52
ronvbree 7:a80cb6b06320 53 public:
ronvbree 7:a80cb6b06320 54 // Constructor
ronvbree 7:a80cb6b06320 55 RobotController();
ronvbree 7:a80cb6b06320 56 // Move the roller to a x,y coordinate
ronvbree 7:a80cb6b06320 57 void moveTo(float x, float y);
ronvbree 7:a80cb6b06320 58 // Move the arms to the indicates arm lengths
ronvbree 7:a80cb6b06320 59 void setArmLengths(float upper, float lower);
ronvbree 7:a80cb6b06320 60 // Move to max y
ronvbree 7:a80cb6b06320 61 void goToTop();
ronvbree 7:a80cb6b06320 62 // Move to min y
ronvbree 7:a80cb6b06320 63 void goToBottom();
ronvbree 7:a80cb6b06320 64 // Make a straight painting movement upwards
ronvbree 7:a80cb6b06320 65 void paintUp();
ronvbree 7:a80cb6b06320 66 // Make a straight painting movement downwards
ronvbree 7:a80cb6b06320 67 void paintDown();
ronvbree 7:a80cb6b06320 68
ronvbree 7:a80cb6b06320 69 // Robot queries
ronvbree 7:a80cb6b06320 70 bool isKilled();
ronvbree 7:a80cb6b06320 71 float getUpperArmLength();
ronvbree 7:a80cb6b06320 72 float getLowerArmLength();
ronvbree 7:a80cb6b06320 73
ronvbree 12:8295c02d740f 74 // Get the robot instance
ronvbree 7:a80cb6b06320 75 Robot* getRobot();
ronvbree 7:a80cb6b06320 76
ronvbree 7:a80cb6b06320 77 };
ronvbree 0:494acf21d3bc 78
ronvbree 0:494acf21d3bc 79