Skip to content

Commit

Permalink
Format source files by clang-format (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat authored Mar 22, 2024
1 parent e86c482 commit c5da19c
Show file tree
Hide file tree
Showing 50 changed files with 686 additions and 587 deletions.
69 changes: 69 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
15 changes: 8 additions & 7 deletions auxlib/cartesian2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
#define __AUXLIB_CARTESIAN2D_H

#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif // __cplusplus

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct cs_t *CSptr;
typedef struct cs_t* CSptr;
typedef struct cs_t
{
double x;
Expand All @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions auxlib/libcarte2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int CS_delete(CSptr target_cs)

if (target_cs)
{
free((void *)target_cs);
free((void*)target_cs);
}
return 1;
}
Expand Down Expand Up @@ -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;

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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;
Expand Down
28 changes: 14 additions & 14 deletions auxlib/libodomssm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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;

Expand Down
13 changes: 7 additions & 6 deletions auxlib/odometry-ssm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions include/adinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
#include <strings.h>
#include <unistd.h>

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);
Expand Down
Loading

0 comments on commit c5da19c

Please sign in to comment.