wheelCtrl.h
Go to the documentation of this file.00001 #ifndef WHEEL_CTRL_H
00002 #define WHEEL_CTRL_H
00003
00013 #include "motorCtrl.h"
00014 #include "encCtrl.h"
00015 #include "math_util.h"
00016
00017
00018 #ifndef WHL_DIAMETER_RIGHT
00019 #define WHL_DIAMETER_RIGHT 84.5
00020 #endif
00021 #ifndef WHL_DIAMETER_LEFT
00022 #define WHL_DIAMETER_LEFT 84.5
00023 #endif
00024
00025 #ifndef WHL_GEAR_RATIO
00026 #define WHL_GEAR_RATIO (3249.0/169.0 * 45.0/16.0)
00027 #endif
00028
00029 #define WHL_CNT_PER_MM_RIGHT \
00030 ((WHL_GEAR_RATIO * ENC_PULSE) / (WHL_DIAMETER_RIGHT * M_PI))
00031 #define WHL_CNT_PER_MM_LEFT \
00032 ((WHL_GEAR_RATIO * ENC_PULSE) / (WHL_DIAMETER_LEFT * M_PI))
00033
00034
00035 enum {
00036 WHL_RIGHT = 0, WHL_LEFT = 1,
00037 WHL_VEL2CNT_16SHIFT_RIGHT = (int)(((1 << 16) * WHL_CNT_PER_MM_RIGHT / 1000)),
00038 WHL_VEL2CNT_16SHIFT_LEFT = (int)(((1 << 16) * WHL_CNT_PER_MM_LEFT / 1000)),
00039
00040 WHL_CNT2VEL_16SHIFT_RIGHT = (int)((1 << 16) * 1000 / WHL_CNT_PER_MM_RIGHT),
00041 WHL_CNT2VEL_16SHIFT_LEFT = (int)((1 << 16) * 1000 / WHL_CNT_PER_MM_LEFT),
00042
00043 WHL_CNT_PER_M_RIGHT = (int)(1000.0 * WHL_CNT_PER_MM_RIGHT),
00044 WHL_CNT_PER_M_LEFT = (int)(1000.0 * WHL_CNT_PER_MM_LEFT),
00045 };
00046
00047
00051 typedef struct {
00052 motorInfo_t *mtr;
00053 encInfo_t *enc;
00054 int next_add;
00055 int vel2cnt_const;
00056 int cnt2vel_const;
00057 int cnt_per_m;
00058 } wheelInfo_t;
00059
00060
00061
00062 BEGIN_C_DECLS;
00063
00064 extern void initWheelInfo(wheelInfo_t *whl,
00065 motorInfo_t *mtr, encInfo_t *enc,
00066 const unsigned char id);
00067 extern int change_wheelVel2Cnt(wheelInfo_t *whl, int mm_sec_vel);
00068 extern int change_wheelCnt2Vel(wheelInfo_t *whl, int cnt_msec_vel);
00069 extern void setWheelFree(wheelInfo_t *whl);
00070 extern void setWheelMoveVelocity(int mm_sec_vel, wheelInfo_t *whl);
00071
00072 END_C_DECLS;
00073 #endif
00074