$search
00001 /* 00002 Common Definitions for ROS driver ArbotiX Firmware 00003 Copyright (c) 2008-2012 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 00008 * Redistributions of source code must retain the above copyright 00009 notice, this list of conditions and the following disclaimer. 00010 * Redistributions in binary form must reproduce the above copyright 00011 notice, this list of conditions and the following disclaimer in the 00012 documentation and/or other materials provided with the distribution. 00013 * Neither the name of Vanadium Labs LLC nor the names of its 00014 contributors may be used to endorse or promote products derived 00015 from this software without specific prior written permission. 00016 00017 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00018 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00019 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00020 DISCLAIMED. IN NO EVENT SHALL VANADIUM LABS BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00022 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00023 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00025 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00026 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00029 /* ArbotiX (id:253) Instruction Definitions */ 00030 #define ARB_SIZE_POSE 7 // pose size: a single param for size of pose 00031 #define ARB_LOAD_POSE 8 // load pose: index, then pose positions (# of params = 2*pose_size) 00032 #define ARB_LOAD_SEQ 9 // seq size: a single param for the size of the seq 00033 #define ARB_PLAY_SEQ 10 // load seq: index/times (# of params = 3*seq_size) 00034 #define ARB_LOOP_SEQ 11 // play seq: no params 00035 //#define ARB_TEST 25 // hardware test: no params 00036 #define ARB_CONTROL_SETUP 26 // write ids: id of controller, params (usually ids of servos, # of params = pose_size + 1) 00037 #define ARB_CONTROL_WRITE 27 // write positions: positions in order of servos (# of params = 2*pose_size) 00038 #define ARB_CONTROL_STAT 28 // retrieve status: id of controller 00039 #define ARB_SYNC_READ 0x84 00040 00041 /* ArbotiX (id:253) Register Table Definitions */ 00042 #define REG_MODEL_NUMBER_L 0 00043 #define REG_MODEL_NUMBER_H 1 00044 #define REG_VERSION 2 00045 #define REG_ID 3 00046 #define REG_BAUD_RATE 4 00047 00048 #define REG_DIGITAL_IN0 5 // First block of digital pins to read 00049 #define REG_DIGITAL_IN1 6 00050 #define REG_DIGITAL_IN2 7 00051 #define REG_DIGITAL_IN3 8 00052 00053 #define REG_RESCAN 15 00054 #define REG_RETURN_LEVEL 16 00055 #define REG_ALARM_LED 17 00056 #define REG_ANA_BASE 18 // First Analog Port 00057 #define REG_SERVO_BASE 26 // Up to 10 servos, each uses 2 bytes (L, then H), pulse width (0, 1000-2000ms) 00058 #define REG_MOVING 46 00059 00060 #define REG_DIGITAL_OUT0 47 // First digital pin to write 00061 // base + index, bit 1 = value (0,1), bit 0 = direction (0,1) 00062 00063 #define REG_RESERVED 79 // 79 -- 99 are reserved for future use 00064 #define REG_USER 100 // 00065 00066 /* Packet Decoding */ 00067 int mode = 0; // where we are in the frame 00068 00069 unsigned char id = 0; // id of this frame 00070 unsigned char length = 0; // length of this frame 00071 unsigned char ins = 0; // instruction of this frame 00072 00073 unsigned char params[143]; // parameters (match RX-64 buffer size) 00074 unsigned char index = 0; // index in param buffer 00075 00076 int checksum; // checksum