mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 03:27:45 +08:00
删除了message center的指针传递支持,增加了定位bug的技巧文档
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
// app
|
||||
#include "balance.h"
|
||||
#include "vmc_project.h"
|
||||
#include "gain_table.h"
|
||||
#include "robot_def.h"
|
||||
#include "general_def.h"
|
||||
// module
|
||||
#include "HT04.h"
|
||||
#include "LK9025.h"
|
||||
#include "bmi088.h"
|
||||
@@ -6,9 +12,8 @@
|
||||
#include "super_cap.h"
|
||||
#include "controller.h"
|
||||
#include "can_comm.h"
|
||||
// standard
|
||||
#include "stdint.h"
|
||||
#include "robot_def.h"
|
||||
#include "general_def.h"
|
||||
#include "arm_math.h" // 需要用到较多三角函数
|
||||
|
||||
/* 底盘拥有的模块实例 */
|
||||
@@ -47,7 +52,7 @@ static float T_leg_left, T_leg_right; // 左右驱动电机力矩
|
||||
*
|
||||
*/
|
||||
static void CalcLQR()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,15 +60,15 @@ static void CalcLQR()
|
||||
*
|
||||
*/
|
||||
static void VMCProject()
|
||||
{
|
||||
{ // 拟将功能封装到vmc_project.h中
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 腿部角度控制:转向和抗劈叉
|
||||
*
|
||||
*/
|
||||
static PIDInstance swerving_pid;
|
||||
static PIDInstance anti_crash_pid;
|
||||
static PIDInstance swerving_pid; // 转向PID,有转向指令时使用IMU的加速度反馈积分以获取速度和位置状态量
|
||||
static PIDInstance anti_crash_pid; // 抗劈叉,将输出以相反的方向叠加到左右腿的上
|
||||
|
||||
static void SynthesizeMotion()
|
||||
{
|
||||
@@ -73,15 +78,16 @@ static void SynthesizeMotion()
|
||||
* @brief 腿长控制:长度 + roll轴补偿(保持机体水平),用PD模拟弹簧的传递函数
|
||||
*
|
||||
*/
|
||||
static PIDInstance leg_length_pid;
|
||||
static PIDInstance roll_compensate_pid;
|
||||
static PIDInstance leg_length_pid; // 用PD模拟弹簧的传递函数,不需要积分项(弹簧是一个无积分的二阶系统),增益不可过大否则抗外界冲击响应时太"硬"
|
||||
static PIDInstance roll_compensate_pid; // roll轴补偿,用于保持机体水平
|
||||
|
||||
static void LegControl()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 离地监测和?跳跃控制
|
||||
* @brief 离地监测和?跳跃控制?
|
||||
* 通过模型解算地面的支持力完成离地检测
|
||||
*
|
||||
*/
|
||||
static void FlyDetect()
|
||||
@@ -89,7 +95,7 @@ static void FlyDetect()
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 功率限制
|
||||
* @brief 功率限制,一般不需要
|
||||
*
|
||||
*/
|
||||
static void WattLimit()
|
||||
@@ -242,6 +248,7 @@ void BalanceInit()
|
||||
PIDInit(&roll_compensate_pid, &roll_compensate_pid_conf);
|
||||
}
|
||||
|
||||
/* balanceTask可能需要以更高频率运行,以提高线性化的精确程度 */
|
||||
void BalanceTask()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
#include "stm32f407xx.h"
|
||||
#include "arm_math.h"
|
||||
#include "math.h"
|
||||
|
||||
#define GAIN_TABLE_SIZE 100 // 增益表大小
|
||||
|
||||
// K 2x6,6个状态变量2个输出(Tp关节电机和T驱动轮电机)
|
||||
static float leglen2gain [GAIN_TABLE_SIZE][2][6] = {};
|
||||
static float leglen2gain [GAIN_TABLE_SIZE][2][6] = {0};
|
||||
|
||||
static interpolation_flag = 0; // 插值方式:1 线性插值 0 关闭插值
|
||||
|
||||
|
||||
14
application/balance_chassis/vmc_project.h
Normal file
14
application/balance_chassis/vmc_project.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef VMC_PROJECT_H
|
||||
#define VMC_PROJECT_H
|
||||
|
||||
#include "stm32f407xx.h"
|
||||
#include "arm_math.h"
|
||||
#include "math.h"
|
||||
#include "general_def.h"
|
||||
|
||||
// 将五连杆和直杆的vmc映射放在此处,方便修改和调试,balance.c不会太长
|
||||
#endif // !VMC_PROJECT_H
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "ins_task.h"
|
||||
#include "message_center.h"
|
||||
#include "general_def.h"
|
||||
|
||||
#include "bmi088.h"
|
||||
|
||||
static attitude_t *gimba_IMU_data; // 云台IMU数据
|
||||
@@ -136,6 +135,7 @@ void GimbalTask()
|
||||
// 后续增加未收到数据的处理
|
||||
SubGetMessage(gimbal_sub, &gimbal_cmd_recv);
|
||||
|
||||
// @todo:现在已不再需要电机反馈,实际上可以始终使用IMU的姿态数据来作为云台的反馈,yaw电机的offset只是用来跟随底盘
|
||||
// 根据控制模式进行电机反馈切换和过渡,视觉模式在robot_cmd模块就已经设置好,gimbal只看yaw_ref和pitch_ref
|
||||
switch (gimbal_cmd_recv.gimbal_mode)
|
||||
{
|
||||
@@ -170,6 +170,10 @@ void GimbalTask()
|
||||
break;
|
||||
}
|
||||
|
||||
// 在合适的地方添加pitch重力补偿前馈力矩
|
||||
// 根据IMU姿态/pitch电机角度反馈计算出当前配重下的重力矩
|
||||
// ...
|
||||
|
||||
// 设置反馈数据,主要是imu和yaw的ecd
|
||||
gimbal_feedback_data.gimbal_imu_data = *gimba_IMU_data;
|
||||
gimbal_feedback_data.yaw_motor_single_round_angle = yaw_motor->motor_measure.angle_single_round;
|
||||
|
||||
Reference in New Issue
Block a user