00001 /* 00002 Common Definitions for ROS driver ArbotiX Firmware 00003 Copyright (c) 2008-2011 Vanadium Labs LLC. All right 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 Vanadium Labs LLC nor the names of its 00013 contributors may be used to endorse or promote products derived 00014 from this software without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00017 ANY 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 VANADIUM LABS BE LIABLE FOR ANY DIRECT, INDIRECT, 00020 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00021 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00022 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00023 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00024 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00025 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 */ 00027 00028 /* ArbotiX (id:253) Instruction Definitions */ 00029 #define ARB_SIZE_POSE 7 // pose size: a single param for size of pose 00030 #define ARB_LOAD_POSE 8 // load pose: index, then pose positions (# of params = 2*pose_size) 00031 #define ARB_LOAD_SEQ 9 // seq size: a single param for the size of the seq 00032 #define ARB_PLAY_SEQ 10 // load seq: index/times (# of params = 3*seq_size) 00033 #define ARB_LOOP_SEQ 11 // play seq: no params 00034 //#define ARB_TEST 25 // hardware test: no params 00035 #define ARB_CONTROL_SETUP 26 // write ids: id of controller, params (usually ids of servos, # of params = pose_size + 1) 00036 #define ARB_CONTROL_WRITE 27 // write positions: positions in order of servos (# of params = 2*pose_size) 00037 #define ARB_CONTROL_STAT 28 // retrieve status: id of controller 00038 #define ARB_SYNC_READ 0x84 00039 00040 /* ArbotiX (id:253) Register Table Definitions */ 00041 #define REG_MODEL_NUMBER_L 0 00042 #define REG_MODEL_NUMBER_H 1 00043 #define REG_VERSION 2 00044 #define REG_ID 3 00045 #define REG_BAUD_RATE 4 00046 #define REG_DIGITAL 5 // First block of digital pins to read 00047 // base + index, bit 1 = value (0,1), bit 0 = direction (0,1) 00048 #define REG_RESCAN 15 00049 #define REG_RETURN_LEVEL 16 00050 #define REG_ALARM_LED 17 00051 #define REG_ANA_BASE 18 // First Analog Port 00052 #define REG_SERVO_BASE 26 // Up to 10 servos, each uses 2 bytes (L, then H), pulse width (0, 1000-2000ms) 00053 #define REG_MOVING 46 00054 #define REG_LM_SIGN 47 // Raw motor pwm (-255 to 255), 1 byte sign + 1 byte speed per side 00055 #define REG_LM_PWM 48 00056 #define REG_RM_SIGN 49 00057 #define REG_RM_PWM 50 00058 00059 /* Packet Decoding */ 00060 int mode = 0; // where we are in the frame 00061 00062 unsigned char id = 0; // id of this frame 00063 unsigned char length = 0; // length of this frame 00064 unsigned char ins = 0; // instruction of this frame 00065 00066 unsigned char params[143]; // parameters (match RX-64 buffer size) 00067 unsigned char index = 0; // index in param buffer 00068 00069 int checksum; // checksum 00070 00071 #define INSTRUCTION_ERROR 0x40 00072 #define CHECKSUM_ERROR 0x10 00073