Skip to content

Commit

Permalink
11.18
Browse files Browse the repository at this point in the history
  • Loading branch information
Luo25177 committed Nov 18, 2023
1 parent edfb5dc commit 227ed0a
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 105 deletions.
7 changes: 4 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BreakBeforeBraces: Custom
BraceWrapping:
Expand All @@ -59,7 +59,7 @@ BreakConstructorInitializersBeforeComma: false
BreakInheritanceList: AfterComma
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
ColumnLimit: 132
ColumnLimit: 100
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: true
ConstructorInitializerIndentWidth: 4
Expand Down Expand Up @@ -156,3 +156,4 @@ SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 4
UseTab: Always

25 changes: 16 additions & 9 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Checks: '-*,

Checks: '-*,
misc-throw-by-value-catch-by-reference,
misc-misplaced-const,
misc-unconventional-assign-operator,
Expand Down Expand Up @@ -39,7 +40,7 @@
readability-deleted-default,
readability-make-member-function-const,
readability-misplaced-array-index,
readability-non-const-parameter,
<!-- readability-non-const-parameter, -->
readability-qualified-auto,
readability-redundant-access-specifiers,
readability-redundant-control-flow,
Expand Down Expand Up @@ -156,9 +157,9 @@ WarningsAsErrors: '*'

CheckOptions:
- key: readability-identifier-naming.ClassCase
value: camelCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: camelBack
value: CamelCase
- key: readability-identifier-naming.LocalVariableCase
value: camelBack
- key: readability-identifier-naming.StaticConstantCase
Expand All @@ -171,16 +172,15 @@ CheckOptions:
value: ''
- key: readability-identifier-naming.ProtectedMemberPrefix
value: ''
- key: readability-identifier-naming.GlobalVariablePrefix
value: g

- key: readability-identifier-naming.GlobalConstantCase
value: camelBack
value: UPPER_CASE
- key: readability-identifier-naming.GlobalConstantPrefix
value: ''
- key: readability-identifier-naming.PublicMemberCase
value: camelBack
- key: readability-identifier-naming.MethodCase
value: camelCase
value: CamelCase
- key: readability-identifier-naming.PrivateMethodPrefix
value: ''
- key: readability-identifier-naming.ProtectedMethodPrefix
Expand All @@ -202,4 +202,11 @@ CheckOptions:
- key: readability-identifier-naming.UsingCase
value: CamelCase
- key: readability-identifier-naming.GlobalFunctionCase
value: CamelCase
value: CamelCase
value: Camel_Snake_Case
# - key: readability-identifier-naming.GlobalConstantPointerPrefix
# value: p_
# - key: readability-identifier-naming.GlobalPointerPrefix
# value: p_
- key: readability-identifier-naming.GlobalVariablePrefix
value: g_
6 changes: 3 additions & 3 deletions Chassis/src/robot.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ void robotInit() {
legInit(&robot->legL, LEGLEFT, motorL, motorLF, motorLB);
legInit(&robot->legR, LEGRIGHT, motorR, motorRF, motorRB);
legInit(&robot->legVir, LEGLEFT, NULL, NULL, NULL);
// TODO: 参数暂定 调节

robot->yawpid = (PID *) malloc(sizeof(PID));
robot->rollpid = (PID *) malloc(sizeof(PID));
robot->splitpid = (PID *) malloc(sizeof(PID));
robot->L0pid = (PID *) malloc(sizeof(PID));

// TODO: 参数暂定 调节
pidInit(robot->yawpid, 1, 1, 1, 0, 0, PIDPOS);
pidInit(robot->rollpid, 1, 1, 1, 0, 0, PIDPOS);
pidInit(robot->splitpid, 1, 1, 1, 0, 0, PIDPOS);
Expand All @@ -50,8 +52,6 @@ void updateState() {
robot->legR.TWheelnow = robot->legR.wheel->currentRead * M3508CURRENTTOTORQUE;

flyCheck();


}

//----
Expand Down
11 changes: 11 additions & 0 deletions Function/src/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ float TposCompute(PID* pid, float input) {
return pid->output;
}

//----
// @brief PID初始化,设置kp,ki,kd 选定pid模式
//
// @param pid
// @param kp
// @param ki
// @param kd
// @param outputLimit
// @param accErrLimit
// @param mode
//----
void pidInit(PID* pid, float kp, float ki, float kd, float outputLimit, float accErrLimit, pidMode mode) {
pid->kp = kp;
pid->ki = ki;
Expand Down
12 changes: 6 additions & 6 deletions Main/inc/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
// @brief 蓝牙通讯
// @version 1.0
// @date 2023-11-17
//
//
// @copyright Copyright (c) 2023
//
//
//----
#pragma once

#include <stdlib.h>
#include <stdbool.h>
#include "stm32f4xx.h"
Expand All @@ -29,13 +30,12 @@ typedef struct {
u8 txDataSize;

bool gethead;
}BlueToothMsg;
} BlueToothMsg;

extern BlueToothMsg* bluetoothmsg;
extern BlueToothMsg *bluetoothmsg;

void blueToothInit();
void blueToothReceive(u8 data);
void blueToothDeal();
void blueToothClear();
void blueToothSend(u8 id, void* data, u8 size);

void blueToothSend(u8 id, void *data, u8 size);
19 changes: 10 additions & 9 deletions Main/inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// @brief main函数,主程序
// @version 1.0
// @date 2023-11-17
//
//
// @copyright Copyright (c) 2023
//
//
//----
#pragma once

Expand All @@ -19,6 +19,7 @@
#include "os_cfg.h"
#include "os_cpu.h"
#include "ucos_ii.h"
#include "masterparam.h"

#define TASK_STK_SIZE 256

Expand All @@ -27,21 +28,21 @@ OS_STK taskStartStk[TASK_STK_SIZE];
OS_STK taskLedStk[TASK_STK_SIZE];
OS_STK taskBeepStk[TASK_STK_SIZE];

OS_EVENT* beepShowSem;
OS_EVENT *beepShowSem;
u8 beepShowErr;

extern u8 beepShowErr;
extern OS_EVENT* beepShowSem;
extern OS_EVENT *beepShowSem;
extern OS_STK taskStartStk[TASK_STK_SIZE];

#define START_TASK_PRIO 5
static void taskStart(void* pdata);
static void taskStart(void *pdata);

#define LED_TASK_PRIO 12
static void taskLed(void* pdata);
#define LED_TASK_PRIO 12
static void taskLed(void *pdata);

#define BEEP_TASK_PRIO 11
static void taskBeep(void* pdata);
static void taskBeep(void *pdata);

#define RUN_TASK_PRIO 6
static void taskRun(void* pdata);
static void taskRun(void *pdata);
17 changes: 17 additions & 0 deletions Main/inc/controlparam.h → Main/inc/masterparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//----

#pragma once

#include <stdbool.h>
#include "stm32f4xx.h"

//----
Expand All @@ -35,3 +37,18 @@ typedef struct {
bool begin; // 开始运行
bool stop; // 急停 打算做一个功能就是为了防止程序疯跑,再怎么说没有急停开关好用
}ControlParam;

//----
// @brief 主控参数
//
//----
typedef struct {
HandleParam handle;
ControlParam control;
}Master;

extern Master master;

void HandleParamInit(HandleParam* handleparam);
void ControlParamInit(ControlParam* controlparam);
void MasterInit(Master* master);
5 changes: 4 additions & 1 deletion Main/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(){
tim2Init();
tim3Init();

// robotInit();
robotInit();

OSInit();
OSTaskCreate(taskStart, (void*) 0, &taskStartStk[TASK_STK_SIZE - 1], START_TASK_PRIO); // 创建初始任务
Expand Down Expand Up @@ -62,6 +62,9 @@ static void taskRun(void* pdata) {
pdata = pdata;
while (1) {
updateState();
if(master.control.begin){
robotRun();
}
OSTimeDly(100);
}
}
25 changes: 25 additions & 0 deletions Main/src/masterparam.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "masterparam.h"

Master master;

void HandleParamInit(HandleParam* handleparam) {
handleparam->forward = 0;
handleparam->backward = 0;
handleparam->left = 0;
handleparam->right = 0;
handleparam->up = 0;
handleparam->down = 0;
handleparam->tiltleft = 0;
handleparam->tiltright = 0;
}

void ControlParamInit(ControlParam* controlparam) {
controlparam->begin = false;
controlparam->stop = true;
}

void MasterInit(Master* master) {
HandleParamInit(&master->handle);
ControlParamInit(&master->control);
}

Loading

0 comments on commit 227ed0a

Please sign in to comment.