123
dynamixel.h@0:a49e4e666e2d, 2017-09-12 (annotated)
- Committer:
- peter16688
- Date:
- Tue Sep 12 13:22:08 2017 +0000
- Revision:
- 0:a49e4e666e2d
3WOK_8dir_1m_PD_p2pcontrol
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
peter16688 | 0:a49e4e666e2d | 1 | // Dynamixel SDK platform independent header |
peter16688 | 0:a49e4e666e2d | 2 | #ifndef _DYNAMIXEL_HEADER |
peter16688 | 0:a49e4e666e2d | 3 | #define _DYNAMIXEL_HEADER |
peter16688 | 0:a49e4e666e2d | 4 | |
peter16688 | 0:a49e4e666e2d | 5 | |
peter16688 | 0:a49e4e666e2d | 6 | #ifdef __cplusplus |
peter16688 | 0:a49e4e666e2d | 7 | extern "C" { |
peter16688 | 0:a49e4e666e2d | 8 | #endif |
peter16688 | 0:a49e4e666e2d | 9 | |
peter16688 | 0:a49e4e666e2d | 10 | |
peter16688 | 0:a49e4e666e2d | 11 | ///////////// device control methods //////////////////////// |
peter16688 | 0:a49e4e666e2d | 12 | int dxl_initialize( int devIndex, int baudnum ); |
peter16688 | 0:a49e4e666e2d | 13 | void dxl_terminate(void); |
peter16688 | 0:a49e4e666e2d | 14 | |
peter16688 | 0:a49e4e666e2d | 15 | |
peter16688 | 0:a49e4e666e2d | 16 | ///////////// set/get packet methods ////////////////////////// |
peter16688 | 0:a49e4e666e2d | 17 | void dxl_set_txpacket_id( int id ); |
peter16688 | 0:a49e4e666e2d | 18 | #define BROADCAST_ID (254) |
peter16688 | 0:a49e4e666e2d | 19 | |
peter16688 | 0:a49e4e666e2d | 20 | void dxl_set_txpacket_instruction( int instruction ); |
peter16688 | 0:a49e4e666e2d | 21 | #define INST_PING (1) |
peter16688 | 0:a49e4e666e2d | 22 | #define INST_READ (2) |
peter16688 | 0:a49e4e666e2d | 23 | #define INST_WRITE (3) |
peter16688 | 0:a49e4e666e2d | 24 | #define INST_REG_WRITE (4) |
peter16688 | 0:a49e4e666e2d | 25 | #define INST_ACTION (5) |
peter16688 | 0:a49e4e666e2d | 26 | #define INST_RESET (6) |
peter16688 | 0:a49e4e666e2d | 27 | #define INST_SYNC_WRITE (131) |
peter16688 | 0:a49e4e666e2d | 28 | |
peter16688 | 0:a49e4e666e2d | 29 | #define MAXNUM_TXPARAM (150) |
peter16688 | 0:a49e4e666e2d | 30 | void dxl_set_txpacket_parameter( int index, int value ); |
peter16688 | 0:a49e4e666e2d | 31 | void dxl_set_txpacket_length( int length ); |
peter16688 | 0:a49e4e666e2d | 32 | |
peter16688 | 0:a49e4e666e2d | 33 | int dxl_get_rxpacket_error( int errbit ); |
peter16688 | 0:a49e4e666e2d | 34 | #define ERRBIT_VOLTAGE (1) |
peter16688 | 0:a49e4e666e2d | 35 | #define ERRBIT_ANGLE (2) |
peter16688 | 0:a49e4e666e2d | 36 | #define ERRBIT_OVERHEAT (4) |
peter16688 | 0:a49e4e666e2d | 37 | #define ERRBIT_RANGE (8) |
peter16688 | 0:a49e4e666e2d | 38 | #define ERRBIT_CHECKSUM (16) |
peter16688 | 0:a49e4e666e2d | 39 | #define ERRBIT_OVERLOAD (32) |
peter16688 | 0:a49e4e666e2d | 40 | #define ERRBIT_INSTRUCTION (64) |
peter16688 | 0:a49e4e666e2d | 41 | |
peter16688 | 0:a49e4e666e2d | 42 | #define MAXNUM_RXPARAM (60) |
peter16688 | 0:a49e4e666e2d | 43 | int dxl_get_rxpacket_parameter( int index ); |
peter16688 | 0:a49e4e666e2d | 44 | int dxl_get_rxpacket_length(void); |
peter16688 | 0:a49e4e666e2d | 45 | |
peter16688 | 0:a49e4e666e2d | 46 | // utility for value |
peter16688 | 0:a49e4e666e2d | 47 | int dxl_makeword( int lowbyte, int highbyte ); |
peter16688 | 0:a49e4e666e2d | 48 | int dxl_get_lowbyte( int word ); |
peter16688 | 0:a49e4e666e2d | 49 | int dxl_get_highbyte( int word ); |
peter16688 | 0:a49e4e666e2d | 50 | |
peter16688 | 0:a49e4e666e2d | 51 | |
peter16688 | 0:a49e4e666e2d | 52 | ////////// packet communication methods /////////////////////// |
peter16688 | 0:a49e4e666e2d | 53 | void dxl_tx_packet(void); |
peter16688 | 0:a49e4e666e2d | 54 | void dxl_rx_packet(void); |
peter16688 | 0:a49e4e666e2d | 55 | void dxl_txrx_packet(void); |
peter16688 | 0:a49e4e666e2d | 56 | |
peter16688 | 0:a49e4e666e2d | 57 | int dxl_get_result(void); |
peter16688 | 0:a49e4e666e2d | 58 | #define COMM_TXSUCCESS (0) |
peter16688 | 0:a49e4e666e2d | 59 | #define COMM_RXSUCCESS (1) |
peter16688 | 0:a49e4e666e2d | 60 | #define COMM_TXFAIL (2) |
peter16688 | 0:a49e4e666e2d | 61 | #define COMM_RXFAIL (3) |
peter16688 | 0:a49e4e666e2d | 62 | #define COMM_TXERROR (4) |
peter16688 | 0:a49e4e666e2d | 63 | #define COMM_RXWAITING (5) |
peter16688 | 0:a49e4e666e2d | 64 | #define COMM_RXTIMEOUT (6) |
peter16688 | 0:a49e4e666e2d | 65 | #define COMM_RXCORRUPT (7) |
peter16688 | 0:a49e4e666e2d | 66 | |
peter16688 | 0:a49e4e666e2d | 67 | |
peter16688 | 0:a49e4e666e2d | 68 | //MX64 Register stanley/// |
peter16688 | 0:a49e4e666e2d | 69 | #define ID_ADDRESS 3 |
peter16688 | 0:a49e4e666e2d | 70 | #define GOAL_POSITION 30 |
peter16688 | 0:a49e4e666e2d | 71 | #define PRESENT_POS 36 |
peter16688 | 0:a49e4e666e2d | 72 | #define RETURN_DELAY_TIME 5 |
peter16688 | 0:a49e4e666e2d | 73 | #define CW_ANGLE_LIMIT_L 6 |
peter16688 | 0:a49e4e666e2d | 74 | #define CW_ANGLE_LIMIT_H 7 |
peter16688 | 0:a49e4e666e2d | 75 | #define CCW_ANGLE_LIMIT_L 8 |
peter16688 | 0:a49e4e666e2d | 76 | #define CCW_ANGLE_LIMIT_H 9 |
peter16688 | 0:a49e4e666e2d | 77 | #define MAX_TORQUE 14 |
peter16688 | 0:a49e4e666e2d | 78 | #define MULTITURN_OFFSET 20 |
peter16688 | 0:a49e4e666e2d | 79 | #define GOAL_POSITION 30 |
peter16688 | 0:a49e4e666e2d | 80 | #define GOAL_SPEED 32 |
peter16688 | 0:a49e4e666e2d | 81 | #define TORQUE_LIMIT 34 |
peter16688 | 0:a49e4e666e2d | 82 | #define PRESENT_POS 36 |
peter16688 | 0:a49e4e666e2d | 83 | |
peter16688 | 0:a49e4e666e2d | 84 | #define STILL_MOVING 46 |
peter16688 | 0:a49e4e666e2d | 85 | |
peter16688 | 0:a49e4e666e2d | 86 | |
peter16688 | 0:a49e4e666e2d | 87 | #define ADDRESS_LED 25 |
peter16688 | 0:a49e4e666e2d | 88 | |
peter16688 | 0:a49e4e666e2d | 89 | |
peter16688 | 0:a49e4e666e2d | 90 | //////////// high communication methods /////////////////////// |
peter16688 | 0:a49e4e666e2d | 91 | void dxl_ping( int id ); |
peter16688 | 0:a49e4e666e2d | 92 | int dxl_read_byte( int id, int address ); |
peter16688 | 0:a49e4e666e2d | 93 | void dxl_write_byte( int id, int address, int value ); |
peter16688 | 0:a49e4e666e2d | 94 | int dxl_read_word( short int id, short int address ); |
peter16688 | 0:a49e4e666e2d | 95 | void dxl_write_word( short int id, short int address, short int value ); |
peter16688 | 0:a49e4e666e2d | 96 | int syncWrite_u16base(unsigned short int start_addr, unsigned short int data_length, unsigned short int *param, unsigned short int param_length); // WORD(16bit) syncwrite() for DXL |
peter16688 | 0:a49e4e666e2d | 97 | void setPosition(int ServoID, int Position, int Speed);//stanley |
peter16688 | 0:a49e4e666e2d | 98 | |
peter16688 | 0:a49e4e666e2d | 99 | |
peter16688 | 0:a49e4e666e2d | 100 | |
peter16688 | 0:a49e4e666e2d | 101 | |
peter16688 | 0:a49e4e666e2d | 102 | |
peter16688 | 0:a49e4e666e2d | 103 | #ifdef __cplusplus |
peter16688 | 0:a49e4e666e2d | 104 | } |
peter16688 | 0:a49e4e666e2d | 105 | #endif |
peter16688 | 0:a49e4e666e2d | 106 | |
peter16688 | 0:a49e4e666e2d | 107 | #endif |