CCPE — 飞机系统

Create: Aeronautics 的电传飞控系统。
支持 ComputerCraft: Tweaked 的传感器、执行器、驾驶舱和引擎——读取飞船的物理状态全貌,并以 20 Hz 的 Minecraft 刻频率进行控制。
Wiki · 示例 · GitHub · 更新日志
本模组存在的意义
Create: Aeronautics 赋予您的机械装置真实的物理特性:带有质量、升力、推力和扭矩的精细子层级结构。但它没有提供闭环控制的方法。原生接口是红石,而红石从未为飞行控制而设计:
- 一切都是 4 位的。 万向节传感器在其默认 ±45° 范围内将姿态量化为每步 3.1°(在 ±90° 时为 6.2°)。默认高度传感器在整个世界高度上仅分为 15 步——即每步 25.6 米。速度传感器给出每步 0.67 m/s,带有 0.05 m/s 的死区,且符号位位于不同的面上。
- 链路很长。 传感器 → 红石中继 → 比较器/模拟传输 → 机械轴承的成本为端到端 3–4 刻(典型值为 150–200 毫秒)。您为“目标值减去实际值”回路添加的每一个比较器阶段都会增加 1–2 刻的延迟,而且误差仍然是 4 位的。
- 没有控制律。 红石只能表达静态比率、开关和定时器。它无法表达四元数 PD、级联、前馈、增益调度、带滞环的死区、看门狗——或者事后分析的 CSV 日志。
CCPE 用 传感器 → Lua → 执行器 替换了该链路,运行在相同的 20 Hz 刻上,但使用双精度浮点数和真正的代码:
|
红石链路 |
CCPE Lua 链路 |
| 信号 |
0–15, 4 位, 无符号, 按面 |
double, 有符号, 三个轴 |
| 姿态读数 |
3.1°/步 (±45°), 6.2° (±90°) |
精确的四元数, 无 4 位步进 |
| 高度读数 |
25.6 m/步 (默认范围) |
米, 飞行中精度达 0.1 米以下 |
| 速度读数 |
0.67 m/s/步 + 0.05 m/s 死区 |
m/s, 静止时恰好为 0 |
| 传感器 → 执行器 |
3–4 刻 (150–200 ms) |
2–3 刻 (100–150 ms) |
| 执行器分辨率 |
16 个速度档位, 开/关, 开环 1° |
推力 0.00–1.00, 角度伺服 |
| 控制律 |
静态比率, 开关, 比较器 |
PD / 级联 / 前馈 / 看门狗 |
两条链路都受限于 Minecraft 的 20 Hz 刻——本模组不会超越这个刻率限制。 它消除的是 4 位量化和红石转换带来的额外 1–2 刻延迟。根据源研究估算的闭环带宽:红石为 0.2–0.5 Hz,而 CCPE 的姿态控制为 0.5–1 Hz。位置控制和终端制导在 CCPE 下为 0.1–0.3 Hz——这一限制在于空气动力学结构,而非导线。
飞行中的实际感受
这些数字来自模组自带飞行项目的实测数据,而非估算:
- 20 Hz 控制循环——整个自动驾驶飞行过程中,周期时间为 0.048 / 0.050 / 0.052 秒(最小值 / 中位数 / 最大值)。
- 0.15 秒从
setThrustScale 阶跃到可见的物理响应。
- ±0.06 米的高度保持。
- 引导进近时的终端误差为 0.42 米,Starship 式捕获时为 0.2 米;撞击后姿态在 1.5 秒内恢复到 cos = 1.00。
- 演示视频:Starship Flight 15 捕获——五个矢量喷嘴,一个 AIC,两台计算机,飞向塔楼并被其机械臂捕获。
这些都不是什么超越刻率的技巧。这就是当每一刻都承载真实数值和真正控制器时的 20 Hz 表现。
Hello, world:一个 20 Hz 控制循环
local ss = require("ccpe.sensor_system")
local elev = assert(peripheral.wrap("left"), "servo bearing (elevator) missing")
local ail = assert(peripheral.wrap("right"), "servo bearing (aileron) missing")
local eng = assert(ss.getEngine(), "need exactly one engine on this body")
elev.assemble() -- once, after placing each control surface
ail.assemble()
local TARGET_PITCH, TARGET_ROLL = 5, 0 -- degrees
local TARGET_ALT = 120 -- metres
local KP, KD, ALT_KP = 1.5, 0.4, 0.02
while true do
local a, r = ss.getAngles(), ss.getAngleRates() -- free: cache reads
local alt, v = ss.getAltitude(), ss.getVelocity()
if not (a and r and alt and v) then error("need an INS and a static port") end
local pitch = math.max(-25, math.min(25, KP * (TARGET_PITCH - a.pitch) - KD * r.pitchRate))
local roll = math.max(-25, math.min(25, KP * (TARGET_ROLL - a.roll ) - KD * r.rollRate))
local thr = math.max(0, math.min(1, 0.5 + ALT_KP * (TARGET_ALT - alt) - 0.5 * v.y))
-- one parallel block = one tick of writes, however many are in it
parallel.waitForAll(
function() elev.setTargetAngle(pitch) end,
function() ail.setTargetAngle(roll) end,
function() eng.setThrottle(thr) end
)
-- no sleep: the block above already costs exactly one tick
end
每个 set... 方法都被排队到服务器主线程,并在下一刻开始时返回。在一个 parallel.waitForAll 中批量提交,它们都会落入同一刻,因此整个循环——读取、计算、指令——恰好花费 一克(20 Hz)。如果逐个调用,每次写入都会占用自己的一刻(四次顺序写入测得为 4 Hz);分成两个并行块则得到 10 Hz;在一个块中包含 10–14 次写入仍能以 20 Hz 运行。这是每个示例程序使用的模式。增益和符号因空气动力学结构而异——从小处开始。完整的自动驾驶(自动滚转、自动油门、高度保持)位于 教练机示例 中——附带可下载的世界文件。
包含内容
🛰️ Sense — 传感器系统
一个 Lua 模块 require("ccpe.sensor_system"),其作用域限定于计算机所在的飞船。静压孔(压力、高度)、皮托管(地面与空中速度)、惯性导航系统 (INS)(姿态、四元数、角速率、速度)、飞行管理计算机 (FMC)(质量、重力、质心、应力、螺旋桨与空气动力学求解器)、自动集成控制器 (AIC)(INS + FMC 整合为一个方块),以及一个将每个刻(tick)的数据记录为 CSV 的 飞行数据记录仪。读数每刻刷新一次,且不占用主线程开销。
🎮 Command — 执行器
- 高级推力喷嘴 — 可在 15° 锥体内指向任意方向,2 pN/RPM,推力和偏转由 Lua 驱动。
- 气动轴承 — 具有轴向动力的 Sable 物理轴承;在 Lua 模式下,角度可直接写入。
- 伺服轴承 — 纯 Lua 角度伺服,刚性连接,无需动力输入,无视觉爬行现象。
- 电子变速箱 — 专为 CC:T: 设计的速度控制器:支持 0.01 RPM 步进、反转和伺服模式。
- 引擎系统 — 模块化多方块动力;油门设定转速,燃料消耗跟随应力负载而非油门开度。
🪑 Cockpit — 驾驶舱
- 控制台 — 坐下即可飞行:摇杆、节流阀、踏板和屏幕,均可通过 Lua 读取。
- 模块化显示器 — 一个由按钮、开关、旋钮和屏幕组成的 12×10 网格,可自行放置和编写脚本。
🔌 Connect — 连接
- 外设扩展器 — 基于通道的 NBT 传输、远程外设调用、无线红石、区块加载。
- 红石收发器 — 读取并发送 Create Redstone Link 频率,无需堆叠链接方块。
- 短程信号链接器 — 针对物理方块的独立通道和红石 I/O。
它不会做什么
- 它无法超越游戏刻。 所有采样率均为 20 Hz,而物理引擎仍以 60 Hz 运行。可用的闭环带宽低于 2 Hz;高频振动仍需依靠质量和阻尼来处理。
- 它不会绕过物理引擎。 推力、惯性、约束和碰撞仍完全由 Sable 处理。
- 它不会让红石过时。 对于缓慢配平、限位开关和安全保持等场景,红石仍然是合适的工具。
起源
CCPE 最初并非作为一个飞行器模组开发。它始于 CC Navigation Table,这是一个从导航表中读取坐标的小型附加组件。随后出现了 Microcontrollers —— 一个与 CC:Tweaked 不同的电脑模组,其传感器可通过通道无线连接,并直接读取目标方块的 NBT,无需针对每个模组的外设适配器。这种“通用传感器”理念演变成了 Peripheral Extender。
此后,我发现依赖的其他模组无法满足我的需求,等待他人更新的感觉比我亲自编写还要慢。于是,模组逐步成长,涵盖了整个链条——传感器 → 飞行计算机 → 执行器 → 引擎——直到“外设扩展器”这一名称不再能描述它。因此,它现在更名为 CCPE — Aircraft Systems(原称 CC Peripheral Extender)。
该模组仍在开发中。如果缺少某些功能,或者你有关于方块或 API 的想法,请提交功能请求。
依赖项
- NeoForge 1.21.1
- CC:Tweaked 1.118.0+
- Create 6.0.10+
- Simulated (Create: Aeronautics) 1.3.0+
- Sable 2.0.3+
链接
CCPE — Aircraft Systems

Fly-by-wire for Create: Aeronautics.
Sensors, actuators, cockpits and engines that speak ComputerCraft: Tweaked — read the whole physical state of a ship and command it at the 20 Hz Minecraft tick.
Wiki · Examples · GitHub · Changelog
Why this mod exists
Create: Aeronautics gives your contraption real physics: Sable sub-levels with mass, lift, thrust and torque. What it does not give you is a way to close a control loop. The native interface is redstone, and redstone was never designed for flight control:
- Everything is 4-bit. A gimbal sensor quantises attitude to 3.1° per step at its default ±45° range (6.2° at ±90°). A default altitude sensor spans the entire world height in 15 steps — 25.6 m each. A velocity sensor gives 0.67 m/s per step with a 0.05 m/s dead zone, and the sign lives on a different face.
- The chain is long. Sensor → redstone link → comparator / analog transmission → mechanical bearing costs 3–4 ticks end to end (150–200 ms typical). Every comparator stage you add for a "target minus actual" loop costs another 1–2 ticks, and the error is still 4-bit.
- There is no control law. Redstone can express a static ratio, a switch and a timer. It cannot express a quaternion PD, a cascade, feedforward, gain scheduling, a deadband with hysteresis, a watchdog — or a CSV log you can analyse afterwards.
CCPE replaces that chain with sensor → Lua → actuator on the same 20 Hz tick, but with doubles and real code:
|
Redstone chain |
CCPE Lua chain |
| Signal |
0–15, 4-bit, unsigned, per-face |
double, signed, three axes |
| Attitude reading |
3.1°/step (±45°), 6.2° (±90°) |
exact quaternion, no 4-bit steps |
| Altitude reading |
25.6 m/step (default range) |
metres, sub-0.1 m in flight |
| Speed reading |
0.67 m/s/step + 0.05 m/s dead zone |
m/s, exactly 0 at rest |
| Sensor → actuator |
3–4 ticks (150–200 ms) |
2–3 ticks (100–150 ms) |
| Actuator resolution |
16 speed steps, on/off, open-loop 1° |
thrust 0.00–1.00, angle servo |
| Control law |
static ratio, switch, comparator |
PD / cascade / feedforward / watchdog |
Both chains are capped by Minecraft's 20 Hz tick — this mod does not beat the tick. What it removes is the 4-bit quantisation and the 1–2 extra ticks of redstone conversion. Closed-loop bandwidth estimated from the source study: 0.2–0.5 Hz with redstone versus 0.5–1 Hz for attitude with CCPE. Position and terminal guidance sit at 0.1–0.3 Hz with CCPE — that limit is the airframe, not the wire.
What that feels like in flight
Numbers measured in the mod's own flight projects, not estimated:
- 20 Hz control loop — cycle time 0.048 / 0.050 / 0.052 s (min / median / max) over a full autopilot flight.
- 0.15 s from a
setThrustScale step to a visible physical response.
- ±0.06 m altitude hold.
- 0.42 m terminal error on a guided approach, 0.2 m on a Starship-style catch; attitude recovered to cos = 1.00 1.5 s after an impact.
- Demo: a Starship Flight 15 catch — five vector nozzles, one AIC, two computers, flown to the tower and caught by its arms.
None of that is a faster-than-tick trick. It is what 20 Hz looks like when every tick carries real numbers and a real controller.
Hello, world: a 20 Hz control loop
local ss = require("ccpe.sensor_system")
local elev = assert(peripheral.wrap("left"), "servo bearing (elevator) missing")
local ail = assert(peripheral.wrap("right"), "servo bearing (aileron) missing")
local eng = assert(ss.getEngine(), "need exactly one engine on this body")
elev.assemble() -- once, after placing each control surface
ail.assemble()
local TARGET_PITCH, TARGET_ROLL = 5, 0 -- degrees
local TARGET_ALT = 120 -- metres
local KP, KD, ALT_KP = 1.5, 0.4, 0.02
while true do
local a, r = ss.getAngles(), ss.getAngleRates() -- free: cache reads
local alt, v = ss.getAltitude(), ss.getVelocity()
if not (a and r and alt and v) then error("need an INS and a static port") end
local pitch = math.max(-25, math.min(25, KP * (TARGET_PITCH - a.pitch) - KD * r.pitchRate))
local roll = math.max(-25, math.min(25, KP * (TARGET_ROLL - a.roll ) - KD * r.rollRate))
local thr = math.max(0, math.min(1, 0.5 + ALT_KP * (TARGET_ALT - alt) - 0.5 * v.y))
-- one parallel block = one tick of writes, however many are in it
parallel.waitForAll(
function() elev.setTargetAngle(pitch) end,
function() ail.setTargetAngle(roll) end,
function() eng.setThrottle(thr) end
)
-- no sleep: the block above already costs exactly one tick
end
Every set... method is queued onto the server main thread and returns at the start of the next tick. Batched in one parallel.waitForAll, they all land in that same tick, so the whole loop — read, compute, command — costs exactly one tick (20 Hz). Called one by one, each write would take its own tick (four sequential writes measured 4 Hz); split across two parallel blocks you get 10 Hz; 10–14 writes in one block still run at 20 Hz. This is the pattern every example program uses. Gains and signs are airframe-specific — start small. The full autopilot (auto-roll, auto-throttle, altitude hold) is in the trainer aircraft example — with a downloadable world.
What's in the box
🛰️ Sense — Sensor System
One Lua module, require("ccpe.sensor_system"), body-scoped to the ship your computer is standing on. Static port (pressure, altitude), pitot tube (ground and air speed), INS (attitude, quaternion, angular rate, velocity), FMC (mass, gravity, centre of mass, stress, propeller and aero solvers), AIC (INS + FMC in one block), plus a flight data recorder that logs every tick to CSV. Readings refresh once per tick and cost the main thread nothing.
🎮 Command — actuators
- Advanced Thrust Nozzle — points anywhere inside a 15° cone, 2 pN/RPM, thrust scale and deflection driven from Lua.
- Aero Bearing — Sable-physics bearing with axial power; in Lua mode the angle is written directly.
- Servo Bearing — pure Lua angle servo, rigid, no power input, no visual crawl.
- Electronic Transmission — a speed controller built for CC:T: 0.01 RPM steps, reverse, servo mode.
- Engine System — modular multi-block power; throttle sets speed, fuel burn follows the stress load instead of the throttle.
🪑 Cockpit
- Control Desk — sit down and fly: joysticks, throttles, pedals and screens, all readable from Lua.
- Modular Monitor — a 12×10 grid of buttons, toggles, knobs and screens you place and script yourself.
🔌 Connect
What it won't do
- It will not beat the tick. Everything samples at 20 Hz and the physics still runs at 60 Hz. Usable closed-loop bandwidth is under 2 Hz; high-frequency vibration is still a job for mass and damping.
- It will not bypass physics. Thrust, inertia, constraints and collisions are all still Sable's.
- It will not make redstone obsolete. For slow trim, limit switches and dead-man hold, redstone is still the right tool.
Where this came from
CCPE did not start as an aircraft mod. It started as CC Navigation Table, a tiny addon that read the coordinates out of the navigation table. Then came Microcontrollers — a computer mod distinct from CC:Tweaked, whose Sensor connected wirelessly over channels and read the target block's NBT directly, with no per-mod peripheral adapter. That "universal sensor" idea became the Peripheral Extender.
After that, the mods I depended on could not do what I wanted, and waiting for someone else's update felt slower than writing it myself. One block at a time the mod grew the whole chain — sensors → flight computers → actuators → engines — until "peripheral extender" no longer described it. So it is now CCPE — Aircraft Systems (formerly CC Peripheral Extender).
It is still in development. If something is missing, or you have an idea for a block or an API, open a feature request.
Requirements
- NeoForge 1.21.1
- CC:Tweaked 1.118.0+
- Create 6.0.10+
- Simulated (Create: Aeronautics) 1.3.0+
- Sable 2.0.3+
Links
评论 0
登录后参与评分
还没有评论,来抢沙发吧