Attitude MFD & UCGOArrowFreighter ship class
Hello,
I was modifying some routine in AttitudeMFD (thx to
tblaxland for including SDK files in release...).
To correct this problem you can pass the "RotLevel" calculated in "AttCtrl.cpp" and add the API function "SetAttitudeRotLevel" for every axis in the end of "Control()" function in "AttitudeMFD.cpp".
This should work.
Example:
(changes in blue)
AttitudeMFD.cpp
////////////////////////////////////////////////////////////////////////////////////
...
void inline AttitudeMFD::Control()
{
int VesselDockedCount; //The number of vessels docked to us
OBJHANDLE DockedObj;
VESSEL *DockedVessel;
...
...
double iP = 0, iY = 0, iR = 0;
if (AttHoldMode==ENGAGED)
{
// Use different function calls to SetAttitude for the rotating reference vector cases than the static reference vector cases
if ( (fabs(PitchYawRoll.data[YAW]) + fabs(PitchYawRoll.data[PITCH])) > DEADBAND_MAX ) {
iP = SetAttitude(0, PitchYawRoll.data[PITCH], PITCH, DB_COARSE, RATE_NULL_HIGH, LastTimeElapsed);
iY = SetAttitude(0, PitchYawRoll.data[YAW], YAW, DB_COARSE, RATE_NULL_HIGH, LastTimeElapsed);
iR = SetAttitude(0, 0, ROLL, DB_COARSE, RATE_NULL_HIGH, TimeElapsed);
}
else {
...
...
TOR_Rate = 2*PI/TOR_op.T;
iP = SetAttitude(0, 0, Status.vrot.data[PITCH] - TOR_Rate, PITCH, DB_MIN, RATE_NULL_LOW, UPDATE_INTERVAL);
iY = SetAttitude(0, 0, YAW, DB_MIN, RATE_NULL_LOW, UPDATE_INTERVAL);
iR = SetAttitude(0, 0, ROLL, DB_MIN, RATE_NULL_LOW, UPDATE_INTERVAL);
}
if(strncmp(Vessel->GetClassNameA(), "UCGO\\Vessels\\UCGOArrowFreighter", 31) == 0){
Spacecraft->SetAttitudeRotLevel(PITCH, iP); //force pitch rotation for UCGOArrowFreigther
Spacecraft->SetAttitudeRotLevel(YAW, iY); //force yaw rotation for UCGOArrowFreigther
Spacecraft->SetAttitudeRotLevel(ROLL, iR); //force roll rotation for UCGOArrowFreigther
}
if (TrimStatus == T_ENGAGED) {
Trim();
}
}
...
//////////////////////////////////////////////////////////////////////////////////
But if you want to use AttitudeMFD with ArrowFreighter, you should want to decrease "RATE_MAX" constant value to avoid excessive use of fuel :
AttCtrl.cpp
//////////////////////////////////////////////////////////////////////////////////
...
double SetAttitude(double TargetAttitude, double CurrentAttitude, double RotRate,
AXIS Axis, DEADBAND DeadbandLow, double RateNull, double DT)
{
double Rate; // Depends on magnitude of DeltaAngle
...
...
double DeltaRate; // The difference between the desired and the actual rate
double DeltaAngle = TargetAttitude - CurrentAttitude;
double Rate_Max;
if(strncmp(Vessel->GetClassNameA(), "UCGO\\Vessels\\UCGOArrowFreighter", 31) == 0){
Rate_Max = Radians(1.5);
}else {Rate_Max = Radians(5.0);}
// Get State
Mass = Vessel->GetMass();
...
...
if (fabs(DeltaAngle) > DEADBAND_MAX) {
Rate =
Rate_Max;
//sprintf(oapiDebugString(), "HIGH");
} else {
// Rate = RATE_HIGH*(pow(RATE_SLOPE,fabs(DeltaAngle))-1)/(pow(RATE_SLOPE,DEADBAND_MAX-1));
Rate =
Rate_Max*fabs(DeltaAngle)/DEADBAND_MAX;
//sprintf(oapiDebugString(), "MAX");
}
// CCK End
...
////////////////////////////////////////////////////////////////////////////////////
Bye.