modify to nucleo STM32F411

Dependents:   MX_control

Fork of MX28 by Georgios Petrou

Committer:
soulx
Date:
Tue Aug 25 08:51:58 2015 +0000
Revision:
4:30da84384307
Parent:
3:7929abcdc22f
modify for Nucleo STM32F411

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GIPetrou 1:5f537df9dca8 1 /* Dynamixel MX28 servo library
GIPetrou 2:85216442d3ef 2 * Copyright (c) 2012-2013 Georgios Petrou, MIT License
GIPetrou 1:5f537df9dca8 3 *
GIPetrou 1:5f537df9dca8 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
GIPetrou 1:5f537df9dca8 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
GIPetrou 1:5f537df9dca8 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
GIPetrou 1:5f537df9dca8 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
GIPetrou 1:5f537df9dca8 8 * furnished to do so, subject to the following conditions:
GIPetrou 1:5f537df9dca8 9 *
GIPetrou 1:5f537df9dca8 10 * The above copyright notice and this permission notice shall be included in all copies or
GIPetrou 1:5f537df9dca8 11 * substantial portions of the Software.
GIPetrou 1:5f537df9dca8 12 *
GIPetrou 1:5f537df9dca8 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
GIPetrou 1:5f537df9dca8 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
GIPetrou 1:5f537df9dca8 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
GIPetrou 1:5f537df9dca8 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
GIPetrou 1:5f537df9dca8 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
GIPetrou 1:5f537df9dca8 18 */
GIPetrou 1:5f537df9dca8 19
GIPetrou 1:5f537df9dca8 20 #ifndef MX28_H
GIPetrou 1:5f537df9dca8 21 #define MX28_H
GIPetrou 1:5f537df9dca8 22
GIPetrou 1:5f537df9dca8 23 #include "mbed.h"
soulx 3:7929abcdc22f 24 //#include "SerialHalfDuplex.h"
soulx 3:7929abcdc22f 25 #include "iSerial.h"
GIPetrou 1:5f537df9dca8 26 #include "Protocol.h"
GIPetrou 1:5f537df9dca8 27 #include "Utilities.h"
GIPetrou 1:5f537df9dca8 28
soulx 4:30da84384307 29 //#define MX28_DEBUG
GIPetrou 1:5f537df9dca8 30
soulx 3:7929abcdc22f 31 #define PIN_RS485_DIRC PC_8
soulx 3:7929abcdc22f 32
soulx 3:7929abcdc22f 33
GIPetrou 1:5f537df9dca8 34 /** MX28 servo control class
GIPetrou 1:5f537df9dca8 35 *
GIPetrou 1:5f537df9dca8 36 * Example:
GIPetrou 1:5f537df9dca8 37 * @code
GIPetrou 1:5f537df9dca8 38 *
GIPetrou 1:5f537df9dca8 39 * #include "mbed.h"
GIPetrou 1:5f537df9dca8 40 * #include "MX28.h"
GIPetrou 1:5f537df9dca8 41 *
GIPetrou 1:5f537df9dca8 42 * Serial pc(USBTX, USBRX);
GIPetrou 1:5f537df9dca8 43 * MX28 mx28(p28, p27, 57600);
GIPetrou 1:5f537df9dca8 44 *
GIPetrou 1:5f537df9dca8 45 * int main()
GIPetrou 1:5f537df9dca8 46 * {
GIPetrou 1:5f537df9dca8 47 * pc.baud(115200);
GIPetrou 1:5f537df9dca8 48 *
GIPetrou 1:5f537df9dca8 49 * pc.getc();
GIPetrou 1:5f537df9dca8 50 * pc.printf("======================================================\r\n");
GIPetrou 1:5f537df9dca8 51 *
GIPetrou 1:5f537df9dca8 52 * uint8_t servoId = 0x01;
GIPetrou 1:5f537df9dca8 53 *
GIPetrou 1:5f537df9dca8 54 * uint16_t modelNumber;
GIPetrou 1:5f537df9dca8 55 * mx28.GetModelNumber(servoId, &modelNumber);
GIPetrou 1:5f537df9dca8 56 *
GIPetrou 1:5f537df9dca8 57 * uint8_t firmwareVersion;
GIPetrou 1:5f537df9dca8 58 * mx28.GetFirmwareVersion(servoId, &firmwareVersion);
GIPetrou 1:5f537df9dca8 59 *
GIPetrou 1:5f537df9dca8 60 * uint8_t id;
GIPetrou 1:5f537df9dca8 61 * mx28.GetId(servoId, &id);
GIPetrou 1:5f537df9dca8 62 * mx28.SetId(servoId, servoId);
GIPetrou 1:5f537df9dca8 63 *
GIPetrou 1:5f537df9dca8 64 * int32_t baudRate;
GIPetrou 1:5f537df9dca8 65 * mx28.GetBaudRate(servoId, &baudRate);
GIPetrou 1:5f537df9dca8 66 * mx28.SetBaudRate(servoId, 57600);
GIPetrou 1:5f537df9dca8 67 *
GIPetrou 1:5f537df9dca8 68 * uint8_t returnDelayTime;
GIPetrou 1:5f537df9dca8 69 * mx28.GetReturnDelayTime(servoId, &returnDelayTime);
GIPetrou 1:5f537df9dca8 70 * mx28.SetReturnDelayTime(servoId, 0xFA);
GIPetrou 1:5f537df9dca8 71 *
GIPetrou 1:5f537df9dca8 72 * uint16_t cwAngleLimit;
GIPetrou 1:5f537df9dca8 73 * mx28.GetCWAngleLimit(servoId, &cwAngleLimit);
GIPetrou 1:5f537df9dca8 74 * mx28.SetCWAngleLimit(servoId, 0x0000);
GIPetrou 1:5f537df9dca8 75 *
GIPetrou 1:5f537df9dca8 76 * uint16_t ccwAngleLimit;
GIPetrou 1:5f537df9dca8 77 * mx28.GetCCWAngleLimit(servoId, &ccwAngleLimit);
GIPetrou 1:5f537df9dca8 78 * mx28.SetCCWAngleLimit(servoId, 0x0FFF);
GIPetrou 1:5f537df9dca8 79 *
GIPetrou 1:5f537df9dca8 80 * uint8_t highestTemperatureLimit;
GIPetrou 1:5f537df9dca8 81 * mx28.GetHighestTemperatureLimit(servoId, &highestTemperatureLimit);
GIPetrou 1:5f537df9dca8 82 * mx28.SetHighestTemperatureLimit(servoId, 0x50);
GIPetrou 1:5f537df9dca8 83 *
GIPetrou 1:5f537df9dca8 84 * uint8_t downLimitVoltage;
GIPetrou 1:5f537df9dca8 85 * mx28.GetLowestVoltageLimit(servoId, &downLimitVoltage);
GIPetrou 1:5f537df9dca8 86 * mx28.SetLowestVoltageLimit(servoId, 0x3C);
GIPetrou 1:5f537df9dca8 87 *
GIPetrou 1:5f537df9dca8 88 * uint8_t upLimitVoltage;
GIPetrou 1:5f537df9dca8 89 * mx28.GetHighestVoltageLimit(servoId, &upLimitVoltage);
GIPetrou 1:5f537df9dca8 90 * mx28.SetHighestVoltageLimit(servoId, 0xA0);
GIPetrou 1:5f537df9dca8 91 *
GIPetrou 1:5f537df9dca8 92 * uint16_t maxTorque;
GIPetrou 1:5f537df9dca8 93 * mx28.GetMaxTorque(servoId, &maxTorque);
GIPetrou 1:5f537df9dca8 94 * mx28.SetMaxTorque(servoId, 0x03FF);
GIPetrou 1:5f537df9dca8 95 *
GIPetrou 1:5f537df9dca8 96 * uint8_t statusReturnLevel;
GIPetrou 1:5f537df9dca8 97 * mx28.GetStatusReturnLevel(servoId, &statusReturnLevel);
GIPetrou 1:5f537df9dca8 98 * mx28.SetStatusReturnLevel(servoId, 0x02);
GIPetrou 1:5f537df9dca8 99 *
GIPetrou 1:5f537df9dca8 100 * uint8_t alarmLED;
GIPetrou 1:5f537df9dca8 101 * mx28.GetAlarmLED(servoId, &alarmLED);
GIPetrou 1:5f537df9dca8 102 * mx28.SetAlarmLED(servoId, 0x24);
GIPetrou 1:5f537df9dca8 103 *
GIPetrou 1:5f537df9dca8 104 * uint8_t alarmShutdown;
GIPetrou 1:5f537df9dca8 105 * mx28.GetAlarmShutdown(servoId, &alarmShutdown);
GIPetrou 1:5f537df9dca8 106 * mx28.SetAlarmShutdown(servoId, 0x24);
GIPetrou 1:5f537df9dca8 107 *
GIPetrou 1:5f537df9dca8 108 * uint8_t enableTorque;
GIPetrou 1:5f537df9dca8 109 * mx28.GetEnableTorque(servoId, &enableTorque);
GIPetrou 1:5f537df9dca8 110 * mx28.SetEnableTorque(servoId, 0x00);
GIPetrou 1:5f537df9dca8 111 *
GIPetrou 1:5f537df9dca8 112 * uint8_t enableLED;
GIPetrou 1:5f537df9dca8 113 * mx28.GetEnableLED(servoId, &enableLED);
GIPetrou 1:5f537df9dca8 114 * mx28.SetEnableLED(servoId, 0x00);
GIPetrou 1:5f537df9dca8 115 *
GIPetrou 1:5f537df9dca8 116 * uint8_t pGain;
GIPetrou 1:5f537df9dca8 117 * mx28.GetPGain(servoId, &pGain);
GIPetrou 1:5f537df9dca8 118 * mx28.SetPGain(servoId, 0x20);
GIPetrou 1:5f537df9dca8 119 *
GIPetrou 1:5f537df9dca8 120 * uint8_t iGain;
GIPetrou 1:5f537df9dca8 121 * mx28.GetIGain(servoId, &iGain);
GIPetrou 1:5f537df9dca8 122 * mx28.SetIGain(servoId, 0x00);
GIPetrou 1:5f537df9dca8 123 *
GIPetrou 1:5f537df9dca8 124 * uint8_t dGain;
GIPetrou 1:5f537df9dca8 125 * mx28.GetDGain(servoId, &dGain);
GIPetrou 1:5f537df9dca8 126 * mx28.SetDGain(servoId, 0x00);
GIPetrou 1:5f537df9dca8 127 *
GIPetrou 1:5f537df9dca8 128 * uint16_t goalPosition;
GIPetrou 1:5f537df9dca8 129 * mx28.GetGoalPosition(servoId, &goalPosition);
GIPetrou 1:5f537df9dca8 130 * mx28.SetGoalPosition(servoId, 0x0800);
GIPetrou 1:5f537df9dca8 131 *
GIPetrou 1:5f537df9dca8 132 * uint16_t movingSpeed;
GIPetrou 1:5f537df9dca8 133 * mx28.GetMovingSpeed(servoId, &movingSpeed);
GIPetrou 1:5f537df9dca8 134 * mx28.SetMovingSpeed(servoId, 0x00FF);
GIPetrou 1:5f537df9dca8 135 *
GIPetrou 1:5f537df9dca8 136 * uint16_t torqueLimit;
GIPetrou 1:5f537df9dca8 137 * mx28.GetTorqueLimit(servoId, &torqueLimit);
GIPetrou 1:5f537df9dca8 138 * mx28.SetTorqueLimit(servoId, 0x03FF);
GIPetrou 1:5f537df9dca8 139 *
GIPetrou 1:5f537df9dca8 140 * uint16_t presentPosition;
GIPetrou 1:5f537df9dca8 141 * mx28.GetPresentPosition(servoId, &presentPosition);
GIPetrou 1:5f537df9dca8 142 *
GIPetrou 1:5f537df9dca8 143 * uint16_t presentSpeed;
GIPetrou 1:5f537df9dca8 144 * mx28.GetPresentSpeed(servoId, &presentSpeed);
GIPetrou 1:5f537df9dca8 145 *
GIPetrou 1:5f537df9dca8 146 * uint16_t presentLoad;
GIPetrou 1:5f537df9dca8 147 * mx28.GetPresentLoad(servoId, &presentLoad);
GIPetrou 1:5f537df9dca8 148 *
GIPetrou 1:5f537df9dca8 149 * uint8_t presentVoltage;
GIPetrou 1:5f537df9dca8 150 * mx28.GetPresentVoltage(servoId, &presentVoltage);
GIPetrou 1:5f537df9dca8 151 *
GIPetrou 1:5f537df9dca8 152 * uint8_t presentTemperature;
GIPetrou 1:5f537df9dca8 153 * mx28.GetPresentTemperature(servoId, &presentTemperature);
GIPetrou 1:5f537df9dca8 154 *
GIPetrou 1:5f537df9dca8 155 * uint8_t isRegistered;
GIPetrou 1:5f537df9dca8 156 *
GIPetrou 1:5f537df9dca8 157 * mx28.GetIsRegistered(servoId, &isRegistered);
GIPetrou 1:5f537df9dca8 158 *
GIPetrou 1:5f537df9dca8 159 * uint8_t isMoving;
GIPetrou 1:5f537df9dca8 160 * mx28.GetIsMoving(servoId, &isMoving);
GIPetrou 1:5f537df9dca8 161 *
GIPetrou 1:5f537df9dca8 162 * uint8_t lock;
GIPetrou 1:5f537df9dca8 163 * mx28.GetIsLocked(servoId, &lock);
GIPetrou 1:5f537df9dca8 164 * mx28.SetIsLocked(servoId, 0x00);
GIPetrou 1:5f537df9dca8 165 *
GIPetrou 1:5f537df9dca8 166 * uint16_t punch;
GIPetrou 1:5f537df9dca8 167 * mx28.GetPunch(servoId, &punch);
GIPetrou 1:5f537df9dca8 168 * mx28.SetPunch(servoId, 0x0020);
GIPetrou 1:5f537df9dca8 169 *
GIPetrou 1:5f537df9dca8 170 * mx28.Ping(servoId);
GIPetrou 1:5f537df9dca8 171 *
GIPetrou 1:5f537df9dca8 172 * mx28.Reset(servoId);
GIPetrou 1:5f537df9dca8 173 *
GIPetrou 1:5f537df9dca8 174 * uint8_t servo1Id = 0x01;
GIPetrou 1:5f537df9dca8 175 * uint8_t servo2Id = 0x02;
GIPetrou 1:5f537df9dca8 176 * uint8_t servo3Id = 0x03;
GIPetrou 1:5f537df9dca8 177 *
GIPetrou 1:5f537df9dca8 178 * uint16_t servo1GoalPosition = 0x0800;
GIPetrou 1:5f537df9dca8 179 * uint16_t servo2GoalPosition = 0x0800;
GIPetrou 1:5f537df9dca8 180 * uint16_t servo3GoalPosition = 0x0800;
GIPetrou 1:5f537df9dca8 181 *
GIPetrou 1:5f537df9dca8 182 * MX28_PROTOCOL_PACKET packet;
GIPetrou 1:5f537df9dca8 183 * packet.servoId = MX28_PROTOCOL_BROADCAST_ID;
GIPetrou 1:5f537df9dca8 184 * // (Data length + 1) * Number of servos + 4
GIPetrou 1:5f537df9dca8 185 * packet.length = (2+ 1) * 3 + 4;
GIPetrou 1:5f537df9dca8 186 * packet.instructionErrorId = MX28_SYNC_WRITE;
GIPetrou 1:5f537df9dca8 187 * packet.parameter[0] = MX28_GOAL_POSITION_L;
GIPetrou 1:5f537df9dca8 188 * packet.parameter[1] = 0x06;
GIPetrou 1:5f537df9dca8 189 * packet.parameter[2] = servo1Id;
GIPetrou 1:5f537df9dca8 190 * Utilities::ConvertUInt16ToUInt8Array(servo1GoalPosition, (uint8_t*)&(packet.parameter[3]));
GIPetrou 1:5f537df9dca8 191 * packet.parameter[9] = servo2Id;
GIPetrou 1:5f537df9dca8 192 * Utilities::ConvertUInt16ToUInt8Array(servo2GoalPosition, (uint8_t*)&(packet.parameter[10]));
GIPetrou 1:5f537df9dca8 193 * packet.parameter[16] = servo3Id;
GIPetrou 1:5f537df9dca8 194 * Utilities::ConvertUInt16ToUInt8Array(servo3GoalPosition, (uint8_t*)&(packet.parameter[17]));
GIPetrou 1:5f537df9dca8 195 *
GIPetrou 1:5f537df9dca8 196 * pc.printf("Set servos goal positions: %hu %hu %hu\r\n", servo1GoalPosition, servo2GoalPosition, servo3GoalPosition);
GIPetrou 1:5f537df9dca8 197 *
GIPetrou 1:5f537df9dca8 198 * mx28.CommunicatePacket(&packet);
GIPetrou 1:5f537df9dca8 199 *
GIPetrou 1:5f537df9dca8 200 * packet.servoId = servoId;
GIPetrou 1:5f537df9dca8 201 * packet.length = 4;
GIPetrou 1:5f537df9dca8 202 * packet.instructionErrorId = MX28_READ_DATA;
GIPetrou 1:5f537df9dca8 203 * packet.parameter[0] = MX28_PRESENT_POSITION_L;
GIPetrou 1:5f537df9dca8 204 * packet.parameter[1] = 0x08;
GIPetrou 1:5f537df9dca8 205 *
GIPetrou 1:5f537df9dca8 206 * mx28.CommunicatePacket(&packet);
GIPetrou 1:5f537df9dca8 207 *
GIPetrou 1:5f537df9dca8 208 * presentPosition = Utilities::ConvertUInt8ArrayToUInt16(packet.parameter);
GIPetrou 1:5f537df9dca8 209 * presentSpeed = Utilities::ConvertUInt8ArrayToUInt16((uint8_t*)&(packet.parameter[2]));
GIPetrou 1:5f537df9dca8 210 * presentLoad = Utilities::ConvertUInt8ArrayToUInt16((uint8_t*)&(packet.parameter[4]));
GIPetrou 1:5f537df9dca8 211 * presentVoltage = packet.parameter[6];
GIPetrou 1:5f537df9dca8 212 * presentTemperature = packet.parameter[7];
GIPetrou 1:5f537df9dca8 213 *
GIPetrou 1:5f537df9dca8 214 * pc.printf("Present position: %hu\r\n", presentPosition);
GIPetrou 1:5f537df9dca8 215 * pc.printf("Present speed: %hu\r\n", presentSpeed);
GIPetrou 1:5f537df9dca8 216 * pc.printf("Present load: %hu\r\n", presentLoad);
GIPetrou 1:5f537df9dca8 217 * pc.printf("Present voltage: 0x%02X\r\n", presentVoltage);
GIPetrou 1:5f537df9dca8 218 * pc.printf("Present temperature: 0x%02X\r\n", presentTemperature);
GIPetrou 1:5f537df9dca8 219 *
GIPetrou 1:5f537df9dca8 220 * uint8_t status = mx28.GetModelNumber(servoId, &modelNumber);
GIPetrou 1:5f537df9dca8 221 *
GIPetrou 1:5f537df9dca8 222 * if(status == MX28_ERRBIT_WRITE_TIMEOUT)
GIPetrou 1:5f537df9dca8 223 * pc.printf("Error: Write timeout\r\n");
GIPetrou 1:5f537df9dca8 224 * else if(status == MX28_ERRBIT_READ_TIMEOUT)
GIPetrou 1:5f537df9dca8 225 * pc.printf("Error: Read timeout\r\n");
GIPetrou 1:5f537df9dca8 226 * else if(status == MX28_ERRBIT_MASTER_CHECKSUM)
GIPetrou 1:5f537df9dca8 227 * pc.printf("Error: Master checksum error\r\n");
GIPetrou 1:5f537df9dca8 228 * else
GIPetrou 1:5f537df9dca8 229 * {
GIPetrou 1:5f537df9dca8 230 * if(status & MX28_ERRBIT_VOLTAGE)
GIPetrou 1:5f537df9dca8 231 * pc.printf("Error: Input voltage error\r\n");
GIPetrou 1:5f537df9dca8 232 * if(status & MX28_ERRBIT_ANGLE)
GIPetrou 1:5f537df9dca8 233 * pc.printf("Error: Angle limit error\r\n");
GIPetrou 1:5f537df9dca8 234 * if(status & MX28_ERRBIT_OVERHEAT)
GIPetrou 1:5f537df9dca8 235 * pc.printf("Error: Overheat error\r\n");
GIPetrou 1:5f537df9dca8 236 * if(status & MX28_ERRBIT_RANGE)
GIPetrou 1:5f537df9dca8 237 * pc.printf("Error: Out of range error\r\n");
GIPetrou 1:5f537df9dca8 238 * if(status & MX28_ERRBIT_CHECKSUM)
GIPetrou 1:5f537df9dca8 239 * pc.printf("Error: Checksum error\r\n");
GIPetrou 1:5f537df9dca8 240 * if(status & MX28_ERRBIT_OVERLOAD)
GIPetrou 1:5f537df9dca8 241 * pc.printf("Error: Overload error\r\n");
GIPetrou 1:5f537df9dca8 242 * if(status & MX28_ERRBIT_INSTRUCTION)
GIPetrou 1:5f537df9dca8 243 * pc.printf("Error: Instruction code error\r\n");
GIPetrou 1:5f537df9dca8 244 * }
GIPetrou 1:5f537df9dca8 245 *
GIPetrou 1:5f537df9dca8 246 * pc.printf("======================================================\r\n");
GIPetrou 1:5f537df9dca8 247 *
GIPetrou 1:5f537df9dca8 248 * return 0;
GIPetrou 1:5f537df9dca8 249 * }
GIPetrou 1:5f537df9dca8 250 * @endcode
GIPetrou 1:5f537df9dca8 251 */
GIPetrou 1:5f537df9dca8 252 class MX28
GIPetrou 1:5f537df9dca8 253 {
GIPetrou 1:5f537df9dca8 254 private:
GIPetrou 1:5f537df9dca8 255 /** PC serial connection used in debug mode.
GIPetrou 1:5f537df9dca8 256 */
GIPetrou 1:5f537df9dca8 257 Serial *pc;
GIPetrou 1:5f537df9dca8 258
GIPetrou 1:5f537df9dca8 259 /** Servo serial half duplex connection.
GIPetrou 1:5f537df9dca8 260 */
soulx 3:7929abcdc22f 261 //SerialHalfDuplex *servoSerialHalfDuplex;
soulx 3:7929abcdc22f 262 iSerial *servoSerialHalfDuplex;
GIPetrou 1:5f537df9dca8 263
GIPetrou 1:5f537df9dca8 264 public:
GIPetrou 1:5f537df9dca8 265 /** Send the MX28 packet over the serial half duplex connection.
GIPetrou 1:5f537df9dca8 266 *
GIPetrou 1:5f537df9dca8 267 * @param packet The MX28 packet.
GIPetrou 1:5f537df9dca8 268 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 269 */
GIPetrou 1:5f537df9dca8 270 uint8_t CommunicatePacket(MX28_PROTOCOL_PACKET *packet);
GIPetrou 1:5f537df9dca8 271
GIPetrou 1:5f537df9dca8 272 /** Get the servo model number.
GIPetrou 1:5f537df9dca8 273 *
GIPetrou 1:5f537df9dca8 274 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 275 * @param modelNumber The variable to store the model number.
GIPetrou 1:5f537df9dca8 276 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 277 */
GIPetrou 1:5f537df9dca8 278 uint8_t GetModelNumber(uint8_t servoId, uint16_t *modelNumber);
GIPetrou 1:5f537df9dca8 279
GIPetrou 1:5f537df9dca8 280 /** Get the servo firmware version.
GIPetrou 1:5f537df9dca8 281 *
GIPetrou 1:5f537df9dca8 282 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 283 * @param firmwareVersion The variable to store the model number.
GIPetrou 1:5f537df9dca8 284 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 285 */
GIPetrou 1:5f537df9dca8 286 uint8_t GetFirmwareVersion(uint8_t servoId, uint8_t *firmwareVersion);
GIPetrou 1:5f537df9dca8 287
GIPetrou 1:5f537df9dca8 288 /** Get the servo id.
GIPetrou 1:5f537df9dca8 289 *
GIPetrou 1:5f537df9dca8 290 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 291 * @param id The variable to store the id.
GIPetrou 1:5f537df9dca8 292 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 293 */
GIPetrou 1:5f537df9dca8 294 uint8_t GetId(uint8_t servoId, uint8_t *id);
GIPetrou 1:5f537df9dca8 295
GIPetrou 1:5f537df9dca8 296 /** Set the servo id.
GIPetrou 1:5f537df9dca8 297 *
GIPetrou 1:5f537df9dca8 298 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 299 * @param newId The new servo id.
GIPetrou 1:5f537df9dca8 300 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 301 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 302 */
GIPetrou 1:5f537df9dca8 303 uint8_t SetId(uint8_t servoId, uint8_t newId, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 304
GIPetrou 1:5f537df9dca8 305 /** Get the servo baudrate.
GIPetrou 1:5f537df9dca8 306 *
GIPetrou 1:5f537df9dca8 307 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 308 * @param baudRate The variable to store the baudrate.
GIPetrou 1:5f537df9dca8 309 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 310 */
GIPetrou 1:5f537df9dca8 311 uint8_t GetBaudRate(uint8_t servoId, int32_t *baudRate);
GIPetrou 1:5f537df9dca8 312
GIPetrou 1:5f537df9dca8 313 /** Set the servo baudrate.
GIPetrou 1:5f537df9dca8 314 *
GIPetrou 1:5f537df9dca8 315 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 316 * @param baudRate The servo baudrate.
GIPetrou 1:5f537df9dca8 317 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 318 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 319 */
GIPetrou 1:5f537df9dca8 320 uint8_t SetBaudRate(uint8_t servoId, int baudRate, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 321
GIPetrou 1:5f537df9dca8 322 /** Get the servo return delay time.
GIPetrou 1:5f537df9dca8 323 *
GIPetrou 1:5f537df9dca8 324 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 325 * @param returnDelayTime The variable to store the return delay time.
GIPetrou 1:5f537df9dca8 326 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 327 */
GIPetrou 1:5f537df9dca8 328 uint8_t GetReturnDelayTime(uint8_t servoId, uint8_t *returnDelayTime);
GIPetrou 1:5f537df9dca8 329
GIPetrou 1:5f537df9dca8 330 /** Set the servo delay time.
GIPetrou 1:5f537df9dca8 331 *
GIPetrou 1:5f537df9dca8 332 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 333 * @param returnDelayTime The servo return delay time.
GIPetrou 1:5f537df9dca8 334 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 335 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 336 */
GIPetrou 1:5f537df9dca8 337 uint8_t SetReturnDelayTime(uint8_t servoId, uint8_t returnDelayTime, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 338
GIPetrou 1:5f537df9dca8 339 /** Get the servo clockwise angle limit.
GIPetrou 1:5f537df9dca8 340 *
GIPetrou 1:5f537df9dca8 341 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 342 * @param cwAngleLimit The variable to store the clockwise angle limit.
GIPetrou 1:5f537df9dca8 343 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 344 */
GIPetrou 1:5f537df9dca8 345 uint8_t GetCWAngleLimit(uint8_t servoId, uint16_t *cwAngleLimit);
GIPetrou 1:5f537df9dca8 346
GIPetrou 1:5f537df9dca8 347 /** Set the servo clockwise angle limit.
GIPetrou 1:5f537df9dca8 348 *
GIPetrou 1:5f537df9dca8 349 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 350 * @param cwAngleLimit The servo clockwise angle limit.
GIPetrou 1:5f537df9dca8 351 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 352 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 353 */
GIPetrou 1:5f537df9dca8 354 uint8_t SetCWAngleLimit(uint8_t servoId, uint16_t cwAngleLimit, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 355
GIPetrou 1:5f537df9dca8 356 /** Get the servo counterclockwise angle limit.
GIPetrou 1:5f537df9dca8 357 *
GIPetrou 1:5f537df9dca8 358 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 359 * @param ccwAngleLimit The variable to store the counterclockwise angle limit.
GIPetrou 1:5f537df9dca8 360 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 361 */
GIPetrou 1:5f537df9dca8 362 uint8_t GetCCWAngleLimit(uint8_t servoId, uint16_t *ccwAngleLimit);
GIPetrou 1:5f537df9dca8 363
GIPetrou 1:5f537df9dca8 364 /** Set the servo counterclockwise angle limit.
GIPetrou 1:5f537df9dca8 365 *
GIPetrou 1:5f537df9dca8 366 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 367 * @param ccwAngleLimit The servo counterclockwise angle limit.
GIPetrou 1:5f537df9dca8 368 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 369 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 370 */
GIPetrou 1:5f537df9dca8 371 uint8_t SetCCWAngleLimit(uint8_t servoId, uint16_t ccwAngleLimit, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 372
GIPetrou 1:5f537df9dca8 373 /** Get the servo up temperature limit.
GIPetrou 1:5f537df9dca8 374 *
GIPetrou 1:5f537df9dca8 375 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 376 * @param highestTemperatureLimit The variable to store the highest temperature limit.
GIPetrou 1:5f537df9dca8 377 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 378 */
GIPetrou 1:5f537df9dca8 379 uint8_t GetHighestTemperatureLimit(uint8_t servoId, uint8_t *highestTemperatureLimit);
GIPetrou 1:5f537df9dca8 380
GIPetrou 1:5f537df9dca8 381 /** Set the servo highest temperature limit.
GIPetrou 1:5f537df9dca8 382 *
GIPetrou 1:5f537df9dca8 383 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 384 * @param highestTemperatureLimit The servo highest temperature limit.
GIPetrou 1:5f537df9dca8 385 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 386 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 387 */
GIPetrou 1:5f537df9dca8 388 uint8_t SetHighestTemperatureLimit(uint8_t servoId, uint8_t highestTemperatureLimit, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 389
GIPetrou 1:5f537df9dca8 390 /** Get the servo lowest voltage limit.
GIPetrou 1:5f537df9dca8 391 *
GIPetrou 1:5f537df9dca8 392 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 393 * @param lowestVoltageLimit The variable to store the lowest voltage limit.
GIPetrou 1:5f537df9dca8 394 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 395 */
GIPetrou 1:5f537df9dca8 396 uint8_t GetLowestVoltageLimit(uint8_t servoId, uint8_t *lowestVoltageLimit);
GIPetrou 1:5f537df9dca8 397
GIPetrou 1:5f537df9dca8 398 /** Set the servo lowest voltage limit.
GIPetrou 1:5f537df9dca8 399 *
GIPetrou 1:5f537df9dca8 400 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 401 * @param lowestVoltageLimit The servo lowest voltage limit.
GIPetrou 1:5f537df9dca8 402 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 403 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 404 */
GIPetrou 1:5f537df9dca8 405 uint8_t SetLowestVoltageLimit(uint8_t servoId, uint8_t lowestVoltageLimit, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 406
GIPetrou 1:5f537df9dca8 407 /** Get the servo highest voltage limit.
GIPetrou 1:5f537df9dca8 408 *
GIPetrou 1:5f537df9dca8 409 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 410 * @param highestVoltageLimit The variable to store the highest voltage limit.
GIPetrou 1:5f537df9dca8 411 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 412 */
GIPetrou 1:5f537df9dca8 413 uint8_t GetHighestVoltageLimit(uint8_t servoId, uint8_t *highestVoltageLimit);
GIPetrou 1:5f537df9dca8 414
GIPetrou 1:5f537df9dca8 415 /** Set the servo highest voltage limit.
GIPetrou 1:5f537df9dca8 416 *
GIPetrou 1:5f537df9dca8 417 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 418 * @param highestVoltageLimit The servo highest voltage limit.
GIPetrou 1:5f537df9dca8 419 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 420 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 421 */
GIPetrou 1:5f537df9dca8 422 uint8_t SetHighestVoltageLimit(uint8_t servoId, uint8_t highestVoltageLimit, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 423
GIPetrou 1:5f537df9dca8 424 /** Get the servo max torque.
GIPetrou 1:5f537df9dca8 425 *
GIPetrou 1:5f537df9dca8 426 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 427 * @param maxTorque The variable to store the max torque.
GIPetrou 1:5f537df9dca8 428 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 429 */
GIPetrou 1:5f537df9dca8 430 uint8_t GetMaxTorque(uint8_t servoId, uint16_t *maxTorque);
GIPetrou 1:5f537df9dca8 431
GIPetrou 1:5f537df9dca8 432 /** Set the servo max torque.
GIPetrou 1:5f537df9dca8 433 *
GIPetrou 1:5f537df9dca8 434 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 435 * @param maxTorque The servo max torque.
GIPetrou 1:5f537df9dca8 436 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 437 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 438 */
GIPetrou 1:5f537df9dca8 439 uint8_t SetMaxTorque(uint8_t servoId, uint16_t maxTorque, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 440
GIPetrou 1:5f537df9dca8 441 /** Get the servo status return level.
GIPetrou 1:5f537df9dca8 442 *
GIPetrou 1:5f537df9dca8 443 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 444 * @param statusReturnLevel The variable to store the status return level.
GIPetrou 1:5f537df9dca8 445 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 446 */
GIPetrou 1:5f537df9dca8 447 uint8_t GetStatusReturnLevel(uint8_t servoId, uint8_t *statusReturnLevel);
GIPetrou 1:5f537df9dca8 448
GIPetrou 1:5f537df9dca8 449 /** Set the servo status return level.
GIPetrou 1:5f537df9dca8 450 *
GIPetrou 1:5f537df9dca8 451 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 452 * @param statusReturnLevel The servo status return level.
GIPetrou 1:5f537df9dca8 453 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 454 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 455 */
GIPetrou 1:5f537df9dca8 456 uint8_t SetStatusReturnLevel(uint8_t servoId, uint8_t statusReturnLevel, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 457
GIPetrou 1:5f537df9dca8 458 /** Get the servo alarm LED.
GIPetrou 1:5f537df9dca8 459 *
GIPetrou 1:5f537df9dca8 460 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 461 * @param alarmLED The variable to store the alarm LED.
GIPetrou 1:5f537df9dca8 462 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 463 */
GIPetrou 1:5f537df9dca8 464 uint8_t GetAlarmLED(uint8_t servoId, uint8_t *alarmLED);
GIPetrou 1:5f537df9dca8 465
GIPetrou 1:5f537df9dca8 466 /** Set the servo alarm LED.
GIPetrou 1:5f537df9dca8 467 *
GIPetrou 1:5f537df9dca8 468 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 469 * @param alarmLED The servo alarm LED.
GIPetrou 1:5f537df9dca8 470 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 471 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 472 */
GIPetrou 1:5f537df9dca8 473 uint8_t SetAlarmLED(uint8_t servoId, uint8_t alarmLED, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 474
GIPetrou 1:5f537df9dca8 475 /** Get the servo alarm shutdown.
GIPetrou 1:5f537df9dca8 476 *
GIPetrou 1:5f537df9dca8 477 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 478 * @param alarmShutdown The variable to store the alarm shutdown.
GIPetrou 1:5f537df9dca8 479 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 480 */
GIPetrou 1:5f537df9dca8 481 uint8_t GetAlarmShutdown(uint8_t servoId, uint8_t *alarmShutdown);
GIPetrou 1:5f537df9dca8 482
GIPetrou 1:5f537df9dca8 483 /** Set the servo alarm shutdown.
GIPetrou 1:5f537df9dca8 484 *
GIPetrou 1:5f537df9dca8 485 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 486 * @param alarmShutdown The servo alarm shutdown.
GIPetrou 1:5f537df9dca8 487 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 488 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 489 */
GIPetrou 1:5f537df9dca8 490 uint8_t SetAlarmShutdown(uint8_t servoId, uint8_t alarmShutdown, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 491
GIPetrou 1:5f537df9dca8 492 /** Get the servo enable torque.
GIPetrou 1:5f537df9dca8 493 *
GIPetrou 1:5f537df9dca8 494 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 495 * @param enableTorque The variable to store the enable torque.
GIPetrou 1:5f537df9dca8 496 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 497 */
GIPetrou 1:5f537df9dca8 498 uint8_t GetEnableTorque(uint8_t servoId, uint8_t *enableTorque);
GIPetrou 1:5f537df9dca8 499
GIPetrou 1:5f537df9dca8 500 /** Set the servo enable torque.
GIPetrou 1:5f537df9dca8 501 *
GIPetrou 1:5f537df9dca8 502 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 503 * @param enableTorque The servo enable torque.
GIPetrou 1:5f537df9dca8 504 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 505 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 506 */
GIPetrou 1:5f537df9dca8 507 uint8_t SetEnableTorque(uint8_t servoId, uint8_t enableTorque, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 508
GIPetrou 1:5f537df9dca8 509 /** Get the servo enable LED.
GIPetrou 1:5f537df9dca8 510 *
GIPetrou 1:5f537df9dca8 511 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 512 * @param enableLED The variable to store the enable LED.
GIPetrou 1:5f537df9dca8 513 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 514 */
GIPetrou 1:5f537df9dca8 515 uint8_t GetEnableLED(uint8_t servoId, uint8_t *enableLED);
GIPetrou 1:5f537df9dca8 516
GIPetrou 1:5f537df9dca8 517 /** Set the servo enable LED.
GIPetrou 1:5f537df9dca8 518 *
GIPetrou 1:5f537df9dca8 519 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 520 * @param enableLED The servo enable LED.
GIPetrou 1:5f537df9dca8 521 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 522 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 523 */
GIPetrou 1:5f537df9dca8 524 uint8_t SetEnableLED(uint8_t servoId, uint8_t enableLED, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 525
GIPetrou 1:5f537df9dca8 526 /** Get the servo P gain.
GIPetrou 1:5f537df9dca8 527 *
GIPetrou 1:5f537df9dca8 528 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 529 * @param pGain The variable to store the P gain.
GIPetrou 1:5f537df9dca8 530 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 531 */
GIPetrou 1:5f537df9dca8 532 uint8_t GetPGain(uint8_t servoId, uint8_t *pGain);
GIPetrou 1:5f537df9dca8 533
GIPetrou 1:5f537df9dca8 534 /** Set the servo P gain.
GIPetrou 1:5f537df9dca8 535 *
GIPetrou 1:5f537df9dca8 536 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 537 * @param pGain The servo P gain.
GIPetrou 1:5f537df9dca8 538 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 539 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 540 */
GIPetrou 1:5f537df9dca8 541 uint8_t SetPGain(uint8_t servoId, uint8_t pGain, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 542
GIPetrou 1:5f537df9dca8 543 /** Get the servo I gain.
GIPetrou 1:5f537df9dca8 544 *
GIPetrou 1:5f537df9dca8 545 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 546 * @param iGain The variable to store the I gain.
GIPetrou 1:5f537df9dca8 547 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 548 */
GIPetrou 1:5f537df9dca8 549 uint8_t GetIGain(uint8_t servoId, uint8_t *iGain);
GIPetrou 1:5f537df9dca8 550
GIPetrou 1:5f537df9dca8 551 /** Set the servo I gain.
GIPetrou 1:5f537df9dca8 552 *
GIPetrou 1:5f537df9dca8 553 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 554 * @param iGain The servo I gain.
GIPetrou 1:5f537df9dca8 555 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 556 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 557 */
GIPetrou 1:5f537df9dca8 558 uint8_t SetIGain(uint8_t servoId, uint8_t iGain, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 559
GIPetrou 1:5f537df9dca8 560 /** Get the servo D gain.
GIPetrou 1:5f537df9dca8 561 *
GIPetrou 1:5f537df9dca8 562 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 563 * @param dGain The variable to store the D gain.
GIPetrou 1:5f537df9dca8 564 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 565 */
GIPetrou 1:5f537df9dca8 566 uint8_t GetDGain(uint8_t servoId, uint8_t *dGain);
GIPetrou 1:5f537df9dca8 567
GIPetrou 1:5f537df9dca8 568 /** Set the servo D gain.
GIPetrou 1:5f537df9dca8 569 *
GIPetrou 1:5f537df9dca8 570 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 571 * @param dGain The servo D gain.
GIPetrou 1:5f537df9dca8 572 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 573 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 574 */
GIPetrou 1:5f537df9dca8 575 uint8_t SetDGain(uint8_t servoId, uint8_t dGain, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 576
GIPetrou 1:5f537df9dca8 577 /** Get the servo goal position.
GIPetrou 1:5f537df9dca8 578 *
GIPetrou 1:5f537df9dca8 579 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 580 * @param goalPosition The variable to store the goal position.
GIPetrou 1:5f537df9dca8 581 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 582 */
GIPetrou 1:5f537df9dca8 583 uint8_t GetGoalPosition(uint8_t servoId, uint16_t *goalPosition);
GIPetrou 1:5f537df9dca8 584
GIPetrou 1:5f537df9dca8 585 /** Set the servo goal position.
GIPetrou 1:5f537df9dca8 586 *
GIPetrou 1:5f537df9dca8 587 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 588 * @param goalPosition The servo goal position.
GIPetrou 1:5f537df9dca8 589 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 590 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 591 */
GIPetrou 1:5f537df9dca8 592 uint8_t SetGoalPosition(uint8_t servoId, uint16_t goalPosition, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 593
GIPetrou 1:5f537df9dca8 594 /** Get the servo moving speed.
GIPetrou 1:5f537df9dca8 595 *
GIPetrou 1:5f537df9dca8 596 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 597 * @param movingSpeed The variable to store the moving speed.
GIPetrou 1:5f537df9dca8 598 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 599 */
GIPetrou 1:5f537df9dca8 600 uint8_t GetMovingSpeed(uint8_t servoId, uint16_t *movingSpeed);
GIPetrou 1:5f537df9dca8 601
GIPetrou 1:5f537df9dca8 602 /** Set the servo moving speed.
GIPetrou 1:5f537df9dca8 603 *
GIPetrou 1:5f537df9dca8 604 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 605 * @param movingSpeed The servo moving speed.
GIPetrou 1:5f537df9dca8 606 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 607 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 608 */
GIPetrou 1:5f537df9dca8 609 uint8_t SetMovingSpeed(uint8_t servoId, uint16_t movingSpeed, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 610
GIPetrou 1:5f537df9dca8 611 /** Get the servo torque limit.
GIPetrou 1:5f537df9dca8 612 * 0 to 1023 (0x3FF) is available, and the unit is about 0.1%.
GIPetrou 1:5f537df9dca8 613 * For example, if the value is 512, it is about 50%; that means only 50% of the maximum torque will be used.
GIPetrou 1:5f537df9dca8 614 * If the power is turned on, the value of Max Torque (Address 14, 15) is used as the initial value.
GIPetrou 1:5f537df9dca8 615 *
GIPetrou 1:5f537df9dca8 616 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 617 * @param torqueLimit The variable to store the torque limit.
GIPetrou 1:5f537df9dca8 618 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 619 */
GIPetrou 1:5f537df9dca8 620 uint8_t GetTorqueLimit(uint8_t servoId, uint16_t *torqueLimit);
GIPetrou 1:5f537df9dca8 621
GIPetrou 1:5f537df9dca8 622 /** Set the servo torque limit.
GIPetrou 1:5f537df9dca8 623 *
GIPetrou 1:5f537df9dca8 624 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 625 * @param torqueLimit The servo torque limit.
GIPetrou 1:5f537df9dca8 626 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 627 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 628 */
GIPetrou 1:5f537df9dca8 629 uint8_t SetTorqueLimit(uint8_t servoId, uint16_t torqueLimit, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 630
GIPetrou 1:5f537df9dca8 631 /** Get the servo present position.
GIPetrou 1:5f537df9dca8 632 * The range of the value is 0~4095 (0xFFF), and the unit is 0.088 degree.
GIPetrou 1:5f537df9dca8 633 *
GIPetrou 1:5f537df9dca8 634 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 635 * @param presentPosition The variable to store the present position.
GIPetrou 1:5f537df9dca8 636 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 637 */
GIPetrou 1:5f537df9dca8 638 uint8_t GetPresentPosition(uint8_t servoId, uint16_t *presentPosition);
GIPetrou 1:5f537df9dca8 639
GIPetrou 1:5f537df9dca8 640 /** Get the servo present speed.
GIPetrou 1:5f537df9dca8 641 * 0~2047 (0x000~0X7FF) can be used.
GIPetrou 1:5f537df9dca8 642 * If a value is in the rage of 0~1023 then the motor rotates to the CCW direction.
GIPetrou 1:5f537df9dca8 643 * If a value is in the rage of 1024~2047 then the motor rotates to the CW direction.
GIPetrou 1:5f537df9dca8 644 * The 10th bit becomes the direction bit to control the direction; 0 and 1024 are equal.
GIPetrou 1:5f537df9dca8 645 * The value unit is about 0.11rpm.
GIPetrou 1:5f537df9dca8 646 * For example, if it is set to 300 then the motor is moving to the CCW direction at a rate of about 34.33rpm.
GIPetrou 1:5f537df9dca8 647 *
GIPetrou 1:5f537df9dca8 648 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 649 * @param presentSpeed The variable to store the present speed.
GIPetrou 1:5f537df9dca8 650 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 651 */
GIPetrou 1:5f537df9dca8 652 uint8_t GetPresentSpeed(uint8_t servoId, uint16_t *presentSpeed);
GIPetrou 1:5f537df9dca8 653
GIPetrou 1:5f537df9dca8 654 /** Get the servo present load.
GIPetrou 1:5f537df9dca8 655 * The range of the value is 0~2047, and the unit is about 0.1%.
GIPetrou 1:5f537df9dca8 656 * If the value is 0~1023, it means the load works to the CCW direction.
GIPetrou 1:5f537df9dca8 657 * If the value is 1024~2047, it means the load works to the CW direction.
GIPetrou 1:5f537df9dca8 658 * That is, the 10th bit becomes the direction bit to control the direction, and 1024 is equal to 0.
GIPetrou 1:5f537df9dca8 659 * For example, the value is 512, it means the load is detected in the direction of CCW about 50% of the maximum torque.
GIPetrou 1:5f537df9dca8 660 *
GIPetrou 1:5f537df9dca8 661 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 662 * @param presentLoad The variable to store the present load.
GIPetrou 1:5f537df9dca8 663 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 664 */
GIPetrou 1:5f537df9dca8 665 uint8_t GetPresentLoad(uint8_t servoId, uint16_t *presentLoad);
GIPetrou 1:5f537df9dca8 666
GIPetrou 1:5f537df9dca8 667 /** Get the servo present voltage.
GIPetrou 1:5f537df9dca8 668 * This value is 10 times larger than the actual voltage.
GIPetrou 1:5f537df9dca8 669 * For example, when 10V is supplied, the data value is 100 (0x64)
GIPetrou 1:5f537df9dca8 670 *
GIPetrou 1:5f537df9dca8 671 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 672 * @param presentVoltage The variable to store the present voltage.
GIPetrou 1:5f537df9dca8 673 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 674 */
GIPetrou 1:5f537df9dca8 675 uint8_t GetPresentVoltage(uint8_t servoId, uint8_t *presentVoltage);
GIPetrou 1:5f537df9dca8 676
GIPetrou 1:5f537df9dca8 677 /** Get the servo present temperature.
GIPetrou 1:5f537df9dca8 678 * It is the internal temperature of Dynamixel in Celsius.
GIPetrou 1:5f537df9dca8 679 * Data value is identical to the actual temperature in Celsius.
GIPetrou 1:5f537df9dca8 680 * For example, if the data value is 85 (0x55), the current internal temperature is 85℃.
GIPetrou 1:5f537df9dca8 681 *
GIPetrou 1:5f537df9dca8 682 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 683 * @param presentTemperature The variable to store the present temperature.
GIPetrou 1:5f537df9dca8 684 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 685 */
GIPetrou 1:5f537df9dca8 686 uint8_t GetPresentTemperature(uint8_t servoId, uint8_t *presentTemperature);
GIPetrou 1:5f537df9dca8 687
GIPetrou 1:5f537df9dca8 688 /** Get if there are commands transmitted by MX28_REG_WRITE.
GIPetrou 1:5f537df9dca8 689 * 0 There are no commands transmitted by REG_WRITE.
GIPetrou 1:5f537df9dca8 690 * 1 There are commands transmitted by REG_WRITE.
GIPetrou 1:5f537df9dca8 691 *
GIPetrou 1:5f537df9dca8 692 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 693 * @param isRegistered The variable to store if it is registered.
GIPetrou 1:5f537df9dca8 694 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 695 */
GIPetrou 1:5f537df9dca8 696 uint8_t GetIsRegistered(uint8_t servoId, uint8_t *isRegistered);
GIPetrou 1:5f537df9dca8 697
GIPetrou 1:5f537df9dca8 698 /** Get if the servo is moving.
GIPetrou 1:5f537df9dca8 699 * 0 Goal position command execution is completed.
GIPetrou 1:5f537df9dca8 700 * 1 Goal position command execution is in progress.
GIPetrou 1:5f537df9dca8 701 *
GIPetrou 1:5f537df9dca8 702 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 703 * @param isMoving The variable to store if the servo is moving.
GIPetrou 1:5f537df9dca8 704 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 705 */
GIPetrou 1:5f537df9dca8 706 uint8_t GetIsMoving(uint8_t servoId, uint8_t *isMoving);
GIPetrou 1:5f537df9dca8 707
GIPetrou 1:5f537df9dca8 708 /** Get if the servo EEPROM is locked.
GIPetrou 1:5f537df9dca8 709 * 0 EEPROM area can be modified.
GIPetrou 1:5f537df9dca8 710 * 1 EEPROM area cannot be modified.
GIPetrou 1:5f537df9dca8 711 *
GIPetrou 1:5f537df9dca8 712 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 713 * @param isLock The variable to store if the servo EEPROM is locked.
GIPetrou 1:5f537df9dca8 714 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 715 */
GIPetrou 1:5f537df9dca8 716 uint8_t GetIsLocked(uint8_t servoId, uint8_t *isLocked);
GIPetrou 1:5f537df9dca8 717
GIPetrou 1:5f537df9dca8 718 /** Set if the servo EEPROM is locked.
GIPetrou 1:5f537df9dca8 719 *
GIPetrou 1:5f537df9dca8 720 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 721 * @param isLocked The variable to store if the servo EEPROM is locked.
GIPetrou 1:5f537df9dca8 722 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 723 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 724 */
GIPetrou 1:5f537df9dca8 725 uint8_t SetIsLocked(uint8_t servoId, uint8_t isLocked, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 726
GIPetrou 1:5f537df9dca8 727 /** Get the servo punch.
GIPetrou 1:5f537df9dca8 728 * Can choose vales from 0x00 to 0x3FF.
GIPetrou 1:5f537df9dca8 729 *
GIPetrou 1:5f537df9dca8 730 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 731 * @param punch The variable to store the servo punch.
GIPetrou 1:5f537df9dca8 732 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 733 */
GIPetrou 1:5f537df9dca8 734 uint8_t GetPunch(uint8_t servoId, uint16_t *punch);
GIPetrou 1:5f537df9dca8 735
GIPetrou 1:5f537df9dca8 736 /** Set the servo punch.
GIPetrou 1:5f537df9dca8 737 *
GIPetrou 1:5f537df9dca8 738 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 739 * @param punch The servo punch value.
GIPetrou 1:5f537df9dca8 740 * @param isRegWrite If the command will be registered.
GIPetrou 1:5f537df9dca8 741 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 742 */
GIPetrou 1:5f537df9dca8 743 uint8_t SetPunch(uint8_t servoId, uint16_t punch, bool isRegWrite = false);
GIPetrou 1:5f537df9dca8 744
GIPetrou 1:5f537df9dca8 745 /** Ping the servo.
GIPetrou 1:5f537df9dca8 746 * No action. Used for obtaining a Status Packet.
GIPetrou 1:5f537df9dca8 747 *
GIPetrou 1:5f537df9dca8 748 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 749 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 750 */
GIPetrou 1:5f537df9dca8 751 uint8_t Ping(uint8_t servoId);
GIPetrou 1:5f537df9dca8 752
GIPetrou 1:5f537df9dca8 753 /** Reset the servo.
GIPetrou 1:5f537df9dca8 754 * Changes the control table values of the Dynamixel actuator
GIPetrou 1:5f537df9dca8 755 * to the Factory Default Value settings
GIPetrou 1:5f537df9dca8 756 *
GIPetrou 1:5f537df9dca8 757 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 758 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 759 */
GIPetrou 1:5f537df9dca8 760 uint8_t Reset(uint8_t servoId);
GIPetrou 1:5f537df9dca8 761
GIPetrou 1:5f537df9dca8 762 /** Trigger the servo.
GIPetrou 1:5f537df9dca8 763 * Triggers the action registered by the REG_WRITE instruction
GIPetrou 1:5f537df9dca8 764 *
GIPetrou 1:5f537df9dca8 765 * @param servoId The servo id.
GIPetrou 1:5f537df9dca8 766 * @return MX28_ERRBIT_NONE if succeeded, error code otherwise.
GIPetrou 1:5f537df9dca8 767 */
GIPetrou 1:5f537df9dca8 768 uint8_t Action(uint8_t servoId);
GIPetrou 1:5f537df9dca8 769
GIPetrou 1:5f537df9dca8 770 /** Create an MX28 servo object connected to the specified serial half duplex pins,
GIPetrou 1:5f537df9dca8 771 * with the specified baudrate.
GIPetrou 1:5f537df9dca8 772 *
GIPetrou 1:5f537df9dca8 773 * @param tx Send pin.
GIPetrou 1:5f537df9dca8 774 * @param rx Receive pin.
GIPetrou 1:5f537df9dca8 775 * @param baudrate The bus speed.
GIPetrou 1:5f537df9dca8 776 */
GIPetrou 1:5f537df9dca8 777 MX28(PinName tx, PinName rx, int baudRate);
GIPetrou 1:5f537df9dca8 778
GIPetrou 1:5f537df9dca8 779 /** Destroy an MX28 servo object
GIPetrou 1:5f537df9dca8 780 */
GIPetrou 1:5f537df9dca8 781 ~MX28();
GIPetrou 1:5f537df9dca8 782 };
GIPetrou 1:5f537df9dca8 783
GIPetrou 0:ea5b951002cf 784 #endif // MX28_H