judgeCtrl.cpp

00001 /*
00002   判定コマンド実装
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 
00007 #include "runCtrl.h"
00008 
00009 
00010 bool RunCtrl::isStable(void) {
00011   int stable = 0;
00012   if (recvStableValue(&stable) < 0) {
00013     throw RunCtrl_Exception("Transmit fail: in recvStableValue()");
00014   }
00015   return (stable == 0) ? false : true;
00016 }
00017 
00018 
00019 int RunCtrl::getLengthToGrid(const VXV::Grid& grid,
00020                              const CoordinateCtrl* crd) {
00021   VXV::Position position = getRunPosition(crd);
00022   int x_diff = position.x - grid.x;
00023   int y_diff = position.y - grid.y;
00024 
00025   return (int)sqrt((float)((x_diff * x_diff) + (y_diff * y_diff)));
00026 }
00027 
00028 
00029 int RunCtrl::getLengthToBody(const VXV::Grid& grid,
00030                              const CoordinateCtrl* crd) {
00031   return getLengthToGrid(grid, crd);
00032 }
00033 
00034 
00035 int RunCtrl::getLengthToLine(const VXV::Position& line,
00036                              const CoordinateCtrl* crd) {
00037 
00038   VXV::Position position = getRunPosition(crd);
00039   int diff_x = position.x - line.x;
00040   int diff_y = position.y - line.y;
00041   double radian = line.zt.to_rad();
00042 
00043   return (int)(diff_x * cos(radian) + diff_y * sin(radian));
00044 }
00045 
00046 
00047 VXV::Direction RunCtrl::getAngleToDirection(const VXV::Direction& t,
00048                                             const CoordinateCtrl* crd) {
00049 
00050   return getRunPosition(crd).zt - t;
00051 }
00052 
00053 
00054 int RunCtrl::getStraightVelDiff(int mm_vel) {
00055   return getStraightVel() - mm_vel;
00056 }
00057 
00058 
00059 VXV::Direction RunCtrl::getRotateVelDiff(const VXV::Direction& t) {
00060   return getRotateVel() - t;
00061 }
00062 

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