ypparam.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 YPPARAM_H
22 #define YPPARAM_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif // __cplusplus
27 
28 #if defined(_WIN32)
29 #if !defined(_WIN64)
30 typedef int pid_t;
31 #endif // !defined(_WIN64)
32 #else
33 #include <unistd.h>
34 #endif // defined(_WIN32)
35 
36 /* コマンドナンバー */
37 enum
38 {
39  YPSPUR_FREE = 0x10,
42 
43  YPSPUR_VEL = 0x20,
48 
49  YPSPUR_ORIENT = 0x30,
50 
51  YPSPUR_SPIN = 0x40,
55 
66 
77  //
82 
83  YPSPUR_FREEZE = 0x200,
86  // 拡張
87  YPSPUR_GETAD = 0x500,
91 
96 
99 
104 };
105 
106 /* パラメータナンバー */
107 /* set_parameter用 */
108 /* マイコンに送る情報は反映されない */
109 typedef enum
110 {
111  // システム
113 
117 
118  // モータパラメータ
129 
130  // キネマティクス
132  YP_PARAM_RADIUS_R, // 後方互換のため
133  YP_PARAM_RADIUS_L, // 後方互換のため
135 
136  // 車体コントロールパラメータ
143 
144  // Spur軌跡追従パラメータ
150 
151  // モータ制御パラメータ
162 
163  // 慣性パラメータ
168 
169  // ボディサイズパラメータ
174 
175  // 慣性・イナーシャ補償パラメータ(上の情報を使って自動計算)
182 
183  // サーボ制御パラメータ
187 
190 
193 
194  // イナーシャパラメータ
197 
198  // エンコーダ拡張
201 
202  // 絶対角
206 
208 } YPSpur_param;
209 
210 // 自分で指定しない(できない)パラメータは最初の文字が'_'で始まっている
211 #define YP_PARAM_NAME \
212  { \
213  "VERSION", \
214  "_TORQUE_UNIT", \
215  "TORQUE_FINENESS", \
216  "_PWM_RESOLUTION", \
217  "COUNT_REV", \
218  "ENCODER_TYPE", \
219  "VOLT", \
220  "CYCLE", \
221  "GEAR", \
222  "MOTOR_R", \
223  "MOTOR_TC", \
224  "MOTOR_VC", \
225  "MOTOR_PHASE", \
226  "PHASE_OFFSET", \
227  "RADIUS", \
228  "RADIUS_R", \
229  "RADIUS_L", \
230  "TREAD", \
231  "CONTROL_CYCLE", \
232  "MAX_VEL", \
233  "MAX_W", \
234  "MAX_ACC_V", \
235  "MAX_ACC_W", \
236  "MAX_CENTRI_ACC", \
237  "L_C1", \
238  "L_K1", \
239  "L_K2", \
240  "L_K3", \
241  "L_DIST", \
242  "GAIN_KP", \
243  "GAIN_KI", \
244  "TORQUE_MAX", \
245  "TORQUE_NEWTON", \
246  "TORQUE_VISCOS", \
247  "-TORQUE_NEWTON", \
248  "-TORQUE_VISCOS", \
249  "INTEGRAL_MAX", \
250  "TORQUE_OFFSET", \
251  "TORQUE_LIMIT", \
252  "MASS", \
253  "MOMENT_INERTIA", \
254  "MOTOR_M_INERTIA", \
255  "TIRE_M_INERTIA", \
256  "SIZE_FRONT", \
257  "SIZE_REAR", \
258  "SIZE_LEFT", \
259  "SIZE_RIGHT", \
260  "_GAIN_A", \
261  "_GAIN_B", \
262  "_GAIN_C", \
263  "_GAIN_D", \
264  "_GAIN_E", \
265  "_GAIN_F", \
266  "STOP_LINEAR", \
267  "SPIN_LINEAR", \
268  "WHEEL_ANG_LINEAR", \
269  "MIN_WHEEL_ANGLE", \
270  "MAX_WHEEL_ANGLE", \
271  "VEHICLE_CONTROL", \
272  "CONTROL_MODE_RESEND", \
273  "_INERTIA_SELF", \
274  "_INERTIA_CROSS", \
275  "ENCODER_DIV", \
276  "ENCODER_DENOMINATOR", \
277  "INDEX_RISE_ANGLE", \
278  "INDEX_FALL_ANGLE", \
279  "INDEX_GEAR", \
280  }
281 
282 #define YP_PARAM_NECESSARY \
283  { \
284  1, \
285  0, \
286  1, \
287  0, \
288  1, \
289  0, \
290  1, \
291  1, \
292  1, \
293  1, \
294  1, \
295  1, \
296  0, \
297  0, \
298  1, \
299  0, \
300  0, \
301  1, \
302  1, \
303  1, \
304  1, \
305  1, \
306  1, \
307  1, \
308  1, \
309  1, \
310  1, \
311  1, \
312  1, \
313  1, \
314  1, \
315  1, \
316  0, \
317  0, \
318  0, \
319  0, \
320  1, \
321  0, \
322  0, \
323  1, \
324  1, \
325  1, \
326  1, \
327  0, \
328  0, \
329  0, \
330  0, \
331  0, \
332  0, \
333  0, \
334  0, \
335  0, \
336  0, \
337  0, \
338  0, \
339  0, \
340  0, \
341  0, \
342  0, \
343  0, \
344  0, \
345  0, \
346  0, \
347  0, \
348  0, \
349  0, \
350  0, \
351  }
352 
353 #define YP_PARAM_COMMENT \
354  { \
355  "Parameter file version", \
356  "[Integer Nm/Nm] Fixed-point position of PC-MCU communication", \
357  "[Nm] Calculation fineness of torque control", \
358  "[Counts] PWM cycle", \
359  "[Counts/rev] Encoder specification", \
360  "Encoder type (2:2-phase incremental, 3:3-phase incremental)", \
361  "[V] Power source voltage", \
362  "[s] Velocity control cycle", \
363  "[in/out] Gear ratio", \
364  "[ohm] Motor internal resistance", \
365  "[Nm/A] Motor torque constant", \
366  "[rpm/V] Motor speed constant", \
367  "Motor type (0:DC, 3:3phase-AC)", \
368  "[rad] Offset angle of AC motor phase", \
369  "[m] Wheel radius", \
370  "[m] Right wheel radius", \
371  "[m] Left wheel radius", \
372  "[m] Tread", \
373  "[s] Trajectory control cycle", \
374  "[m/s] Maximum velocity", \
375  "[rad/s] Maximum angular velocity", \
376  "[m/ss] Maximum acceleration", \
377  "[rad/ss] Maximum angular acceleration", \
378  "[m/ss] Centrifugal acceleration limit", \
379  "[m/s / rad/s] Deacceleration factor of trajectory control", \
380  "[rad/ss / m] Feedback gain for distance error", \
381  "[rad/ss / rad] Feedback gain for angular error", \
382  "[rad/ss / rad/s] Feedback gain for angular velocity", \
383  "[m] Clipping value of line following control", \
384  "[1/s] PI control parameter Kp", \
385  "[1/ss] PI control parameter Ki", \
386  "[Nm] Motor maximum torque", \
387  "[Nm] Constant friction", \
388  "[Nm/(rad/s)] Viscous friction", \
389  "[Nm] Constant friction (neg-direction)", \
390  "[Nm/(rad/s)] Viscous friction (neg-direction)", \
391  "[Nm] Motor torque limit", \
392  "[rev] Maximum integrated error of PI control", \
393  "[Nm] Offset value of motor torque", \
394  "[kg] Robot weight", \
395  "[kgm^2] Robot moment of inertia", \
396  "[kgm^2] Rotor moment of inertia of motor", \
397  "[kgm^2] Tire moment of inertia", \
398  "[m] Robot size of front", \
399  "[m] Robot size of rear", \
400  "[m] Robot size of left", \
401  "[m] Robot size of right", \
402  "PWS parameter A", \
403  "PWS parameter B", \
404  "PWS parameter C", \
405  "PWS parameter D", \
406  "PWS parameter E", \
407  "PWS parameter F", \
408  "[m] Linear feedback area of stop command", \
409  "[rad] Linear feedback area of spin command", \
410  "[rad] Linear feedback area of wheel_ang command", \
411  "[rad] Minimum wheel angle (for wheel_angle command)", \
412  "[rad] Maximum wheel angle (for wheel_angle command)", \
413  "Used for vehicle control (0: false, 1: true)", \
414  "[s] Time-span to resend control mode (0: don't resend)", \
415  "Motor load inertia", \
416  "Motor load cross inertia", \
417  "Encoder count divider 2^x (e.g. 4 means divide by 16)", \
418  "Encoder count denominator" \
419  " (COUNT_REV/ENCODER_DENOMINATOR is encoder resolution for one electrical revolution)", \
420  "[rad] Index signal rising edge angle at CW rotation", \
421  "[rad] Index signal falling edge angle at CW rotation", \
422  "[in/out] Index signal gear ratio", \
423  }
424 
426 {
429 };
430 #define YP_PARAM_MAX_MOTOR_NUM 16
431 
432 #define YP_PARAM_ALIAS_NUM 2
433 // clang-format off
434 #define YP_PARAM_ALIAS \
435  { \
436  { \
437  YP_PARAM_RADIUS_L, YP_PARAM_RADIUS, MOTOR_LEFT \
438  }, \
439  { \
440  YP_PARAM_RADIUS_R, YP_PARAM_RADIUS, MOTOR_RIGHT \
441  } \
442  }
443 // clang-format on
444 
445 #define YP_PARAM_REQUIRED_VERSION 4.0
446 #define YP_PARAM_SUPPORTED_VERSION 5.0
447 
448 /* パラメータの有効・無効 */
449 /* control_state用   */
450 typedef enum
451 {
457 
459 } YPSpur_state;
460 
462 typedef enum
463 {
464  CS_BS = 0,
471 } YPSpur_cs;
472 
473 static const char YPSpur_CSName[CS_MAX][16] = {
474  { "BS" },
475  { "SP" },
476  { "GL" },
477  { "LC" },
478  { "FS" },
479  { "BL" },
480 };
481 
482 typedef struct
483 {
484  long msg_type;
485  long pid;
486  int type;
487  int cs;
488  double data[4];
489 } YPSpur_msg;
490 
491 #define YPSPUR_MAX_SOCKET 64
492 
493 struct ipcmd_t
494 {
496  {
499  } type;
501  {
504  } tcp_type;
505  int socket;
508  pid_t pid;
510  int (*send)(struct ipcmd_t *ipcmd, YPSpur_msg *data);
511  int (*recv)(struct ipcmd_t *ipcmd, YPSpur_msg *data);
512  void (*flush)(struct ipcmd_t *ipcmd);
513 };
514 
515 #define YPSPUR_MSQ_KEY 0x7045
516 #define YPSPUR_MSG_CMD 1
517 #define YPSPUR_MSG_SIZE (sizeof(YPSpur_msg) - sizeof(long))
518 
519 #define ENABLE 1
520 #define DISABLE 0
521 
522 #ifdef __cplusplus
523 }
524 #endif // __cplusplus
525 
526 #endif // YPPARAM_H
int connection_error
Definition: ypparam.h:507
enum ipcmd_t::ipcmd_type_t type
Definition: ypparam.h:465
YPSpur_state
Definition: ypparam.h:450
long pid
Definition: ypparam.h:485
#define YPSPUR_MAX_SOCKET
Definition: ypparam.h:491
Definition: ypparam.h:469
void(* flush)(struct ipcmd_t *ipcmd)
Definition: ypparam.h:512
int clients[YPSPUR_MAX_SOCKET]
Definition: ypparam.h:506
int type
Definition: ypparam.h:486
Definition: ypparam.h:466
パラメータの最大値
Definition: ypparam.h:207
pid_t pid
Definition: ypparam.h:508
pid_t pids[YPSPUR_MAX_SOCKET]
Definition: ypparam.h:509
YPSpur_param
Definition: ypparam.h:109
enum ipcmd_t::ipcmd_tcp_type_t tcp_type
Definition: ypparam.h:468
static const char YPSpur_CSName[CS_MAX][16]
Definition: ypparam.h:473
int(* recv)(struct ipcmd_t *ipcmd, YPSpur_msg *data)
Definition: ypparam.h:511
ipcmd_type_t
Definition: ypparam.h:495
long msg_type
Definition: ypparam.h:484
int cs
Definition: ypparam.h:487
int socket
Definition: ypparam.h:505
ipcmd_tcp_type_t
Definition: ypparam.h:500
Definition: ypparam.h:467
int(* send)(struct ipcmd_t *ipcmd, YPSpur_msg *data)
Definition: ypparam.h:510
YPSpur_cs
Definition: ypparam.h:462
Definition: ypparam.h:464
motor_id
Definition: ypparam.h:425


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