跳转到内容

UBot Sensor Component

C++
UUBotSensorComponent
父类
UStaticMeshComponent
类型
组件 · 抽象类 · 可作为蓝图父类
模块
UBotSensor · UBotSensor 0.1.1
头文件
Source/UBotSensor/Public/UBotSensorComponent.h

所有 uBot 传感器组件的基类。组件本身就是传感器坐标系;启动后按 Update Rate Hz 在 uBot 仿真时间上定时采样,每帧最多采样一次。

纯函数 · UUBotSensorComponent.GetDroppedSampleCount

因为一帧跨过了多个采样时刻而跳过的采样次数。Start Sensor 时清零。

引脚方向类型
Return Value输出Integer64

纯函数 · UUBotSensorComponent.GetLatestFrameHeader

返回最近一次采样的帧头。

引脚方向类型
Return Value输出UBot Frame Header结构体

纯函数 · UUBotSensorComponent.IsSensorModelVisibleInGame

返回游戏中是否显示传感器模型,等于 Hide Sensor Model in Game 取反。

引脚方向类型
Return Value输出Boolean

函数 · UUBotSensorComponent.SampleSensor

立即采样一次,不要求传感器已经启动。本次样本为 Valid 时返回 true。

引脚方向类型
Return Value输出Boolean

函数 · UUBotSensorComponent.SetSensorModelVisibleInGame

运行中显示或隐藏传感器模型。Model Visible 为 true 时显示。

引脚方向类型默认值
Model VisiblebModelVisible输入Booleanfalse

函数 · UUBotSensorComponent.SetUpdateRateHz

修改采样频率,限制在 0.1–240 Hz。运行中的传感器不会重启,下一次采样时刻保持不变。

引脚方向类型默认值
New Update Rate Hz输入Float0.0

函数 · UUBotSensorComponent.StartSensor

启动传感器:立即采样一次,之后按 Update Rate Hz 定时采样。Sensor Enabled 为 false 时返回 false。

引脚方向类型
Return Value输出Boolean

函数 · UUBotSensorComponent.StopSensor

停止定时采样。手动调用 Sample Sensor 仍然可以采样。

在 Components 面板选中组件,在 Details 面板底部 Events 区点事件旁的 + 即可生成事件节点。

事件 · UUBotSensorComponent.OnSensorError

采样出错时触发,Error Message 说明原因,例如位姿传感器的参考组件无效。

引脚方向类型
Error Message输出String

事件 · UUBotSensorComponent.OnSensorSampled

每次采样后触发,Header 是本次的帧头。每种传感器都有这个事件。

引脚方向类型
Header输出UBot Frame Header结构体

事件 · UUBotSensorComponent.OnSensorStarted

传感器成功启动时触发,在启动时的第一个样本之前。

事件 · UUBotSensorComponent.OnSensorStopped

传感器从运行变为停止时触发,包括运行结束时的自动停止。

未特别标注的属性:蓝图里只读,Details 面板里可以编辑。

属性类型默认值说明
Auto StartbAutoStart · uBot SensorBooleantrue为 true 时在 BeginPlay 自动启动传感器。
Frame IdFrameId · uBot SensorString""写入帧头的坐标系名(TF frame id)。为空时用传感器标识;各传感器有自己的默认值。
Sensor EnabledbSensorEnabled · uBot SensorBooleantrue为 false 时无法启动;手动采样只得到 Disabled 帧头。
Sensor IdSensorId · uBot SensorString""写入帧头的传感器标识。为空时用组件名;各传感器有自己的默认值。
Update Rate HzUpdateRateHz · uBot SensorFloat10.0自动采样频率,单位 Hz。运行中修改请用 Set Update Rate Hz。范围 0.1 – 240.0
Debug VisualizationbDebugVisualization · uBot Sensor|DebugBooleanfalse为 true 时,运行中画出调试射线。只有激光雷达使用。
Hide Sensor Model in GamebHideSensorModelInGame · uBot Sensor|ModelBooleantrue为 true 时,游戏中隐藏传感器模型。运行中可用 Set Sensor Model Visible in Game 切换。
Noise EnabledbNoiseEnabled · uBot Sensor|NoiseBooleanfalse噪声总开关。只对 IMU、里程计和 2D / 3D 激光雷达有效,位姿传感器和相机没有噪声。
Random SeedRandomSeed · uBot Sensor|NoiseInteger1337噪声随机序列的种子。每次 Start Sensor 都用它重置随机序列。