摇杆控制动感平台
本示例主要用到2个设备,Joystick与MOTION-PLAT两个设备,通过Joystick的输入控制动感平台的相关动作。
示例代码
auto& _jsDevice = IODeviceController::Instance()
.GetIODevice("Joystick");
auto& _motionPlatDevice = IODeviceController::Instance()
.GetIODevice("MotionPlatform");
// 响应俯仰动作
_jsDevice.BindAxis("Pitch", [&_motionPlatDevice](float PitchVal) {
_motionPlatDevice.SetDO(EKeys::OAxis_01, PitchVal);
});
// 响应翻滚动作
_jsDevice.BindAxis("Roll", [&_motionPlatDevice](float RollVal) {
_motionPlatDevice.SetDO(EKeys::OAxis_03, RollVal);
});
// 控制平台速度
_jsDevice.BindAxis("Speed", [&_motionPlatDevice](float SpeedVal) {
_motionPlatDevice.SetDO(EKeys::OAxis_00, SpeedVal);
});
<IORoot>
<Device Name="Standard" Type="Standard" />
<!-- 摇杆设备 -->
<Device Name="Joystick" Type="Joystick" Index="0">
<!-- 控制平台速度 -->
<Axis Name="Speed">
<Key Name="JS_Slider_00" Scale="20"/>
</Axis>
<Axis Name="Pitch">
<Key Name="JS_X" Scale="45"/>
</Axis>
<Axis Name="Roll">
<Key Name="JS_Z" Scale="45"/>
</Axis>
</Device>
<!-- 动感平台设备 -->
<Device Name="MotionPlatform" Type="External" DllName="MOTION-PLAT">
</Device>
</IORoot>
最后更新于
这有帮助吗?