A library to control MX28 servos. It could also be used with the rest of the MX series servos.

Dependents:   IDcheck

Fork of MX28 by Georgios Petrou

This library is based on Robotis documentation regarding the dynamixel and MX28 protocols

It is part of a bigger project involving seven mbeds to control a hexapod robot.

I have not tried to control other MX series servos, but it should be possible to use this library with minor modifications.

Committer:
GIPetrou
Date:
Wed Apr 03 16:44:50 2013 +0000
Revision:
2:85216442d3ef
Parent:
1:5f537df9dca8
Updated code to work with latest mbed version

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