IMS2
Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
|
Manages and controls RCS thrusters. More...
Inherits IMS_Manager_Base.
Public Member Functions | |
IMS_RcsManager (IMS2 *_vessel) | |
void | AddThruster (THRUSTER_HANDLE thruster) |
Adds a thruster to the rcs managment. More... | |
void | AddThrusterPair (THRUSTER_HANDLE thruster1, THRUSTER_HANDLE thruster2) |
Adds a thruster as a pair to the rcs managment. More... | |
void | RemoveThruster (THRUSTER_HANDLE thruster) |
Removes a thruster to the rcs managment. More... | |
void | PreStep (double simdt) |
Checks if the firing solution is still valid and recalculates if necessary. More... | |
void | SetIntelligentRcs (bool enabled) |
Enables or disables the intelligent RCS. The option to disable it is for compatibility with MFD autopilots that rely on querying RCS performance. More... | |
bool | GetIntelligentRcs () |
void | SetCommandedTorque (VECTOR3 &torque) |
Private Member Functions | |
bool | ProcessEvent (Event_Base *e) |
Receives all events coming through this EventHandler. More... | |
void | createDummyThrusters () |
Creates the virtual rcs needed to process userinput. | |
void | destroyDummyThrusters () |
Destroys the virtual rcs. | |
void | createPhysicalRcsGroups () |
Adds the vessels RCS thrusters to the actual rcs groups, enabling direct control by autopilots but losing its intelligence. | |
void | destroyPhysicalRcsGroups () |
Destroys the unintelligent RCS groups, but leaves the thrusters untouched. | |
void | getCommandedForce (VECTOR3 &OUT_force) |
reads userinput and converts it into a force vector | |
void | getCommandedTorque (VECTOR3 &OUT_torque) |
reads userinput and converts it into a torque vector | |
void | calculateFiringSolution () |
starts the calculation of a new firing solution in a new thread. More... | |
void | destroyFiringSolution () |
aborts calculation of new firing solution and deletes the current one. | |
Private Attributes | |
THRUSTER_HANDLE | dummyThrusters [24] |
array of virtual thrusters to gauge the applied thrust. Unfortunately the thruster group level will not return correctly if there are no thrusters in the group. | |
vector< THRUSTER_HANDLE > | rcsthrusters |
an array containing all thruster handles that are registered as RCS. | |
PROPELLANT_HANDLE | dummypropellant |
virtual propellant source for the virtual thrusters. | |
bool | dummiesexist = false |
flag indicating whether the dummy thrusters currently exist. | |
bool | thrustersfiring = false |
Flag to easily track whether thrusters are currently firing. | |
bool | intelligentrcs = true |
registers if RCS is set to intelligent mode | |
FiringSolutionCalculator * | firingsolution = NULL |
The firing solution currently in use. | |
FiringSolutionCalculator * | newfiringsolution = NULL |
When allocated, means that a new solution is being calculated in a separate thread. | |
VECTOR3 | commandedtorque = _V(0, 0, 0) |
If non-user input sets a torque, it will be remembered here until processed. | |
bool | torqueset = false |
True if torque was commanded during the current frame. | |
Manages and controls RCS thrusters.
Rcs behavior is controlled according to a pretty complex solution that tries to get induce as little secondary effects as possible, no matter where the thrusters are located. If your design is extremely bad this might simply not be possible, but in general it works pretty nicely. This way of doing things requires that the rcs thrusters actually not be part of a thruster group. The levels of the individual thrusters are controlled directly. This in turn means that there have to be virtual thrusters created to fill up the standard rotation and translation thruster groups, as it would otherwise be impossible to read the user input to these thrusters.
void IMS_RcsManager::AddThruster | ( | THRUSTER_HANDLE | thruster | ) |
Adds a thruster to the rcs managment.
thruster | The thruster to add as an rcs thruster |
void IMS_RcsManager::AddThrusterPair | ( | THRUSTER_HANDLE | thruster1, |
THRUSTER_HANDLE | thruster2 | ||
) |
Adds a thruster as a pair to the rcs managment.
thruster1 | one of the thruster to add as an rcs thruster. |
thruster2 | Another thruster to add, its direction being opposite of thruster1. |
|
private |
starts the calculation of a new firing solution in a new thread.
|
inline |
void IMS_RcsManager::PreStep | ( | double | simdt | ) |
Checks if the firing solution is still valid and recalculates if necessary.
simdt | Time elapsed sice last frame |
|
privatevirtual |
Receives all events coming through this EventHandler.
Overload to implement event handling in your inheriting class. The function will receive Events one by one as they are coming through your event sinks, regardless of which pipe they belong to. Return true to consume an event, but be sure it was only meant for you when you do that.
e | The event coming through the event pipe |
Implements EventHandler.
void IMS_RcsManager::RemoveThruster | ( | THRUSTER_HANDLE | thruster | ) |
Removes a thruster to the rcs managment.
thruster | The thruster to remove (must have been added prior!) |
void IMS_RcsManager::SetCommandedTorque | ( | VECTOR3 & | torque | ) |
Sets commanded torque for next frame. Use this to control intelligent RCS with autopiliots.
void IMS_RcsManager::SetIntelligentRcs | ( | bool | enabled | ) |
Enables or disables the intelligent RCS. The option to disable it is for compatibility with MFD autopilots that rely on querying RCS performance.
enabled |