Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI biquadFilter
Diff: controller.h
- Revision:
- 7:a80cb6b06320
- Parent:
- 0:494acf21d3bc
- Child:
- 12:8295c02d740f
--- a/controller.h	Wed Nov 02 09:26:38 2016 +0000
+++ b/controller.h	Wed Nov 02 16:29:13 2016 +0000
@@ -1,7 +1,51 @@
-#include "arm.h"
+#include "robot.h"
 
-bool constantMovementTo(Arm arm, float length);
-
-bool proportionalMovementTo(Arm upper, Arm lower, float y);
+class RobotController {
+    private:
+        // Robot
+        Robot robot;
+        // Serial communication for debugging purposes
+        Serial debug;
+        // Ticker
+        Ticker ticker;
+        // Controllers
+        PIDController upperArmController;
+        PIDController lowerArmController;
+        // Reference arm lengths
+        volatile float upperArmLengthReference;
+        volatile float lowerArmLengthReference;
+        
+        // Control state flags
+        volatile bool MOVE_BY_REFERENCE;
+        volatile bool PAINT_MOVE_UP;
+        volatile bool PAINT_MOVE_DOWN;
+        
+        void doTick();
+        
+    public:
+        // Constructor
+        RobotController();
+        // Move the roller to a x,y coordinate
+        void moveTo(float x, float y);
+        // Move the arms to the indicates arm lengths
+        void setArmLengths(float upper, float lower);
+        // Move to max y
+        void goToTop();
+        // Move to min y
+        void goToBottom();
+        // Make a straight painting movement upwards
+        void paintUp();
+        // Make a straight painting movement downwards
+        void paintDown();
+        
+        // Robot queries
+        bool isKilled();
+        float getUpperArmLength();
+        float getLowerArmLength();
+        
+        // Get the robot object
+        Robot* getRobot();
+    
+};