Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PARAM_H
00022 #define PARAM_H
00023
00024 #include <ypparam.h>
00025 #include <utility.h>
00026
00027 #include <pthread.h>
00028
00029 typedef enum
00030 {
00031 OPTION_SHOW_ODOMETRY = 0x0001,
00032 OPTION_PARAM_CONTROL = 0x0002,
00033 OPTION_SHOW_TIMESTAMP = 0x0004,
00034 OPTION_SHOW_HELP = 0x0008,
00035 OPTION_SHOW_LONGHELP = 0x0010,
00036 OPTION_SHOW_PARAMHELP = 0x0020,
00037 OPTION_VERSION = 0x0040,
00038 OPTION_DAEMON = 0x0080,
00039
00040 OPTION_SOCKET = 0x00200,
00041 OPTION_PARAM_FILE = 0x00400,
00042
00043 OPTION_WITHOUT_DEVICE = 0x00800,
00044 OPTION_WITHOUT_SSM = 0x01000,
00045 OPTION_ENABLE_SET_BS = 0x02000,
00046 OPTION_DO_NOT_USE_YP = 0x04000,
00047 OPTION_RECONNECT = 0x08000,
00048 OPTION_ENABLE_GET_DIGITAL_IO = 0x10000,
00049 OPTION_PASSIVE = 0x20000,
00050 OPTION_UPDATE_PARAM = 0x40000,
00051 OPTION_HIGH_PREC = 0x80000,
00052 } ParamOptions;
00053
00054 #define OPTION_DEFAULT (OPTION_HIGH_PREC)
00055
00056 #define DEFAULT_PARAMETER_FILE "./robot.param"
00057 #define DEFAULT_DEVICE_NAME "/dev/ttyUSB0"
00058
00059 #define GRAVITY 9.81
00060 #define SIGN(x) ((x < 0) ? -1 : 1)
00061
00062 typedef enum
00063 {
00064 OUTPUT_LV_ERROR,
00065 OUTPUT_LV_WARNING,
00066 OUTPUT_LV_INFO,
00067 OUTPUT_LV_DEBUG,
00068 } ParamOutputLv;
00069
00070 typedef struct _parameters *ParametersPtr;
00071 typedef struct _parameters
00072 {
00073 char parameter_filename[132];
00074 char device_name[132];
00075 int msq_key;
00076 int port;
00077 int speed;
00078 ParamOptions option;
00079 ParamOutputLv output_lv;
00080 unsigned char admask;
00081 int ssm_id;
00082 int motor_enable[YP_PARAM_MAX_MOTOR_NUM];
00083 int num_motor_enable;
00084 int device_version;
00085 int device_version_age;
00086 int parameter_applying;
00087 } Parameters;
00088
00089 int arg_analyze(int argc, char *argv[]);
00090 void arg_help(int argc, char *argv[]);
00091 void param_help(void);
00092 void arg_longhelp(int argc, char *argv[]);
00093 int set_param(char *filename, char *concrete_path);
00094 int set_paramptr(FILE *paramfile);
00095 void calc_param_inertia2ff(void);
00096 int set_param_motor(void);
00097 int set_param_velocity(void);
00098 int parameter_set(char param, char id, long long int value64);
00099 int apply_robot_params(void);
00100
00101 int does_option_set(ParamOptions option);
00102 int state(YPSpur_state id);
00103 void enable_state(YPSpur_state id);
00104 void disable_state(YPSpur_state id);
00105 double p(YPSpur_param id, enum motor_id motor);
00106 int isset_p(YPSpur_param id, enum motor_id motor);
00107 double *pp(YPSpur_param id, enum motor_id motor);
00108 ParametersPtr get_param_ptr();
00109 int option(ParamOptions option);
00110 ParamOutputLv output_lv(void);
00111 void param_calc();
00112
00113 void param_update(void *filename);
00114 void init_param_update_thread(pthread_t *thread, char *filename);
00115 void param_update_loop_cleanup(void *data);
00116
00117 #endif // PARAM_H