palm and chin / BEAR_Protocol_Edited

Dependencies:   Communication_Robot

Fork of BEAR_Protocol by BE@R lab

Files at this revision

API Documentation at this revision

Comitter:
b0ssiz
Date:
Fri Jan 22 02:25:26 2016 +0000
Parent:
9:c22410169d9f
Child:
11:b34eababcf56
Commit message:
Update; -Add function set and get UpperLink and LowerLink; -Add macro to Command.h

Changed in this revision

BEAR_Protocol.cpp Show annotated file Show diff for this revision Revisions of this file
BEAR_Protocol.h Show annotated file Show diff for this revision Revisions of this file
Command.h Show annotated file Show diff for this revision Revisions of this file
--- a/BEAR_Protocol.cpp	Thu Jan 21 18:48:02 2016 +0000
+++ b/BEAR_Protocol.cpp	Fri Jan 22 02:25:26 2016 +0000
@@ -1017,3 +1017,112 @@
     return status;
 }
 
+
+uint8_t Bear_Communicate::setUpLinkLength(uint8_t id,float length)
+{
+    uint8_t IntLength[2],FloatLength[2];
+    FloatSep(length,IntLength,FloatLength);
+
+    ANDANTE_PROTOCOL_PACKET package;
+
+    package.robotId = id;
+    package.length = 7;
+    package.instructionErrorId = WRITE_DATA;
+    package.parameter[0]=UP_LINK_LENGTH;
+    package.parameter[1]=IntLength[0];
+    package.parameter[2]=IntLength[1];
+    package.parameter[3]=FloatLength[0];
+    package.parameter[4]=FloatLength[1];
+
+    rs485_dirc=1;
+    wait_us(RS485_DELAY);
+    return com->sendCommunicatePacket(&package);
+}
+
+
+uint8_t Bear_Communicate::getUpLinkLength(uint8_t id,float *length)
+{
+    uint8_t IntLength[2],FloatLength[2];
+    float int_buffer,float_buffer;
+    ANDANTE_PROTOCOL_PACKET package;
+    
+    package.robotId = id;
+    package.length = 3;
+    package.instructionErrorId = READ_DATA;
+    package.parameter[0]=UP_LINK_LENGTH;
+
+
+    rs485_dirc=1;
+    wait_us(RS485_DELAY);
+    com->sendCommunicatePacket(&package);
+
+    rs485_dirc=0;
+    wait_us(RS485_DELAY);
+    uint8_t status=com->receiveCommunicatePacket(&package);
+    if(status == ANDANTE_ERRBIT_NONE) {
+        IntLength[0]=package.parameter[0];
+        IntLength[1]=package.parameter[1];
+        FloatLength[0]=package.parameter[2];
+        FloatLength[1]=package.parameter[3];
+        int_buffer=(float)Utilities::ConvertUInt8ArrayToInt16(IntLength);
+        float_buffer=(float)Utilities::ConvertUInt8ArrayToInt16(FloatLength)/FLOAT_CONVERTER;
+        *length=int_buffer+float_buffer;
+    }
+    return status;
+}
+
+
+
+uint8_t Bear_Communicate::setLowLinkLength(uint8_t id,float length)
+{
+    uint8_t IntLength[2],FloatLength[2];
+    FloatSep(length,IntLength,FloatLength);
+
+    ANDANTE_PROTOCOL_PACKET package;
+
+    package.robotId = id;
+    package.length = 7;
+    package.instructionErrorId = WRITE_DATA;
+    package.parameter[0]=LOW_LINK_LENGTH;
+    package.parameter[1]=IntLength[0];
+    package.parameter[2]=IntLength[1];
+    package.parameter[3]=FloatLength[0];
+    package.parameter[4]=FloatLength[1];
+
+    rs485_dirc=1;
+    wait_us(RS485_DELAY);
+    return com->sendCommunicatePacket(&package);
+}
+
+
+
+uint8_t Bear_Communicate::getLowLinkLength(uint8_t id,float *length)
+{
+    uint8_t IntLength[2],FloatLength[2];
+    float int_buffer,float_buffer;
+    ANDANTE_PROTOCOL_PACKET package;
+
+    package.robotId = id;
+    package.length = 3;
+    package.instructionErrorId = READ_DATA;
+    package.parameter[0]=LOW_LINK_LENGTH;
+
+
+    rs485_dirc=1;
+    wait_us(RS485_DELAY);
+    com->sendCommunicatePacket(&package);
+
+    rs485_dirc=0;
+    wait_us(RS485_DELAY);
+    uint8_t status=com->receiveCommunicatePacket(&package);
+    if(status == ANDANTE_ERRBIT_NONE) {
+        IntLength[0]=package.parameter[0];
+        IntLength[1]=package.parameter[1];
+        FloatLength[0]=package.parameter[2];
+        FloatLength[1]=package.parameter[3];
+        int_buffer=(float)Utilities::ConvertUInt8ArrayToInt16(IntLength);
+        float_buffer=(float)Utilities::ConvertUInt8ArrayToInt16(FloatLength)/FLOAT_CONVERTER;
+        *length=int_buffer+float_buffer;
+    }
+    return status;
+}
\ No newline at end of file
--- a/BEAR_Protocol.h	Thu Jan 21 18:48:02 2016 +0000
+++ b/BEAR_Protocol.h	Fri Jan 22 02:25:26 2016 +0000
@@ -35,6 +35,8 @@
     uint8_t setBodyLength(uint8_t,float);
     uint8_t setUpAngleRange(uint8_t,float,float);
     uint8_t setLowAngleRange(uint8_t,float,float);
+    uint8_t setUpLinkLength(uint8_t,float);
+    uint8_t setLowLinkLength(uint8_t,float);
 
 // get Command
     uint8_t getMotorPos(uint8_t,float*,float*);
@@ -50,6 +52,9 @@
     uint8_t getBodyLength(uint8_t,float*);
     uint8_t getUpAngleRange(uint8_t,float*,float*);
     uint8_t getLowAngleRange(uint8_t,float*,float*);
+    uint8_t getUpLinkLength(uint8_t,float*);
+    uint8_t getLowLinkLength(uint8_t,float*);
+    
     
     uint8_t saveDataToEEPROM(uint8_t,uint8_t);
 };
\ No newline at end of file
--- a/Command.h	Thu Jan 21 18:48:02 2016 +0000
+++ b/Command.h	Fri Jan 22 02:25:26 2016 +0000
@@ -24,4 +24,6 @@
 #define BODY_LENGTH        0x11
 #define ANGLE_RANGE_UP     0x12
 #define ANGLE_RANGE_LOW    0x13
-#define SAVE_EEPROM_DATA   0x14
\ No newline at end of file
+#define UP_LINK_LENGTH     0x14
+#define LOW_LINK_LENGTH    0x15
+#define SAVE_EEPROM_DATA   0x16
\ No newline at end of file