Provides an interface to an AX-12A servo. Requires the Dynamixel bus protocol library/
Fork of AX-12A by
AX12.h@1:d7642b2e155d, 2015-12-15 (annotated)
- Committer:
- jepickett
- Date:
- Tue Dec 15 04:37:54 2015 +0000
- Revision:
- 1:d7642b2e155d
- Parent:
- 0:1a48094c99d1
- Child:
- 2:f2da3b1d9988
- Child:
- 3:7b970151bf19
propagating changes from ServoTerminal
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jepickett | 0:1a48094c99d1 | 1 | /* Copyright (c) 2012 Martin Smith, MIT License |
jepickett | 0:1a48094c99d1 | 2 | * |
jepickett | 0:1a48094c99d1 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
jepickett | 0:1a48094c99d1 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
jepickett | 0:1a48094c99d1 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
jepickett | 0:1a48094c99d1 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
jepickett | 0:1a48094c99d1 | 7 | * furnished to do so, subject to the following conditions: |
jepickett | 0:1a48094c99d1 | 8 | * |
jepickett | 0:1a48094c99d1 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
jepickett | 0:1a48094c99d1 | 10 | * substantial portions of the Software. |
jepickett | 0:1a48094c99d1 | 11 | * |
jepickett | 0:1a48094c99d1 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
jepickett | 0:1a48094c99d1 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
jepickett | 0:1a48094c99d1 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
jepickett | 0:1a48094c99d1 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
jepickett | 0:1a48094c99d1 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
jepickett | 0:1a48094c99d1 | 17 | */ |
jepickett | 0:1a48094c99d1 | 18 | |
jepickett | 0:1a48094c99d1 | 19 | #ifndef MBED_AX12_H |
jepickett | 0:1a48094c99d1 | 20 | #define MBED_AX12_H |
jepickett | 0:1a48094c99d1 | 21 | |
jepickett | 0:1a48094c99d1 | 22 | #include "mbed.h" |
jepickett | 0:1a48094c99d1 | 23 | #include "DynamixelBus.h" |
jepickett | 0:1a48094c99d1 | 24 | |
jepickett | 0:1a48094c99d1 | 25 | |
jepickett | 0:1a48094c99d1 | 26 | enum ControlTable |
jepickett | 0:1a48094c99d1 | 27 | { |
jepickett | 1:d7642b2e155d | 28 | ctModelNumberLow = 0, // RD |
jepickett | 1:d7642b2e155d | 29 | ctModelNumberHigh = 1, // RD |
jepickett | 1:d7642b2e155d | 30 | ctFirmwareVersion = 2, // RD |
jepickett | 1:d7642b2e155d | 31 | ctID = 3, // RD/WR |
jepickett | 1:d7642b2e155d | 32 | ctBaudRate = 4, // RD/WR |
jepickett | 1:d7642b2e155d | 33 | ctReturnDelayTime = 5, // RD/WR |
jepickett | 1:d7642b2e155d | 34 | ctCWAngleLimitL = 6, // RD/WR |
jepickett | 1:d7642b2e155d | 35 | ctCWAngleLimitH = 7, // RD/WR |
jepickett | 1:d7642b2e155d | 36 | ctCCWAngleLimitL = 8, // RD/WR |
jepickett | 1:d7642b2e155d | 37 | ctCCWAngleLimitH = 9, // RD/WR |
jepickett | 1:d7642b2e155d | 38 | ctReserved1 = 10, |
jepickett | 1:d7642b2e155d | 39 | ctTemperatureLimit = 11, // RD/WR |
jepickett | 1:d7642b2e155d | 40 | ctVoltageLow = 12, // RD/WR |
jepickett | 1:d7642b2e155d | 41 | ctVoltageHigh = 13, // RD/WR |
jepickett | 1:d7642b2e155d | 42 | ctMaxTorqueL = 14, // RD/WR |
jepickett | 1:d7642b2e155d | 43 | ctMaxTorqueH = 15, // RD/WR |
jepickett | 1:d7642b2e155d | 44 | ctStatusReturnLevel = 16, // RD/WR |
jepickett | 1:d7642b2e155d | 45 | ctAlarmLED = 17, // RD/WR |
jepickett | 1:d7642b2e155d | 46 | ctAlarmShutdown = 18, // RD/WR |
jepickett | 1:d7642b2e155d | 47 | ctReserved2 = 19, |
jepickett | 1:d7642b2e155d | 48 | ctDownCalibrationL = 20, // RR |
jepickett | 1:d7642b2e155d | 49 | ctDownCalibrationH = 21, // RD |
jepickett | 1:d7642b2e155d | 50 | ctUpCalibrationL = 22, // RD |
jepickett | 1:d7642b2e155d | 51 | ctUpCalibrationH = 23, // RD |
jepickett | 1:d7642b2e155d | 52 | ctTorqueEnable = 24, // RD/WR |
jepickett | 1:d7642b2e155d | 53 | ctLED = 25, // RD/WR |
jepickett | 1:d7642b2e155d | 54 | ctCWComplianceMargin = 26, // RD/WR |
jepickett | 1:d7642b2e155d | 55 | ctCCWComplianceMargin = 27, // RD/WR |
jepickett | 1:d7642b2e155d | 56 | ctCWComplianceSlope = 28, // RD/WR |
jepickett | 1:d7642b2e155d | 57 | ctCCWComplianceSlope = 29, // RD/WR |
jepickett | 1:d7642b2e155d | 58 | ctGoalPositionL = 30, // RD/WR |
jepickett | 1:d7642b2e155d | 59 | ctGoalPositionH = 31, // RD/WR |
jepickett | 1:d7642b2e155d | 60 | ctMovingSpeedL = 32, // RD/WR |
jepickett | 1:d7642b2e155d | 61 | ctMovingSpeedH = 33, // RD/WR |
jepickett | 1:d7642b2e155d | 62 | ctTorqueLimitL = 34, // RD/WR |
jepickett | 1:d7642b2e155d | 63 | ctTorqueLimitH = 35, // RD/WR |
jepickett | 1:d7642b2e155d | 64 | ctPresentPositionL = 36, // RD |
jepickett | 1:d7642b2e155d | 65 | ctPresentPositionH = 37, // RD |
jepickett | 1:d7642b2e155d | 66 | ctPresentSpeedL = 38, // RD |
jepickett | 1:d7642b2e155d | 67 | ctPresentSpeedH = 39, // RD |
jepickett | 1:d7642b2e155d | 68 | ctPresentLoadL = 40, // RD |
jepickett | 1:d7642b2e155d | 69 | ctPresentLoadH = 41, // RD |
jepickett | 1:d7642b2e155d | 70 | ctPresentVoltage = 42, // RD |
jepickett | 1:d7642b2e155d | 71 | ctPresentTemperature = 43, // RD |
jepickett | 1:d7642b2e155d | 72 | ctRegisteredInst = 44, // RD/WR |
jepickett | 1:d7642b2e155d | 73 | ctReserved3 = 45, |
jepickett | 1:d7642b2e155d | 74 | ctMoving = 46, // RD |
jepickett | 1:d7642b2e155d | 75 | ctLock = 47, // RD/WR |
jepickett | 1:d7642b2e155d | 76 | ctPunchL = 48, // RD/WR |
jepickett | 1:d7642b2e155d | 77 | ctPunchH = 49 // RD/WR |
jepickett | 0:1a48094c99d1 | 78 | }; |
jepickett | 0:1a48094c99d1 | 79 | |
jepickett | 0:1a48094c99d1 | 80 | class AX12 |
jepickett | 0:1a48094c99d1 | 81 | { |
jepickett | 0:1a48094c99d1 | 82 | |
jepickett | 0:1a48094c99d1 | 83 | public: |
jepickett | 0:1a48094c99d1 | 84 | AX12(DynamixelBus* pbus, ServoId = 1); |
jepickett | 0:1a48094c99d1 | 85 | |
jepickett | 0:1a48094c99d1 | 86 | // returns the status of the servo (connected/not connected + errors) |
jepickett | 0:1a48094c99d1 | 87 | StatusCode Ping(); |
jepickett | 0:1a48094c99d1 | 88 | |
jepickett | 0:1a48094c99d1 | 89 | // Sets toe goal position of the servo in degrees |
jepickett | 0:1a48094c99d1 | 90 | StatusCode SetGoal(float degrees); |
jepickett | 0:1a48094c99d1 | 91 | |
jepickett | 0:1a48094c99d1 | 92 | // determines if the servo is moving |
jepickett | 0:1a48094c99d1 | 93 | bool IsMoving(void); |
jepickett | 0:1a48094c99d1 | 94 | |
jepickett | 0:1a48094c99d1 | 95 | // gets the position of the servo in degrees |
jepickett | 0:1a48094c99d1 | 96 | float GetPosition(); |
jepickett | 0:1a48094c99d1 | 97 | |
jepickett | 0:1a48094c99d1 | 98 | // gets the internal temperature of the servo |
jepickett | 1:d7642b2e155d | 99 | int GetTemperature(void); |
jepickett | 0:1a48094c99d1 | 100 | |
jepickett | 0:1a48094c99d1 | 101 | // gets the servo power supply voltage |
jepickett | 0:1a48094c99d1 | 102 | float GetSupplyVoltage(void); |
jepickett | 1:d7642b2e155d | 103 | |
jepickett | 1:d7642b2e155d | 104 | // enables/disables holding torque |
jepickett | 1:d7642b2e155d | 105 | StatusCode TorqueEnable( bool ); |
jepickett | 0:1a48094c99d1 | 106 | |
jepickett | 0:1a48094c99d1 | 107 | private : |
jepickett | 0:1a48094c99d1 | 108 | ServoId _ID; |
jepickett | 0:1a48094c99d1 | 109 | DynamixelBus* _pbus; |
jepickett | 0:1a48094c99d1 | 110 | }; |
jepickett | 0:1a48094c99d1 | 111 | #endif |