00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00029 #include <aversive.h>
00030 #include <f64.h>
00031
00032 #include "angle_distance.h"
00033
00034 #ifndef _ROBOT_SYSTEM_H_
00035 #define _ROBOT_SYSTEM_H_
00036
00037
00038 #define RS_USE_EXT 1
00039 #define RS_IGNORE_EXT_GAIN 2
00040 #define RS_IGNORE_MOT_GAIN 4
00041
00042
00043 struct robot_system
00044 {
00045 uint8_t flags;
00046
00047 #ifdef CONFIG_MODULE_ROBOT_SYSTEM_MOT_AND_EXT
00048 struct rs_polar pmot_prev;
00049 struct rs_wheels wmot_prev;
00050
00051 f64 ratio_mot_ext;
00052
00053
00054 int32_t (*left_mot_encoder)(void *);
00055 void* left_mot_encoder_param;
00056 f64 left_mot_gain;
00057
00058 int32_t (*right_mot_encoder)(void *);
00059 void* right_mot_encoder_param;
00060 f64 right_mot_gain;
00061 #endif
00062
00063 struct rs_polar virtual_pwm;
00064 struct rs_polar virtual_encoders;
00065
00066 struct rs_polar pext_prev;
00067 struct rs_wheels wext_prev;
00068
00069
00070 int32_t (*left_ext_encoder)(void *);
00071 void* left_ext_encoder_param;
00072 f64 left_ext_gain;
00073
00074 int32_t (*right_ext_encoder)(void *);
00075 void* right_ext_encoder_param;
00076 f64 right_ext_gain;
00077
00078
00079 void (*left_pwm)(void *, int32_t);
00080 void *left_pwm_param;
00081 void (*right_pwm)(void *, int32_t);
00082 void *right_pwm_param;
00083 };
00084
00086 void rs_init( struct robot_system * );
00087
00088
00089
00090 #ifdef CONFIG_MODULE_ROBOT_SYSTEM_MOT_AND_EXT
00091
00092 void rs_set_ratio(struct robot_system * rs, double ratio);
00093 #endif
00094
00096 void rs_set_left_pwm(struct robot_system * rs, void (*left_pwm)(void *, int32_t), void *left_pwm_param);
00097
00099 void rs_set_right_pwm(struct robot_system * rs, void (*right_pwm)(void *, int32_t), void *right_pwm_param);
00100
00101 #ifdef CONFIG_MODULE_ROBOT_SYSTEM_MOT_AND_EXT
00102
00103 void rs_set_left_mot_encoder(struct robot_system * rs, int32_t (*left_mot_encoder)(void *),
00104 void *left_mot_encoder_param, double gain);
00105
00107 void rs_set_right_mot_encoder(struct robot_system * rs, int32_t (*right_mot_encoder)(void *),
00108 void *right_mot_encoder_param, double gain);
00109 #endif
00110
00112 void rs_set_left_ext_encoder(struct robot_system * rs, int32_t (*left_ext_encoder)(void *),
00113 void *left_ext_encoder_param, double gain);
00114
00116 void rs_set_right_ext_encoder(struct robot_system * rs, int32_t (*right_ext_encoder)(void *),
00117 void *right_ext_encoder_param, double gain);
00118
00119
00120
00125 void rs_set_angle(void * rs, int32_t angle);
00126
00131 void rs_set_distance(void * rs, int32_t distance);
00132
00136 int32_t rs_get_angle(void * rs);
00137
00141 int32_t rs_get_distance(void * rs);
00142
00146 int32_t rs_get_ext_angle(void * rs);
00147
00151 int32_t rs_get_ext_distance(void * rs);
00152
00153 #ifdef CONFIG_MODULE_ROBOT_SYSTEM_MOT_AND_EXT
00154
00157 int32_t rs_get_mot_angle(void * rs);
00158
00162 int32_t rs_get_mot_distance(void * rs);
00163 #endif
00164
00165
00166 int32_t rs_get_ext_left(void * rs);
00167 int32_t rs_get_ext_right(void * rs);
00168 #ifdef CONFIG_MODULE_ROBOT_SYSTEM_MOT_AND_EXT
00169 int32_t rs_get_mot_left(void * rs);
00170 int32_t rs_get_mot_right(void * rs);
00171 #endif
00172
00173
00180 void rs_update(void * rs);
00181
00182 void rs_set_flags(struct robot_system * rs, uint8_t flags);
00183
00184
00185 #endif