From c5da19c6d2fe484c04f617b504800da13f6d6a96 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Fri, 22 Mar 2024 12:17:35 +0900 Subject: [PATCH] Format source files by clang-format (#187) --- .clang-format | 69 +++++++++++++++++ auxlib/cartesian2d.h | 15 ++-- auxlib/libcarte2d.c | 12 +-- auxlib/libodomssm.c | 28 +++---- auxlib/odometry-ssm.h | 13 ++-- include/adinput.h | 6 +- include/command.h | 108 +++++++++++++------------- include/communication.h | 4 +- include/control.h | 4 +- include/ipcommunication.h | 24 +++--- include/msq.win32.h | 6 +- include/odometry.h | 10 +-- include/param.h | 20 ++--- include/serial.h | 10 +-- include/ssm_spur_handler.h | 6 +- include/ssmtype/pws-motor.h | 2 +- include/utility.h | 2 +- include/ypparam.h | 21 ++--- include/ypprotocol.h | 9 ++- include/yprintf.h | 2 +- include/ypspur-md.h | 127 ++++++++++++++++--------------- include/ypspur.h | 37 ++++----- samples/MOI-estimate.c | 2 +- samples/cartesian2d-test.c | 2 +- samples/run-test.c | 2 +- src/adinput.c | 12 +-- src/command.c | 10 +-- src/command_aux.c | 10 +-- src/command_get.c | 22 +++--- src/command_joint.c | 20 ++--- src/command_param.c | 10 +-- src/command_run.c | 22 +++--- src/command_set.c | 22 +++--- src/communication.c | 4 +- src/control_vehicle.c | 8 +- src/ipcommunication.c | 37 ++++----- src/libypspur-md.c | 120 ++++++++++++++--------------- src/libypspur.c | 36 ++++----- src/msq.win32.c | 46 +++++------ src/odometry.c | 22 +++--- src/param.c | 92 +++++++++++++--------- src/serial.c | 29 +++---- src/ssm_spur_handler.c | 12 +-- src/utility.c | 6 +- src/ypprotocol.c | 24 +++--- src/yprintf.c | 2 +- src/ypspur-coordinator.c | 7 +- src/ypspur-free.c | 4 +- src/ypspur-interpreter.c | 148 ++++++++++++++++++------------------ test/param_load.cpp | 7 +- 50 files changed, 686 insertions(+), 587 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..b71ccf1 --- /dev/null +++ b/.clang-format @@ -0,0 +1,69 @@ +BasedOnStyle: Google + +AccessModifierOffset: -2 +AlignEscapedNewlinesLeft: false +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackParameters: true +BreakBeforeBinaryOperators: false +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: true +ColumnLimit: 0 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +ExperimentalAutoDetectBinPacking: false +IncludeBlocks: Preserve +IndentCaseLabels: true +IndentExternBlock: NoIndent +IndentFunctionDeclarationAfterType: false +IndentWidth: 2 +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 60 +PenaltyBreakFirstLessLess: 1000 +PenaltyBreakString: 1 +PenaltyExcessCharacter: 1000 +PenaltyReturnTypeOnItsOwnLine: 90 +PointerAlignment: Left +SortIncludes: false +SpaceAfterControlStatementKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +Standard: Cpp11 +TabWidth: 2 +UseTab: Never + +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: true + BeforeWhile: true + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true diff --git a/auxlib/cartesian2d.h b/auxlib/cartesian2d.h index c801791..ab7f899 100644 --- a/auxlib/cartesian2d.h +++ b/auxlib/cartesian2d.h @@ -22,7 +22,8 @@ #define __AUXLIB_CARTESIAN2D_H #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // __cplusplus #include @@ -30,7 +31,7 @@ extern "C" { #include #include -typedef struct cs_t *CSptr; +typedef struct cs_t* CSptr; typedef struct cs_t { double x; @@ -46,12 +47,12 @@ CSptr CS_add(CSptr parent_cs, double x, double y, double theta); int CS_delete(CSptr target_cs); int CS_set(CSptr target_cs, double x, double y, double theta); int CS_set_on_CS(CSptr target_cs, CSptr on_cs, double x, double y, double theta); -void CS_turn_base(double *x, double *y, double *theta); +void CS_turn_base(double* x, double* y, double* theta); -void CS_recursive_trans(CSptr target_cs, CSptr now_cs, double *x, double *y, double *theta); -void inv_trans_cs(CSptr target_cs, double *x, double *y, double *theta); -void trans_cs(CSptr target_cs, double *x, double *y, double *theta); -void trace_trans_cs(CSptr target_cs, double *x, double *y, double *theta); +void CS_recursive_trans(CSptr target_cs, CSptr now_cs, double* x, double* y, double* theta); +void inv_trans_cs(CSptr target_cs, double* x, double* y, double* theta); +void trans_cs(CSptr target_cs, double* x, double* y, double* theta); +void trace_trans_cs(CSptr target_cs, double* x, double* y, double* theta); #ifdef __cplusplus } diff --git a/auxlib/libcarte2d.c b/auxlib/libcarte2d.c index b6af5c4..5a31c14 100644 --- a/auxlib/libcarte2d.c +++ b/auxlib/libcarte2d.c @@ -91,7 +91,7 @@ int CS_delete(CSptr target_cs) if (target_cs) { - free((void *)target_cs); + free((void*)target_cs); } return 1; } @@ -120,7 +120,7 @@ int CS_set_on_CS(CSptr target_cs, CSptr on_cs, double x, double y, double theta) } /* 子から見た親の位置を、親から見た自分の位置に変換する */ -void CS_turn_base(double *x, double *y, double *theta) +void CS_turn_base(double* x, double* y, double* theta) { double xx, yy; @@ -134,7 +134,7 @@ void CS_turn_base(double *x, double *y, double *theta) /*-----------------座標変換まわり-----------------*/ /* 目的の座標系へひとっとび? */ /*               */ -void CS_recursive_trans(CSptr target_cs, CSptr now_cs, double *x, double *y, double *theta) +void CS_recursive_trans(CSptr target_cs, CSptr now_cs, double* x, double* y, double* theta) { /* 座標系が有効か */ if (!target_cs || !now_cs) @@ -170,7 +170,7 @@ void CS_recursive_trans(CSptr target_cs, CSptr now_cs, double *x, double *y, dou } /* 座標系を一段下る(1段前の座標系での座標に変換する) */ -void inv_trans_cs(CSptr target_cs, double *x, double *y, double *theta) +void inv_trans_cs(CSptr target_cs, double* x, double* y, double* theta) { double xx, yy; if (target_cs) @@ -184,7 +184,7 @@ void inv_trans_cs(CSptr target_cs, double *x, double *y, double *theta) } /* 座標系を一段あがる(一段後での座標系での座標に変換する) */ -void trans_cs(CSptr target_cs, double *x, double *y, double *theta) +void trans_cs(CSptr target_cs, double* x, double* y, double* theta) { double xx, yy; if (target_cs) @@ -198,7 +198,7 @@ void trans_cs(CSptr target_cs, double *x, double *y, double *theta) } /* 上にあがるだけ */ -void trace_trans_cs(CSptr target_cs, double *x, double *y, double *theta) +void trace_trans_cs(CSptr target_cs, double* x, double* y, double* theta) { if (target_cs == CSroot_ptr) return; diff --git a/auxlib/libodomssm.c b/auxlib/libodomssm.c index 9560a23..603b4f2 100644 --- a/auxlib/libodomssm.c +++ b/auxlib/libodomssm.c @@ -44,20 +44,20 @@ int OdometrySSM_init(void) } /* 線形補間で位置取得 */ -int SSM_get_pos_GL_time(double time, double *x, double *y, double *theta) +int SSM_get_pos_GL_time(double time, double* x, double* y, double* theta) { Spur_Odometry odm1, odm2; int tid, tid2; double time1, time2; double rate; - tid = readSSM_time(odm_gl_sid, (char *)&odm1, time, &time1); - tid2 = readSSM(odm_gl_sid, (char *)&odm2, &time2, tid + 1); + tid = readSSM_time(odm_gl_sid, (char*)&odm1, time, &time1); + tid2 = readSSM(odm_gl_sid, (char*)&odm2, &time2, tid + 1); if (tid2 < 0) { /* 次のがなければ前のでなんとか。 */ time2 = time1; odm2 = odm1; - tid = readSSM(odm_gl_sid, (char *)&odm1, &time1, tid - 1); + tid = readSSM(odm_gl_sid, (char*)&odm1, &time1, tid - 1); } if (fabs(time2 - time1) < 0.000001) return 0; @@ -83,20 +83,20 @@ int SSM_get_pos_GL_time(double time, double *x, double *y, double *theta) } /* 線形補間で位置取得 */ -int SSM_get_pos_BS_time(double time, double *x, double *y, double *theta) +int SSM_get_pos_BS_time(double time, double* x, double* y, double* theta) { Spur_Odometry odm1, odm2; int tid, tid2; double time1, time2; double rate; - tid = readSSM_time(odm_bs_sid, (char *)&odm1, time, &time1); - tid2 = readSSM(odm_bs_sid, (char *)&odm2, &time2, tid + 1); + tid = readSSM_time(odm_bs_sid, (char*)&odm1, time, &time1); + tid2 = readSSM(odm_bs_sid, (char*)&odm2, &time2, tid + 1); if (tid2 < 0) { /* 次のがなければ前のでなんとか。 */ time2 = time1; odm2 = odm1; - tid = readSSM(odm_bs_sid, (char *)&odm1, &time1, tid - 1); + tid = readSSM(odm_bs_sid, (char*)&odm1, &time1, tid - 1); } if (fabs(time2 - time1) < 0.000001) return 0; @@ -122,13 +122,13 @@ int SSM_get_pos_BS_time(double time, double *x, double *y, double *theta) } /* */ -double SSM_get_pos_GL(double *x, double *y, double *theta) +double SSM_get_pos_GL(double* x, double* y, double* theta) { Spur_Odometry odm1; int tid; double time1; - tid = readSSM(odm_gl_sid, (char *)&odm1, &time1, -1); + tid = readSSM(odm_gl_sid, (char*)&odm1, &time1, -1); if (tid < 0) return -1.0; *x = odm1.x; @@ -139,13 +139,13 @@ double SSM_get_pos_GL(double *x, double *y, double *theta) } /* */ -double SSM_get_pos_BS(double *x, double *y, double *theta) +double SSM_get_pos_BS(double* x, double* y, double* theta) { Spur_Odometry odm1; int tid; double time1; - tid = readSSM(odm_bs_sid, (char *)&odm1, &time1, -1); + tid = readSSM(odm_bs_sid, (char*)&odm1, &time1, -1); if (tid < 0) return -1.0; @@ -157,13 +157,13 @@ double SSM_get_pos_BS(double *x, double *y, double *theta) } /* */ -double SSM_get_vel(double *v, double *w) +double SSM_get_vel(double* v, double* w) { Spur_Odometry odm1; int tid; double time1; - tid = readSSM(odm_bs_sid, (char *)&odm1, &time1, -1); + tid = readSSM(odm_bs_sid, (char*)&odm1, &time1, -1); if (tid < 0) return -1.0; diff --git a/auxlib/odometry-ssm.h b/auxlib/odometry-ssm.h index 8032760..5f86c6a 100644 --- a/auxlib/odometry-ssm.h +++ b/auxlib/odometry-ssm.h @@ -22,15 +22,16 @@ #define __AUXLIB_ODOMETRY_SSM_H #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // __cplusplus int OdometrySSM_init(void); -int SSM_get_pos_GL_time(double time, double *x, double *y, double *theta); -int SSM_get_pos_BS_time(double time, double *x, double *y, double *theta); -double SSM_get_pos_GL(double *x, double *y, double *theta); -double SSM_get_pos_BS(double *x, double *y, double *theta); -double SSM_get_vel(double *v, double *w); +int SSM_get_pos_GL_time(double time, double* x, double* y, double* theta); +int SSM_get_pos_BS_time(double time, double* x, double* y, double* theta); +double SSM_get_pos_GL(double* x, double* y, double* theta); +double SSM_get_pos_BS(double* x, double* y, double* theta); +double SSM_get_vel(double* v, double* w); int SSM_near_pos_GL(double x, double y, double r); int SSM_near_ang(double th, double d); int SSM_over_line(double x, double y, double theta); diff --git a/include/adinput.h b/include/adinput.h index 41df5ac..1a13bc5 100644 --- a/include/adinput.h +++ b/include/adinput.h @@ -26,10 +26,10 @@ #include #include -int process_addata(unsigned char *buf, int len); -const int *get_addataptr(); +int process_addata(unsigned char* buf, int len); +const int* get_addataptr(); int get_addata(int num); -int admask_receive(char *buf, int len, double receive_time, void *data); +int admask_receive(char* buf, int len, double receive_time, void* data); int set_admask(unsigned char mask); int set_diomask(unsigned char enable); int get_ad_num(void); diff --git a/include/command.h b/include/command.h index 8f5cb4b..a61518f 100644 --- a/include/command.h +++ b/include/command.h @@ -51,7 +51,7 @@ typedef enum MOTOR_CONTROL_ANGLE_VEL } MotorControlMode; -typedef struct _spur_user_params *SpurUserParamsPtr; +typedef struct _spur_user_params* SpurUserParamsPtr; typedef struct _spur_user_params { double dv; @@ -90,72 +90,72 @@ typedef struct _spur_user_params void init_spur_command(void); void command(void); -void message_return(struct ipcmd_t *ipcmd, long retpid, YPSpur_msg *res_msg); +void message_return(struct ipcmd_t* ipcmd, long retpid, YPSpur_msg* res_msg); -void init_command_thread(pthread_t *thread); +void init_command_thread(pthread_t* thread); SpurUserParamsPtr get_spur_user_param_ptr(); /* command_run.c */ -void line_com(int cs, double *data, SpurUserParamsPtr spur); -void stop_line_com(int cs, double *data, SpurUserParamsPtr spur); -void circle_com(int cs, double *data, SpurUserParamsPtr spur); -void spin_com(int cs, double *data, SpurUserParamsPtr spur); -void orient_com(int cs, double *data, SpurUserParamsPtr spur); -void stop_com(double *data, SpurUserParamsPtr spur); -void free_com(double *data, SpurUserParamsPtr spur); -void openfree_com(double *data, SpurUserParamsPtr spur); -void vel_com(double *data, SpurUserParamsPtr spur); -void wheel_vel_com(double *data, SpurUserParamsPtr spur); -void wheel_angle_com(double *data, SpurUserParamsPtr spur); +void line_com(int cs, double* data, SpurUserParamsPtr spur); +void stop_line_com(int cs, double* data, SpurUserParamsPtr spur); +void circle_com(int cs, double* data, SpurUserParamsPtr spur); +void spin_com(int cs, double* data, SpurUserParamsPtr spur); +void orient_com(int cs, double* data, SpurUserParamsPtr spur); +void stop_com(double* data, SpurUserParamsPtr spur); +void free_com(double* data, SpurUserParamsPtr spur); +void openfree_com(double* data, SpurUserParamsPtr spur); +void vel_com(double* data, SpurUserParamsPtr spur); +void wheel_vel_com(double* data, SpurUserParamsPtr spur); +void wheel_angle_com(double* data, SpurUserParamsPtr spur); /* command_set.c */ -void set_pos_com(int cs, double *data, SpurUserParamsPtr spur); -void set_GL_on_GL_com(double *data, SpurUserParamsPtr spur); -void set_adjust_com(int cs, double *data, SpurUserParamsPtr spur); -void set_vel_com(double *data, SpurUserParamsPtr spur); -void set_ang_accel_com(double *data, SpurUserParamsPtr spur); -void set_accel_com(double *data, SpurUserParamsPtr spur); -void set_ang_vel_com(double *data, SpurUserParamsPtr spur); -void set_tilt_com(int cs, double *data, SpurUserParamsPtr spur); -void set_torque_com(double *data, SpurUserParamsPtr spur); -void set_wheel_vel_com(double *data, SpurUserParamsPtr spur); -void set_wheel_accel_com(double *data, SpurUserParamsPtr spur); +void set_pos_com(int cs, double* data, SpurUserParamsPtr spur); +void set_GL_on_GL_com(double* data, SpurUserParamsPtr spur); +void set_adjust_com(int cs, double* data, SpurUserParamsPtr spur); +void set_vel_com(double* data, SpurUserParamsPtr spur); +void set_ang_accel_com(double* data, SpurUserParamsPtr spur); +void set_accel_com(double* data, SpurUserParamsPtr spur); +void set_ang_vel_com(double* data, SpurUserParamsPtr spur); +void set_tilt_com(int cs, double* data, SpurUserParamsPtr spur); +void set_torque_com(double* data, SpurUserParamsPtr spur); +void set_wheel_vel_com(double* data, SpurUserParamsPtr spur); +void set_wheel_accel_com(double* data, SpurUserParamsPtr spur); /* command_get.c */ -void get_pos_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); -void get_vel_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); -void get_vref_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); -void get_wheel_vref_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); -int near_pos_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); -int near_ang_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); -int over_line_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); -void get_wheel_vel_com(double *data, double *resdata, SpurUserParamsPtr spur); -void get_wheel_ang_com(double *data, double *resdata, SpurUserParamsPtr spur); -void get_force_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); -void get_wheel_torque_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur); +void get_pos_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); +void get_vel_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); +void get_vref_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); +void get_wheel_vref_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); +int near_pos_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); +int near_ang_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); +int over_line_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); +void get_wheel_vel_com(double* data, double* resdata, SpurUserParamsPtr spur); +void get_wheel_ang_com(double* data, double* resdata, SpurUserParamsPtr spur); +void get_force_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); +void get_wheel_torque_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur); /* command_param.c */ -void param_set_com(int cs, double *data, SpurUserParamsPtr spur); -int param_get_com(int cs, double *resdata, SpurUserParamsPtr spur); -void param_state_com(int cs, double *data, SpurUserParamsPtr spur); +void param_set_com(int cs, double* data, SpurUserParamsPtr spur); +int param_get_com(int cs, double* resdata, SpurUserParamsPtr spur); +void param_state_com(int cs, double* data, SpurUserParamsPtr spur); /* command_ad.c */ -void get_ad_com(double *data, double *resdata); -void set_io_dir_com(double *data, double *resdata); -void set_io_data_com(double *data, double *resdata); +void get_ad_com(double* data, double* resdata); +void set_io_dir_com(double* data, double* resdata); +void set_io_data_com(double* data, double* resdata); -void joint_torque_com(int id, double *data, SpurUserParamsPtr spur); -void joint_vel_com(int id, double *data, SpurUserParamsPtr spur); -void joint_ang_com(int id, double *data, SpurUserParamsPtr spur); -void joint_ang_vel_com(int id, double *data, SpurUserParamsPtr spur); -void set_joint_accel_com(int id, double *data, SpurUserParamsPtr spur); -void set_joint_vel_com(int id, double *data, SpurUserParamsPtr spur); -void get_joint_vel_com(int id, double *data, SpurUserParamsPtr spur); -void get_joint_vref_com(int id, double *data, SpurUserParamsPtr spur); -void get_joint_ang_com(int id, double *data, SpurUserParamsPtr spur); -void get_joint_torque_com(int id, double *data, SpurUserParamsPtr spur); +void joint_torque_com(int id, double* data, SpurUserParamsPtr spur); +void joint_vel_com(int id, double* data, SpurUserParamsPtr spur); +void joint_ang_com(int id, double* data, SpurUserParamsPtr spur); +void joint_ang_vel_com(int id, double* data, SpurUserParamsPtr spur); +void set_joint_accel_com(int id, double* data, SpurUserParamsPtr spur); +void set_joint_vel_com(int id, double* data, SpurUserParamsPtr spur); +void get_joint_vel_com(int id, double* data, SpurUserParamsPtr spur); +void get_joint_vref_com(int id, double* data, SpurUserParamsPtr spur); +void get_joint_ang_com(int id, double* data, SpurUserParamsPtr spur); +void get_joint_torque_com(int id, double* data, SpurUserParamsPtr spur); -void get_error_state_com(double *data, double *resdata); -void dump_device_com(double *data, double *resdata); +void get_error_state_com(double* data, double* resdata); +void dump_device_com(double* data, double* resdata); #endif // COMMAND_H diff --git a/include/communication.h b/include/communication.h index 1eb9f96..6585e27 100644 --- a/include/communication.h +++ b/include/communication.h @@ -30,8 +30,8 @@ extern "C" { #endif -int encode(const unsigned char *src, int len, unsigned char *dst, int buf_max); -int decode(const unsigned char *src, int len, unsigned char *dst, int buf_max); +int encode(const unsigned char* src, int len, unsigned char* dst, int buf_max); +int decode(const unsigned char* src, int len, unsigned char* dst, int buf_max); #ifdef __cplusplus } diff --git a/include/control.h b/include/control.h index 8fc59a1..bf255b2 100644 --- a/include/control.h +++ b/include/control.h @@ -45,7 +45,7 @@ double spin(OdometryPtr odm, SpurUserParamsPtr spur); double orient(OdometryPtr odm, SpurUserParamsPtr spur); void wheel_vel(OdometryPtr odm, SpurUserParamsPtr spur); void wheel_angle(OdometryPtr odm, SpurUserParamsPtr spur); -void wheel_torque(OdometryPtr odm, SpurUserParamsPtr spur, double *torque); +void wheel_torque(OdometryPtr odm, SpurUserParamsPtr spur, double* torque); double regurator(double d, double q, double r, double v_max, double w_max, SpurUserParamsPtr spur); @@ -53,7 +53,7 @@ double gravity_compensation(OdometryPtr odm, SpurUserParamsPtr spur); void run_control(Odometry odometry, SpurUserParamsPtr spur); void control_loop(void); -void init_control_thread(pthread_t *thread); +void init_control_thread(pthread_t* thread); void set_run_mode(SpurRunMode mode); SpurRunMode get_run_mode(void); diff --git a/include/ipcommunication.h b/include/ipcommunication.h index d7ad364..2f9fa1a 100644 --- a/include/ipcommunication.h +++ b/include/ipcommunication.h @@ -24,18 +24,18 @@ #include #include -int ipcmd_send_msq(struct ipcmd_t *ipcmd, YPSpur_msg *data); -int ipcmd_recv_msq(struct ipcmd_t *ipcmd, YPSpur_msg *data); -void ipcmd_flush_msq(struct ipcmd_t *ipcmd); -int ipcmd_send_tcp(struct ipcmd_t *ipcmd, YPSpur_msg *data); -int ipcmd_recv_tcp(struct ipcmd_t *ipcmd, YPSpur_msg *data); -void ipcmd_flush_tcp(struct ipcmd_t *ipcmd); -int ipcmd_send(struct ipcmd_t *ipcmd, YPSpur_msg *data); -int ipcmd_recv(struct ipcmd_t *ipcmd, YPSpur_msg *data); -void ipcmd_flush(struct ipcmd_t *ipcmd); +int ipcmd_send_msq(struct ipcmd_t* ipcmd, YPSpur_msg* data); +int ipcmd_recv_msq(struct ipcmd_t* ipcmd, YPSpur_msg* data); +void ipcmd_flush_msq(struct ipcmd_t* ipcmd); +int ipcmd_send_tcp(struct ipcmd_t* ipcmd, YPSpur_msg* data); +int ipcmd_recv_tcp(struct ipcmd_t* ipcmd, YPSpur_msg* data); +void ipcmd_flush_tcp(struct ipcmd_t* ipcmd); +int ipcmd_send(struct ipcmd_t* ipcmd, YPSpur_msg* data); +int ipcmd_recv(struct ipcmd_t* ipcmd, YPSpur_msg* data); +void ipcmd_flush(struct ipcmd_t* ipcmd); -int ipcmd_open_msq(struct ipcmd_t *ipcmd, int key, int creat); -int ipcmd_open_tcp(struct ipcmd_t *ipcmd, char *host, int port); -void ipcmd_close(struct ipcmd_t *ipcmd); +int ipcmd_open_msq(struct ipcmd_t* ipcmd, int key, int creat); +int ipcmd_open_tcp(struct ipcmd_t* ipcmd, char* host, int port); +void ipcmd_close(struct ipcmd_t* ipcmd); #endif // IPCOMMUNICATION_H diff --git a/include/msq.win32.h b/include/msq.win32.h index 8a20412..aafe46b 100644 --- a/include/msq.win32.h +++ b/include/msq.win32.h @@ -96,9 +96,9 @@ struct msqid_ds }; int msgget(key_t key, int msgflg); -int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); -ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); -int msgctl(int msqid, int cmd, struct msqid_ds *buf); +int msgsnd(int msqid, const void* msgp, size_t msgsz, int msgflg); +ssize_t msgrcv(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg); +int msgctl(int msqid, int cmd, struct msqid_ds* buf); #else // Linux用 diff --git a/include/odometry.h b/include/odometry.h index 10c57ac..3147c06 100644 --- a/include/odometry.h +++ b/include/odometry.h @@ -27,7 +27,7 @@ #include #include -typedef struct _odometry *OdometryPtr; +typedef struct _odometry* OdometryPtr; typedef struct _odometry { double x; @@ -48,7 +48,7 @@ typedef struct _odometry int packet_lost_last; } Odometry; -typedef struct _error_state *ErrorStatePtr; +typedef struct _error_state* ErrorStatePtr; typedef struct _error_state { YPSpur_shvel_error_state state[YP_PARAM_MAX_MOTOR_NUM]; @@ -57,12 +57,12 @@ typedef struct _error_state double time_estimate(int readnum); void cstrans_odometry(YPSpur_cs cs, OdometryPtr dst_odm); -void cstrans_xy(YPSpur_cs src, YPSpur_cs dest, double *x, double *y, double *theta); -void odometry(OdometryPtr xp, short *cnt, short *pwm, double dt, double time); +void cstrans_xy(YPSpur_cs src, YPSpur_cs dest, double* x, double* y, double* theta); +void odometry(OdometryPtr xp, short* cnt, short* pwm, double dt, double time); void process_int( OdometryPtr xp, ErrorStatePtr err, int param_id, int id, int value, double receive_time); void odm_logging(OdometryPtr, double, double); -int odm_read(OdometryPtr odm, double *v, double *w); +int odm_read(OdometryPtr odm, double* v, double* w); void cs_odometry(YPSpur_cs cs, OdometryPtr dst_odm); void init_odometry(void); void init_coordinate_systems(void); diff --git a/include/param.h b/include/param.h index 1a282a9..cc188cd 100644 --- a/include/param.h +++ b/include/param.h @@ -70,7 +70,7 @@ typedef enum OUTPUT_LV_DEBUG, } ParamOutputLv; -typedef struct _parameters *ParametersPtr; +typedef struct _parameters* ParametersPtr; typedef struct _parameters { char parameter_filename[132]; @@ -89,12 +89,12 @@ typedef struct _parameters int parameter_applying; } Parameters; -int arg_analyze(int argc, char *argv[]); -void arg_help(int argc, char *argv[]); +int arg_analyze(int argc, char* argv[]); +void arg_help(int argc, char* argv[]); void param_help(void); -void arg_longhelp(int argc, char *argv[]); -int set_param(char *filename, char *concrete_path); -int set_paramptr(FILE *paramfile); +void arg_longhelp(int argc, char* argv[]); +int set_param(char* filename, char* concrete_path); +int set_paramptr(FILE* paramfile); void calc_param_inertia2ff(void); int set_param_motor(void); int set_param_velocity(void); @@ -107,14 +107,14 @@ void enable_state(YPSpur_state id); void disable_state(YPSpur_state id); double p(YPSpur_param id, enum motor_id motor); int isset_p(YPSpur_param id, enum motor_id motor); -double *pp(YPSpur_param id, enum motor_id motor); +double* pp(YPSpur_param id, enum motor_id motor); ParametersPtr get_param_ptr(); int option(ParamOptions option); ParamOutputLv output_lv(void); void param_calc(); -void param_update(void *filename); -void init_param_update_thread(pthread_t *thread, char *filename); -void param_update_loop_cleanup(void *data); +void param_update(void* filename); +void init_param_update_thread(pthread_t* thread, char* filename); +void param_update_loop_cleanup(void* data); #endif // PARAM_H diff --git a/include/serial.h b/include/serial.h index 0e5d8f0..260f73d 100644 --- a/include/serial.h +++ b/include/serial.h @@ -32,16 +32,16 @@ extern double SER_BAUDRATE; /// (Byte/sec) シリアルの通信速度 // #define SER_BYTES 13.0 // #define SER_TIME_BYTE (11.0/SER_BAUDRATE) -int serial_tryconnect(char *device_name); -int serial_connect(char *device_name); +int serial_tryconnect(char* device_name); +int serial_connect(char* device_name); int serial_change_baudrate(int baud); /*----------------PBS_close------------------*/ int serial_close(void); -int serial_write(char *buf, int len); -int serial_recieve(int (*serial_event)(char *, int, double, void *), void *data); +int serial_write(char* buf, int len); +int serial_recieve(int (*serial_event)(char*, int, double, void*), void* data); void serial_flush_in(void); void serial_flush_out(void); -int encode_write(char *data, int len); +int encode_write(char* data, int len); #endif // SERIAL_H diff --git a/include/ssm_spur_handler.h b/include/ssm_spur_handler.h index fc812b4..c384e97 100644 --- a/include/ssm_spur_handler.h +++ b/include/ssm_spur_handler.h @@ -27,8 +27,8 @@ void init_ypspurSSM(int ssm_id); void end_ypspurSSM(void); void write_ypspurSSM( int odometry_updated, int receive_count, - Odometry *odm_log, int readdata_num, Short_2Char *cnt1_log, Short_2Char *cnt2_log, - Short_2Char *pwm1_log, Short_2Char *pwm2_log, int ad_log[][8]); -void coordinate_synchronize(Odometry *odm, SpurUserParamsPtr spur); + Odometry* odm_log, int readdata_num, Short_2Char* cnt1_log, Short_2Char* cnt2_log, + Short_2Char* pwm1_log, Short_2Char* pwm2_log, int ad_log[][8]); +void coordinate_synchronize(Odometry* odm, SpurUserParamsPtr spur); #endif // SSM_SPUR_HANDLER_H diff --git a/include/ssmtype/pws-motor.h b/include/ssmtype/pws-motor.h index f591f26..edd7c64 100644 --- a/include/ssmtype/pws-motor.h +++ b/include/ssmtype/pws-motor.h @@ -23,7 +23,7 @@ #define SNAME_PWS_MOTOR "pws_motor" -typedef struct _pws_motor *PWSMotorPtr; +typedef struct _pws_motor* PWSMotorPtr; typedef struct _pws_motor { int counter1; diff --git a/include/utility.h b/include/utility.h index 269ebe4..9dd3c91 100644 --- a/include/utility.h +++ b/include/utility.h @@ -28,7 +28,7 @@ void hook_pre_global(void); #if !defined(HAVE_STRTOK_R) #ifndef strtok_r -char *strtok_r(char *str, const char *delim, char **nextp); +char* strtok_r(char* str, const char* delim, char** nextp); #endif // strtok_r #endif // !defined(HAVE_STRTOK_R) diff --git a/include/ypparam.h b/include/ypparam.h index c3fb025..d000608 100644 --- a/include/ypparam.h +++ b/include/ypparam.h @@ -22,7 +22,8 @@ #define YPPARAM_H #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // __cplusplus #if defined(_WIN32) @@ -497,12 +498,12 @@ typedef enum } YPSpur_cs; static const char YPSpur_CSName[CS_MAX][16] = { - { "BS" }, - { "SP" }, - { "GL" }, - { "LC" }, - { "FS" }, - { "BL" }, + {"BS"}, + {"SP"}, + {"GL"}, + {"LC"}, + {"FS"}, + {"BL"}, }; typedef struct @@ -533,9 +534,9 @@ struct ipcmd_t int connection_error; pid_t pid; pid_t pids[YPSPUR_MAX_SOCKET]; - int (*send)(struct ipcmd_t *ipcmd, YPSpur_msg *data); - int (*recv)(struct ipcmd_t *ipcmd, YPSpur_msg *data); - void (*flush)(struct ipcmd_t *ipcmd); + int (*send)(struct ipcmd_t* ipcmd, YPSpur_msg* data); + int (*recv)(struct ipcmd_t* ipcmd, YPSpur_msg* data); + void (*flush)(struct ipcmd_t* ipcmd); }; #define YPSPUR_MSQ_KEY 0x7045 diff --git a/include/ypprotocol.h b/include/ypprotocol.h index e33975b..a558a40 100644 --- a/include/ypprotocol.h +++ b/include/ypprotocol.h @@ -25,7 +25,8 @@ #include #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // __cplusplus /** Structure of VV command */ @@ -46,10 +47,10 @@ typedef struct PARAMETER_INFO char robot_name[128]; } Param_t; -int get_version(Ver_t *apVer); -int get_parameter(Param_t *apParam); +int get_version(Ver_t* apVer); +int get_parameter(Param_t* apParam); int set_baudrate(int baud); -int get_embedded_param(char *param); +int get_embedded_param(char* param); #ifdef __cplusplus } diff --git a/include/yprintf.h b/include/yprintf.h index 12d5251..e624a11 100644 --- a/include/yprintf.h +++ b/include/yprintf.h @@ -25,7 +25,7 @@ #include -void yprintf(ParamOutputLv level, const char *format, ...); +void yprintf(ParamOutputLv level, const char* format, ...); void ansi_clear_line(ParamOutputLv level); #endif // YPRINTF_H diff --git a/include/ypspur-md.h b/include/ypspur-md.h index a7db169..78fb170 100644 --- a/include/ypspur-md.h +++ b/include/ypspur-md.h @@ -24,7 +24,8 @@ #include #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // __cplusplus #define Spur_md_init(dev) YPSpur_md_init(dev) @@ -121,86 +122,86 @@ typedef struct } YPSpur; /** init */ -int YPSpur_md_init(YPSpur *dev); -int YPSpur_md_initex(YPSpur *dev, int msq_key); -int YPSpur_md_init_socket(YPSpur *dev, char *ip, int port); +int YPSpur_md_init(YPSpur* dev); +int YPSpur_md_initex(YPSpur* dev, int msq_key); +int YPSpur_md_init_socket(YPSpur* dev, char* ip, int port); /** freeze */ -int YPSpur_md_isfreeze(YPSpur *dev); -int YPSpur_md_freeze(YPSpur *dev); -int YPSpur_md_unfreeze(YPSpur *dev); +int YPSpur_md_isfreeze(YPSpur* dev); +int YPSpur_md_freeze(YPSpur* dev); +int YPSpur_md_unfreeze(YPSpur* dev); /** motor servo */ -int YPSpur_md_stop(YPSpur *dev); -int YPSpur_md_free(YPSpur *dev); -int YP_md_openfree(YPSpur *dev); +int YPSpur_md_stop(YPSpur* dev); +int YPSpur_md_free(YPSpur* dev); +int YP_md_openfree(YPSpur* dev); /** Spur_md */ -int YPSpur_md_line(YPSpur *dev, int cs, double x, double y, double theta); -int YPSpur_md_stop_line(YPSpur *dev, int cs, double x, double y, double theta); -int YPSpur_md_circle(YPSpur *dev, int cs, double x, double y, double r); -int YPSpur_md_spin(YPSpur *dev, int cs, double theta); -int YPSpur_md_orient(YPSpur *dev, int cs, double theta); +int YPSpur_md_line(YPSpur* dev, int cs, double x, double y, double theta); +int YPSpur_md_stop_line(YPSpur* dev, int cs, double x, double y, double theta); +int YPSpur_md_circle(YPSpur* dev, int cs, double x, double y, double r); +int YPSpur_md_spin(YPSpur* dev, int cs, double theta); +int YPSpur_md_orient(YPSpur* dev, int cs, double theta); /** setter */ -int YPSpur_md_set_pos(YPSpur *dev, int cs, double x, double y, double theta); -int YPSpur_md_adjust_pos(YPSpur *dev, int cs, double x, double y, double theta); -int YPSpur_md_set_vel(YPSpur *dev, double v); -int YPSpur_md_set_angvel(YPSpur *dev, double w); -int YPSpur_md_set_accel(YPSpur *dev, double v); -int YPSpur_md_set_angaccel(YPSpur *dev, double w); +int YPSpur_md_set_pos(YPSpur* dev, int cs, double x, double y, double theta); +int YPSpur_md_adjust_pos(YPSpur* dev, int cs, double x, double y, double theta); +int YPSpur_md_set_vel(YPSpur* dev, double v); +int YPSpur_md_set_angvel(YPSpur* dev, double w); +int YPSpur_md_set_accel(YPSpur* dev, double v); +int YPSpur_md_set_angaccel(YPSpur* dev, double w); /** getter */ -double YPSpur_md_get_pos(YPSpur *dev, int cs, double *x, double *y, double *theta); -double YPSpur_md_get_vel(YPSpur *dev, double *v, double *w); -double YPSpur_md_get_force(YPSpur *dev, double *trans, double *angular); +double YPSpur_md_get_pos(YPSpur* dev, int cs, double* x, double* y, double* theta); +double YPSpur_md_get_vel(YPSpur* dev, double* v, double* w); +double YPSpur_md_get_force(YPSpur* dev, double* trans, double* angular); /** check position */ -int YPSpur_md_near_pos(YPSpur *dev, int cs, double x, double y, double r); -int YPSpur_md_near_ang(YPSpur *dev, int cs, double th, double d); -int YPSpur_md_over_line(YPSpur *dev, int cs, double x, double y, double theta); +int YPSpur_md_near_pos(YPSpur* dev, int cs, double x, double y, double r); +int YPSpur_md_near_ang(YPSpur* dev, int cs, double th, double d); +int YPSpur_md_over_line(YPSpur* dev, int cs, double x, double y, double theta); /** direct */ -int YPSpur_md_vel(YPSpur *dev, double v, double w); +int YPSpur_md_vel(YPSpur* dev, double v, double w); /** tilt */ -int YPSpur_md_tilt(YPSpur *dev, int cs, double dir, double tilt); +int YPSpur_md_tilt(YPSpur* dev, int cs, double dir, double tilt); /* 裏コマンド集 */ -int YP_md_get_error_state(YPSpur *dev); -void YP_md_request_device_dump(YPSpur *dev, int id, int block); - -int YP_md_set_parameter(YPSpur *dev, int param_id, double value); -int YP_md_set_parameter_array(YPSpur *dev, int param_id, double *value); -int YP_md_get_parameter(YPSpur *dev, int param_id, double *value); -int YP_md_get_parameter_array(YPSpur *dev, int param_id, double *value); -int YP_md_set_control_state(YPSpur *dev, int control_id, int state); - -int YP_md_get_ad_value(YPSpur *dev, int num); -int YP_md_set_io_dir(YPSpur *dev, unsigned char dir); -int YP_md_set_io_data(YPSpur *dev, unsigned char data); -double YP_md_get_device_error_state(YPSpur *dev, int id, int *err); -int YP_md_wheel_vel(YPSpur *dev, double r, double l); -int YP_md_wheel_torque(YPSpur *dev, double r, double l); -double YP_md_get_wheel_vel(YPSpur *dev, double *wr, double *wl); -double YP_md_get_wheel_ang(YPSpur *dev, double *theta_r, double *theta_l); -double YP_md_get_wheel_torque(YPSpur *dev, double *torque_r, double *torque_l); -int YP_md_set_wheel_vel(YPSpur *dev, double r, double l); -int YP_md_set_wheel_accel(YPSpur *dev, double r, double l); -int YP_md_wheel_ang(YPSpur *dev, double r, double l); -double YP_md_get_vref(YPSpur *dev, double *vref, double *wref); -double YP_md_get_wheel_vref(YPSpur *dev, double *wrref, double *wlref); - -int YP_md_joint_torque(YPSpur *spur, int id, double t); -int YP_md_joint_vel(YPSpur *spur, int id, double v); -int YP_md_joint_ang(YPSpur *spur, int id, double a); -int YP_md_joint_ang_vel(YPSpur *spur, int id, double a, double v); -int YP_md_set_joint_accel(YPSpur *spur, int id, double a); -int YP_md_set_joint_vel(YPSpur *spur, int id, double v); -double YP_md_get_joint_vel(YPSpur *spur, int id, double *v); -double YP_md_get_joint_vref(YPSpur *spur, int id, double *v); -double YP_md_get_joint_ang(YPSpur *spur, int id, double *a); -double YP_md_get_joint_torque(YPSpur *spur, int id, double *t); +int YP_md_get_error_state(YPSpur* dev); +void YP_md_request_device_dump(YPSpur* dev, int id, int block); + +int YP_md_set_parameter(YPSpur* dev, int param_id, double value); +int YP_md_set_parameter_array(YPSpur* dev, int param_id, double* value); +int YP_md_get_parameter(YPSpur* dev, int param_id, double* value); +int YP_md_get_parameter_array(YPSpur* dev, int param_id, double* value); +int YP_md_set_control_state(YPSpur* dev, int control_id, int state); + +int YP_md_get_ad_value(YPSpur* dev, int num); +int YP_md_set_io_dir(YPSpur* dev, unsigned char dir); +int YP_md_set_io_data(YPSpur* dev, unsigned char data); +double YP_md_get_device_error_state(YPSpur* dev, int id, int* err); +int YP_md_wheel_vel(YPSpur* dev, double r, double l); +int YP_md_wheel_torque(YPSpur* dev, double r, double l); +double YP_md_get_wheel_vel(YPSpur* dev, double* wr, double* wl); +double YP_md_get_wheel_ang(YPSpur* dev, double* theta_r, double* theta_l); +double YP_md_get_wheel_torque(YPSpur* dev, double* torque_r, double* torque_l); +int YP_md_set_wheel_vel(YPSpur* dev, double r, double l); +int YP_md_set_wheel_accel(YPSpur* dev, double r, double l); +int YP_md_wheel_ang(YPSpur* dev, double r, double l); +double YP_md_get_vref(YPSpur* dev, double* vref, double* wref); +double YP_md_get_wheel_vref(YPSpur* dev, double* wrref, double* wlref); + +int YP_md_joint_torque(YPSpur* spur, int id, double t); +int YP_md_joint_vel(YPSpur* spur, int id, double v); +int YP_md_joint_ang(YPSpur* spur, int id, double a); +int YP_md_joint_ang_vel(YPSpur* spur, int id, double a, double v); +int YP_md_set_joint_accel(YPSpur* spur, int id, double a); +int YP_md_set_joint_vel(YPSpur* spur, int id, double v); +double YP_md_get_joint_vel(YPSpur* spur, int id, double* v); +double YP_md_get_joint_vref(YPSpur* spur, int id, double* v); +double YP_md_get_joint_ang(YPSpur* spur, int id, double* a); +double YP_md_get_joint_torque(YPSpur* spur, int id, double* t); #define YPSPUR_JOINT_SUPPORT 1 #define YPSPUR_JOINT_ANG_VEL_SUPPORT 1 diff --git a/include/ypspur.h b/include/ypspur.h index 8884087..2cc5743 100644 --- a/include/ypspur.h +++ b/include/ypspur.h @@ -24,7 +24,8 @@ #include #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // __cplusplus /* YPSpurコマンド集 */ @@ -117,7 +118,7 @@ extern "C" { /** init */ int YPSpur_init(void); int YPSpur_initex(int msq_key); -int YPSpur_init_socket(char *ip, int port); +int YPSpur_init_socket(char* ip, int port); /** freeze */ int YPSpur_isfreeze(void); @@ -145,9 +146,9 @@ int YPSpur_set_accel(double v); int YPSpur_set_angaccel(double w); /** getter */ -double YPSpur_get_pos(int cs, double *x, double *y, double *theta); -double YPSpur_get_vel(double *v, double *w); -double YPSpur_get_force(double *trans, double *angular); +double YPSpur_get_pos(int cs, double* x, double* y, double* theta); +double YPSpur_get_vel(double* v, double* w); +double YPSpur_get_force(double* trans, double* angular); /** check position */ int YPSpur_near_pos(int cs, double x, double y, double r); @@ -165,25 +166,25 @@ int YP_get_error_state(void); void YP_request_device_dump(int id, int block); int YP_set_parameter(int param_id, double value); -int YP_set_parameter_array(int param_id, double *value); -int YP_get_parameter(int param_id, double *value); -int YP_get_parameter_array(int param_id, double *value); +int YP_set_parameter_array(int param_id, double* value); +int YP_get_parameter(int param_id, double* value); +int YP_get_parameter_array(int param_id, double* value); int YP_set_control_state(int control_id, int state); int YP_get_ad_value(int num); int YP_set_io_dir(unsigned char dir); int YP_set_io_data(unsigned char data); -double YP_get_device_error_state(int id, int *err); +double YP_get_device_error_state(int id, int* err); int YP_wheel_vel(double r, double l); int YP_wheel_torque(double r, double l); -double YP_get_wheel_vel(double *wr, double *wl); -double YP_get_wheel_ang(double *theta_r, double *theta_l); -double YP_get_wheel_torque(double *torque_r, double *torque_l); +double YP_get_wheel_vel(double* wr, double* wl); +double YP_get_wheel_ang(double* theta_r, double* theta_l); +double YP_get_wheel_torque(double* torque_r, double* torque_l); int YP_wheel_ang(double r, double l); int YP_set_wheel_accel(double r, double l); int YP_set_wheel_vel(double r, double l); -double YP_get_vref(double *vref, double *wref); -double YP_get_wheel_vref(double *wrref, double *wlref); +double YP_get_vref(double* vref, double* wref); +double YP_get_wheel_vref(double* wrref, double* wlref); int YP_joint_torque(int id, double t); int YP_joint_vel(int id, double v); @@ -191,10 +192,10 @@ int YP_joint_ang(int id, double a); int YP_joint_ang_vel(int id, double a, double v); int YP_set_joint_accel(int id, double a); int YP_set_joint_vel(int id, double v); -double YP_get_joint_vel(int id, double *v); -double YP_get_joint_vref(int id, double *v); -double YP_get_joint_ang(int id, double *a); -double YP_get_joint_torque(int id, double *t); +double YP_get_joint_vel(int id, double* v); +double YP_get_joint_vref(int id, double* v); +double YP_get_joint_ang(int id, double* a); +double YP_get_joint_torque(int id, double* t); #define YPSPUR_JOINT_SUPPORT 1 #define YPSPUR_JOINT_ANG_VEL_SUPPORT 1 diff --git a/samples/MOI-estimate.c b/samples/MOI-estimate.c index 270d43f..33d5517 100644 --- a/samples/MOI-estimate.c +++ b/samples/MOI-estimate.c @@ -24,7 +24,7 @@ #include #include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { double refvel; double torque, force; diff --git a/samples/cartesian2d-test.c b/samples/cartesian2d-test.c index 432059f..7f6824c 100644 --- a/samples/cartesian2d-test.c +++ b/samples/cartesian2d-test.c @@ -25,7 +25,7 @@ CSptr BS, GL, LC, LC2, LC3, LC4; -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { double x, y, theta; diff --git a/samples/run-test.c b/samples/run-test.c index 124a116..2639242 100644 --- a/samples/run-test.c +++ b/samples/run-test.c @@ -23,7 +23,7 @@ #include #include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { double x, y, theta; diff --git a/src/adinput.c b/src/adinput.c index 26008ac..a279665 100644 --- a/src/adinput.c +++ b/src/adinput.c @@ -49,7 +49,7 @@ int ad[16]; // ad値保存用バッファ int ad_num = 0; // adでいくつデータを出力するように指令したか int dio_num = 0; // dioでいくつデータを出力するように指令したか -int process_addata(unsigned char *buf, int len) +int process_addata(unsigned char* buf, int len) { int j; int ad_num; @@ -68,7 +68,7 @@ int process_addata(unsigned char *buf, int len) } /* read ad data func for ssm write */ -const int *get_addataptr() +const int* get_addataptr() { return ad; } @@ -92,13 +92,13 @@ int get_dio_num(void) return dio_num; } -int admask_receive(char *buf, int len, double receive_time, void *data) +int admask_receive(char* buf, int len, double receive_time, void* data) { buf[len] = 0; - strcat((char *)data, buf); - if (strstr((char *)data, "00P\n\n")) + strcat((char*)data, buf); + if (strstr((char*)data, "00P\n\n")) return -1; - if (strstr((char *)data, "\n\n")) + if (strstr((char*)data, "\n\n")) return -2; return 0; } diff --git a/src/command.c b/src/command.c index b2765cb..8ff3976 100644 --- a/src/command.c +++ b/src/command.c @@ -55,9 +55,9 @@ SpurUserParamsPtr get_spur_user_param_ptr() return &g_spur; } -void command_loop_cleanup(void *data) +void command_loop_cleanup(void* data) { - struct ipcmd_t *ipcmd; + struct ipcmd_t* ipcmd; ipcmd = data; yprintf(OUTPUT_LV_INFO, "Command analyzer stopped.\n"); @@ -455,7 +455,7 @@ void command(void) } /* メッセージを返す */ -void message_return(struct ipcmd_t *ipcmd, long retpid, YPSpur_msg *res_msg) +void message_return(struct ipcmd_t* ipcmd, long retpid, YPSpur_msg* res_msg) { res_msg->type = 0; res_msg->msg_type = retpid; @@ -464,9 +464,9 @@ void message_return(struct ipcmd_t *ipcmd, long retpid, YPSpur_msg *res_msg) } /* すれっどの初期化 */ -void init_command_thread(pthread_t *thread) +void init_command_thread(pthread_t* thread) { - if (pthread_create(thread, NULL, (void *)command, NULL) != 0) + if (pthread_create(thread, NULL, (void*)command, NULL) != 0) { yprintf(OUTPUT_LV_ERROR, "Can't create command thread\n"); } diff --git a/src/command_aux.c b/src/command_aux.c index ecd8fb3..73447d7 100644 --- a/src/command_aux.c +++ b/src/command_aux.c @@ -45,7 +45,7 @@ #include #include -void get_ad_com(double *data, double *resdata) +void get_ad_com(double* data, double* resdata) { int num; @@ -53,7 +53,7 @@ void get_ad_com(double *data, double *resdata) resdata[0] = get_addata(num); } -void set_io_dir_com(double *data, double *resdata) +void set_io_dir_com(double* data, double* resdata) { int num; @@ -61,7 +61,7 @@ void set_io_dir_com(double *data, double *resdata) parameter_set(PARAM_io_dir, 0, num); } -void set_io_data_com(double *data, double *resdata) +void set_io_data_com(double* data, double* resdata) { int num; @@ -69,7 +69,7 @@ void set_io_data_com(double *data, double *resdata) parameter_set(PARAM_io_data, 0, num); } -void get_error_state_com(double *data, double *resdata) +void get_error_state_com(double* data, double* resdata) { int num = (int)data[0]; ErrorStatePtr err = get_error_state_ptr(); @@ -78,7 +78,7 @@ void get_error_state_com(double *data, double *resdata) resdata[1] = err->time[num]; } -void dump_device_com(double *data, double *resdata) +void dump_device_com(double* data, double* resdata) { int id, block; diff --git a/src/command_get.c b/src/command_get.c index 7c79ac6..8c066e8 100644 --- a/src/command_get.c +++ b/src/command_get.c @@ -45,7 +45,7 @@ #include #include -void get_pos_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +void get_pos_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { Odometry odometry; @@ -58,7 +58,7 @@ void get_pos_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) // printf( "get %f %f %f\n", x, y, theta ); } -void get_wheel_vref_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +void get_wheel_vref_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -69,7 +69,7 @@ void get_wheel_vref_com(int cs, double *data, double *resdata, SpurUserParamsPtr resdata[2] = odometry->time; } -void get_vref_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +void get_vref_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -80,7 +80,7 @@ void get_vref_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) resdata[2] = odometry->time; } -void get_vel_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +void get_vel_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -93,7 +93,7 @@ void get_vel_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) // printf("getvel %f %f %f\n",); } -void get_force_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +void get_force_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -106,7 +106,7 @@ void get_force_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur // printf("getvel %f %f %f\n",); } -void get_wheel_torque_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +void get_wheel_torque_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -119,7 +119,7 @@ void get_wheel_torque_com(int cs, double *data, double *resdata, SpurUserParamsP // printf("getvel %f %f %f\n",); } -void get_wheel_vel_com(double *data, double *resdata, SpurUserParamsPtr spur) +void get_wheel_vel_com(double* data, double* resdata, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -132,7 +132,7 @@ void get_wheel_vel_com(double *data, double *resdata, SpurUserParamsPtr spur) // printf("getvel %f %f %f\n",); } -void get_wheel_ang_com(double *data, double *resdata, SpurUserParamsPtr spur) +void get_wheel_ang_com(double* data, double* resdata, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -145,7 +145,7 @@ void get_wheel_ang_com(double *data, double *resdata, SpurUserParamsPtr spur) // printf("getvel %f %f %f\n",); } -int near_pos_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +int near_pos_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { double x, y, theta, cx, cy; double dist; @@ -170,7 +170,7 @@ int near_pos_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) return 0; } -int near_ang_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +int near_ang_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { double x, y, theta; double dist; @@ -196,7 +196,7 @@ int near_ang_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) return 0; } -int over_line_com(int cs, double *data, double *resdata, SpurUserParamsPtr spur) +int over_line_com(int cs, double* data, double* resdata, SpurUserParamsPtr spur) { double x, y, theta; double dist; diff --git a/src/command_joint.c b/src/command_joint.c index 33be057..eeb6c23 100644 --- a/src/command_joint.c +++ b/src/command_joint.c @@ -44,7 +44,7 @@ /* ライブラリ用 */ #include -void joint_torque_com(int id, double *data, SpurUserParamsPtr spur) +void joint_torque_com(int id, double* data, SpurUserParamsPtr spur) { if (id > YP_PARAM_MAX_MOTOR_NUM) { @@ -55,7 +55,7 @@ void joint_torque_com(int id, double *data, SpurUserParamsPtr spur) spur->wheel_mode[id] = MOTOR_CONTROL_FREE; } -void joint_vel_com(int id, double *data, SpurUserParamsPtr spur) +void joint_vel_com(int id, double* data, SpurUserParamsPtr spur) { if (id > YP_PARAM_MAX_MOTOR_NUM) { @@ -66,7 +66,7 @@ void joint_vel_com(int id, double *data, SpurUserParamsPtr spur) spur->wheel_mode[id] = MOTOR_CONTROL_VEL; } -void joint_ang_com(int id, double *data, SpurUserParamsPtr spur) +void joint_ang_com(int id, double* data, SpurUserParamsPtr spur) { if (id > YP_PARAM_MAX_MOTOR_NUM) { @@ -77,7 +77,7 @@ void joint_ang_com(int id, double *data, SpurUserParamsPtr spur) spur->wheel_mode[id] = MOTOR_CONTROL_ANGLE; } -void joint_ang_vel_com(int id, double *data, SpurUserParamsPtr spur) +void joint_ang_vel_com(int id, double* data, SpurUserParamsPtr spur) { if (id > YP_PARAM_MAX_MOTOR_NUM) { @@ -89,7 +89,7 @@ void joint_ang_vel_com(int id, double *data, SpurUserParamsPtr spur) spur->wheel_mode[id] = MOTOR_CONTROL_ANGLE_VEL; } -void set_joint_accel_com(int id, double *data, SpurUserParamsPtr spur) +void set_joint_accel_com(int id, double* data, SpurUserParamsPtr spur) { if (id > YP_PARAM_MAX_MOTOR_NUM) { @@ -99,7 +99,7 @@ void set_joint_accel_com(int id, double *data, SpurUserParamsPtr spur) spur->wheel_accel[id] = data[0]; } -void set_joint_vel_com(int id, double *data, SpurUserParamsPtr spur) +void set_joint_vel_com(int id, double* data, SpurUserParamsPtr spur) { if (id > YP_PARAM_MAX_MOTOR_NUM) { @@ -109,7 +109,7 @@ void set_joint_vel_com(int id, double *data, SpurUserParamsPtr spur) spur->wheel_vel[id] = data[0]; } -void get_joint_vel_com(int id, double *data, SpurUserParamsPtr spur) +void get_joint_vel_com(int id, double* data, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -124,7 +124,7 @@ void get_joint_vel_com(int id, double *data, SpurUserParamsPtr spur) data[1] = odometry->time; } -void get_joint_vref_com(int id, double *data, SpurUserParamsPtr spur) +void get_joint_vref_com(int id, double* data, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -139,7 +139,7 @@ void get_joint_vref_com(int id, double *data, SpurUserParamsPtr spur) data[1] = odometry->time; } -void get_joint_ang_com(int id, double *data, SpurUserParamsPtr spur) +void get_joint_ang_com(int id, double* data, SpurUserParamsPtr spur) { OdometryPtr odometry; @@ -154,7 +154,7 @@ void get_joint_ang_com(int id, double *data, SpurUserParamsPtr spur) data[1] = odometry->time; } -void get_joint_torque_com(int id, double *data, SpurUserParamsPtr spur) +void get_joint_torque_com(int id, double* data, SpurUserParamsPtr spur) { OdometryPtr odometry; diff --git a/src/command_param.c b/src/command_param.c index f0a1833..680b8e8 100644 --- a/src/command_param.c +++ b/src/command_param.c @@ -48,7 +48,7 @@ #include #include -void param_set_com(int cs, double *data, SpurUserParamsPtr spur) +void param_set_com(int cs, double* data, SpurUserParamsPtr spur) { if (cs >= 0 && cs < YP_PARAM_NUM) { @@ -57,7 +57,7 @@ void param_set_com(int cs, double *data, SpurUserParamsPtr spur) } } -int param_get_com(int cs, double *resdata, SpurUserParamsPtr spur) +int param_get_com(int cs, double* resdata, SpurUserParamsPtr spur) { if (cs >= 0 && cs < YP_PARAM_NUM) { @@ -71,13 +71,13 @@ int param_get_com(int cs, double *resdata, SpurUserParamsPtr spur) } } -void param_set_motor_com(int cs, double *data, SpurUserParamsPtr spur) +void param_set_motor_com(int cs, double* data, SpurUserParamsPtr spur) { if (cs >= 0 && cs < YP_PARAM_NUM) *pp(cs, data[0]) = data[1]; } -int param_get_motor_com(int cs, double *resdata, SpurUserParamsPtr spur) +int param_get_motor_com(int cs, double* resdata, SpurUserParamsPtr spur) { if (cs >= 0 && cs < YP_PARAM_NUM) { @@ -90,7 +90,7 @@ int param_get_motor_com(int cs, double *resdata, SpurUserParamsPtr spur) } } -void param_state_com(int cs, double *data, SpurUserParamsPtr spur) +void param_state_com(int cs, double* data, SpurUserParamsPtr spur) { OdometryPtr odometry; diff --git a/src/command_run.c b/src/command_run.c index 65c179f..8afe26a 100644 --- a/src/command_run.c +++ b/src/command_run.c @@ -45,7 +45,7 @@ #include #include -void line_com(int cs, double *data, SpurUserParamsPtr spur) +void line_com(int cs, double* data, SpurUserParamsPtr spur) { double x, y, theta; @@ -61,7 +61,7 @@ void line_com(int cs, double *data, SpurUserParamsPtr spur) spur->run_mode = RUN_LINEFOLLOW; } -void stop_line_com(int cs, double *data, SpurUserParamsPtr spur) +void stop_line_com(int cs, double* data, SpurUserParamsPtr spur) { double x, y, theta; @@ -77,7 +77,7 @@ void stop_line_com(int cs, double *data, SpurUserParamsPtr spur) spur->run_mode = RUN_STOP_LINE; } -void circle_com(int cs, double *data, SpurUserParamsPtr spur) +void circle_com(int cs, double* data, SpurUserParamsPtr spur) { double x, y, theta; @@ -93,7 +93,7 @@ void circle_com(int cs, double *data, SpurUserParamsPtr spur) spur->run_mode = RUN_CIRCLEFOLLOW; } -void spin_com(int cs, double *data, SpurUserParamsPtr spur) +void spin_com(int cs, double* data, SpurUserParamsPtr spur) { double x, y, theta; @@ -107,7 +107,7 @@ void spin_com(int cs, double *data, SpurUserParamsPtr spur) spur->run_mode = RUN_SPIN; } -void orient_com(int cs, double *data, SpurUserParamsPtr spur) +void orient_com(int cs, double* data, SpurUserParamsPtr spur) { double x, y, theta; @@ -121,36 +121,36 @@ void orient_com(int cs, double *data, SpurUserParamsPtr spur) spur->run_mode = RUN_ORIENT; } -void stop_com(double *data, SpurUserParamsPtr spur) +void stop_com(double* data, SpurUserParamsPtr spur) { spur->run_mode = RUN_STOP; } -void free_com(double *data, SpurUserParamsPtr spur) +void free_com(double* data, SpurUserParamsPtr spur) { spur->run_mode = RUN_FREE; } -void openfree_com(double *data, SpurUserParamsPtr spur) +void openfree_com(double* data, SpurUserParamsPtr spur) { spur->run_mode = RUN_OPENFREE; } -void vel_com(double *data, SpurUserParamsPtr spur) +void vel_com(double* data, SpurUserParamsPtr spur) { spur->vref = data[0]; spur->wref = data[1]; spur->run_mode = RUN_VEL; } -void wheel_vel_com(double *data, SpurUserParamsPtr spur) +void wheel_vel_com(double* data, SpurUserParamsPtr spur) { spur->wvelref[0] = data[0]; spur->wvelref[1] = data[1]; spur->run_mode = RUN_WHEEL_VEL; } -void wheel_angle_com(double *data, SpurUserParamsPtr spur) +void wheel_angle_com(double* data, SpurUserParamsPtr spur) { double r, l; diff --git a/src/command_set.c b/src/command_set.c index 86df764..479201d 100644 --- a/src/command_set.c +++ b/src/command_set.c @@ -46,7 +46,7 @@ #include #include -void set_pos_com(int cs, double *data, SpurUserParamsPtr spur) +void set_pos_com(int cs, double* data, SpurUserParamsPtr spur) { double x, y, theta; CSptr cs_src; @@ -77,7 +77,7 @@ void set_pos_com(int cs, double *data, SpurUserParamsPtr spur) } } -void set_GL_on_GL_com(double *data, SpurUserParamsPtr spur) +void set_GL_on_GL_com(double* data, SpurUserParamsPtr spur) { double x, y, theta; x = data[0]; @@ -88,7 +88,7 @@ void set_GL_on_GL_com(double *data, SpurUserParamsPtr spur) set_cs(CS_GL, x, y, theta); } -void set_adjust_com(int cs, double *data, SpurUserParamsPtr spur) +void set_adjust_com(int cs, double* data, SpurUserParamsPtr spur) { double x, y, theta; double xgl, ygl, thetagl; @@ -124,7 +124,7 @@ void set_adjust_com(int cs, double *data, SpurUserParamsPtr spur) set_cs(CS_SP, x, y, theta); } -void set_vel_com(double *data, SpurUserParamsPtr spur) +void set_vel_com(double* data, SpurUserParamsPtr spur) { spur->v = data[0]; if (spur->v > p(YP_PARAM_MAX_VEL, 0)) @@ -133,14 +133,14 @@ void set_vel_com(double *data, SpurUserParamsPtr spur) spur->v = -p(YP_PARAM_MAX_VEL, 0); } -void set_torque_com(double *data, SpurUserParamsPtr spur) +void set_torque_com(double* data, SpurUserParamsPtr spur) { spur->torque[1] = data[1]; spur->torque[0] = data[0]; spur->run_mode = RUN_WHEEL_TORQUE; } -void set_ang_vel_com(double *data, SpurUserParamsPtr spur) +void set_ang_vel_com(double* data, SpurUserParamsPtr spur) { spur->w = data[0]; if (spur->w > p(YP_PARAM_MAX_W, 0)) @@ -149,7 +149,7 @@ void set_ang_vel_com(double *data, SpurUserParamsPtr spur) spur->w = 0; } -void set_accel_com(double *data, SpurUserParamsPtr spur) +void set_accel_com(double* data, SpurUserParamsPtr spur) { spur->dv = data[0]; if (spur->dv > p(YP_PARAM_MAX_ACC_V, 0)) @@ -158,7 +158,7 @@ void set_accel_com(double *data, SpurUserParamsPtr spur) spur->dv = 0; } -void set_ang_accel_com(double *data, SpurUserParamsPtr spur) +void set_ang_accel_com(double* data, SpurUserParamsPtr spur) { spur->dw = data[0]; if (spur->dw > p(YP_PARAM_MAX_ACC_W, 0)) @@ -167,7 +167,7 @@ void set_ang_accel_com(double *data, SpurUserParamsPtr spur) spur->dw = 0; } -void set_tilt_com(int cs, double *data, SpurUserParamsPtr spur) +void set_tilt_com(int cs, double* data, SpurUserParamsPtr spur) { double x, y, theta; @@ -181,13 +181,13 @@ void set_tilt_com(int cs, double *data, SpurUserParamsPtr spur) spur->tilt = data[1]; } -void set_wheel_accel_com(double *data, SpurUserParamsPtr spur) +void set_wheel_accel_com(double* data, SpurUserParamsPtr spur) { spur->wheel_accel[1] = data[1]; spur->wheel_accel[0] = data[0]; } -void set_wheel_vel_com(double *data, SpurUserParamsPtr spur) +void set_wheel_vel_com(double* data, SpurUserParamsPtr spur) { spur->wheel_vel[1] = data[1]; spur->wheel_vel[0] = data[0]; diff --git a/src/communication.c b/src/communication.c index ccbd963..86d078b 100644 --- a/src/communication.c +++ b/src/communication.c @@ -39,7 +39,7 @@ /** * @brief エンコード */ -int encode(const unsigned char *src, int len, unsigned char *dst, int buf_max) +int encode(const unsigned char* src, int len, unsigned char* dst, int buf_max) { int pos, s_pos, w_pos; unsigned short b; @@ -83,7 +83,7 @@ int encode(const unsigned char *src, int len, unsigned char *dst, int buf_max) * @param buf_max[in] デコード後のデータバッファのサイズ * @return デコード後のバイト数 */ -int decode(const unsigned char *src, int len, unsigned char *dst, int buf_max) +int decode(const unsigned char* src, int len, unsigned char* dst, int buf_max) { unsigned short dat, b; int pos, s_pos, w_pos; diff --git a/src/control_vehicle.c b/src/control_vehicle.c index 86404a5..39990e4 100644 --- a/src/control_vehicle.c +++ b/src/control_vehicle.c @@ -312,7 +312,7 @@ void wheel_angle(OdometryPtr odm, SpurUserParamsPtr spur) } } -void wheel_torque(OdometryPtr odm, SpurUserParamsPtr spur, double *torque) +void wheel_torque(OdometryPtr odm, SpurUserParamsPtr spur, double* torque) { int i; ParametersPtr param; @@ -452,7 +452,7 @@ double gravity_compensation(OdometryPtr odm, SpurUserParamsPtr spur) return tilt; } -void control_loop_cleanup(void *data) +void control_loop_cleanup(void* data) { yprintf(OUTPUT_LV_INFO, "Trajectory control loop stopped.\n"); } @@ -668,9 +668,9 @@ void run_control(Odometry odometry, SpurUserParamsPtr spur) } /* すれっどの初期化 */ -void init_control_thread(pthread_t *thread) +void init_control_thread(pthread_t* thread) { - if (pthread_create(thread, NULL, (void *)control_loop, NULL) != 0) + if (pthread_create(thread, NULL, (void*)control_loop, NULL) != 0) { yprintf(OUTPUT_LV_ERROR, "Can't create control_loop thread\n"); } diff --git a/src/ipcommunication.c b/src/ipcommunication.c index 1504576..ebb9b65 100644 --- a/src/ipcommunication.c +++ b/src/ipcommunication.c @@ -48,15 +48,15 @@ #if defined(__MINGW32__) #define SOCK_SHUTDOWN_OPTION SD_BOTH -#define SOCK_DATATYPE char * +#define SOCK_DATATYPE char* #define SIZE_TYPE int #else #define SOCK_SHUTDOWN_OPTION SHUT_RDWR -#define SOCK_DATATYPE void * +#define SOCK_DATATYPE void* #define SIZE_TYPE unsigned int #endif // defined(__MINGW32__) -int ipcmd_open_msq(struct ipcmd_t *ipcmd, int key, int creat) +int ipcmd_open_msq(struct ipcmd_t* ipcmd, int key, int creat) { if (creat) creat = IPC_CREAT; @@ -86,7 +86,7 @@ int ipcmd_open_msq(struct ipcmd_t *ipcmd, int key, int creat) return 1; } -int ipcmd_send_msq(struct ipcmd_t *ipcmd, YPSpur_msg *data) +int ipcmd_send_msq(struct ipcmd_t* ipcmd, YPSpur_msg* data) { size_t len = YPSPUR_MSG_SIZE; @@ -101,7 +101,7 @@ int ipcmd_send_msq(struct ipcmd_t *ipcmd, YPSpur_msg *data) return len; } -int ipcmd_recv_msq(struct ipcmd_t *ipcmd, YPSpur_msg *data) +int ipcmd_recv_msq(struct ipcmd_t* ipcmd, YPSpur_msg* data) { int received; size_t len = YPSPUR_MSG_SIZE; @@ -118,7 +118,7 @@ int ipcmd_recv_msq(struct ipcmd_t *ipcmd, YPSpur_msg *data) return received; } -void ipcmd_flush_msq(struct ipcmd_t *ipcmd) +void ipcmd_flush_msq(struct ipcmd_t* ipcmd) { char dummy[128]; @@ -134,7 +134,7 @@ void ipcmd_flush_msq(struct ipcmd_t *ipcmd) } } -int ipcmd_open_tcp(struct ipcmd_t *ipcmd, char *host, int port) +int ipcmd_open_tcp(struct ipcmd_t* ipcmd, char* host, int port) { struct sockaddr_in addr; int i; @@ -164,7 +164,7 @@ int ipcmd_open_tcp(struct ipcmd_t *ipcmd, char *host, int port) if (!host) { addr.sin_addr.s_addr = htonl(INADDR_ANY); - bind(ipcmd->socket, (struct sockaddr *)&addr, sizeof(addr)); + bind(ipcmd->socket, (struct sockaddr*)&addr, sizeof(addr)); listen(ipcmd->socket, YPSPUR_MAX_SOCKET); ipcmd->tcp_type = IPCMD_TCP_SERVER; @@ -173,7 +173,7 @@ int ipcmd_open_tcp(struct ipcmd_t *ipcmd, char *host, int port) { addr.sin_addr.s_addr = inet_addr(host); - if (connect(ipcmd->socket, (struct sockaddr *)&addr, sizeof(addr)) == -1) + if (connect(ipcmd->socket, (struct sockaddr*)&addr, sizeof(addr)) == -1) { return -1; } @@ -190,7 +190,7 @@ int ipcmd_open_tcp(struct ipcmd_t *ipcmd, char *host, int port) return 1; } -int ipcmd_send_tcp(struct ipcmd_t *ipcmd, YPSpur_msg *data) +int ipcmd_send_tcp(struct ipcmd_t* ipcmd, YPSpur_msg* data) { int sock; size_t len = sizeof(YPSpur_msg); @@ -219,7 +219,7 @@ int ipcmd_send_tcp(struct ipcmd_t *ipcmd, YPSpur_msg *data) return len; } -int ipcmd_recv_tcp(struct ipcmd_t *ipcmd, YPSpur_msg *data) +int ipcmd_recv_tcp(struct ipcmd_t* ipcmd, YPSpur_msg* data) { fd_set fds; struct sockaddr_in client; @@ -268,7 +268,7 @@ int ipcmd_recv_tcp(struct ipcmd_t *ipcmd, YPSpur_msg *data) } addr_size = sizeof(client); - sock = accept(ipcmd->socket, (struct sockaddr *)&client, &addr_size); + sock = accept(ipcmd->socket, (struct sockaddr*)&client, &addr_size); if (sock <= 0) { yprintf(OUTPUT_LV_ERROR, "Invalid socket.\n"); @@ -321,15 +321,16 @@ int ipcmd_recv_tcp(struct ipcmd_t *ipcmd, YPSpur_msg *data) ipcmd->clients[i] = -1; continue; } - } while (0); + } + while (0); return len; } -void ipcmd_flush_tcp(struct ipcmd_t *ipcmd) +void ipcmd_flush_tcp(struct ipcmd_t* ipcmd) { } -void ipcmd_close(struct ipcmd_t *ipcmd) +void ipcmd_close(struct ipcmd_t* ipcmd) { if (ipcmd == NULL) return; @@ -350,18 +351,18 @@ void ipcmd_close(struct ipcmd_t *ipcmd) ipcmd->flush = ipcmd_flush; } -int ipcmd_send(struct ipcmd_t *ipcmd, YPSpur_msg *data) +int ipcmd_send(struct ipcmd_t* ipcmd, YPSpur_msg* data) { ipcmd->connection_error = 1; return -1; } -int ipcmd_recv(struct ipcmd_t *ipcmd, YPSpur_msg *data) +int ipcmd_recv(struct ipcmd_t* ipcmd, YPSpur_msg* data) { ipcmd->connection_error = 1; return -1; } -void ipcmd_flush(struct ipcmd_t *ipcmd) +void ipcmd_flush(struct ipcmd_t* ipcmd) { } diff --git a/src/libypspur-md.c b/src/libypspur-md.c index e111f58..e8a3923 100644 --- a/src/libypspur-md.c +++ b/src/libypspur-md.c @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -/* +/* * YP-Spurとの通信ライブラリ複数デバイス対応版 Communication Library for YP-Spur */ @@ -40,12 +40,12 @@ #include /* エラー確認 */ -int YP_md_get_error_state(YPSpur *spur) +int YP_md_get_error_state(YPSpur* spur) { return spur->dev.connection_error; } -double YP_md_get_device_error_state(YPSpur *spur, int id, int *error_state) +double YP_md_get_device_error_state(YPSpur* spur, int id, int* error_state) { YPSpur_msg msg; int len; @@ -78,7 +78,7 @@ double YP_md_get_device_error_state(YPSpur *spur, int id, int *error_state) } /* coordinatorとのメッセージ通信を開始する */ -int YPSpur_md_initex(YPSpur *spur, int msq_key) +int YPSpur_md_initex(YPSpur* spur, int msq_key) { /* メッセージ・キューのオープン */ if (ipcmd_open_msq(&spur->dev, msq_key, 0) < 0) @@ -91,7 +91,7 @@ int YPSpur_md_initex(YPSpur *spur, int msq_key) return 1; } -int YPSpur_md_init_socket(YPSpur *spur, char *ip, int port) +int YPSpur_md_init_socket(YPSpur* spur, char* ip, int port) { /* メッセージ・キューのオープン */ if (ipcmd_open_tcp(&spur->dev, ip, port) < 0) @@ -105,13 +105,13 @@ int YPSpur_md_init_socket(YPSpur *spur, char *ip, int port) } /* coordinatorとのメッセージ通信を開始する */ -int YPSpur_md_init(YPSpur *spur) +int YPSpur_md_init(YPSpur* spur) { return YPSpur_md_initex(spur, YPSPUR_MSQ_KEY); } /* 直線追従 */ -int YPSpur_md_line(YPSpur *spur, int cs, double x, double y, double theta) +int YPSpur_md_line(YPSpur* spur, int cs, double x, double y, double theta) { YPSpur_msg msg; @@ -133,7 +133,7 @@ int YPSpur_md_line(YPSpur *spur, int cs, double x, double y, double theta) } /* 直線追従 */ -int YPSpur_md_stop_line(YPSpur *spur, int cs, double x, double y, double theta) +int YPSpur_md_stop_line(YPSpur* spur, int cs, double x, double y, double theta) { YPSpur_msg msg; @@ -155,7 +155,7 @@ int YPSpur_md_stop_line(YPSpur *spur, int cs, double x, double y, double theta) } /* 円弧追従 */ -int YPSpur_md_circle(YPSpur *spur, int cs, double x, double y, double r) +int YPSpur_md_circle(YPSpur* spur, int cs, double x, double y, double r) { YPSpur_msg msg; @@ -177,7 +177,7 @@ int YPSpur_md_circle(YPSpur *spur, int cs, double x, double y, double r) } /* 旋回 */ -int YPSpur_md_spin(YPSpur *spur, int cs, double theta) +int YPSpur_md_spin(YPSpur* spur, int cs, double theta) { YPSpur_msg msg; @@ -197,7 +197,7 @@ int YPSpur_md_spin(YPSpur *spur, int cs, double theta) } /* 方位 */ -int YPSpur_md_orient(YPSpur *spur, int cs, double theta) +int YPSpur_md_orient(YPSpur* spur, int cs, double theta) { YPSpur_msg msg; @@ -217,7 +217,7 @@ int YPSpur_md_orient(YPSpur *spur, int cs, double theta) } /* 急ブレーキ */ -int YPSpur_md_stop(YPSpur *spur) +int YPSpur_md_stop(YPSpur* spur) { YPSpur_msg msg; @@ -236,7 +236,7 @@ int YPSpur_md_stop(YPSpur *spur) } /* 緊急停止 */ -int YPSpur_md_freeze(YPSpur *spur) +int YPSpur_md_freeze(YPSpur* spur) { YPSpur_msg msg; @@ -255,7 +255,7 @@ int YPSpur_md_freeze(YPSpur *spur) } /* 緊急停止解除 */ -int YPSpur_md_unfreeze(YPSpur *spur) +int YPSpur_md_unfreeze(YPSpur* spur) { YPSpur_msg msg; @@ -274,7 +274,7 @@ int YPSpur_md_unfreeze(YPSpur *spur) } /* ソフトウェア補助フリーモード */ -int YPSpur_md_free(YPSpur *spur) +int YPSpur_md_free(YPSpur* spur) { YPSpur_msg msg; @@ -293,7 +293,7 @@ int YPSpur_md_free(YPSpur *spur) } /* 制御なしフリーモード */ -int YP_md_openfree(YPSpur *spur) +int YP_md_openfree(YPSpur* spur) { YPSpur_msg msg; @@ -312,7 +312,7 @@ int YP_md_openfree(YPSpur *spur) } /* 位置指定 */ -int YPSpur_md_set_pos(YPSpur *spur, int cs, double x, double y, double theta) +int YPSpur_md_set_pos(YPSpur* spur, int cs, double x, double y, double theta) { YPSpur_msg msg; @@ -334,7 +334,7 @@ int YPSpur_md_set_pos(YPSpur *spur, int cs, double x, double y, double theta) } /* 位置指定 */ -int YPSpur_md_adjust_pos(YPSpur *spur, int cs, double x, double y, double theta) +int YPSpur_md_adjust_pos(YPSpur* spur, int cs, double x, double y, double theta) { YPSpur_msg msg; @@ -356,7 +356,7 @@ int YPSpur_md_adjust_pos(YPSpur *spur, int cs, double x, double y, double theta) } /* 速度指定 */ -int YPSpur_md_set_vel(YPSpur *spur, double v) +int YPSpur_md_set_vel(YPSpur* spur, double v) { YPSpur_msg msg; @@ -376,7 +376,7 @@ int YPSpur_md_set_vel(YPSpur *spur, double v) } /* 角速度指定 */ -int YPSpur_md_set_angvel(YPSpur *spur, double w) +int YPSpur_md_set_angvel(YPSpur* spur, double w) { YPSpur_msg msg; @@ -396,7 +396,7 @@ int YPSpur_md_set_angvel(YPSpur *spur, double w) } /* 速度指定 */ -int YPSpur_md_set_accel(YPSpur *spur, double dv) +int YPSpur_md_set_accel(YPSpur* spur, double dv) { YPSpur_msg msg; @@ -416,7 +416,7 @@ int YPSpur_md_set_accel(YPSpur *spur, double dv) } /* 角速度指定 */ -int YPSpur_md_set_angaccel(YPSpur *spur, double dw) +int YPSpur_md_set_angaccel(YPSpur* spur, double dw) { YPSpur_msg msg; @@ -436,7 +436,7 @@ int YPSpur_md_set_angaccel(YPSpur *spur, double dw) } /* 位置取得 */ -double YPSpur_md_get_pos(YPSpur *spur, int cs, double *x, double *y, double *theta) +double YPSpur_md_get_pos(YPSpur* spur, int cs, double* x, double* y, double* theta) { YPSpur_msg msg; int len; @@ -470,7 +470,7 @@ double YPSpur_md_get_pos(YPSpur *spur, int cs, double *x, double *y, double *the } /* 速度取得 */ -double YPSpur_md_get_vel(YPSpur *spur, double *v, double *w) +double YPSpur_md_get_vel(YPSpur* spur, double* v, double* w) { YPSpur_msg msg; int len; @@ -503,7 +503,7 @@ double YPSpur_md_get_vel(YPSpur *spur, double *v, double *w) } /* 速度取得 */ -double YP_md_get_vref(YPSpur *spur, double *v, double *w) +double YP_md_get_vref(YPSpur* spur, double* v, double* w) { YPSpur_msg msg; int len; @@ -536,7 +536,7 @@ double YP_md_get_vref(YPSpur *spur, double *v, double *w) } /* 速度取得 */ -double YP_md_get_wheel_vref(YPSpur *spur, double *wr, double *wl) +double YP_md_get_wheel_vref(YPSpur* spur, double* wr, double* wl) { YPSpur_msg msg; int len; @@ -569,7 +569,7 @@ double YP_md_get_wheel_vref(YPSpur *spur, double *wr, double *wl) } /* 速度取得 */ -double YP_md_get_wheel_vel(YPSpur *spur, double *wr, double *wl) +double YP_md_get_wheel_vel(YPSpur* spur, double* wr, double* wl) { YPSpur_msg msg; int len; @@ -602,7 +602,7 @@ double YP_md_get_wheel_vel(YPSpur *spur, double *wr, double *wl) } /* 角度取得 */ -double YP_md_get_wheel_ang(YPSpur *spur, double *theta_r, double *theta_l) +double YP_md_get_wheel_ang(YPSpur* spur, double* theta_r, double* theta_l) { YPSpur_msg msg; int len; @@ -635,7 +635,7 @@ double YP_md_get_wheel_ang(YPSpur *spur, double *theta_r, double *theta_l) } /* トルク取得 */ -double YP_md_get_wheel_torque(YPSpur *spur, double *torque_r, double *torque_l) +double YP_md_get_wheel_torque(YPSpur* spur, double* torque_r, double* torque_l) { YPSpur_msg msg; int len; @@ -668,7 +668,7 @@ double YP_md_get_wheel_torque(YPSpur *spur, double *torque_r, double *torque_l) } /* 力取得 */ -double YPSpur_md_get_force(YPSpur *spur, double *trans, double *angular) +double YPSpur_md_get_force(YPSpur* spur, double* trans, double* angular) { YPSpur_msg msg; int len; @@ -701,7 +701,7 @@ double YPSpur_md_get_force(YPSpur *spur, double *trans, double *angular) } /* 緊急停止状態取得 */ -int YPSpur_md_isfreeze(YPSpur *spur) +int YPSpur_md_isfreeze(YPSpur* spur) { YPSpur_msg msg; int len; @@ -732,7 +732,7 @@ int YPSpur_md_isfreeze(YPSpur *spur) } /* 直接速度入力 */ -int YPSpur_md_vel(YPSpur *spur, double v, double w) +int YPSpur_md_vel(YPSpur* spur, double v, double w) { YPSpur_msg msg; @@ -753,7 +753,7 @@ int YPSpur_md_vel(YPSpur *spur, double v, double w) } /* 内部パラメータの変更 */ -int YP_md_set_parameter(YPSpur *spur, int param_id, double value) +int YP_md_set_parameter(YPSpur* spur, int param_id, double value) { YPSpur_msg msg; @@ -775,7 +775,7 @@ int YP_md_set_parameter(YPSpur *spur, int param_id, double value) } /* 内部パラメータの変更 */ -int YP_md_set_parameter_array(YPSpur *spur, int param_id, double *value) +int YP_md_set_parameter_array(YPSpur* spur, int param_id, double* value) { YPSpur_msg msg; @@ -797,7 +797,7 @@ int YP_md_set_parameter_array(YPSpur *spur, int param_id, double *value) } /* 内部パラメータの取得 */ -int YP_md_get_parameter(YPSpur *spur, int param_id, double *value) +int YP_md_get_parameter(YPSpur* spur, int param_id, double* value) { YPSpur_msg msg; int len; @@ -826,7 +826,7 @@ int YP_md_get_parameter(YPSpur *spur, int param_id, double *value) return msg.cs; } -int YP_md_get_parameter_array(YPSpur *spur, int param_id, double *value) +int YP_md_get_parameter_array(YPSpur* spur, int param_id, double* value) { YPSpur_msg msg; int len; @@ -857,7 +857,7 @@ int YP_md_get_parameter_array(YPSpur *spur, int param_id, double *value) } /* 内部状態の変更 */ -int YP_md_set_control_state(YPSpur *spur, int control_id, int state) +int YP_md_set_control_state(YPSpur* spur, int control_id, int state) { YPSpur_msg msg; @@ -878,7 +878,7 @@ int YP_md_set_control_state(YPSpur *spur, int control_id, int state) } /* 重力補償用地面の傾き指定 */ -int YPSpur_md_tilt(YPSpur *spur, int cs, double dir, double tilt) +int YPSpur_md_tilt(YPSpur* spur, int cs, double dir, double tilt) { YPSpur_msg msg; @@ -900,7 +900,7 @@ int YPSpur_md_tilt(YPSpur *spur, int cs, double dir, double tilt) } /* 位置判定 */ -int YPSpur_md_near_pos(YPSpur *spur, int cs, double x, double y, double r) +int YPSpur_md_near_pos(YPSpur* spur, int cs, double x, double y, double r) { YPSpur_msg msg; int len; @@ -932,7 +932,7 @@ int YPSpur_md_near_pos(YPSpur *spur, int cs, double x, double y, double r) } /* 角度判定 */ -int YPSpur_md_near_ang(YPSpur *spur, int cs, double th, double d) +int YPSpur_md_near_ang(YPSpur* spur, int cs, double th, double d) { YPSpur_msg msg; int len; @@ -963,7 +963,7 @@ int YPSpur_md_near_ang(YPSpur *spur, int cs, double th, double d) } /* 領域判定 */ -int YPSpur_md_over_line(YPSpur *spur, int cs, double x, double y, double theta) +int YPSpur_md_over_line(YPSpur* spur, int cs, double x, double y, double theta) { YPSpur_msg msg; int len; @@ -995,7 +995,7 @@ int YPSpur_md_over_line(YPSpur *spur, int cs, double x, double y, double theta) } /* アナログ値取得 */ -int YP_md_get_ad_value(YPSpur *spur, int num) +int YP_md_get_ad_value(YPSpur* spur, int num) { YPSpur_msg msg; int len; @@ -1026,7 +1026,7 @@ int YP_md_get_ad_value(YPSpur *spur, int num) return ret; } -int YP_md_set_io_dir(YPSpur *spur, unsigned char dir) +int YP_md_set_io_dir(YPSpur* spur, unsigned char dir) { YPSpur_msg msg; @@ -1045,7 +1045,7 @@ int YP_md_set_io_dir(YPSpur *spur, unsigned char dir) return 1; } -int YP_md_set_io_data(YPSpur *spur, unsigned char data) +int YP_md_set_io_data(YPSpur* spur, unsigned char data) { YPSpur_msg msg; @@ -1065,7 +1065,7 @@ int YP_md_set_io_data(YPSpur *spur, unsigned char data) } /* 直接タイヤ回転速度入力 */ -int YP_md_wheel_vel(YPSpur *spur, double r, double l) +int YP_md_wheel_vel(YPSpur* spur, double r, double l) { YPSpur_msg msg; @@ -1085,7 +1085,7 @@ int YP_md_wheel_vel(YPSpur *spur, double r, double l) return 1; } -int YP_md_wheel_torque(YPSpur *spur, double r, double l) +int YP_md_wheel_torque(YPSpur* spur, double r, double l) { YPSpur_msg msg; @@ -1105,7 +1105,7 @@ int YP_md_wheel_torque(YPSpur *spur, double r, double l) return 1; } -int YP_md_set_wheel_vel(YPSpur *spur, double r, double l) +int YP_md_set_wheel_vel(YPSpur* spur, double r, double l) { YPSpur_msg msg; @@ -1125,7 +1125,7 @@ int YP_md_set_wheel_vel(YPSpur *spur, double r, double l) return 1; } -int YP_md_set_wheel_accel(YPSpur *spur, double r, double l) +int YP_md_set_wheel_accel(YPSpur* spur, double r, double l) { YPSpur_msg msg; @@ -1145,7 +1145,7 @@ int YP_md_set_wheel_accel(YPSpur *spur, double r, double l) return 1; } -int YP_md_wheel_ang(YPSpur *spur, double r, double l) +int YP_md_wheel_ang(YPSpur* spur, double r, double l) { YPSpur_msg msg; @@ -1165,7 +1165,7 @@ int YP_md_wheel_ang(YPSpur *spur, double r, double l) return 1; } -int YP_md_joint_torque(YPSpur *spur, int id, double t) +int YP_md_joint_torque(YPSpur* spur, int id, double t) { YPSpur_msg msg; @@ -1185,7 +1185,7 @@ int YP_md_joint_torque(YPSpur *spur, int id, double t) return 1; } -int YP_md_joint_vel(YPSpur *spur, int id, double v) +int YP_md_joint_vel(YPSpur* spur, int id, double v) { YPSpur_msg msg; @@ -1205,7 +1205,7 @@ int YP_md_joint_vel(YPSpur *spur, int id, double v) return 1; } -int YP_md_joint_ang(YPSpur *spur, int id, double a) +int YP_md_joint_ang(YPSpur* spur, int id, double a) { YPSpur_msg msg; @@ -1225,7 +1225,7 @@ int YP_md_joint_ang(YPSpur *spur, int id, double a) return 1; } -int YP_md_joint_ang_vel(YPSpur *spur, int id, double a, double v) +int YP_md_joint_ang_vel(YPSpur* spur, int id, double a, double v) { YPSpur_msg msg; @@ -1246,7 +1246,7 @@ int YP_md_joint_ang_vel(YPSpur *spur, int id, double a, double v) return 1; } -int YP_md_set_joint_accel(YPSpur *spur, int id, double a) +int YP_md_set_joint_accel(YPSpur* spur, int id, double a) { YPSpur_msg msg; @@ -1266,7 +1266,7 @@ int YP_md_set_joint_accel(YPSpur *spur, int id, double a) return 1; } -int YP_md_set_joint_vel(YPSpur *spur, int id, double v) +int YP_md_set_joint_vel(YPSpur* spur, int id, double v) { YPSpur_msg msg; @@ -1286,7 +1286,7 @@ int YP_md_set_joint_vel(YPSpur *spur, int id, double v) return 1; } -double YP_md_get_joint_vel(YPSpur *spur, int id, double *v) +double YP_md_get_joint_vel(YPSpur* spur, int id, double* v) { YPSpur_msg msg; int len; @@ -1317,7 +1317,7 @@ double YP_md_get_joint_vel(YPSpur *spur, int id, double *v) return time; } -double YP_md_get_joint_vref(YPSpur *spur, int id, double *v) +double YP_md_get_joint_vref(YPSpur* spur, int id, double* v) { YPSpur_msg msg; int len; @@ -1348,7 +1348,7 @@ double YP_md_get_joint_vref(YPSpur *spur, int id, double *v) return time; } -double YP_md_get_joint_ang(YPSpur *spur, int id, double *a) +double YP_md_get_joint_ang(YPSpur* spur, int id, double* a) { YPSpur_msg msg; int len; @@ -1379,7 +1379,7 @@ double YP_md_get_joint_ang(YPSpur *spur, int id, double *a) return time; } -double YP_md_get_joint_torque(YPSpur *spur, int id, double *t) +double YP_md_get_joint_torque(YPSpur* spur, int id, double* t) { YPSpur_msg msg; int len; @@ -1410,7 +1410,7 @@ double YP_md_get_joint_torque(YPSpur *spur, int id, double *t) return time; } -void YP_md_request_device_dump(YPSpur *spur, int id, int block) +void YP_md_request_device_dump(YPSpur* spur, int id, int block) { YPSpur_msg msg; int len; diff --git a/src/libypspur.c b/src/libypspur.c index 08ab8d7..e497a46 100644 --- a/src/libypspur.c +++ b/src/libypspur.c @@ -18,7 +18,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -/* +/* * YP-Spurとの通信ライブラリ Communication Library for YP-Spur */ @@ -47,7 +47,7 @@ int YP_get_error_state() return YP_md_get_error_state(&spur); } -double YP_get_device_error_state(int id, int *err) +double YP_get_device_error_state(int id, int* err) { return YP_md_get_device_error_state(&spur, id, err); } @@ -58,7 +58,7 @@ int YPSpur_initex(int msq_key) return YPSpur_md_initex(&spur, msq_key); } -int YPSpur_init_socket(char *ip, int port) +int YPSpur_init_socket(char* ip, int port) { return YPSpur_md_init_socket(&spur, ip, port); } @@ -166,49 +166,49 @@ int YPSpur_set_angaccel(double dw) } /* 位置取得 */ -double YPSpur_get_pos(int cs, double *x, double *y, double *theta) +double YPSpur_get_pos(int cs, double* x, double* y, double* theta) { return YPSpur_md_get_pos(&spur, cs, x, y, theta); } /* 速度取得 */ -double YPSpur_get_vel(double *v, double *w) +double YPSpur_get_vel(double* v, double* w) { return YPSpur_md_get_vel(&spur, v, w); } /* 速度取得 */ -double YP_get_vref(double *v, double *w) +double YP_get_vref(double* v, double* w) { return YP_md_get_vref(&spur, v, w); } /* 速度取得 */ -double YP_get_wheel_vref(double *wr, double *wl) +double YP_get_wheel_vref(double* wr, double* wl) { return YP_md_get_wheel_vref(&spur, wr, wl); } /* 速度取得 */ -double YP_get_wheel_vel(double *wr, double *wl) +double YP_get_wheel_vel(double* wr, double* wl) { return YP_md_get_wheel_vel(&spur, wr, wl); } /* 角度取得 */ -double YP_get_wheel_ang(double *theta_r, double *theta_l) +double YP_get_wheel_ang(double* theta_r, double* theta_l) { return YP_md_get_wheel_ang(&spur, theta_r, theta_l); } /* トルク取得 */ -double YP_get_wheel_torque(double *torque_r, double *torque_l) +double YP_get_wheel_torque(double* torque_r, double* torque_l) { return YP_md_get_wheel_torque(&spur, torque_r, torque_l); } /* 力取得 */ -double YPSpur_get_force(double *trans, double *angular) +double YPSpur_get_force(double* trans, double* angular) { return YPSpur_md_get_force(&spur, trans, angular); } @@ -232,19 +232,19 @@ int YP_set_parameter(int param_id, double value) } /* 内部パラメータの変更 */ -int YP_set_parameter_array(int param_id, double *value) +int YP_set_parameter_array(int param_id, double* value) { return YP_md_set_parameter_array(&spur, param_id, value); } /* 内部パラメータの取得 */ -int YP_get_parameter(int param_id, double *value) +int YP_get_parameter(int param_id, double* value) { return YP_md_get_parameter(&spur, param_id, value); } /* 内部パラメータの取得 */ -int YP_get_parameter_array(int param_id, double *value) +int YP_get_parameter_array(int param_id, double* value) { return YP_md_get_parameter_array(&spur, param_id, value); } @@ -351,22 +351,22 @@ int YP_set_joint_vel(int id, double v) return YP_md_set_joint_vel(&spur, id, v); } -double YP_get_joint_vel(int id, double *v) +double YP_get_joint_vel(int id, double* v) { return YP_md_get_joint_vel(&spur, id, v); } -double YP_get_joint_vref(int id, double *v) +double YP_get_joint_vref(int id, double* v) { return YP_md_get_joint_vref(&spur, id, v); } -double YP_get_joint_ang(int id, double *a) +double YP_get_joint_ang(int id, double* a) { return YP_md_get_joint_ang(&spur, id, a); } -double YP_get_joint_torque(int id, double *w) +double YP_get_joint_torque(int id, double* w) { return YP_md_get_joint_torque(&spur, id, w); } diff --git a/src/msq.win32.c b/src/msq.win32.c index b288a30..9949127 100644 --- a/src/msq.win32.c +++ b/src/msq.win32.c @@ -35,7 +35,7 @@ #include HANDLE g_shm = NULL; -void *g_shm_data; +void* g_shm_data; HANDLE g_mutex = NULL; int msgget(key_t key, int msgflg) @@ -45,13 +45,13 @@ int msgget(key_t key, int msgflg) _stprintf(name, "MessageQueueShm%d", (int)key); g_shm = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 8192, name); - g_shm_data = (void *)MapViewOfFile(g_shm, FILE_MAP_ALL_ACCESS, 0, 0, 8192); + g_shm_data = (void*)MapViewOfFile(g_shm, FILE_MAP_ALL_ACCESS, 0, 0, 8192); _stprintf(name, "MessageQueueMutex%d", (int)key); if (msgflg & IPC_CREAT) { g_mutex = CreateMutex(NULL, FALSE, name); - *((int32_t *)g_shm_data) = 0; + *((int32_t*)g_shm_data) = 0; } else { @@ -65,9 +65,9 @@ int msgget(key_t key, int msgflg) return 1; } -int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) +int msgsnd(int msqid, const void* msgp, size_t msgsz, int msgflg) { - char *pos; + char* pos; if (WaitForSingleObject(g_mutex, INFINITE) == WAIT_FAILED) { @@ -78,37 +78,37 @@ int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) msgsz += sizeof(long); // add size of msg_type - pos = (char *)g_shm_data; + pos = (char*)g_shm_data; while (1) { int32_t size; - size = *(int32_t *)pos; + size = *(int32_t*)pos; if (size == 0) break; pos += sizeof(int32_t) + size; } - if ((char *)pos + msgsz + sizeof(int32_t) - (char *)g_shm_data > 8192) + if ((char*)pos + msgsz + sizeof(int32_t) - (char*)g_shm_data > 8192) return 0; - *((int32_t *)pos) = (int32_t)msgsz; + *((int32_t*)pos) = (int32_t)msgsz; pos += sizeof(int32_t); memcpy(pos, msgp, msgsz); pos += msgsz; - *((int32_t *)pos) = 0; + *((int32_t*)pos) = 0; ReleaseMutex(g_mutex); return 1; } -ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) +ssize_t msgrcv(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg) { - char *pos; - char *pos_before; - char *pos_target; + char* pos; + char* pos_before; + char* pos_target; int32_t readsize; msgsz += sizeof(long); // add size of msg_type @@ -123,19 +123,19 @@ ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) return -1; } - pos = (char *)g_shm_data; + pos = (char*)g_shm_data; pos_target = NULL; while (1) { int32_t size; - int32_t *ptype; + int32_t* ptype; - size = *(int32_t *)pos; + size = *(int32_t*)pos; if (size == 0) break; pos_before = pos; - ptype = (int32_t *)(pos_before + sizeof(int32_t)); + ptype = (int32_t*)(pos_before + sizeof(int32_t)); if (((*ptype == msgtyp && msgtyp > 0) || (*ptype <= -msgtyp && msgtyp < 0)) && !pos_target) { pos_target = pos_before; @@ -144,18 +144,18 @@ ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) } if (pos_target) { - char *pos_next; + char* pos_next; int32_t sizeleft; - if (*((int32_t *)pos_target) < msgsz) + if (*((int32_t*)pos_target) < msgsz) { - readsize = *((int32_t *)pos_target); + readsize = *((int32_t*)pos_target); } else { readsize = msgsz; } - pos_next = pos_target + sizeof(int32_t) + *((int32_t *)pos_target); + pos_next = pos_target + sizeof(int32_t) + *((int32_t*)pos_target); sizeleft = pos - pos_next + 1; memcpy(msgp, pos_target + sizeof(int32_t), readsize); memcpy(pos_target, pos_next, sizeleft); @@ -176,7 +176,7 @@ ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) return readsize; } -int msgctl(int msqid, int cmd, struct msqid_ds *buf) +int msgctl(int msqid, int cmd, struct msqid_ds* buf) { switch (cmd) { diff --git a/src/odometry.c b/src/odometry.c index f3975af..8eef3bb 100644 --- a/src/odometry.c +++ b/src/odometry.c @@ -129,7 +129,7 @@ CSptr get_cs_pointer(YPSpur_cs cs) return NULL; } -void cstrans_xy(YPSpur_cs src, YPSpur_cs dest, double *x, double *y, double *theta) +void cstrans_xy(YPSpur_cs src, YPSpur_cs dest, double* x, double* y, double* theta) { if (src == dest) return; @@ -142,14 +142,14 @@ void set_cs(YPSpur_cs cs, double x, double y, double theta) } /* オドメトリ計算 */ -void odometry(OdometryPtr xp, short *cnt, short *pwm, double dt, double time) +void odometry(OdometryPtr xp, short* cnt, short* pwm, double dt, double time) { double v, w; double wvel[YP_PARAM_MAX_MOTOR_NUM], mvel[YP_PARAM_MAX_MOTOR_NUM]; double mtorque[YP_PARAM_MAX_MOTOR_NUM], wtorque[YP_PARAM_MAX_MOTOR_NUM]; double volt[YP_PARAM_MAX_MOTOR_NUM], vc[YP_PARAM_MAX_MOTOR_NUM]; double torque_trans, torque_angular; - Parameters *param; + Parameters* param; param = get_param_ptr(); int i; @@ -248,7 +248,7 @@ void odometry(OdometryPtr xp, short *cnt, short *pwm, double dt, double time) void process_int4( OdometryPtr xp, ErrorStatePtr err, int param_id, int id, int value, double receive_time) { - Parameters *param; + Parameters* param; param = get_param_ptr(); switch (param_id) @@ -467,16 +467,18 @@ double time_synchronize(double receive_time, int readnum, int wp) } /* シリアル受信処理 */ -int odometry_receive(char *buf, int len, double receive_time, void *data) +int odometry_receive(char* buf, int len, double receive_time, void* data) { static int com_wp = 0; static int receive_count = 0; static char com_buf[128]; - static enum + + typedef enum { ISOCHRONOUS = 0, INTERRUPT - } mode = 0; + } OdometryDataMode; + static OdometryDataMode mode = 0; int i; int odometry_updated; @@ -492,7 +494,7 @@ int odometry_receive(char *buf, int len, double receive_time, void *data) Short_2Char pwm1_log[100]; Short_2Char pwm2_log[100]; int ad_log[100][8]; - Parameters *param; + Parameters* param; param = get_param_ptr(); @@ -522,7 +524,7 @@ int odometry_receive(char *buf, int len, double receive_time, void *data) unsigned char data[48]; /* デコード処理 */ - decoded_len = decode((unsigned char *)com_buf, com_wp, (unsigned char *)data, 48); + decoded_len = decode((unsigned char*)com_buf, com_wp, (unsigned char*)data, 48); switch (mode) { @@ -649,7 +651,7 @@ int odometry_receive(char *buf, int len, double receive_time, void *data) int odometry_receive_loop(void) { int ret; - Parameters *param; + Parameters* param; param = get_param_ptr(); g_interval = SER_INTERVAL; diff --git a/src/param.c b/src/param.c index f60d5d3..a787914 100644 --- a/src/param.c +++ b/src/param.c @@ -56,7 +56,7 @@ double g_P[YP_PARAM_NUM][YP_PARAM_MAX_MOTOR_NUM]; int g_P_changed[YP_PARAM_NUM][YP_PARAM_MAX_MOTOR_NUM]; int g_P_set[YP_PARAM_NUM][YP_PARAM_MAX_MOTOR_NUM]; -struct rpf_t *g_Pf[YP_PARAM_NUM][YP_PARAM_MAX_MOTOR_NUM]; +struct rpf_t* g_Pf[YP_PARAM_NUM][YP_PARAM_MAX_MOTOR_NUM]; char g_state[YP_STATE_NUM]; Parameters g_param; int g_param_init = 1; @@ -91,7 +91,7 @@ int ischanged_p(YPSpur_param id, enum motor_id motor) return g_P_changed[id][motor]; } -double *pp(YPSpur_param id, enum motor_id motor) +double* pp(YPSpur_param id, enum motor_id motor) { return &g_P[id][motor]; } @@ -117,7 +117,7 @@ int is_character(int c); int is_number(int c); /* 引数の説明 */ -void arg_help(int argc, char *argv[]) +void arg_help(int argc, char* argv[]) { fprintf(stderr, "USAGE: %s [OPTION]...\n\n", argv[0]); fprintf(stderr, " -v, --version Display version info and exit.\n"); @@ -131,7 +131,7 @@ void arg_help(int argc, char *argv[]) } /* 隠しコマンドの説明 */ -void arg_longhelp(int argc, char *argv[]) +void arg_longhelp(int argc, char* argv[]) { arg_help(argc, argv); fprintf(stderr, " -o, --show-odometry Display estimated robot position.\n"); @@ -172,7 +172,7 @@ void param_help(void) } /* 引数の解析 */ -int arg_analyze(int argc, char *argv[]) +int arg_analyze(int argc, char* argv[]) { int i; @@ -241,7 +241,7 @@ int arg_analyze(int argc, char *argv[]) { if (i + 1 < argc) { - char *pos; + char* pos; i++; g_param.admask = 0; @@ -451,7 +451,7 @@ void param_calc() } /* パラメータファイルからの読み込み */ -int set_paramptr(FILE *paramfile) +int set_paramptr(FILE* paramfile) { char param_names[YP_PARAM_NUM][20] = YP_PARAM_NAME; char param_names0[YP_PARAM_NUM][24] = YP_PARAM_NAME; @@ -460,23 +460,43 @@ int set_paramptr(FILE *paramfile) #define VARIABLE_NUM 37 char variable_names[VARIABLE_NUM][20] = { - "X", "Y", "THETA", "V", "W", - "WHEEL_VEL[0]", "WHEEL_VEL[1]", - "WHEEL_VEL[2]", "WHEEL_VEL[3]", - "WHEEL_VEL[4]", "WHEEL_VEL[5]", - "WHEEL_VEL[6]", "WHEEL_VEL[7]", - "WHEEL_VEL[8]", "WHEEL_VEL[9]", - "WHEEL_VEL[10]", "WHEEL_VEL[11]", - "WHEEL_VEL[12]", "WHEEL_VEL[13]", - "WHEEL_VEL[14]", "WHEEL_VEL[15]", - "WHEEL_ANGLE[0]", "WHEEL_ANGLE[1]", - "WHEEL_ANGLE[2]", "WHEEL_ANGLE[3]", - "WHEEL_ANGLE[4]", "WHEEL_ANGLE[5]", - "WHEEL_ANGLE[6]", "WHEEL_ANGLE[7]", - "WHEEL_ANGLE[8]", "WHEEL_ANGLE[9]", - "WHEEL_ANGLE[10]", "WHEEL_ANGLE[11]", - "WHEEL_ANGLE[12]", "WHEEL_ANGLE[13]", - "WHEEL_ANGLE[14]", "WHEEL_ANGLE[15]", + "X", + "Y", + "THETA", + "V", + "W", + "WHEEL_VEL[0]", + "WHEEL_VEL[1]", + "WHEEL_VEL[2]", + "WHEEL_VEL[3]", + "WHEEL_VEL[4]", + "WHEEL_VEL[5]", + "WHEEL_VEL[6]", + "WHEEL_VEL[7]", + "WHEEL_VEL[8]", + "WHEEL_VEL[9]", + "WHEEL_VEL[10]", + "WHEEL_VEL[11]", + "WHEEL_VEL[12]", + "WHEEL_VEL[13]", + "WHEEL_VEL[14]", + "WHEEL_VEL[15]", + "WHEEL_ANGLE[0]", + "WHEEL_ANGLE[1]", + "WHEEL_ANGLE[2]", + "WHEEL_ANGLE[3]", + "WHEEL_ANGLE[4]", + "WHEEL_ANGLE[5]", + "WHEEL_ANGLE[6]", + "WHEEL_ANGLE[7]", + "WHEEL_ANGLE[8]", + "WHEEL_ANGLE[9]", + "WHEEL_ANGLE[10]", + "WHEEL_ANGLE[11]", + "WHEEL_ANGLE[12]", + "WHEEL_ANGLE[13]", + "WHEEL_ANGLE[14]", + "WHEEL_ANGLE[15]", }; struct variables_t variables[YP_PARAM_NUM * 3 + 1 + VARIABLE_NUM]; struct @@ -617,8 +637,8 @@ int set_paramptr(FILE *paramfile) } if (read_state != 3) { - char *num_start; - char *num_end = NULL; + char* num_start; + char* num_end = NULL; int num; param_num = YP_PARAM_NUM; @@ -930,9 +950,9 @@ int set_paramptr(FILE *paramfile) } /* パラメータファイルからの読み込み */ -int set_param(char *filename, char *concrete_path) +int set_param(char* filename, char* concrete_path) { - FILE *paramfile; + FILE* paramfile; paramfile = fopen(filename, "r"); if (!paramfile) @@ -940,8 +960,8 @@ int set_param(char *filename, char *concrete_path) #if HAVE_PKG_CONFIG char dir_name[256]; char file_name[256]; - char *pret; - FILE *fd; + char* pret; + FILE* fd; #endif // HAVE_PKG_CONFIG yprintf(OUTPUT_LV_DEBUG, "Warn: File [%s] is not exist.\n", filename); @@ -949,8 +969,8 @@ int set_param(char *filename, char *concrete_path) #if HAVE_PKG_CONFIG if (!strchr(filename, '/')) { - /* ファイルが見つからないとき、かつパス指定でないときshareディレクトリを見に行く - */ + /* ファイルが見つからないとき、かつパス指定でないときshareディレクトリを見に行く + */ fd = popen("pkg-config --variable=YP_PARAMS_DIR yp-robot-params", "r"); if ((fd == NULL)) { @@ -1000,21 +1020,21 @@ int set_param(char *filename, char *concrete_path) return set_paramptr(paramfile); } -void init_param_update_thread(pthread_t *thread, char *filename) +void init_param_update_thread(pthread_t* thread, char* filename) { g_param.parameter_applying = 0; - if (pthread_create(thread, NULL, (void *)param_update, filename) != 0) + if (pthread_create(thread, NULL, (void*)param_update, filename) != 0) { yprintf(OUTPUT_LV_ERROR, "Can't create command thread\n"); } } -void param_update_loop_cleanup(void *data) +void param_update_loop_cleanup(void* data) { yprintf(OUTPUT_LV_INFO, "Parameter updater stopped.\n"); } -void param_update(void *filename) +void param_update(void* filename) { struct stat prev_status; diff --git a/src/serial.c b/src/serial.c index ee0d386..c3e7684 100644 --- a/src/serial.c +++ b/src/serial.c @@ -175,7 +175,7 @@ DWORD i2baud(int baud) #endif // !defined(__MINGW32__) // ポートが接続可能か調べる -int serial_tryconnect(char *device_name) +int serial_tryconnect(char* device_name) { #if !defined(__MINGW32__) // Unix用 @@ -198,11 +198,11 @@ int serial_tryconnect(char *device_name) return 1; } -int recieve_throw(char *buf, int len, double t, void *data) +int recieve_throw(char* buf, int len, double t, void* data) { buf[len] = 0; - strcat((char *)data, buf); - if (strstr((char *)data, "\n\n")) + strcat((char*)data, buf); + if (strstr((char*)data, "\n\n")) { return -2; } @@ -317,7 +317,7 @@ int serial_change_baudrate(int baud) } // ポートをオープンして 通信の準備をする -int serial_connect(char *device_name) +int serial_connect(char* device_name) { #if !defined(__MINGW32__) g_device_port = open(device_name, O_RDWR); @@ -431,7 +431,7 @@ void serial_flush_out(void) } // シリアルポートからの受信処理 -int serial_recieve(int (*serial_event)(char *, int, double, void *), void *data) +int serial_recieve(int (*serial_event)(char*, int, double, void*), void* data) { char buf[4096]; double receive_time; @@ -527,16 +527,16 @@ int serial_recieve(int (*serial_event)(char *, int, double, void *), void *data) } } -int encode_write(char *data, int len) +int encode_write(char* data, int len) { unsigned char buf[128]; int encode_len, ret; buf[0] = COMMUNICATION_START_BYTE; - encode_len = encode((unsigned char *)data, len, buf + 1, 126); + encode_len = encode((unsigned char*)data, len, buf + 1, 126); buf[encode_len + 1] = COMMUNICATION_END_BYTE; - ret = serial_write((char *)buf, encode_len + 2); + ret = serial_write((char*)buf, encode_len + 2); if (ret <= 0) { return -1; @@ -546,16 +546,16 @@ int encode_write(char *data, int len) return 0; } -int encode_int_write(char *data, int len) +int encode_int_write(char* data, int len) { unsigned char buf[128]; int encode_len, ret; buf[0] = COMMUNICATION_INT_BYTE; - encode_len = encode((unsigned char *)data, len, buf + 1, 126); + encode_len = encode((unsigned char*)data, len, buf + 1, 126); buf[encode_len + 1] = COMMUNICATION_END_BYTE; - ret = serial_write((char *)buf, encode_len + 2); + ret = serial_write((char*)buf, encode_len + 2); if (ret <= 0) { return -1; @@ -565,7 +565,7 @@ int encode_int_write(char *data, int len) return 0; } -int serial_write(char *buf, int len) +int serial_write(char* buf, int len) { #if !defined(__MINGW32__) // Unix用 @@ -592,7 +592,8 @@ int serial_write(char *buf, int len) } len -= ret; buf += ret; - } while (len > 0); + } + while (len > 0); #ifdef __APPLE__ yp_usleep(100); diff --git a/src/ssm_spur_handler.c b/src/ssm_spur_handler.c index 1a324fa..ff374f0 100644 --- a/src/ssm_spur_handler.c +++ b/src/ssm_spur_handler.c @@ -94,8 +94,8 @@ void end_ypspurSSM() } void write_ypspurSSM(int odometry_updated, int receive_count, - Odometry *odm_log, int readdata_num, Short_2Char *cnt1_log, Short_2Char *cnt2_log, - Short_2Char *pwm1_log, Short_2Char *pwm2_log, int ad_log[][8]) + Odometry* odm_log, int readdata_num, Short_2Char* cnt1_log, Short_2Char* cnt2_log, + Short_2Char* pwm1_log, Short_2Char* pwm2_log, int ad_log[][8]) { #ifdef HAVE_SSM if (g_ssm_enable) @@ -140,7 +140,7 @@ void write_ypspurSSM(int odometry_updated, int receive_count, } /* オドメトリ修正情報との融合 */ -void coordinate_synchronize(Odometry *odm, SpurUserParamsPtr spur) +void coordinate_synchronize(Odometry* odm, SpurUserParamsPtr spur) { #ifdef HAVE_SSM static double before_time; @@ -173,12 +173,12 @@ void coordinate_synchronize(Odometry *odm, SpurUserParamsPtr spur) /* パラメータの変更がおこらないようにブロック */ pthread_mutex_lock(&spur->mutex); // 最新の修正位置 - if ((tid = readSSM(g_odm_adj_sid, (char *)&adj_odometry, &now_time, -1)) >= 0) + if ((tid = readSSM(g_odm_adj_sid, (char*)&adj_odometry, &now_time, -1)) >= 0) { // 同時刻のGL座標 if (now_time > get_time() - 1) { - if ((tid = readSSM_time(g_odm_bs_sid, (char *)&bs_odometry, now_time, &time)) >= 0) + if ((tid = readSSM_time(g_odm_bs_sid, (char*)&bs_odometry, now_time, &time)) >= 0) { // 時間が1秒以内(止まっていない)で、データがあるなら実行 /* 座標系作成 */ @@ -195,7 +195,7 @@ void coordinate_synchronize(Odometry *odm, SpurUserParamsPtr spur) /* 微妙な差を付け加える */ inv_trans_cs(&adj_cs, &target_pos.x, &target_pos.y, &target_pos.theta); - double data[3] = { target_pos.x, target_pos.y, target_pos.theta }; + double data[3] = {target_pos.x, target_pos.y, target_pos.theta}; set_adjust_com(CS_GL, data, spur); } } diff --git a/src/utility.c b/src/utility.c index d56ce94..126da4d 100644 --- a/src/utility.c +++ b/src/utility.c @@ -80,7 +80,7 @@ void hook_pre_global() #if !defined(HAVE_STRTOK_R) #ifndef strtok_r -/* +/* * public domain strtok_r() by Charlie Gordon * from comp.lang.c 9/14/2007 * http://groups.google.com/group/comp.lang.c/msg/2ab1ecbb86646684 @@ -88,9 +88,9 @@ void hook_pre_global() * http://groups.google.com/group/comp.lang.c/msg/7c7b39328fefab9c */ -char *strtok_r(char *str, const char *delim, char **nextp) +char* strtok_r(char* str, const char* delim, char** nextp) { - char *ret; + char* ret; if (str == NULL) str = *nextp; diff --git a/src/ypprotocol.c b/src/ypprotocol.c index 684daf2..08ffa21 100644 --- a/src/ypprotocol.c +++ b/src/ypprotocol.c @@ -39,15 +39,15 @@ #define RECEIVE_BUFFER_SIZE 2048 -int ss_receive(char *buf, int len, double receive_time, void *data) +int ss_receive(char* buf, int len, double receive_time, void* data) { buf[len] = 0; - if (len + strlen((char *)data) > RECEIVE_BUFFER_SIZE) + if (len + strlen((char*)data) > RECEIVE_BUFFER_SIZE) { return -3; } - strcat((char *)data, buf); - if (strstr((char *)data, "\n\n")) + strcat((char*)data, buf); + if (strstr((char*)data, "\n\n")) { return -2; } @@ -88,15 +88,15 @@ int set_baudrate(int baud) return 0; } -int vv_receive(char *buf, int len, double receive_time, void *data) +int vv_receive(char* buf, int len, double receive_time, void* data) { buf[len] = 0; - if (len + strlen((char *)data) > RECEIVE_BUFFER_SIZE) + if (len + strlen((char*)data) > RECEIVE_BUFFER_SIZE) { return -3; } - strcat((char *)data, buf); - if (strstr((char *)data, "\n\n")) + strcat((char*)data, buf); + if (strstr((char*)data, "\n\n")) { return -2; } @@ -108,7 +108,7 @@ int vv_receive(char *buf, int len, double receive_time, void *data) @param *apVer Pointer to version structure @return failed: 0, succeeded: 1 */ -int get_version(Ver_t *apVer) +int get_version(Ver_t* apVer) { /* Send & Recive Buffer */ char buf[RECEIVE_BUFFER_SIZE], *readpos; @@ -183,7 +183,7 @@ int get_version(Ver_t *apVer) @param *apVer Pointer to version structure @return failed: 0, succeeded: 1 */ -int get_parameter(Param_t *apParam) +int get_parameter(Param_t* apParam) { /* Send & Recive Buffer */ char buf[RECEIVE_BUFFER_SIZE], *readpos; @@ -245,12 +245,12 @@ int get_parameter(Param_t *apParam) return 1; } -int get_embedded_param(char *param) +int get_embedded_param(char* param) { /* Send & Recive Buffer */ char buf[RECEIVE_BUFFER_SIZE], *readpos; /* Temporary */ - char *lf; + char* lf; readpos = buf; memset(buf, 0, sizeof(buf)); diff --git a/src/yprintf.c b/src/yprintf.c index 832b9ef..2fde85c 100644 --- a/src/yprintf.c +++ b/src/yprintf.c @@ -29,7 +29,7 @@ #include -void yprintf(ParamOutputLv level, const char *format, ...) +void yprintf(ParamOutputLv level, const char* format, ...) { va_list ap; diff --git a/src/ypspur-coordinator.c b/src/ypspur-coordinator.c index e074a29..66bc075 100644 --- a/src/ypspur-coordinator.c +++ b/src/ypspur-coordinator.c @@ -135,7 +135,7 @@ void escape_road(const int enable) } /* main */ -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { pthread_t command_thread; pthread_t control_thread; @@ -230,7 +230,7 @@ int main(int argc, char *argv[]) command_thread_en = 0; do { - FILE *temp_paramfile = NULL; + FILE* temp_paramfile = NULL; quit = 0; yprintf(OUTPUT_LV_INFO, "Device Information\n"); @@ -576,7 +576,8 @@ int main(int argc, char *argv[]) continue; } break; - } while (1); + } + while (1); if (!(option(OPTION_WITHOUT_DEVICE))) serial_close(); diff --git a/src/ypspur-free.c b/src/ypspur-free.c index 6b97691..585ba18 100644 --- a/src/ypspur-free.c +++ b/src/ypspur-free.c @@ -30,13 +30,13 @@ #include #include -int main(int argc, char **argv) +int main(int argc, char** argv) { hook_pre_global(); if (argc > 1) { char ip[64]; - char *p; + char* p; int port; strncpy(ip, argv[1], 64); diff --git a/src/ypspur-interpreter.c b/src/ypspur-interpreter.c index 5164e5d..f9bdadb 100644 --- a/src/ypspur-interpreter.c +++ b/src/ypspur-interpreter.c @@ -105,60 +105,59 @@ typedef struct SPUR_COMMAND } SpurCommand; static const SpurCommand SPUR_COMMAND[SPUR_COMMAND_MAX] = { - { SPUR_LINE, { "line" }, 3 }, - { SPUR_STOP_LINE, { "stop_line" }, 3 }, - { SPUR_CIRCLE, { "circle" }, 3 }, - { SPUR_SPIN, { "spin" }, 1 }, - { SPUR_GETPOS, { "get_pos" }, 0 }, - { SPUR_GETVEL, { "get_vel" }, 0 }, - { SPUR_GETFORCE, { "get_force" }, 0 }, - { SPUR_SETPOS, { "set_pos" }, 3 }, - { SPUR_NEAR_POS, { "near_pos" }, 3 }, - { SPUR_NEAR_ANG, { "near_ang" }, 2 }, - { SPUR_OVER_LINE, { "over_line" }, 3 }, - { SPUR_ADJUSTPOS, { "adjust_pos" }, 3 }, - { SPUR_SETVEL, { "set_vel" }, 1 }, - { SPUR_SETANGVEL, { "set_angvel" }, 1 }, - { SPUR_SETACCEL, { "set_accel" }, 1 }, - { SPUR_SETANGACCEL, { "set_angaccel" }, 1 }, - { SPUR_FREE, { "free" }, 0 }, - { SPUR_OPENFREE, { "openfree" }, 0 }, - { SPUR_STOP, { "stop" }, 0 }, - { SPUR_INIT, { "init" }, 0 }, - { SPUR_FREEZE, { "freeze" }, 0 }, - { SPUR_UNFREEZE, { "unfreeze" }, 0 }, - { SPUR_ISFREEZE, { "isfreeze" }, 0 }, - { SPUR_GETAD, { "get_ad_value" }, 1 }, - { SPUR_SET_IO_DIR, { "set_io_dir" }, 1 }, - { SPUR_SET_IO_DATA, { "set_io_data" }, 1 }, - { SPUR_GET_DEVICE_ERROR_STATE, { "get_device_error_state" }, 1 }, - { SPUR_VEL, { "vel" }, 2 }, - { SPUR_WHEEL_VEL, { "wheel_vel" }, 2 }, - { SPUR_GET_WHEEL_VEL, { "get_wheel_vel" }, 0 }, - { SPUR_GET_WHEEL_ANG, { "get_wheel_ang" }, 0 }, - { SPUR_GET_WHEEL_TORQUE, { "get_wheel_torque" }, 0 }, - { SPUR_WHEEL_TORQUE, { "wheel_torque" }, 2 }, - { SPUR_ORIENT, { "orient" }, 1 }, - { SPUR_GET_VREF, { "get_vref" }, 0 }, - { SPUR_GET_WHEEL_VREF, { "get_wheel_vref" }, 0 }, - { SPUR_SET_WHEEL_VEL, { "set_wheel_vel" }, 2 }, - { SPUR_SET_WHEEL_ACCEL, { "set_wheel_accel" }, 2 }, - { SPUR_WHEEL_ANG, { "wheel_ang" }, 2 }, - { SPUR_JOINT_TORQUE, { "joint_torque" }, 2 }, - { SPUR_JOINT_VEL, { "joint_vel" }, 2 }, - { SPUR_JOINT_ANG, { "joint_ang" }, 2 }, - { SPUR_JOINT_ANG_VEL, { "joint_ang_vel" }, 3 }, - { SPUR_SET_JOINT_ACCEL, { "set_joint_accel" }, 2 }, - { SPUR_SET_JOINT_VEL, { "set_joint_vel" }, 2 }, - { SPUR_GET_JOINT_VEL, { "get_joint_vel" }, 1 }, - { SPUR_GET_JOINT_VREF, { "get_joint_vref" }, 1 }, - { SPUR_GET_JOINT_ANG, { "get_joint_ang" }, 1 }, - { SPUR_GET_JOINT_TORQUE, { "get_joint_torque" }, 1 }, - { SPUR_SLEEP, { "sleep" }, 1 }, - { SPUR_REQUEST_DEVICE_DUMP, { "request_device_dump" }, 2 }, - { HELP, { "help" }, 0 }, - { EXIT, { "exit" }, 0 } -}; + {SPUR_LINE, {"line"}, 3}, + {SPUR_STOP_LINE, {"stop_line"}, 3}, + {SPUR_CIRCLE, {"circle"}, 3}, + {SPUR_SPIN, {"spin"}, 1}, + {SPUR_GETPOS, {"get_pos"}, 0}, + {SPUR_GETVEL, {"get_vel"}, 0}, + {SPUR_GETFORCE, {"get_force"}, 0}, + {SPUR_SETPOS, {"set_pos"}, 3}, + {SPUR_NEAR_POS, {"near_pos"}, 3}, + {SPUR_NEAR_ANG, {"near_ang"}, 2}, + {SPUR_OVER_LINE, {"over_line"}, 3}, + {SPUR_ADJUSTPOS, {"adjust_pos"}, 3}, + {SPUR_SETVEL, {"set_vel"}, 1}, + {SPUR_SETANGVEL, {"set_angvel"}, 1}, + {SPUR_SETACCEL, {"set_accel"}, 1}, + {SPUR_SETANGACCEL, {"set_angaccel"}, 1}, + {SPUR_FREE, {"free"}, 0}, + {SPUR_OPENFREE, {"openfree"}, 0}, + {SPUR_STOP, {"stop"}, 0}, + {SPUR_INIT, {"init"}, 0}, + {SPUR_FREEZE, {"freeze"}, 0}, + {SPUR_UNFREEZE, {"unfreeze"}, 0}, + {SPUR_ISFREEZE, {"isfreeze"}, 0}, + {SPUR_GETAD, {"get_ad_value"}, 1}, + {SPUR_SET_IO_DIR, {"set_io_dir"}, 1}, + {SPUR_SET_IO_DATA, {"set_io_data"}, 1}, + {SPUR_GET_DEVICE_ERROR_STATE, {"get_device_error_state"}, 1}, + {SPUR_VEL, {"vel"}, 2}, + {SPUR_WHEEL_VEL, {"wheel_vel"}, 2}, + {SPUR_GET_WHEEL_VEL, {"get_wheel_vel"}, 0}, + {SPUR_GET_WHEEL_ANG, {"get_wheel_ang"}, 0}, + {SPUR_GET_WHEEL_TORQUE, {"get_wheel_torque"}, 0}, + {SPUR_WHEEL_TORQUE, {"wheel_torque"}, 2}, + {SPUR_ORIENT, {"orient"}, 1}, + {SPUR_GET_VREF, {"get_vref"}, 0}, + {SPUR_GET_WHEEL_VREF, {"get_wheel_vref"}, 0}, + {SPUR_SET_WHEEL_VEL, {"set_wheel_vel"}, 2}, + {SPUR_SET_WHEEL_ACCEL, {"set_wheel_accel"}, 2}, + {SPUR_WHEEL_ANG, {"wheel_ang"}, 2}, + {SPUR_JOINT_TORQUE, {"joint_torque"}, 2}, + {SPUR_JOINT_VEL, {"joint_vel"}, 2}, + {SPUR_JOINT_ANG, {"joint_ang"}, 2}, + {SPUR_JOINT_ANG_VEL, {"joint_ang_vel"}, 3}, + {SPUR_SET_JOINT_ACCEL, {"set_joint_accel"}, 2}, + {SPUR_SET_JOINT_VEL, {"set_joint_vel"}, 2}, + {SPUR_GET_JOINT_VEL, {"get_joint_vel"}, 1}, + {SPUR_GET_JOINT_VREF, {"get_joint_vref"}, 1}, + {SPUR_GET_JOINT_ANG, {"get_joint_ang"}, 1}, + {SPUR_GET_JOINT_TORQUE, {"get_joint_torque"}, 1}, + {SPUR_SLEEP, {"sleep"}, 1}, + {SPUR_REQUEST_DEVICE_DUMP, {"request_device_dump"}, 2}, + {HELP, {"help"}, 0}, + {EXIT, {"exit"}, 0}}; #if HAVE_SIGLONGJMP sigjmp_buf ctrlc_capture; @@ -172,12 +171,12 @@ void ctrlc(int num) #endif // HAVE_SIGLONGJMP } -int proc_spur_cmd(char *line, int *coordinate) +int proc_spur_cmd(char* line, int* coordinate) { int i; SpurCommand spur; int lcoordinate; - char *argv; + char* argv; int ret; int ad; int error; @@ -186,7 +185,7 @@ int proc_spur_cmd(char *line, int *coordinate) MODE_COMMAND, MODE_ARG } mode = MODE_COMMAND; - char *toksave; + char* toksave; spur.id = -1; lcoordinate = *coordinate; @@ -448,10 +447,10 @@ int proc_spur_cmd(char *line, int *coordinate) return 1; } -int proc_spur(char *line, int *coordinate) +int proc_spur(char* line, int* coordinate) { - char *line_div; - char *toksave; + char* line_div; + char* toksave; int ret; ret = 0; @@ -468,7 +467,7 @@ int proc_spur(char *line, int *coordinate) return ret; } -void print_help(char *argv[]) +void print_help(char* argv[]) { fprintf(stderr, "USAGE: %s\n", argv[0]); fputs("\t-V | --set-vel VALUE : [m/s] set max vel of SPUR to VALUE\n", stderr); @@ -481,7 +480,7 @@ void print_help(char *argv[]) fputs("\t-h | --help : print this help\n", stderr); } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { int coordinate = CS_FS; char ip[64]; @@ -499,16 +498,15 @@ int main(int argc, char *argv[]) int msqid = 0; struct option options[9] = { - { "set-vel", 1, 0, 'V' }, - { "set-angvel", 1, 0, 'W' }, - { "set-accel", 1, 0, 'A' }, - { "set-angaccel", 1, 0, 'O' }, - { "command", 1, 0, 'c' }, - { "msq-id", 1, 0, 'q' }, - { "socket", 1, 0, 's' }, - { "help", 0, 0, 'h' }, - { 0, 0, 0, 0 } - }; + {"set-vel", 1, 0, 'V'}, + {"set-angvel", 1, 0, 'W'}, + {"set-accel", 1, 0, 'A'}, + {"set-angaccel", 1, 0, 'O'}, + {"command", 1, 0, 'c'}, + {"msq-id", 1, 0, 'q'}, + {"socket", 1, 0, 's'}, + {"help", 0, 0, 'h'}, + {0, 0, 0, 0}}; int opt; hook_pre_global(); @@ -549,7 +547,7 @@ int main(int argc, char *argv[]) case 's': strncpy(ip, optarg, 64); { - char *p; + char* p; p = strchr(ip, ':'); if (p == NULL) { @@ -596,8 +594,8 @@ int main(int argc, char *argv[]) #endif // HAVE_LIBREADLINE while (active) { - static char *line = NULL; - static char *line_prev = NULL; + static char* line = NULL; + static char* line_prev = NULL; char text[16]; #if !HAVE_LIBREADLINE #if HAVE_GETLINE diff --git a/test/param_load.cpp b/test/param_load.cpp index f8cac67..5d4cf74 100644 --- a/test/param_load.cpp +++ b/test/param_load.cpp @@ -26,7 +26,8 @@ #include #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif // __cplusplus #include @@ -41,7 +42,7 @@ extern Parameters g_param; class ParamLoadTest : public ::testing::Test { protected: - FILE *fp; + FILE* fp; virtual void SetUp() { @@ -175,7 +176,7 @@ TEST_F(ParamLoadTest, EncoderDenominatorSupported) ASSERT_DOUBLE_EQ(p(static_cast(YP_PARAM_ENCODER_DENOMINATOR), MOTOR_LEFT), 5.0); } -int main(int argc, char **argv) +int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv);