IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
IMS_RcsManager Class Reference

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
 
FiringSolutionCalculatorfiringsolution = NULL
 The firing solution currently in use.
 
FiringSolutionCalculatornewfiringsolution = 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.
 

Detailed Description

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.

Author
meson800, Jedidia

Member Function Documentation

void IMS_RcsManager::AddThruster ( THRUSTER_HANDLE  thruster)

Adds a thruster to the rcs managment.

Parameters
thrusterThe thruster to add as an rcs thruster
Note
This does not create any thrusters on the vessel. The thruster itself is expected to be created and managed by the PropulsionManager. RcsManager merely notes that the thruster is used as rcs (yes, technically ANY old thruster could be added here, doesn't make a difference!)
See also
AddThrusterPair(), RemoveThruster()
void IMS_RcsManager::AddThrusterPair ( THRUSTER_HANDLE  thruster1,
THRUSTER_HANDLE  thruster2 
)

Adds a thruster as a pair to the rcs managment.

Parameters
thruster1one of the thruster to add as an rcs thruster.
thruster2Another thruster to add, its direction being opposite of thruster1.
See also
AddThruster(), RemoveThruster()
void IMS_RcsManager::calculateFiringSolution ( )
private

starts the calculation of a new firing solution in a new thread.

Note
The new solution will be allocated as newfiringsolution.
bool IMS_RcsManager::GetIntelligentRcs ( )
inline
Returns
True if RCS is in intelligent mode, false otherwise.
void IMS_RcsManager::PreStep ( double  simdt)

Checks if the firing solution is still valid and recalculates if necessary.

Parameters
simdtTime elapsed sice last frame
bool IMS_RcsManager::ProcessEvent ( Event_Base e)
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.

Parameters
eThe event coming through the event pipe
Note
Event generators will NOT send events to this function, only sinks.

Implements EventHandler.

void IMS_RcsManager::RemoveThruster ( THRUSTER_HANDLE  thruster)

Removes a thruster to the rcs managment.

Parameters
thrusterThe thruster to remove (must have been added prior!)
Note
This does not delete any thrusters on the vessel. The thruster merely stops being used as an RCS thruster.
If the thruster is part of a pair, both thrusters will be removed!
See also
AddThruster(), AddThrusterPair()
void IMS_RcsManager::SetCommandedTorque ( VECTOR3 &  torque)

Sets commanded torque for next frame. Use this to control intelligent RCS with autopiliots.

Note
User input will still override this setting!
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.

Parameters
enabled

The documentation for this class was generated from the following files: