demo project
Dependencies: AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL
Diff: RobotArm.h
- Revision:
- 7:6723f6887d00
- Parent:
- 5:36916b1c5a06
- Child:
- 8:d98e2dec0f40
--- a/RobotArm.h Mon Dec 28 17:29:12 2015 +0000 +++ b/RobotArm.h Tue Dec 29 23:31:28 2015 +0000 @@ -36,15 +36,13 @@ IS_SendStatus = 0x2 }; + class RobotArm { public: RobotArm(); - // move all parts to specified postions in ms time - bool MoveArmPositions(vector<float> positions, int ms, int steps); - // start - move all parts to specified postions in ms time bool MoveArmPositionsStart(vector<float> positions, int ms); @@ -52,16 +50,16 @@ bool MoveArmPositionsHasNext(); // start - move all parts to specified postions - next step - bool MoveArmPositionsNext(int& nextdelay); + bool MoveArmPositionsNext(); + + // start - move all parts to specified postions - next delay + bool MoveArmPositionsDelay(int& nextdelay); // start - move all parts to specified postions - finish bool MoveArmPositionsEnd(); // start - test if positions are close to expected - bool TestArmPosition(int& partix, float& diffpos); - - // move one part to specified postion in ms time - bool MovePartPosition(int partIx, float position, int ms, int steps); + bool MoveArmPositionTest(); // get all parts positions bool GetArmPositions(vector<float>& outPos); @@ -69,17 +67,11 @@ // get all parts last positions bool GetArmLastPositions(vector<float>& outPos); - // get one part position - float GetPartPosition(int partIx); - // get all parts for a measurement bool GetArmMeasure(int measureId, vector<float>& outPos); // get all parts last measurement bool GetArmLastMeasure(int measureId, vector<float>& outPos); - - // get one part measurement - float GetPartMeasure(int measureId, int partIx); int GetNumParts(); @@ -93,11 +85,17 @@ RobotNode* GetArmPart(int partIx); // get last error code from action - unsigned char GetLastError(); + int GetLastError(); // get index of part with error int GetLastErrorPart(); + // 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]; @@ -112,6 +110,10 @@ // part ix for last error int _lastErrorPart; + // last HW error + int _lastError; + // last position error + float _lastPosDiff; // for thread friendly moves vector<float> lastpos; @@ -119,7 +121,9 @@ vector<float> lastgoals; // allowance for difference between expected pos and actual pos - static const float allowance = 1.0f; + float allowance; + // keep track of time period when position is off + int failms; int numsteps; int curstep;