Target shooting simulator using game controllers
This example examines the simulation in Engee of a target shooting simulator. With the help of the external equipment support package in Engee, the position of the front sight and the speed of guidance are set using the game controls HOTAS (hands on throttle-and-stick) - the aircraft control knob and the engine control lever. The coordinates of the targets are generated in the Engee model using random number generators, and aiming at the target is visually observed in the Engee graph. A counter for successful hits of targets is also implemented.
Introduction
Game controllers HOTAS - a joystick as an airplane control stick, and a manipulator as an airplane engine control lever. They are connected to the user's computer via USB, and are identified as human interface device (HID) devices.
With the help of specialized blocks and tools for working with external equipment from Engee, it is possible to receive data in the model from specific HID devices - Thrustmaster Hotas Warthog. This allows, for example, to implement and debug an aircraft's integrated control system (CCU) based on real control actions. In this example, we implement an algorithm for processing operator actions to implement a target targeting simulator.
Preparation for work
Before launching the model in Engee, several preparatory steps must be performed, as described in the manual.
In addition, similar preparation steps can be found in an example of working with COM-портом. After successfully connecting to Engee, you can proceed to connecting the equipment.
Connecting equipment
The HOTAS controllers are connected directly to the computer and identified by the system. For most modern operating systems, controllers are detected and installed automatically. In the Windows 11 Device Manager, for example, they are displayed as follows:
If the devices are successfully connected, you can proceed to running the sample model.
The example model
The example model - hotas_target_practice.engee.
The model has two interface blocks for connecting external equipment Thrustmaster HOTAS:
-
Thrustmaster HOTAS Throttle (ORE): The throttle position signals are sent to the model, and are used to set the speed of movement of the sight along the coordinate plane.
-
Thrustmaster HOTAS Joystick (RUS): The model receives roll and pitch signals (used to move the target designator sight along the coordinate plane), as well as signals for pressing the release button and trigger.
The roll and pitch signals (cursor positions in X and Y) are transmitted to the "sight" subsystem, where the coordinates of the rotating sight are generated using two sinusoidal signals.
The speed of movement of the sight along the axes is regulated by signals throttle_left and throttle_right using blocks Discrete Variable Time Delay "The delay." The pitch signal is additionally inverted so that the positive pitch corresponds to the negative half of the Y axis of the coordinate plane.
The coordinates of the target are formed by blocks of uniform random numbers in the range with a period of 5 seconds (subsystem "Target coordinates").
The coordinates of the target and the coordinates of the sight are compared in the subsystem "detection of a_fall". If the target falls into the sight area and one of the firing buttons on the joystick is pressed, the target signal is counted. попадание takes the value "true".
The subsystem "counter_fall" is activated by the positive edge of the signal попадание and increments the variable счёт.
Target shooting simulation
After configuring the connection of external equipment and reviewing the model, we will proceed to modeling the simulator operation. The current score of hits, as well as the coordinates of the target and sight, can be displayed on the graphs of the model. Fine-tuning the sampling period of the model and external equipment units allows you to adjust the response of the equipment and adjust the visualization quality of the simulator.
The following video demonstrates how the simulator works.
Engee's capabilities in visualization on the graphs of the model allow you to build the location of the target, its movement and the display of the sight.
Conclusion
In this example, we looked at the Engee target shooting simulator model. On this model, you can check the connection, calibrate and debug the connection of HOTAS HID game controllers to Engee before using them in more complex models, for example, aircraft control systems. In addition, it allows you to improve the operator's skills in managing HOTAS.