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

Calculates a new firing solution for Rcs thrusters in a new thread. More...

Public Member Functions

 FiringSolutionCalculator (IMS2 *vessel, vector< THRUSTER_HANDLE > rcsthrusters)
 
void Apply (VECTOR3 &torque, VECTOR3 &force, double thrust)
 Applies the firing solution to the vessels thrusters to achieve the demanded torque and force levels. More...
 
void CalculateTorqueLevels (VECTOR3 &IN_OUT_torque)
 Calculates the thrust levels to achieve the requested torque. More...
 
bool IsSolutionReady ()
 

Private Member Functions

void calculateFiringSolutions ()
 
FIRING_SOLUTION constructFiringSolution (VECTOR3 &desiredForce, VECTOR3 &desiredTorque)
 
FIRING_SOLUTION calculateFiringSolution (THGROUP_TYPE group)
 
FIRING_SOLUTION completeFiringSolution (FIRING_SOLUTION &sol)
 
map< FORCETYPE, VECTOR3 > calculateGeneratedForce (FIRING_SOLUTION &sol, vector< FiringSolutionThruster * > &involvedthrusters)
 Calculates the total force a firing solution can produce with a certain subset of thrusters. More...
 
void setMaxForcesForGroup (THGROUP_TYPE group, map< FORCETYPE, VECTOR3 > forces)
 Notes the passed forces as the maximum forces this group can produce. More...
 
vector< THGROUP_TYPE > getGroupsFromForceVector (VECTOR3 &force, FORCETYPE type)
 

Private Attributes

FIRING_SOLUTION pitchUpSol
 
FIRING_SOLUTION pitchDownSol
 
FIRING_SOLUTION yawRightSol
 
FIRING_SOLUTION yawLeftSol
 
FIRING_SOLUTION bankRightSol
 
FIRING_SOLUTION bankLeftSol
 
FIRING_SOLUTION leftSol
 
FIRING_SOLUTION rightSol
 
FIRING_SOLUTION upSol
 
FIRING_SOLUTION downSol
 
FIRING_SOLUTION forwardSol
 
FIRING_SOLUTION backSol
 
FSThrusterCollectionthrusters = NULL
 
vector< THRUSTER_HANDLE > thrusterhandles
 
IMS2 * vessel
 
bool solutionready = false
 shows true if the solution is calculated
 
bool abort = false
 flag that signifies the thread to terminate at the next opportunity.
 
thread * calculationthread
 
map< THGROUP_TYPE, map< FORCETYPE, VECTOR3 > > maxforces
 

Detailed Description

Calculates a new firing solution for Rcs thrusters in a new thread.

Instantiating the class immediately starts a new thread in which the new solution is calculated. Use the IsSolutionReady() method to querry if the calculation has finished. The thread can be safely terminated at any point by deleting the instance. The thread is joined in the destructor. The thread is safe under most circumstances, except for when one of the RCS thruster actually get deleted from the vessel. Make sure to kill the thread first, then delete any thrusters.

Author
meson800

Member Function Documentation

void FiringSolutionCalculator::Apply ( VECTOR3 &  torque,
VECTOR3 &  force,
double  thrust 
)

Applies the firing solution to the vessels thrusters to achieve the demanded torque and force levels.

Note
Has no effect if called on an instance that is still calculating its solution.
Parameters
torqueVector containing the thrust levels for rotation groups in the three axes, between -1.0 and 1.0.
forceVector containing the thrust levels for translation groups in the three axes, between -1.0 and 1.0.
Note
A level of 1.0 or -1.0 means that the maximum thrust will be applied that still guarantees avoiding artifacts. If both torque and force are requested at the same time, that caution is thrown to the wind.
See also
IsSolutionReady()
map< FORCETYPE, VECTOR3 > FiringSolutionCalculator::calculateGeneratedForce ( FIRING_SOLUTION &  sol,
vector< FiringSolutionThruster * > &  involvedthrusters 
)
private

Calculates the total force a firing solution can produce with a certain subset of thrusters.

Parameters
solThe firing solution you want to know the generated forces for.
involvedthrustersA list of all thrusters to be used in the solution.
Returns
A map with two vectors keyed to F_LINEAR and F_TORQUE.
void FiringSolutionCalculator::CalculateTorqueLevels ( VECTOR3 &  IN_OUT_torque)

Calculates the thrust levels to achieve the requested torque.

Parameters
torqueDesired torque around 3 axes, in Nm. Will be converted to values between -1.0 and 1.0, proportional to the maximum maneuverability.
Note
If the torque cannot be produced, hrusters will be set to max level allowed to avoid lateral force.
FIRING_SOLUTION FiringSolutionCalculator::completeFiringSolution ( FIRING_SOLUTION &  sol)
private
Returns
A firing solution with the passed coefficients, and all other thrusters initialised to 0
Parameters
solA firing solution that contains all thrusters actually contributing to the solution
vector< THGROUP_TYPE > FiringSolutionCalculator::getGroupsFromForceVector ( VECTOR3 &  force,
FORCETYPE  type 
)
private
Returns
the thruster groups able to generate a certain force
Parameters
forceThe force vector you are looking to generate
typeWhether force represents linear force or torque
bool FiringSolutionCalculator::IsSolutionReady ( )
inline
Returns
true if the solution has been calculated, false if it is still running.
void FiringSolutionCalculator::setMaxForcesForGroup ( THGROUP_TYPE  group,
map< FORCETYPE, VECTOR3 >  forces 
)
private

Notes the passed forces as the maximum forces this group can produce.

Parameters
groupThe thruster group the forces are for.
forcesa map containing the maximum values for F_TORQUE and F_LINEAR.
Note
Since this saves magnitudes, the forces are always positive. Howver, the sign of the forces you pass to this method do not matter, it will convert them itself.

Member Data Documentation

FIRING_SOLUTION FiringSolutionCalculator::pitchUpSol
private

The current firing solutions for the various actions rcs has to perform


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