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 Sep 12 15:59:54 2012 +0000
Revision:
1:5f537df9dca8
Parent:
0:ea5b951002cf
Child:
2:85216442d3ef
First commit of library

Who changed what in which revision?

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