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:
Sun Sep 09 22:09:00 2012 +0000
Revision:
0:ea5b951002cf
Child:
1:5f537df9dca8
First version of library

Who changed what in which revision?

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