Compare commits

..

No commits in common. "main" and "main" have entirely different histories.
main ... main

79 changed files with 45435 additions and 45594 deletions

File diff suppressed because one or more lines are too long

View File

@ -62,7 +62,8 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
User/component/pid.c
User/component/user_math.c
User/component/crc16.c
User/component/PowerControl.c
/home/shentou/workspace/SuperCap/god-yuan-hero/User/component/PowerControl.c
# User/device sources
User/device/dr16.c
User/device/AT9S_Pro.c
@ -71,7 +72,8 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
User/device/motor_dm.c
User/device/motor_rm.c
User/device/vofa.c
User/device/supercap.c
/home/shentou/workspace/SuperCap/god-yuan-hero/User/device/supercap.c
# User/module sources
User/module/chassis.c
User/module/config.c
@ -88,7 +90,7 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
User/task/init.c
User/task/rc.c
User/task/user_task.c
User/task/supercap.c
/home/shentou/workspace/SuperCap/god-yuan-hero/User/task/supercap.c
)
# Add include paths

View File

@ -27,3 +27,4 @@ void power_out_calu(power_model_t* param,float scale,float* in_array,float* rpm_
#endif
#endif

View File

@ -93,46 +93,7 @@ Config_RobotParam_t robot_config = {
.max_current = 16000.0f
},
},
.track_param = {
.motor = {
{
.can = BSP_CAN_1,
.id = 0x205,
.module = MOTOR_M3508,
.reverse = false,
.gear = true,
},
{
.can = BSP_CAN_1,
.id = 0x206,
.module = MOTOR_M3508,
.reverse = true,
.gear = true,
},
},
.pid = {
{
.k = 0.001f,
.p = 1.0f,
.i = 0.0f,
.d = 0.0f,
.i_limit = 1.0f,
.out_limit = 1.0f,
.d_cutoff_freq = -1.0f,
.range = -1.0f,
},
{
.k = 0.001f,
.p = 1.0f,
.i = 0.0f,
.d = 0.0f,
.i_limit = 1.0f,
.out_limit = 1.0f,
.d_cutoff_freq = -1.0f,
.range = -1.0f,
},
},
},
.gimbal_param = {
.pid = {
.yaw_omega = {
@ -189,7 +150,7 @@ Config_RobotParam_t robot_config = {
.gyro = 1000.0f,
},
.pit_motor ={
.can = BSP_CAN_2,
.can = BSP_CAN_1,
.can_id = 0x2,
.master_id = 0x12,
.module = MOTOR_DM_J4310,

View File

@ -15,14 +15,12 @@ extern "C" {
#include "module/shoot.h"
#include "module/gimbal.h"
#include "module/chassis.h"
#include "module/track.h"
#include "module/cmd.h"
#include "component/PowerControl.h"
typedef struct {
Shoot_Params_t shoot_param;
Gimbal_Params_t gimbal_param;
Chassis_Params_t chassis_param;
Track_Params_t track_param;
CMD_Params_t cmd_param;
} Config_RobotParam_t;

View File

@ -32,7 +32,7 @@ void Task(void *argument) {
/* Includes ----------------------------------------------------------------- */
#include <string.h>
#include "shoot_Master&Slave.h"
#include "shoot.h"
#include "bsp/mm.h"
#include "bsp/time.h"
#include "component/filter.h"

View File

@ -1,57 +0,0 @@
/*
*
*/
/* Includes ----------------------------------------------------------------- */
#include <math.h>
#include <string.h>
#include "track.h"
#include "bsp/mm.h"
#include "bsp/time.h"
#include "component/filter.h"
#include "component/user_math.h"
/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* Private function -------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
uint8_t TRACK_Init(Track_t *t, Track_Params_t *param, float target_freq)
{
if (t == NULL || param == NULL) {
return TRACK_ERR_NULL; // 参数错误
}
t->param = param;
for (int i=0; i<TRACK_MOTOR_NUM; i++) {
PID_Init(&t->pid[i], KPID_MODE_CALC_D, target_freq, &param->pid[i]);
}
return TRACK_OK;
}
uint8_t TRACK_Control(Track_t *t, Track_CMD_t *cmd)
{
if (t == NULL || cmd == NULL) {
return TRACK_ERR_NULL; // 参数错误
}
t->timer.now = BSP_TIME_Get_us()/1000000.0f;
t->timer.dt = t->timer.now - t->timer.lask_wakeup/1000000.0f;
t->timer.lask_wakeup = BSP_TIME_Get_us();
for (int i=0; i<TRACK_MOTOR_NUM; i++) {
t->output.iout[i] = PID_Calc(&t->pid[i], cmd->vel, t->motor.feedback.rotor_speed, 0.0f, t->timer.dt);
MOTOR_RM_SetOutput(&t->param->motor[i], t->output.iout[i]);
}
MOTOR_RM_Ctrl(&t->param->motor[0]);
return TRACK_OK;
}

View File

@ -1,64 +0,0 @@
/*
* far
*/
#pragma once
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "main.h"
#include "component/pid.h"
#include "device/motor_rm.h"
/* Exported constants ------------------------------------------------------- */
#define TRACK_MOTOR_NUM 2
#define TRACK_CMD_RPM_MAX 8000.0f
#define TRACK_OK (0) /* 运行正常 */
#define TRACK_ERR_NULL (-1) /* 运行时发现NULL指针 */
#define TRACK_ERR_ERR (-2) /* 运行时发现了其他错误 */
#define TRACK_ERR_MODE (-3) /* 运行时配置了错误的Mode */
#define TRACK_ERR_MOTOR (-4) /* 运行时配置了不存在的电机类型 */
#define TRACK_ERR_MALLOC (-5) /* 内存分配失败 */
/* Exported macro ----------------------------------------------------------- */
/* Exported types ----------------------------------------------------------- */
typedef struct {
float now; /* 当前时间,单位秒 */
uint64_t lask_wakeup; /* 上次唤醒时间,单位微秒 */
float dt; /* 两次唤醒间隔时间,单位秒 */
} Track_Timer_t;
typedef struct {
MOTOR_RM_Param_t motor[TRACK_MOTOR_NUM];
KPID_Params_t pid[TRACK_MOTOR_NUM];
} Track_Params_t;
typedef struct {
bool enable;
float vel;
} Track_CMD_t;
typedef struct {
Track_Params_t *param;
Track_Timer_t timer;
KPID_t pid[TRACK_MOTOR_NUM];
MOTOR_RM_t motor;
struct {
float iout[TRACK_MOTOR_NUM];
}output;
} Track_t;
/* Exported functions prototypes -------------------------------------------- */
#ifdef __cplusplus
}
#endif

View File

@ -1 +0,0 @@
/home/shentou/workspace/SuperCap/god-yuan-hero/./build/Debug/compile_commands.json