dynamixel_const.h
Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2011, Antons Rebguns <email>
00003     All rights reserved.
00004 
00005     Redistribution and use in source and binary forms, with or without
00006     modification, are permitted provided that the following conditions are met:
00007         * Redistributions of source code must retain the above copyright
00008         notice, this list of conditions and the following disclaimer.
00009         * Redistributions in binary form must reproduce the above copyright
00010         notice, this list of conditions and the following disclaimer in the
00011         documentation and/or other materials provided with the distribution.
00012         * Neither the name of the <organization> nor the
00013         names of its contributors may be used to endorse or promote products
00014         derived from this software without specific prior written permission.
00015 
00016     THIS SOFTWARE IS PROVIDED BY Antons Rebguns <email> ''AS IS'' AND ANY
00017     EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019     DISCLAIMED. IN NO EVENT SHALL Antons Rebguns <email> BE LIABLE FOR ANY
00020     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #ifndef DYNAMIXEL_CONST_H__
00029 #define DYNAMIXEL_CONST_H__
00030 
00031 #include <stdint.h>
00032 #include <string>
00033 
00034 namespace dynamixel_hardware_interface
00035 {
00036 
00037 const uint16_t DXL_MAX_LOAD_ENCODER = 1023;     // 0x3FF
00038 const uint16_t DXL_MAX_VELOCITY_ENCODER = 1023; // 0x3FF
00039 const uint16_t DXL_MAX_TORQUE_ENCODER = 1023;   // 0x3FF
00040 
00041 // Control Table Constants
00042 typedef enum DynamixelControlEnum
00043 {
00044     DXL_MODEL_NUMBER_L = 0,
00045     DXL_MODEL_NUMBER_H = 1,
00046     DXL_FIRMWARE_VERSION = 2,
00047     DXL_ID = 3,
00048     DXL_BAUD_RATE = 4,
00049     DXL_RETURN_DELAY_TIME = 5,
00050     DXL_CW_ANGLE_LIMIT_L = 6,
00051     DXL_CW_ANGLE_LIMIT_H = 7,
00052     DXL_CCW_ANGLE_LIMIT_L = 8,
00053     DXL_CCW_ANGLE_LIMIT_H = 9,
00054     DXL_DRIVE_MODE = 10,
00055     DXL_LIMIT_TEMPERATURE = 11,
00056     DXL_DOWN_LIMIT_VOLTAGE = 12,
00057     DXL_UP_LIMIT_VOLTAGE = 13,
00058     DXL_MAX_TORQUE_L = 14,
00059     DXL_MAX_TORQUE_H = 15,
00060     DXL_RETURN_LEVEL = 16,
00061     DXL_ALARM_LED = 17,
00062     DXL_ALARM_SHUTDOWN = 18,
00063     DXL_OPERATING_MODE = 19,
00064     DXL_DOWN_CALIBRATION_L = 20,
00065     DXL_DOWN_CALIBRATION_H = 21,
00066     DXL_UP_CALIBRATION_L = 22,
00067     DXL_UP_CALIBRATION_H = 23,
00068     DXL_TORQUE_ENABLE = 24,
00069     DXL_LED = 25,
00070     DXL_CW_COMPLIANCE_MARGIN = 26,
00071     DXL_CCW_COMPLIANCE_MARGIN = 27,
00072     DXL_CW_COMPLIANCE_SLOPE = 28,
00073     DXL_CCW_COMPLIANCE_SLOPE = 29,
00074     DXL_GOAL_POSITION_L = 30,
00075     DXL_GOAL_POSITION_H = 31,
00076     DXL_GOAL_SPEED_L = 32,
00077     DXL_GOAL_SPEED_H = 33,
00078     DXL_TORQUE_LIMIT_L = 34,
00079     DXL_TORQUE_LIMIT_H = 35,
00080     DXL_PRESENT_POSITION_L = 36,
00081     DXL_PRESENT_POSITION_H = 37,
00082     DXL_PRESENT_SPEED_L = 38,
00083     DXL_PRESENT_SPEED_H = 39,
00084     DXL_PRESENT_LOAD_L = 40,
00085     DXL_PRESENT_LOAD_H = 41,
00086     DXL_PRESENT_VOLTAGE = 42,
00087     DXL_PRESENT_TEMPERATURE = 43,
00088     DXL_REGISTERED_INSTRUCTION = 44,
00089     DXL_PAUSE_TIME = 45,
00090     DXL_MOVING = 46,
00091     DXL_LOCK = 47,
00092     DXL_PUNCH_L = 48,
00093     DXL_PUNCH_H = 49,
00094     DXL_SENSED_CURRENT_L = 56,
00095     DXL_SENSED_CURRENT_H = 57,
00096 
00097 } DynamixelControl;
00098 
00099 typedef enum DynamixelInstructionEnum
00100 {
00101     DXL_PING = 1,
00102     DXL_READ_DATA = 2,
00103     DXL_WRITE_DATA = 3,
00104     DXL_REG_WRITE = 4,
00105     DXL_ACTION = 5,
00106     DXL_RESET = 6,
00107     DXL_SYNC_WRITE = 131,
00108     DXL_BROADCAST = 254,
00109 
00110 } DynamixelInstruction;
00111 
00112 typedef enum DynamixelErrorCodeEnum
00113 {
00114     DXL_INSTRUCTION_ERROR = 64,
00115     DXL_OVERLOAD_ERROR = 32,
00116     DXL_CHECKSUM_ERROR = 16,
00117     DXL_RANGE_ERROR = 8,
00118     DXL_OVERHEATING_ERROR = 4,
00119     DXL_ANGLE_LIMIT_ERROR = 2,
00120     DXL_INPUT_VOLTAGE_ERROR = 1,
00121     DXL_NO_ERROR = 0,
00122 
00123 } DynamixelErrorCode;
00124 
00125 
00126 typedef enum DynamixelParamsEnum
00127 {
00128     ENCODER_RESOLUTION,
00129     RANGE_DEGREES,
00130     TORQUE_PER_VOLT,
00131     VELOCITY_PER_VOLT
00132 
00133 } DynamixelParams;
00134 
00135 inline std::string getMotorModelName(int model_number)
00136 {
00137     if (model_number == 113) { return "DX-113"; }
00138     else if (model_number == 116) { return "DX-116"; }
00139     else if (model_number == 117) { return "DX-117"; }
00140     else if (model_number == 12) { return "AX-12"; }
00141     else if (model_number == 18) { return "AX-18"; }
00142     else if (model_number == 10) { return "RX-10"; }
00143     else if (model_number == 24) { return "RX-24"; }
00144     else if (model_number == 28) { return "RX-28"; }
00145     else if (model_number == 64) { return "RX-64"; }
00146     else if (model_number == 107) { return "EX-106"; }
00147     else if (model_number == 29) { return "MX-28"; }
00148 
00149     return "";
00150 }
00151 
00152 const double KGCM_TO_NM = 0.0980665;        // 1 kg-cm is that many N-m
00153 const double RPM_TO_RADSEC = 0.104719755;   // 1 RPM is that many rad/sec
00154 
00155 inline double getMotorModelParams(int model_number, DynamixelParams param)
00156 {
00157     if (model_number == 113)
00158     {
00159         switch (param)
00160         {
00161             case ENCODER_RESOLUTION: { return 1024.0; }
00162             case RANGE_DEGREES:      { return 300.0; }
00163             case TORQUE_PER_VOLT:    { return (10.0 * KGCM_TO_NM) / 12.0; }
00164             case VELOCITY_PER_VOLT:  { return (54.0 * RPM_TO_RADSEC) / 12.0; }
00165         }
00166     }
00167     else if (model_number == 116)
00168     {
00169         switch (param)
00170         {
00171             case ENCODER_RESOLUTION: { return 1024.0; }
00172             case RANGE_DEGREES:      { return 300.0; }
00173             case TORQUE_PER_VOLT:    { return (21.0 * KGCM_TO_NM) / 12.0; }
00174             case VELOCITY_PER_VOLT:  { return (78.0 * RPM_TO_RADSEC) / 12.0; }
00175         }
00176     }
00177     else if (model_number == 117)
00178     {
00179         switch (param)
00180         {
00181             case ENCODER_RESOLUTION: { return 1024.0; }
00182             case RANGE_DEGREES:      { return 300.0; }
00183             case TORQUE_PER_VOLT:    { return (37.0 * KGCM_TO_NM) / 18.5; }
00184             case VELOCITY_PER_VOLT:  { return (85.0 * RPM_TO_RADSEC) / 18.5; }
00185         }
00186     }
00187     else if (model_number == 12)
00188     {
00189         switch (param)
00190         {
00191             case ENCODER_RESOLUTION: { return 1024.0; }
00192             case RANGE_DEGREES:      { return 300.0; }
00193             case TORQUE_PER_VOLT:    { return (15.0 * KGCM_TO_NM) / 12.0; }
00194             case VELOCITY_PER_VOLT:  { return (59.0 * RPM_TO_RADSEC) / 12.0; }
00195         }
00196     }
00197     else if (model_number == 18)
00198     {
00199         switch (param)
00200         {
00201             case ENCODER_RESOLUTION: { return 1024.0; }
00202             case RANGE_DEGREES:      { return 300.0; }
00203             case TORQUE_PER_VOLT:    { return (18.0 * KGCM_TO_NM) / 12.0; }
00204             case VELOCITY_PER_VOLT:  { return (97.0 * RPM_TO_RADSEC) / 12.0; }
00205         }
00206     }
00207     else if (model_number == 10)
00208     {
00209         switch (param)
00210         {
00211             case ENCODER_RESOLUTION: { return 1024.0; }
00212             case RANGE_DEGREES:      { return 300.0; }
00213             case TORQUE_PER_VOLT:    { return (13.0 * KGCM_TO_NM) / 12.0; }
00214             case VELOCITY_PER_VOLT:  { return (54.0 * RPM_TO_RADSEC) / 12.0; }
00215         }
00216     }
00217     else if (model_number == 24)
00218     {
00219         switch (param)
00220         {
00221             case ENCODER_RESOLUTION: { return 1024.0; }
00222             case RANGE_DEGREES:      { return 300.0; }
00223             case TORQUE_PER_VOLT:    { return (26.0 * KGCM_TO_NM) / 12.0; }
00224             case VELOCITY_PER_VOLT:  { return (126.0 * RPM_TO_RADSEC) / 12.0; }
00225         }
00226     }
00227     else if (model_number == 28)
00228     {
00229         switch (param)
00230         {
00231             case ENCODER_RESOLUTION: { return 1024.0; }
00232             case RANGE_DEGREES:      { return 300.0; }
00233             case TORQUE_PER_VOLT:    { return (37.0 * KGCM_TO_NM) / 18.5; }
00234             case VELOCITY_PER_VOLT:  { return (85.0 * RPM_TO_RADSEC) / 18.5; }
00235         }
00236     }
00237     else if (model_number == 64)
00238     {
00239         switch (param)
00240         {
00241             case ENCODER_RESOLUTION: { return 1024.0; }
00242             case RANGE_DEGREES:      { return 300.0; }
00243             case TORQUE_PER_VOLT:    { return (52.0 * KGCM_TO_NM) / 18.5; }
00244             case VELOCITY_PER_VOLT:  { return (64.0 * RPM_TO_RADSEC) / 18.5; }
00245         }
00246     }
00247     else if (model_number == 107)
00248     {
00249         switch (param)
00250         {
00251             case ENCODER_RESOLUTION: { return 4096.0; }
00252             case RANGE_DEGREES:      { return 250.92; }
00253             case TORQUE_PER_VOLT:    { return (107.0 * KGCM_TO_NM) / 18.5; }
00254             case VELOCITY_PER_VOLT:  { return (91.0 * RPM_TO_RADSEC) / 18.5; }
00255         }
00256     }
00257     else if (model_number == 29)
00258     {
00259         switch (param)
00260         {
00261             case ENCODER_RESOLUTION: { return 4096.0; }
00262             case RANGE_DEGREES:      { return 360.0; }
00263             case TORQUE_PER_VOLT:    { return (24.0 * KGCM_TO_NM) / 12.0; }
00264             case VELOCITY_PER_VOLT:  { return (54.0 * RPM_TO_RADSEC) / 12.0; }
00265         }
00266     }
00267 
00268     return -1;
00269 }
00270 
00271 }
00272 
00273 #endif  // DYNAMIXEL_CONST_H__


dynamixel_hardware_interface
Author(s): Antons Rebguns
autogenerated on Sun Oct 5 2014 23:33:10