00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2011, Southwest Research Institute 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are met: 00009 * 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * * Neither the name of the Southwest Research Institute, nor the names 00016 * of its contributors may be used to endorse or promote products derived 00017 * from this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 * POSSIBILITY OF SUCH DAMAGE. 00030 */ 00031 00032 #ifndef CONTROLLER_H 00033 #define CONTROLLER_H 00034 00035 #include "motoPlus.h" 00036 00037 00038 namespace motoman 00039 { 00040 namespace controller 00041 { 00042 00043 00044 #define MP_DRAM_DEV_DOS "MPRAM1:" //This macro is supposed to be defined in motoPlus.h 00045 00052 //* Controller 00064 class Controller 00065 { 00066 public: 00067 00072 Controller(); 00073 00078 ~Controller(); 00079 00088 int getInteger(int index); 00089 00090 00098 void setInteger(int index, int value); 00099 00108 void setDigitalOut(int bit_offset, bool value); 00109 00118 void waitDigitalIn(int bit_offset, bool wait_value); 00119 00120 00127 bool isMotionEnabled(void) {return motionEnabled;}; 00128 00135 bool isJobStarted(void) {return jobStarted;}; 00136 00142 void enableMotion(void); 00143 00149 void disableMotion(void); 00150 00156 void startMotionJob(char* job_name); 00157 00162 void stopMotionJob(char* job_name); 00163 00169 void delayTicks(int ticks) { mpTaskDelay(ticks);}; 00170 00180 bool writeJob(char* path, char* job); 00181 00192 bool loadJob(char* path, char * job); 00193 00200 double getVelocityLimit() 00201 {return (double) this->getInteger(VELOCITY_LIMIT_INDEX);}; 00202 00203 00204 protected: 00205 00209 static const int VELOCITY_LIMIT_INDEX = 94; 00210 \ 00211 00212 00216 static const int MP_ERROR = -1; 00217 00223 static const int MP_OK = 0; 00224 00228 static const int VAR_POLL_DELAY_ = 10; //ms 00229 static const int UNIV_IN_DATA_START_ = 10; 00230 static const int UNIV_OUT_DATA_START_ = 10010; 00231 static const int UNIV_IO_DATA_SIZE_ = 2048; 00232 00233 // Servo power variables 00234 MP_SERVO_POWER_SEND_DATA servo_power_data; 00235 MP_STD_RSP_DATA servo_power_error; 00236 00237 // Job variables 00238 MP_START_JOB_SEND_DATA job_start_data; 00239 MP_DELETE_JOB_SEND_DATA job_delete_data; 00240 MP_STD_RSP_DATA job_error; 00241 00242 00243 // Hold variables 00244 MP_HOLD_SEND_DATA hold_data; 00245 MP_STD_RSP_DATA hold_error; 00246 00247 //TODO: motion and job flags are just internal state variables, we may 00248 //want to make them query the appropriate motoplus API calls instead. 00252 bool motionEnabled; 00253 00257 bool jobStarted; 00258 00259 00260 }; 00261 00262 00263 00264 } //controller 00265 } //motoman 00266 00267 #endif //CONTROLLER_H