param.h
Go to the documentation of this file.
1 // Copyright (c) 2010-2016 The YP-Spur Authors, except where otherwise indicated.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef PARAM_H
22 #define PARAM_H
23 
24 #include <ypparam.h>
25 #include <utility.h>
26 
27 #include <pthread.h>
28 
29 typedef enum
30 {
34  OPTION_SHOW_HELP = 0x0008,
37  OPTION_VERSION = 0x0040,
38  OPTION_DAEMON = 0x0080,
39 
40  OPTION_SOCKET = 0x00200,
41  OPTION_PARAM_FILE = 0x00400,
42 
44  OPTION_WITHOUT_SSM = 0x01000,
47  OPTION_RECONNECT = 0x08000,
49  OPTION_PASSIVE = 0x20000,
51  OPTION_HIGH_PREC = 0x80000,
52 } ParamOptions;
53 
54 #define OPTION_DEFAULT (OPTION_HIGH_PREC)
55 
56 #define DEFAULT_PARAMETER_FILE "./robot.param"
57 #define DEFAULT_DEVICE_NAME "/dev/ttyUSB0"
58 
59 #define GRAVITY 9.81
60 #define SIGN(x) ((x < 0) ? -1 : 1)
61 
62 typedef enum
63 {
69 
70 typedef struct _parameters *ParametersPtr;
71 typedef struct _parameters
72 {
73  char parameter_filename[132];
74  char device_name[132];
75  int msq_key;
76  int port;
77  int speed;
80  unsigned char admask;
81  int ssm_id;
87 } Parameters;
88 
89 int arg_analyze(int argc, char *argv[]);
90 void arg_help(int argc, char *argv[]);
91 void param_help(void);
92 void arg_longhelp(int argc, char *argv[]);
93 int set_param(char *filename, char *concrete_path);
94 int set_paramptr(FILE *paramfile);
95 void calc_param_inertia2ff(void);
96 int set_param_motor(void);
97 int set_param_velocity(void);
98 int parameter_set(char param, char id, long long int value64);
99 int apply_robot_params(void);
100 
102 int state(YPSpur_state id);
103 void enable_state(YPSpur_state id);
104 void disable_state(YPSpur_state id);
105 double p(YPSpur_param id, enum motor_id motor);
106 int isset_p(YPSpur_param id, enum motor_id motor);
107 double *pp(YPSpur_param id, enum motor_id motor);
108 ParametersPtr get_param_ptr();
111 void param_calc();
112 
113 void param_update(void *filename);
114 void init_param_update_thread(pthread_t *thread, char *filename);
115 void param_update_loop_cleanup(void *data);
116 
117 #endif // PARAM_H
unsigned char admask
Definition: param.h:80
double * pp(YPSpur_param id, enum motor_id motor)
Definition: param.c:94
int speed
Definition: param.h:77
YPSpur_state
Definition: ypparam.h:450
int set_param_velocity(void)
Definition: param.c:1355
ParamOptions
Definition: param.h:29
char device_name[132]
Definition: param.h:74
double p(YPSpur_param id, enum motor_id motor)
Definition: param.c:79
void arg_longhelp(int argc, char *argv[])
Definition: param.c:134
YPSpur_param
Definition: ypparam.h:109
int apply_robot_params(void)
Definition: param.c:1046
void enable_state(YPSpur_state id)
Definition: param.c:69
int ssm_id
Definition: param.h:81
void param_calc()
Definition: param.c:429
char parameter_filename[132]
Definition: param.h:73
void param_help(void)
Definition: param.c:158
void calc_param_inertia2ff(void)
Definition: param.c:1094
ParamOutputLv
Definition: param.h:62
int parameter_set(char param, char id, long long int value64)
Definition: param.c:379
struct _parameters Parameters
void param_update_loop_cleanup(void *data)
Definition: param.c:1001
int set_paramptr(FILE *paramfile)
Definition: param.c:449
int num_motor_enable
Definition: param.h:83
#define YP_PARAM_MAX_MOTOR_NUM
Definition: ypparam.h:430
void param_update(void *filename)
Definition: param.c:1006
int device_version_age
Definition: param.h:85
int motor_enable[YP_PARAM_MAX_MOTOR_NUM]
Definition: param.h:82
int port
Definition: param.h:76
ParamOutputLv output_lv
Definition: param.h:79
int state(YPSpur_state id)
Definition: param.c:64
int set_param_motor(void)
Definition: param.c:1187
int device_version
Definition: param.h:84
int isset_p(YPSpur_param id, enum motor_id motor)
Definition: param.c:84
int set_param(char *filename, char *concrete_path)
Definition: param.c:922
void disable_state(YPSpur_state id)
Definition: param.c:74
int arg_analyze(int argc, char *argv[])
Definition: param.c:174
ParametersPtr get_param_ptr()
Definition: param.c:111
ParamOptions option
Definition: param.h:78
void init_param_update_thread(pthread_t *thread, char *filename)
Definition: param.c:992
motor_id
Definition: ypparam.h:425
int parameter_applying
Definition: param.h:86
struct _parameters * ParametersPtr
Definition: param.h:70
int msq_key
Definition: param.h:75
void arg_help(int argc, char *argv[])
Definition: param.c:120
int does_option_set(ParamOptions option)


yp-spur
Author(s):
autogenerated on Sat May 11 2019 02:08:24