
嵌入式物联网机器人自动驾驶智能硬件【免费下载链接】PX4-AutopilotPX4 Autopilot Software项目地址https://gitcode.com/gh_mirrors/px/PX4-Autopilot点击查看免费下载本指南聚焦 PX4-Autopilot 中的InternalCombustionEngineStatusuORB 消息它是内燃机ICEInternal Combustion Engine状态反馈的标准数据接口由internal_combustion_engine_control模块状态机、DroneCAN 传感器桥等发布被 MAVLinkEFI_STATUS流、飞行日志系统订阅消费。读完本文你将掌握该消息的完整字段语义、状态/子状态枚举、标志位FLAG位图设计以及它在源码中的发布链路与消费映射可直接用于固件开发、日志分析与地面站数据对接。消息定位内燃机状态的“统一出口”在 PX4 的 uORB 消息体系中InternalCombustionEngineStatus专门承载一台内燃机在运行周期内的全部可观测状态从停机、起动、怠速、正常运行到故障以及发动机负载、转速、各温度点、油压、燃油消耗等实时测量值。消息主题名为internal_combustion_engine_status即文档中TOPICS字段所示在整个 PX4 生态中承担三重角色状态机结果反馈internal_combustion_engine_control模块InternalCombustionEngineControl.cpp以 50 Hz 周期运行状态机并将状态机输出发布到该主题外部 ECU 接入支持 DroneCANUAVCAN总线上符合uavcan.equipment.ice.reciprocating.Status协议的 ECU 状态桥接发布ice_status.cpp对外互联出口MAVLink 的EFI_STATUS消息流将其字段映射转发给地面站飞行日志系统也会按需记录该主题logged_topics.cpp。消息字段完整定义InternalCombustionEngineStatus共包含 22 个字段涵盖状态枚举、标志位位图、转速/负载、温度压力、燃油与点火参数等。字段定义如下单位与范围来自消息中的[range]注解字段名类型单位范围说明timestampuint64us—系统启动以来的时间stateuint8—STATE发动机状态substateuint8—SUBSTATE发动机子状态flagsuint32—FLAG发动机状态标志位位图engine_load_percentuint8%[0 : 127]发动机负载估算engine_speed_rpmuint32rpm[0 : inf]发动机转速spark_dwell_time_msfloat32ms[0 : inf]火花塞充电时间点火线圈导通时间atmospheric_pressure_kpafloat32kPa[0 : inf]大气气压计压力intake_manifold_pressure_kpafloat32kPa[0 : inf]进气歧管压力intake_manifold_temperaturefloat32K[0 : inf]进气歧管温度coolant_temperaturefloat32K[0 : inf]冷却液温度oil_pressurefloat32kPa[0 : inf]机油压力oil_temperaturefloat32K[0 : inf]机油温度fuel_pressurefloat32kPa[0 : inf]燃油压力fuel_consumption_rate_cm3pmfloat32cm³/min[0 : inf]瞬时燃油消耗估算estimated_consumed_fuel_volume_cm3float32cm³[0 : inf]发动机启动以来累计消耗燃油量估算throttle_position_percentuint8%[0 : 100]节气门位置ecu_indexuint8—[0 : 255]发布该消息的 ECU 索引多 ECU 场景下区分来源spark_plug_usageuint8—SPARK_PLUG火花塞活动报告ignition_timing_degfloat32deg[-inf : inf]气缸点火提前角曲轴角度injection_time_msfloat32ms[0 : inf]喷油时间cylinder_head_temperaturefloat32K[0 : inf]气缸头温度CHTexhaust_gas_temperaturefloat32K[0 : inf]排气温度EGTlambda_coefficientfloat32—[0 : inf]估算的过量空气系数 λ无量纲比值pid_idle_rpm_integralfloat32—[-1 : 1]怠速转速闭环 PID 控制器的积分项字段语义要点engine_load_percent范围 [0 : 127]这是 MAVLinkEFI_STATUS协议对该字段的原始编码约定用 0–127 表示 0–100% 负载百分比为地面站协议兼容保留了余量ignition_timing_deg允许负值提前角在曲轴角度坐标系下可能为负点火时刻在 TDC 之后因此范围是[-inf : inf]lambda_coefficient空燃比控制的核心反馈量λ1 为理论空燃比大于 1 偏稀、小于 1 偏浓。MAVLink 映射中它被写入了EFI_STATUS的pt_compensation字段见下文ecu_index在多个 ECU 同时挂载时用于区分消息来源这在多缸分组控制或双 ECU 冗余场景下至关重要pid_idle_rpm_integral闭环节气门怠速控制器积分项的快照范围被限制在 [-1, 1]可用于调试怠速振荡、积分饱和等问题。STATE 枚举发动机主状态state字段使用以下枚举值描述发动机的整体运行阶段名称值说明STATE_STOPPED0发动机未运行默认状态STATE_STARTING1发动机正在起动瞬态状态STATE_RUNNING2发动机正常运行STATE_FAULT3发动机无法继续工作从源码结构看该枚举与internal_combustion_engine_control模块的 C 状态机一一对应InternalCombustionEngineControl.hpp 中注释明确要求枚举“必须与internal_combustion_engine_status_s::State保持一致”// 与 internal_combustion_engine_status_s::State 对应的状态机 enum class State { Stopped, // 0 Starting, // 1 Running, // 2 Fault // 3 };状态机在 InternalCombustionEngineControl.cpp 的Run()主循环中以switch (_state)方式流转收到用户起动请求取决于ICE_ON_SOURCE参数配置的起动源后从Stopped进入Starting起动期间若在限定尝试次数内检测到转速超过ICE_MIN_RUN_RPM默认 2000 rpmmodule.yaml则进入Running若尝试次数用尽则进入Fault。启用ICE_RUN_FAULT_D运行故障检测默认开启时若运行中转速丢失_rpm_estimate超过 2 秒未更新且低于阈值会退回Starting尝试重新起动并发送 Critical 级别的事件internal_combustion_engine_running_fault。SUBSTATE 枚举运行期细分状态substate字段描述发动机在运行周期内的细分阶段名称值说明SUBSTATE_RUN0发动机运行中默认状态SUBSTATE_IDLE1发动机怠速转速控制器运行中SUBSTATE_REST2发动机处于静止等待再次起动对应源码中的SubState枚举Run / Idle / Rest。子状态机主要用于两类场景怠速控制在Running状态下若启用了怠速转速调节ICE_IDLE_RPM大于 0且节气门指令接近 0throttle_in 0.02或非有限值或实测转速低于怠速设定值模块切换到SubState::Idle由controlEngineIdle()运行闭环节气门 PIDICE_IDLE_RPM_P、ICE_IDLE_RPM_I、ICE_IDLE_THR_FF三个参数标定当节气门指令大于当前怠速节气门时切回SubState::Run起动冷却间隔SubState::Rest出现在起动尝试失败后的静置等待期模块需等待DELAY_BEFORE_RESTARTING秒才允许下一次起动尝试isStartingPermitted()以保护起动机与电瓶。FLAG 标志位位图故障与告警的按位编码flags是一个uint32位图通过按位或组合表达发动机的各种告警与故障状态。设计上遵循“能力声明位*_SUPPORTED 事件位”的模式*_SUPPORTED位表示该 ECU 是否具备对应传感器/监测能力事件位表示当前是否实际触发。事件位只有在对应SUPPORTED位被置位时才具有意义。位值名称说明1FLAG_GENERAL_ERROR一般性错误2FLAG_CRANKSHAFT_SENSOR_ERROR_SUPPORTED曲轴传感器错误可选能力声明4FLAG_CRANKSHAFT_SENSOR_ERROR曲轴传感器错误事件8FLAG_TEMPERATURE_SUPPORTED温度监测可选能力声明16FLAG_TEMPERATURE_BELOW_NOMINAL欠温告警32FLAG_TEMPERATURE_ABOVE_NOMINAL过温告警64FLAG_TEMPERATURE_OVERHEATING严重过热128FLAG_TEMPERATURE_EGT_ABOVE_NOMINAL排气温度过温告警256FLAG_FUEL_PRESSURE_SUPPORTED燃油压力监测可选能力声明512FLAG_FUEL_PRESSURE_BELOW_NOMINAL油压偏低告警1024FLAG_FUEL_PRESSURE_ABOVE_NOMINAL油压偏高告警2048FLAG_DETONATION_SUPPORTED爆震监测可选能力声明4096FLAG_DETONATION_OBSERVED检测到爆震8192FLAG_MISFIRE_SUPPORTED失火监测可选能力声明16384FLAG_MISFIRE_OBSERVED检测到失火32768FLAG_OIL_PRESSURE_SUPPORTED机油压力监测可选能力声明65536FLAG_OIL_PRESSURE_BELOW_NOMINAL机油压力偏低告警131072FLAG_OIL_PRESSURE_ABOVE_NOMINAL机油压力偏高告警262144FLAG_DEBRIS_SUPPORTED碎屑/杂质监测可选能力声明524288FLAG_DEBRIS_DETECTED检测到碎屑位值设计为 2 的幂次从 1 到 524288 连续分配方便程序按位掩码处理。文档中未给具体描述的两个位FLAG_CRANKSHAFT_SENSOR_ERROR、SPARK_PLUG相关位在消息源文件 InternalCombustionEngineStatus.msg 中同样未附加注释属于协议保留语义由实现方ECU 固件约定。SPARK_PLUG 枚举火花塞活动报告spark_plug_usage字段报告双火花塞系统的活动情况名称值说明SPARK_PLUG_SINGLE0单火花塞工作SPARK_PLUG_FIRST_ACTIVE1第一个火花塞工作SPARK_PLUG_SECOND_ACTIVE2第二个火花塞工作SPARK_PLUG_BOTH_ACTIVE3双火花塞同时工作该枚举为双火花塞twin-spark点火系统设计可用来监控两套点火回路是否都在正常参与燃烧属于运行状态监测项由 ECU 上报。源码级剖析消息定义与三大发布/消费链路消息定义源文件消息的规范定义位于 msg/InternalCombustionEngineStatus.msg构建时由 uORB 代码生成器px_generate_uorb_topic_files.py 等生成uORB/topics/internal_combustion_engine_status.h及对应 C/C 结构体internal_combustion_engine_status_s。源文件全文如下uint64 timestamp # [us] Time since system start uint8 STATE_STOPPED 0 # The engine is not running. This is the default state. uint8 STATE_STARTING 1 # The engine is starting. This is a transient state. uint8 STATE_RUNNING 2 # The engine is running normally. uint8 STATE_FAULT 3 # The engine can no longer function. uint8 state # [enum STATE] Engine state uint8 SUBSTATE_RUN 0 # The engine is running. This is the default state. uint8 SUBSTATE_IDLE 1 # The engine idle rpm controller is running. uint8 SUBSTATE_REST 2 # The engine is at rest. uint8 substate # [enum SUBSTATE] Engine substate uint32 FLAG_GENERAL_ERROR 1 # General error. uint32 FLAG_CRANKSHAFT_SENSOR_ERROR_SUPPORTED 2 # Error of the crankshaft sensor. This flag is optional. uint32 FLAG_CRANKSHAFT_SENSOR_ERROR 4 uint32 FLAG_TEMPERATURE_SUPPORTED 8 # Temperature levels. These flags are optional uint32 FLAG_TEMPERATURE_BELOW_NOMINAL 16 # Under-temperature warning uint32 FLAG_TEMPERATURE_ABOVE_NOMINAL 32 # Over-temperature warning uint32 FLAG_TEMPERATURE_OVERHEATING 64 # Critical overheating uint32 FLAG_TEMPERATURE_EGT_ABOVE_NOMINAL 128 # Exhaust gas over-temperature warning uint32 FLAG_FUEL_PRESSURE_SUPPORTED 256 # Fuel pressure. These flags are optional uint32 FLAG_FUEL_PRESSURE_BELOW_NOMINAL 512 # Under-pressure warning uint32 FLAG_FUEL_PRESSURE_ABOVE_NOMINAL 1024 # Over-pressure warning uint32 FLAG_DETONATION_SUPPORTED 2048 # Detonation warning. This flag is optional. uint32 FLAG_DETONATION_OBSERVED 4096 # Detonation condition observed warning uint32 FLAG_MISFIRE_SUPPORTED 8192 # Misfire warning. This flag is optional. uint32 FLAG_MISFIRE_OBSERVED 16384 # Misfire condition observed warning uint32 FLAG_OIL_PRESSURE_SUPPORTED 32768 # Oil pressure. These flags are optional uint32 FLAG_OIL_PRESSURE_BELOW_NOMINAL 65536 # Under-pressure warning uint32 FLAG_OIL_PRESSURE_ABOVE_NOMINAL 131072 # Over-pressure warning uint32 FLAG_DEBRIS_SUPPORTED 262144 # Debris warning. This flag is optional uint32 FLAG_DEBRIS_DETECTED 524288 # Detection of debris warning uint32 flags # [enum FLAG] Engine status flags bitmap uint8 engine_load_percent # [%] [range 0, 127] Engine load estimate uint32 engine_speed_rpm # [rpm] [range 0, inf] Engine speed float32 spark_dwell_time_ms # [ms] [range 0, inf] Spark dwell time float32 atmospheric_pressure_kpa # [kPa] [range 0, inf] Atmospheric (barometric) pressure float32 intake_manifold_pressure_kpa # [kPa] [range 0, inf] Engine intake manifold pressure float32 intake_manifold_temperature # [K] [range 0, inf] Engine intake manifold temperature float32 coolant_temperature # [K] [range 0, inf] Engine coolant temperature float32 oil_pressure # [kPa] [range 0, inf] Oil pressure float32 oil_temperature # [K] [range 0, inf] Oil temperature float32 fuel_pressure # [kPa] [range 0, inf] Fuel pressure float32 fuel_consumption_rate_cm3pm # [cm^3/min] [range 0, inf] Instant fuel consumption estimate float32 estimated_consumed_fuel_volume_cm3 # [cm^3] [range 0, inf] Estimate of the consumed fuel since the start of the engine uint8 throttle_position_percent # [%] [range 0, 100] Throttle position uint8 ecu_index # [-] [range 0, 255] The index of the publishing ECU uint8 SPARK_PLUG_SINGLE 0 uint8 SPARK_PLUG_FIRST_ACTIVE 1 uint8 SPARK_PLUG_SECOND_ACTIVE 2 uint8 SPARK_PLUG_BOTH_ACTIVE 3 uint8 spark_plug_usage # [enum SPARK_PLUG] Spark plug activity report float32 ignition_timing_deg # [deg] [range -inf, inf] Cylinder ignition timing, angular degrees of the crankshaft float32 injection_time_ms # [ms] [range 0, inf] Fuel injection time float32 cylinder_head_temperature # [K] [range 0, inf] Cylinder head temperature (CHT) float32 exhaust_gas_temperature # [K] [range 0, inf] Exhaust gas temperature (EGT) float32 lambda_coefficient # [-] [range 0, inf] Estimated lambda coefficient, dimensionless ratio float32 pid_idle_rpm_integral # [-] [range 1, 1] Integral of the PID for the closed loop idle RPM controller链路一状态机发布端internal_combustion_engine_control模块在启动文件参数 ICE_EN 置位时随系统启动默认构建不含此模块在每个周期结束时通过publishControl()发布状态消息// InternalCombustionEngineControl.cpp internal_combustion_engine_status_s ice_status{}; ice_status.state static_castuint8_t(_state); ice_status.substate static_castuint8_t(_sub_state); ice_status.timestamp now; ice_status.pid_idle_rpm_integral _rpm_idle_pid.getIntegral(); _internal_combustion_engine_status_pub.publish(ice_status);注意该模块只填充state、substate、timestamp与pid_idle_rpm_integral四个字段——其余测量字段转速、温度、压力、燃油等依赖外部传感器/ECU 数据源通过 DroneCAN 等总线桥接补充。模块的完整参数族ICE_ON_SOURCE起动源、ICE_CHOKE_ST_DUR起动阻风时长、ICE_STRT_DUR起动尝试时长、ICE_STRT_THR起动节气门等定义见 module.yaml。链路二DroneCANUAVCANECU 桥接端对于挂接 DroneCAN 总线的第三方发动机 ECUice_status.cpp 中的UavcanIceStatusBridge订阅 UAVCAN 标准消息uavcan.equipment.ice.reciprocating.Status逐字段拷贝为internal_combustion_engine_status_s后发布到 uORBauto report ::internal_combustion_engine_status_s(); report.timestamp hrt_absolute_time(); report.state msg.state; report.flags msg.flags; report.engine_load_percent msg.engine_load_percent; report.engine_speed_rpm msg.engine_speed_rpm; // ... 温度、压力、燃油等字段直接透传 report.ecu_index msg.ecu_index; report.spark_plug_usage msg.spark_plug_usage; if (msg.cylinder_status.size() 0) { report.ignition_timing_deg msg.cylinder_status[0].ignition_timing_deg; report.injection_time_ms msg.cylinder_status[0].injection_time_ms; report.cylinder_head_temperature msg.cylinder_status[0].cylinder_head_temperature; report.exhaust_gas_temperature msg.cylinder_status[0].exhaust_gas_temperature; report.lambda_coefficient msg.cylinder_status[0].lambda_coefficient; } publish(msg.getSrcNodeID().get(), report);这段代码还揭示了字段来源的一个关键细节ignition_timing_deg、injection_time_ms、cylinder_head_temperature、exhaust_gas_temperature、lambda_coefficient五个字段来自 UAVCAN 协议中的cylinder_status[0]首气缸状态数组表明这些参数本质上是“按气缸”上报的uORB 消息取了首气缸数据作为单缸聚合表示。链路三MAVLink EFI_STATUS 对外转发地面站侧EFI_STATUS.hpp 中的MavlinkStreamEfiStatus流订阅该主题并将其映射为 MAVLinkEFI_STATUS消息仅在主题被发布时流才计费启用get_size()中通过advertised()判断InternalCombustionEngineStatus 字段MAVLink EFI_STATUS 字段statehealthecu_indexecu_indexengine_speed_rpmrpmestimated_consumed_fuel_volume_cm3fuel_consumedfuel_consumption_rate_cm3pmfuel_flowengine_load_percentengine_loadthrottle_position_percentthrottle_position/throttle_outspark_dwell_time_msspark_dwell_timeatmospheric_pressure_kpabarometric_pressureintake_manifold_pressure_kpaintake_manifold_pressureintake_manifold_temperatureintake_manifold_temperaturecylinder_head_temperaturecylinder_head_temperatureignition_timing_degignition_timinginjection_time_msinjection_timeexhaust_gas_temperatureexhaust_gas_temperaturelambda_coefficientpt_compensationstate被直接写入 MAVLink 的health字段意味着地面站可通过EFI_STATUS.health感知发动机状态机阶段0停机、1起动、2运行、3故障。订阅与调试实践在固件运行环境NuttX shell / SITL中可通过 uORB 工具实时查看该主题数据# 打印一次主题内容 listener internal_combustion_engine_status # 持续监听50 Hz 发布时每秒输出 50 帧 listener internal_combustion_engine_status -n 50输出示例结构internal_combustion_engine_status: timestamp: 123456789 (0.123s ago) state: 2, substate: 1, flags: 0 engine_load_percent: 35, engine_speed_rpm: 2400 spark_dwell_time_ms: 3.5, atmospheric_pressure_kpa: 101.3 ...飞行日志方面该主题在 logged_topics.cpp 中被注册为可选日志主题add_optional_topic(internal_combustion_engine_status, 10)是否记录由日志配置文件如 logging 的SDLOG_MODE与主题配置决定开启后可通过 PX4 日志分析工具还原发动机运行曲线用于故障定位与怠速 PID 调参。关联资源消息定义源文件msg/InternalCombustionEngineStatus.msg控制与发布模块InternalCombustionEngineControl.cpp、InternalCombustionEngineControl.hpp、参数定义 module.yamlDroneCAN 桥接ice_status.cppMAVLink 转发EFI_STATUS.hpp配套控制消息状态机输出的控制指令集InternalCombustionEngineControl完整消息索引docs/en/msg_docs/index.md赞分享嵌入式物联网机器人自动驾驶智能硬件【免费下载链接】PX4-AutopilotPX4 Autopilot Software项目地址https://gitcode.com/gh_mirrors/px/PX4-Autopilot点击查看免费下载相关推荐PX4 ActuatorControlsStatus uORB 消息详解控制功率反馈与姿态自整定保护机制PX4 ActuatorControlsStatus uORB 消息详解控制功率反馈与姿态自整定保护机制 ActuatorControlsStatus 是 P嵌入式物联网机器人自动驾驶智能硬件PX4-Autopilot UORB 消息详解FailureDetectorStatus 故障检测器状态消息PX4 Autopilot UORB 消息详解FailureDetectorStatus 故障检测器状态消息 failure_detector_status嵌入式物联网机器人自动驾驶智能硬件PX4 CameraCapture uORB 消息解析从相机触发反馈到地理标记的完整数据链路PX4 CameraCapture uORB 消息解析从相机触发反馈到地理标记的完整数据链路 CameraCapture 是 PX4 飞行控制栈中用于描述一嵌入式物联网机器人自动驾驶智能硬件上一篇突破大文件上传限制TusPHP服务器配置终极指南下一篇openHAB开源项目使用教程创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考