demo project

Dependencies:   AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL

Revision:
13:ffeff9b5e513
Parent:
12:ac6c9d7f8c40
Child:
15:4bd10f531cdc
--- a/RobotArm.h	Thu Jan 07 17:31:23 2016 +0000
+++ b/RobotArm.h	Fri Jan 15 22:02:46 2016 +0000
@@ -11,7 +11,8 @@
 #include "DynamixelBus.h"
 #include "NodeAX12.h"
 
-#define MAX_PARTS   8
+// define number of joints for this arm
+#define NUMJOINTS   5
 
 
 enum ArmAction
@@ -43,38 +44,44 @@
     
     RobotArm();
     
-    // start - move all parts to specified postions in ms time
-    bool MoveArmPositionsStart(vector<float> positions, int ms);
+    // move all parts to specified postions in ms time - start
+    bool MoveArmPositionsStart(float positions[], int ms);
+    
+    // move all parts to specified postions - resume after pause
+    bool MoveArmPositionsResume();
 
-    // start - move all parts to specified postions - test if done
+    // move all parts to specified postions - test if done
     bool MoveArmPositionsHasNext();
     
-    // start - move all parts to specified postions - next step
+    // move all parts to specified postions - next step
     bool MoveArmPositionsNext();
 
-    // start - move all parts to specified postions - next delay
+    // move all parts to specified postions - next step delay
     bool MoveArmPositionsDelay(int& nextdelay);
 
-    // start - move all parts to specified postions - finish
+    // move all parts to specified postions - finish
     bool MoveArmPositionsEnd();
     
-    // start - test if positions are close to expected
-    bool MoveArmPositionTest();
+    // reset goal to the current position ie.  stop trying to move
+    void MoveArmPositionsStop();
     
     // clear part error state
     void ClearErrorState();
     
     // get all parts positions
-    bool GetArmPositions(vector<float>& outPos);
+    bool GetArmPositions(float outVals[]);
     
     // get all parts last positions
-    bool GetArmLastPositions(vector<float>& outPos);
+    bool GetArmLastPositions(float outVals[]);
+    
+    // test if measurements are in expected range
+    int ArmMeasuresTest(int measureId);
     
     // get all parts for a measurement
-    bool GetArmMeasure(int measureId, vector<float>& outPos);
+    bool GetArmMeasure(int measureId, float outVals[]);
     
     // get all parts last measurement
-    bool GetArmLastMeasure(int measureId, vector<float>& outPos);
+    bool GetArmLastMeasure(int measureId, float outVals[]);
    
     int GetNumParts();
     
@@ -96,12 +103,9 @@
     // get size of position diff (valid if error)
     float GetLastPosDiff();
     
-    // set allwable position diff
-    void SetAllowance(float allow);
-    
 private:
     // sensors and actuators
-    RobotNode* _armParts[MAX_PARTS];
+    RobotNode* _armParts[NUMJOINTS];
     
     int _numParts;
     
@@ -119,15 +123,15 @@
     float _lastPosDiff;
     
     // step-wise position moves
-    vector<float> endgoals;
-    vector<float> differentials;
-    vector<float> lastpos;
-    vector<float> lastgoals;
+    float endgoals[NUMJOINTS];
+    float differentials[NUMJOINTS];
+    float lastpos[NUMJOINTS];
+    float lastgoals[NUMJOINTS];
     
     // allowance for difference between expected pos and actual pos
     float allowance;
     // keep track of time period when position is off
-    int failms;
+    int failms[NUMJOINTS];
     
     int numsteps;
     int curstep;