parameter_ctrl.c

00001 /*
00002   パラメータ制御
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 #define C_RUNCTRL_SOURCE
00007 
00008 #include "parameter_ctrl.h"
00009 #include "commandCtrl.h"
00010 #include <stdio.h>
00011 
00012 
00013 static runParams_t *Param = NULL;
00014 
00015 
00023 void run_initRunParam(runParams_t *params) {
00024   Param = params;
00025   Param->straight_ref_vel = STRAIGHT_MM_VEL;
00026   Param->straight_ref_acc = STRAIGHT_MM_ACC;
00027   Param->rotate_ref_vel = ROTATE_DIV16_VEL;
00028   Param->rotate_ref_acc = ROTATE_DIV16_ACC;
00029   Param->follow_r = FOLLOW_RADIUS_MM;
00030 }
00031 
00032 
00040 int run_setStraightVel(int mm_vel) {
00041   Param->straight_ref_vel = mm_vel;
00042   if (sendStraightRef(mm_vel, Param->straight_ref_acc) < 0) {
00043     return -1;
00044   }
00045   return 0;
00046 }
00047 
00048 
00056 int run_setStraightAcc(int mm_acc) {
00057   Param->straight_ref_acc = mm_acc;
00058   if (sendStraightRef(Param->straight_ref_vel, mm_acc) < 0) {
00059     return -1;
00060   }
00061   return 0;
00062 }
00063 
00064 
00072 int run_setRotateVel(int div16_vel) {
00073   Param->rotate_ref_vel = div16_vel;
00074   if (sendRotateRef(div16_vel, Param->rotate_ref_acc) < 0) {
00075     return -1;
00076   }
00077   return 0;
00078 }
00079 
00080 
00088 int run_setRotateAcc(int div16_acc) {
00089   Param->rotate_ref_acc = div16_acc;
00090   if (sendRotateRef(Param->rotate_ref_vel, div16_acc) < 0) {
00091     return -1;
00092   }
00093   return 0;
00094 }
00095 
00096 
00104 int run_setCurveRadius(int radius_mm) {
00105   Param->follow_r = radius_mm;
00106   if (sendCurveRadius(radius_mm) < 0) {
00107     return -1;
00108   }
00109   return 0;
00110 }
00111 
00112 
00120 int run_getStraightVel(int *mm_vel) {
00121   return recvStraightVel(mm_vel);
00122 }
00123 
00124 
00132 int run_getRotateVel(int *div16_vel) {
00133   return recvRotateVel(div16_vel);
00134 }
00135 
00136 
00143 int run_is_stable(void) {
00144   int isStable;
00145   int ret_value = recvStableValue(&isStable);
00146   if (ret_value < 0) {
00147     return ret_value;
00148   }
00149   return isStable;
00150 }
00151 

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