feat(example): 新增飞行控制 C 示例项目
- 提供传感器、滤波、控制律和执行器等模块化示例 - 包含约 35 个函数用于代码分析与文档生成流程测试 - 使用 Makefile 支持最小化编译验证
This commit is contained in:
35
src/actuators.c
Normal file
35
src/actuators.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "flight_app.h"
|
||||
|
||||
void Actuator_Init(ActuatorState *actuator) {
|
||||
actuator->throttle = 0.0f;
|
||||
actuator->elevator = 0.0f;
|
||||
actuator->armed = 0U;
|
||||
}
|
||||
|
||||
void Actuator_Arm(ActuatorState *actuator) {
|
||||
actuator->armed = 1U;
|
||||
}
|
||||
|
||||
void Actuator_WriteThrottle(ActuatorState *actuator, float throttle) {
|
||||
if (actuator->armed) {
|
||||
actuator->throttle = Filter_Limit(throttle, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void Actuator_WriteElevator(ActuatorState *actuator, float elevator) {
|
||||
if (actuator->armed) {
|
||||
actuator->elevator = Filter_Limit(elevator, -20.0f, 20.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void Actuator_UpdateOutputs(ActuatorState *actuator) {
|
||||
Actuator_Arm(actuator);
|
||||
Actuator_WriteThrottle(actuator, actuator->throttle);
|
||||
Actuator_WriteElevator(actuator, actuator->elevator);
|
||||
}
|
||||
|
||||
void Actuator_Disarm(ActuatorState *actuator) {
|
||||
actuator->armed = 0U;
|
||||
actuator->throttle = 0.0f;
|
||||
actuator->elevator = 0.0f;
|
||||
}
|
||||
Reference in New Issue
Block a user