Provides an interface to an AX-12A servo. Requires the Dynamixel bus protocol library/
Fork of AX-12A by
AX12.h@0:1a48094c99d1, 2015-12-10 (annotated)
- Committer:
- jepickett
- Date:
- Thu Dec 10 21:45:59 2015 +0000
- Revision:
- 0:1a48094c99d1
- Child:
- 1:d7642b2e155d
Initial check in for AX-12A servo. Depends on the dynamixel bus protocol library.
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 | 0:1a48094c99d1 | 28 | ModelNumberLow = 0, // RD |
jepickett | 0:1a48094c99d1 | 29 | ModelNumberHigh = 1, // RD |
jepickett | 0:1a48094c99d1 | 30 | FirmwareVersion = 2, // RD |
jepickett | 0:1a48094c99d1 | 31 | ID = 3, // RD/WR |
jepickett | 0:1a48094c99d1 | 32 | BaudRate = 4, // RD/WR |
jepickett | 0:1a48094c99d1 | 33 | ReturnDelayTime = 5, // RD/WR |
jepickett | 0:1a48094c99d1 | 34 | CWAngleLimitL = 6, // RD/WR |
jepickett | 0:1a48094c99d1 | 35 | CWAngleLimitH = 7, // RD/WR |
jepickett | 0:1a48094c99d1 | 36 | CCWAngleLimitL = 8, // RD/WR |
jepickett | 0:1a48094c99d1 | 37 | CCWAngleLimitH = 9, // RD/WR |
jepickett | 0:1a48094c99d1 | 38 | Reserved1 = 10, |
jepickett | 0:1a48094c99d1 | 39 | TemperatureLimit = 11, // RD/WR |
jepickett | 0:1a48094c99d1 | 40 | VoltageLow = 12, // RD/WR |
jepickett | 0:1a48094c99d1 | 41 | VoltageHigh = 13, // RD/WR |
jepickett | 0:1a48094c99d1 | 42 | MaxTorqueL = 14, // RD/WR |
jepickett | 0:1a48094c99d1 | 43 | MaxTorqueH = 15, // RD/WR |
jepickett | 0:1a48094c99d1 | 44 | StatusReturnLevel = 16, // RD/WR |
jepickett | 0:1a48094c99d1 | 45 | AlarmLED = 17, // RD/WR |
jepickett | 0:1a48094c99d1 | 46 | AlarmShutdown = 18, // RD/WR |
jepickett | 0:1a48094c99d1 | 47 | Reserved2 = 19, |
jepickett | 0:1a48094c99d1 | 48 | DownCalibrationL = 20, // RR |
jepickett | 0:1a48094c99d1 | 49 | DownCalibrationH = 21, // RD |
jepickett | 0:1a48094c99d1 | 50 | UpCalibrationL = 22, // RD |
jepickett | 0:1a48094c99d1 | 51 | UpCalibrationH = 23, // RD |
jepickett | 0:1a48094c99d1 | 52 | TorqueEnable = 24, // RD/WR |
jepickett | 0:1a48094c99d1 | 53 | LED = 25, // RD/WR |
jepickett | 0:1a48094c99d1 | 54 | CWComplianceMargin = 26, // RD/WR |
jepickett | 0:1a48094c99d1 | 55 | CCWComplianceMargin = 27, // RD/WR |
jepickett | 0:1a48094c99d1 | 56 | CWComplianceSlope = 28, // RD/WR |
jepickett | 0:1a48094c99d1 | 57 | CCWComplianceSlope = 29, // RD/WR |
jepickett | 0:1a48094c99d1 | 58 | GoalPositionL = 30, // RD/WR |
jepickett | 0:1a48094c99d1 | 59 | GoalPositionH = 31, // RD/WR |
jepickett | 0:1a48094c99d1 | 60 | MovingSpeedL = 32, // RD/WR |
jepickett | 0:1a48094c99d1 | 61 | MovingSpeedH = 33, // RD/WR |
jepickett | 0:1a48094c99d1 | 62 | TorqueLimitL = 34, // RD/WR |
jepickett | 0:1a48094c99d1 | 63 | TorqueLimitH = 35, // RD/WR |
jepickett | 0:1a48094c99d1 | 64 | PresentPositionL = 36, // RD |
jepickett | 0:1a48094c99d1 | 65 | PresentPositionH = 37, // RD |
jepickett | 0:1a48094c99d1 | 66 | PresentSpeedL = 38, // RD |
jepickett | 0:1a48094c99d1 | 67 | PresentSpeedH = 39, // RD |
jepickett | 0:1a48094c99d1 | 68 | PresentLoadL = 40, // RD |
jepickett | 0:1a48094c99d1 | 69 | PresentLoadH = 41, // RD |
jepickett | 0:1a48094c99d1 | 70 | PresentVoltage = 42, // RD |
jepickett | 0:1a48094c99d1 | 71 | PresentTemperature = 43, // RD |
jepickett | 0:1a48094c99d1 | 72 | RegisteredInst = 44, // RD/WR |
jepickett | 0:1a48094c99d1 | 73 | Reserved3 = 45, |
jepickett | 0:1a48094c99d1 | 74 | Moving = 46, // RD |
jepickett | 0:1a48094c99d1 | 75 | Lock = 47, // RD/WR |
jepickett | 0:1a48094c99d1 | 76 | PunchL = 48, // RD/WR |
jepickett | 0:1a48094c99d1 | 77 | PunchH = 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 | 0:1a48094c99d1 | 99 | float GetTemperature(void); |
jepickett | 0:1a48094c99d1 | 100 | |
jepickett | 0:1a48094c99d1 | 101 | // gets the servo power supply voltage |
jepickett | 0:1a48094c99d1 | 102 | float GetSupplyVoltage(void); |
jepickett | 0:1a48094c99d1 | 103 | |
jepickett | 0:1a48094c99d1 | 104 | private : |
jepickett | 0:1a48094c99d1 | 105 | ServoId _ID; |
jepickett | 0:1a48094c99d1 | 106 | DynamixelBus* _pbus; |
jepickett | 0:1a48094c99d1 | 107 | }; |
jepickett | 0:1a48094c99d1 | 108 | #endif |