Esempio n. 1
0
//------------------------------------------------------------------------------
// void SetRvector(Integer item, const Rvector &value)
//------------------------------------------------------------------------------
void AttitudeData::SetRvector(Integer item, const Rvector &value)
{
   #ifdef DEBUG_SET_RVECTOR
   MessageInterface::ShowMessage
      ("AttitudeData::SetRvector() entered, item = %d, value = '%s'\n",
       item, value.c_str());
   #endif
   
   if (mSpacecraft == NULL)
      InitializeRefObjects();
   
   Attitude *attitude = (Attitude*)mSpacecraft->GetRefObject(Gmat::ATTITUDE, "");
   if (attitude == NULL)
      throw ParameterException
         ("AttitudeData::SetRvector() Attitude of the Spacecraft \"" +
          mSpacecraft->GetName() + "\" is NULL\n");
   
   switch (item)
   {
   case QUATERNION:
      attitude->SetRvectorParameter("Quaternion", value);
      break;
   default:
      // otherwise, there is an error   
      throw ParameterException
         ("AttitudeData::SetString() Unknown item id: " +
          GmatRealUtil::ToString(item));
   }
}
Esempio n. 2
0
//------------------------------------------------------------------------------
// Rvector GetRvector(Integer item)
//------------------------------------------------------------------------------
Rvector AttitudeData::GetRvector(Integer item)
{
   #ifdef DEBUG_GET_RVECTOR
   MessageInterface::ShowMessage
      ("AttitudeData::GetRvector() entered, item = %d\n", item);
   #endif
   
   if (mSpacecraft == NULL)
      InitializeRefObjects();
   
   Real epoch = mSpacecraft->GetEpoch();
   
   // Get cosine matrix which is internal representation and always gets updated
   Rmatrix33 cosMat = mSpacecraft->GetAttitude(epoch);
   Rvector quat = AttitudeConversionUtility::ToQuaternion(cosMat);
   
   switch (item)
   {
   case QUATERNION:
   {
      return quat;
   }
   default:
      // otherwise, there is an error   
      throw ParameterException
         ("AttitudeData::SetString() Not redable or unknown item id: " +
          GmatRealUtil::ToString(item));
   }
}
Esempio n. 3
0
//------------------------------------------------------------------------------
bool BurnReal::Initialize()
{
   try
   {
      InitializeRefObjects();
   }
   catch(BaseException &e)
   {
      throw GmatBaseException
         ("BurnReal::Initialize() Fail to initialize Parameter:" +
          this->GetTypeName() + "\n" + e.GetFullMessage());
   }
   
   return true;
}
Esempio n. 4
0
//------------------------------------------------------------------------------
// bool Initialize()
//------------------------------------------------------------------------------
bool OrbitRmat66::Initialize()
{
   try
   {
      InitializeRefObjects();
   }
   catch(BaseException &e)
   {
      throw GmatBaseException
         (wxT("OrbitRmat66::Initialize() Fail to initialize Parameter:") +
          this->GetTypeName() + wxT("\n") + e.GetFullMessage());
   }
   
   return true;
}
Esempio n. 5
0
//------------------------------------------------------------------------------
// bool Initialize()
//------------------------------------------------------------------------------
bool BallisticMassReal::Initialize()
{
   try
   {
      InitializeRefObjects();  // NOTE - as of 2012.08.16, InitializeRefObejcts
                               // does not throw an exception
   }
   catch(BaseException &e)
   {
      throw GmatBaseException
         ("BallisticMassReal::Initialize() failed to initialize Parameter:" +
          this->GetTypeName() + "\n" + e.GetFullMessage());
   }
   
   return true;
}
Esempio n. 6
0
//------------------------------------------------------------------------------
bool AttitudeString::Initialize()
{
   try
   {
      InitializeRefObjects();
   }
   catch (BaseException &e)
   {
      #if DEBUG_TIMESTRING
      MessageInterface::ShowMessage
         ("AttitudeString::Initialize() Fail to initialize Parameter '%s'\n",
          this->GetName().c_str());
      #endif
      
      throw ParameterException
         ("WARNING:  " + e.GetFullMessage() + " in " + GetName() + "\n");
   }
   
   return true;
}
Esempio n. 7
0
//------------------------------------------------------------------------------
bool OrbitReal::Initialize()
{
   RealVar::Initialize();
   
   try
   {
      #if DEBUG_ORBITREAL
      MessageInterface::ShowMessage
         ("===> OrbitReal::Initialize() calling InitializeRefObjects() on %s\n",
          instanceName.c_str());
      #endif
      
      InitializeRefObjects();
   }
   catch(InvalidDependencyException &e)
   {
      #if DEBUG_ORBITREAL
      MessageInterface::ShowMessage
         ("OrbitReal::Initialize() Fail to initialize Parameter:%s\n",
          this->GetName().c_str());
      #endif
      
      throw ParameterException
         ("Incorrect parameter dependency: " + GetName() + ".\n" +
          this->GetTypeName() + e.GetFullMessage() + "\n");
   }
   catch(BaseException &e)
   {
      #if DEBUG_ORBITREAL
      MessageInterface::ShowMessage
         ("OrbitReal::Initialize() Fail to initialize Parameter:%s\n",
          this->GetName().c_str());
      #endif
      
      throw ParameterException
         (e.GetFullMessage() + " in " + GetName() + "\n");
   }
   
   return true;
}
Esempio n. 8
0
//------------------------------------------------------------------------------
bool OrbitRvec6::Initialize()
{
   InitializeRefObjects();
   return true;
}
Esempio n. 9
0
//------------------------------------------------------------------------------
Real TimeData::GetCurrentTimeReal(Integer id)
{
    // Get current time from Spacecraft
    if (mSpacecraft == NULL)
        InitializeRefObjects();

    Real a1mjd = mSpacecraft->GetEpoch();

#ifdef DEBUG_TIMEDATA_GET
    MessageInterface::ShowMessage
    (wxT("TimeData::GetCurrentTimeReal() mSpacecraft=<%p>'%s', a1mjd=%f\n"),
     mSpacecraft, mSpacecraft->GetName().c_str(), a1mjd);
#endif

    Real time = -9999.999;

    switch (id)
    {
    case A1_MJD:
        time = a1mjd;
        break;
    case TAI_MJD:
        time = TimeConverterUtil::Convert(a1mjd, TimeConverterUtil::A1MJD,
                                          TimeConverterUtil::TAIMJD,
                                          GmatTimeConstants::JD_JAN_5_1941);
        break;
    case TT_MJD:
        time = TimeConverterUtil::Convert(a1mjd, TimeConverterUtil::A1MJD,
                                          TimeConverterUtil::TTMJD,
                                          GmatTimeConstants::JD_JAN_5_1941);
        break;
    case TDB_MJD:
        time = TimeConverterUtil::Convert(a1mjd, TimeConverterUtil::A1MJD,
                                          TimeConverterUtil::TDBMJD,
                                          GmatTimeConstants::JD_JAN_5_1941);
        break;
    case TCB_MJD:
        time = TimeConverterUtil::Convert(a1mjd, TimeConverterUtil::A1MJD,
                                          TimeConverterUtil::TCBMJD,
                                          GmatTimeConstants::JD_JAN_5_1941);
        break;
    case UTC_MJD:
        time = TimeConverterUtil::Convert(a1mjd, TimeConverterUtil::A1MJD,
                                          TimeConverterUtil::UTCMJD,
                                          GmatTimeConstants::JD_JAN_5_1941);
        break;
    case JD:
        time = a1mjd + GmatTimeConstants::JD_JAN_5_1941;
        break;
    default:
        throw ParameterException(wxT("TimeData::GetCurrentTimeReal() Unknown parameter id: ") +
                                 GmatRealUtil::ToString(id));
    }

#ifdef DEBUG_TIMEDATA_GET
    MessageInterface::ShowMessage
    (wxT("TimeData::GetCurrentTimeReal() id=%d, a1mjd=%.10f, return time=%.10f\n"),
     id, a1mjd, time);
#endif

    return time;
}
Esempio n. 10
0
//------------------------------------------------------------------------------
void AttitudeData::SetReal(Integer item, Real value)
{
   #ifdef DEBUG_SET_REAL
   MessageInterface::ShowMessage
      ("AttitudeData::SetReal() entered, item = %d, value = %f\n", item, value);
   #endif
   
   if (mSpacecraft == NULL)
      InitializeRefObjects();
   
   Attitude *attitude = (Attitude*)mSpacecraft->GetRefObject(Gmat::ATTITUDE, "");
   if (attitude == NULL)
      throw ParameterException
         ("AttitudeData::SetReal() Attitude of the Spacecraft \"" +
          mSpacecraft->GetName() + "\" is NULL\n");
   
   switch (item)
   {
   case DCM_11:
      attitude->SetRealParameter("DCM11", value);
      break;
   case DCM_12:
      attitude->SetRealParameter("DCM12", value);
      break;
   case DCM_13:
      attitude->SetRealParameter("DCM13", value);
      break;
   case DCM_21:
      attitude->SetRealParameter("DCM21", value);
      break;
   case DCM_22:
      attitude->SetRealParameter("DCM22", value);
      break;
   case DCM_23:
      attitude->SetRealParameter("DCM23", value);
      break;
   case DCM_31:
      attitude->SetRealParameter("DCM31", value);
      break;
   case DCM_32:
      attitude->SetRealParameter("DCM32", value);
      break;
   case DCM_33:
      attitude->SetRealParameter("DCM33", value);
      break;
   case EULER_ANGLE_1:
      attitude->SetRealParameter("EulerAngle1", value);
      break;
   case EULER_ANGLE_2:
      attitude->SetRealParameter("EulerAngle2", value);
      break;
   case EULER_ANGLE_3:
      attitude->SetRealParameter("EulerAngle3", value);
      break;
   case ANGULAR_VELOCITY_X:
      attitude->SetRealParameter("AngularVelocityX", value);
      break;
   case ANGULAR_VELOCITY_Y:
      attitude->SetRealParameter("AngularVelocityY", value);
      break;
   case ANGULAR_VELOCITY_Z:
      attitude->SetRealParameter("AngularVelocityZ", value);
      break;
   case EULER_ANGLE_RATE_1:
      attitude->SetRealParameter("EulerAngleRate1", value);
      break;
   case EULER_ANGLE_RATE_2:
      attitude->SetRealParameter("EulerAngleRate2", value);
      break;
   case EULER_ANGLE_RATE_3:
      attitude->SetRealParameter("EulerAngleRate3", value);
      break;
      
   default:
      // otherwise, there is an error   
      throw ParameterException
         ("AttitudeData::SetReal() Not settable or unknown item id: " + 
          GmatRealUtil::ToString(item));
   }
}
Esempio n. 11
0
//------------------------------------------------------------------------------
Real AttitudeData::GetReal(Integer item)
{
   if (mSpacecraft == NULL)
      InitializeRefObjects();
   
   Real epoch = mSpacecraft->GetEpoch();
   
   // get the basics - cosine matrix, angular velocity, euler angle sequence
   Rmatrix33        cosMat        = mSpacecraft->GetAttitude(epoch);
   // Some attitude models don't compute rates, so we only want to try to get
   // rates if that is the data we need to return
   Rvector3 angVel(0.0,0.0,0.0);
   if (((item >= EULER_ANGLE_RATE_1) && (item <= EULER_ANGLE_RATE_3)) ||
       ((item >= ANGULAR_VELOCITY_X) && (item <= ANGULAR_VELOCITY_Z)))
   {
      angVel        = mSpacecraft->GetAngularVelocity(epoch)
                                 * GmatMathConstants::DEG_PER_RAD;
   }
   UnsignedIntArray seq           = mSpacecraft->GetEulerAngleSequence();
   Rvector3         euler;
   
   if (item == DCM_11)   return cosMat(0,0);
   if (item == DCM_12)   return cosMat(0,1);
   if (item == DCM_13)   return cosMat(0,2);
   if (item == DCM_21)   return cosMat(1,0);
   if (item == DCM_22)   return cosMat(1,1);
   if (item == DCM_23)   return cosMat(1,2);
   if (item == DCM_31)   return cosMat(2,0);
   if (item == DCM_32)   return cosMat(2,1);
   if (item == DCM_33)   return cosMat(2,2);
   if (item == ANGULAR_VELOCITY_X) return angVel[0];
   if (item == ANGULAR_VELOCITY_Y) return angVel[1];
   if (item == ANGULAR_VELOCITY_Z) return angVel[2];
   
   // do conversions if necessary
   if ((item >= QUAT_1) && (item <= QUAT_4))
   {
      Rvector quat = AttitudeConversionUtility::ToQuaternion(cosMat);
      return quat[item - QUAT_1];
   }    
   if ((item >= EULER_ANGLE_1) && (item <= EULER_ANGLE_3))
   {
      euler = AttitudeConversionUtility::ToEulerAngles(cosMat,
              (Integer) seq[0], 
              (Integer) seq[1], 
              (Integer) seq[2]) * GmatMathConstants::DEG_PER_RAD;
      return euler[item - EULER_ANGLE_1];
   }
   // Dunn added conversion below with the comment that this
   // is slightly hacked!  We might want to change to a more
   // obvious method of index control.
   if ((item >= MRP_1) && (item <= MRP_3))
   {
      Rvector  quat = AttitudeConversionUtility::ToQuaternion(cosMat);
      Rvector3 mrp  = AttitudeConversionUtility::ToMRPs(quat);
      return mrp[item - MRP_1];
   }           
   if ((item >= EULER_ANGLE_RATE_1) && (item <= EULER_ANGLE_RATE_3))
   {
      euler = AttitudeConversionUtility::ToEulerAngles(cosMat,
              (Integer) seq[0], 
              (Integer) seq[1], 
              (Integer) seq[2]) * GmatMathConstants::DEG_PER_RAD;
      Rvector3 eulerRates = AttitudeConversionUtility::ToEulerAngleRates(
                            angVel * GmatMathConstants::RAD_PER_DEG,
                            euler  * GmatMathConstants::RAD_PER_DEG,
                            (Integer) seq[0], 
                            (Integer) seq[1], 
                            (Integer) seq[2]) * GmatMathConstants::DEG_PER_RAD;
      return eulerRates[item - EULER_ANGLE_RATE_1];
   }        
   
   // otherwise, there is an error   
   throw ParameterException
      ("AttitudeData::GetReal() Not readable or unknown item id: " +
       GmatRealUtil::ToString(item));   
}