Project Paint / Mbed 2 deprecated arm_control

Dependencies:   mbed QEI biquadFilter

Committer:
ronvbree
Date:
Thu Nov 03 16:41:47 2016 +0000
Revision:
24:5c67674a40cf
Parent:
18:1c9dc6caab9d
comments

Who changed what in which revision?

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