directCmdCtrl.cpp

00001 /*
00002   デバイスの直接制御実装
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 
00007 #include "runCtrl.h"
00008 
00009 
00010 void RunCtrl::servoCtrl(bool on) {
00011   if (sendServoCtrl(on ? 1 : 0)) {
00012     throw RunCtrl_Exception("sendServoCtrl()");
00013   }
00014 }
00015 
00016 
00024 void RunCtrl::setMotorPwm(int id, unsigned char duty) {
00025   unsigned char duty_array[1] = { duty };
00026   if (sendMotorDuty(id, duty_array, 1) < 0) {
00027     throw RunCtrl_Exception("sendMotorDuty()");
00028   }
00029 }
00030 
00031 void RunCtrl::setMotorPwm(int id, unsigned char duty[], int num) {
00032   if (sendMotorDuty(id, duty, num) < 0) {
00033     throw RunCtrl_Exception("sendMotorDuty()");
00034   }
00035 }
00036 
00037 
00047 void RunCtrl::setMotorMode(int id, unsigned char mode) {
00048   unsigned char mode_array[1] = { mode };
00049   if (sendMotorMode(id, mode_array, 1) < 0) {
00050     throw RunCtrl_Exception("sendMotorMode()");
00051   }
00052 }
00053 
00054 void RunCtrl::setMotorMode(int id, unsigned char mode[], int num) {
00055   if (sendMotorMode(id, mode, num) < 0) {
00056     throw RunCtrl_Exception("sendMotorMode()");
00057   }
00058 }
00059 
00060 
00070 void RunCtrl::getEncoderVel(int id, int *cnt) {
00071   int cnt_array[1];
00072   if (recvEncoderDiff(id, cnt_array, 1) < 0) {
00073     throw RunCtrl_Exception("recvEncoderDiff()");
00074   }
00075   *cnt = cnt_array[0];
00076 }
00077 
00078 void RunCtrl::getEncoderVel(int id, int cnt[], int num) {
00079   if (recvEncoderDiff(id, cnt, num) < 0) {
00080     throw RunCtrl_Exception("recvEncoderDiff()");
00081   }
00082 }
00083 
00084 
00096 void RunCtrl::getEncoderValue(int id, unsigned short *cnt) {
00097   unsigned short cnt_array[1];
00098   if (recvEncoderValue(id, cnt_array, 1) < 0) {
00099     throw RunCtrl_Exception("recvEncoderValue()");
00100   }
00101   *cnt = cnt_array[0];
00102 }
00103 
00104 void RunCtrl::getEncoderValue(int id, unsigned short cnt[], int num) {
00105   if (recvEncoderValue(id, cnt, num) < 0) {
00106     throw RunCtrl_Exception("recvEncoderValue()");
00107   }
00108 }
00109 
00110 
00118 void RunCtrl::setWheelVel(int id, int mm_vel) {
00119   int mm_vel_array[1] = { mm_vel };
00120   if (sendWheelVel(id, mm_vel_array, 1) < 0) {
00121     throw RunCtrl_Exception("sendWheelVel()");
00122   }
00123 }
00124 
00125 void RunCtrl::setWheelVel(int id, int mm_vel[], int num) {
00126   if (sendWheelVel(id, mm_vel, num) < 0) {
00127     throw RunCtrl_Exception("sendWheelVel()");
00128   }
00129 }
00130 

Generated on Mon Apr 13 22:52:03 2009 by  doxygen 1.5.7.1