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


yp-spur
Author(s):
autogenerated on Fri May 7 2021 02:12:17