|
FhSim
3.1.0
Marine systems simulation
|
Collaboration diagram for Ship console input:Reads the ship console joystick with SDL device index ConsoleID (OIS JoyStick::getID() until 3.0.0), through SDL (visualization builds only; without visualization the outputs stay zero). It opens the joystick in RenderInit and polls it in RenderUpdate. Without the joystick it logs a warning and the outputs stay at their initial values; the camera is still placed when ControlCamera is true.
Mapping from OIS to SDL. The SDL indices are the OIS indices (JoystickInput.h):
| Input | OIS | SDL |
|---|---|---|
| RudderAngle | axis 4 / MAX_AXIS | SDL_JoystickGetAxis(4) / 32767 |
| EngineCommandPort | axis 0 / MAX_AXIS | SDL_JoystickGetAxis(0) / 32767 |
| EngineCommandStarboard | slider 0 / MAX_AXIS | SDL_JoystickGetAxis(5) / 32767 (slider 0) |
| Camera control on/off | button 0 released | SDL button 0 released |
| Reset camera rotation | button 1 released | SDL button 1 released |
| Port, starboard engine on/off | buttons 6, 7 released | SDL buttons 6, 7 released |
| Camera 0 to 3 | buttons 15 to 18 released | SDL buttons 15 to 18 released |
| Thruster 0, 1, 2 on/off | buttons 19, 20, 21 released | SDL buttons 19, 20, 21 released |
| Thruster 0, 1, 2 command +1/20 | buttons 3, 4, 9 released | SDL buttons 3, 4, 9 released |
| Thruster 0, 2 command -1/20 | buttons 2, 10 released | SDL buttons 2, 10 released |
| Camera rotation | POV moved | hat moved (SDL_JoystickGetHat) |
The axes are read on any axis or slider change. Each POV change adds the direction to the rotation of the active camera: North (SDL_HAT_UP) pitch +1, South (SDL_HAT_DOWN) pitch -1, East (SDL_HAT_RIGHT) yaw +1, West (SDL_HAT_LEFT) yaw -1, and the diagonals both; SouthEast (SDL_HAT_RIGHTDOWN) sets yaw 1 and pitch -1, as before. Button 4 has no thruster 1 decrement, as before.
| Name | Width | Description |
|---|---|---|
| PositionNED | 3 | Position of the ship; the active camera is placed relative to it |
| QuaternionNED | 4 | Orientation of the ship; it rotates the camera offsets |
| Name | Width | Description |
|---|---|---|
| RudderAngle | 1 | Rudder axis value, -1 to 1 |
| EngineCommand | 2 | Port and starboard engine command (-1 to 1) |
| EngineCommandPort | 1 | Port engine command |
| EngineCommandStarboard | 1 | Starboard engine command |
| EnginePower | 2 | Port and starboard engine power: the engine power parameter when the engine is on, else 0 |
| EnginePowerPort | 1 | Port engine power |
| EnginePowerStarboard | 1 | Starboard engine power |
| ThrusterCommand | 3 | Thruster commands: the number of steps (button presses) divided by 20 |
| ThrusterCommand0 | 1 | Command of thruster 0 |
| ThrusterCommand1 | 1 | Command of thruster 1 |
| ThrusterCommand2 | 1 | Command of thruster 2 |
| ThrusterPower | 3 | Power of the thrusters: the thruster power parameter when the thruster is on, else 0 |
| ThrusterPower0 | 1 | Power of thruster 0 |
| ThrusterPower1 | 1 | Power of thruster 1 |
| ThrusterPower2 | 1 | Power of thruster 2 |
| Name | Width | Description |
|---|---|---|
| ConsoleID | 1 | SDL device index of the console joystick, written as a string of an integer. Required |
| EnginePower | 1 | Default of PortEnginePower and StarboardEnginePower. Default 1e6. Unit not stated in the code |
| PortEnginePower | 1 | Power output of the port engine when it is on. Default EnginePower |
| StarboardEnginePower | 1 | Power output of the starboard engine when it is on. Default EnginePower |
| ThrusterPower | 1 | Default of ThrusterPower0 to 2. Default 1e4. Unit not stated in the code |
| ThrusterPower0 | 1 | Power output of thruster 0 when it is on. Default ThrusterPower |
| ThrusterPower1 | 1 | Power output of thruster 1 when it is on. Default ThrusterPower |
| ThrusterPower2 | 1 | Power output of thruster 2 when it is on. Default ThrusterPower |
| CameraOffset0 | 3 | Offset of camera 0 in the body frame of the ship. Default 0, 0, 0 |
| CameraOffset1 | 3 | Offset of camera 1. Default 0, 0, 0 |
| CameraOffset2 | 3 | Offset of camera 2. Default 0, 0, 0 |
| CameraOffset3 | 3 | Offset of camera 3. Default 0, 0, 0 |
| ControlCamera | 1 | The console places and rotates the camera. Default true |