Tudat/SimulationSetup/PropagationSetup/createTorqueModel.cpp
//! Function to create a second-degree gravitational torque.
Function to create a second-degree gravitational torque.
Function to create a second - degree gravitational torque .
std::shared_ptr< gravitation::SecondDegreeGravitationalTorqueModel > createSecondDegreeGravitationalTorqueModel(
        const std::shared_ptr< simulation_setup::Body > bodyUndergoingTorque,
        const std::shared_ptr< simulation_setup::Body > bodyExertingTorque,
        const std::string& nameOfBodyUndergoingTorque,
        const std::string& nameOfBodyExertingTorque )
{
    std::function< Eigen::Vector3d( ) > positionOfBodySubjectToTorqueFunction =
            std::bind( &simulation_setup::Body::getPosition, bodyUndergoingTorque );
    std::function< Eigen::Vector3d( ) > positionOfBodyExertingTorqueFunction =
            std::bind( &simulation_setup::Body::getPosition, bodyExertingTorque );
    std::shared_ptr< gravitation::GravityFieldModel > gravityFieldModel = bodyExertingTorque->getGravityFieldModel( );
    std::function< double( ) > gravitationalParameterOfAttractingBodyFunction;
    if( gravityFieldModel ==  nullptr )
    {
        throw std::runtime_error( "Error when making second degree gravitational torque, " + nameOfBodyExertingTorque +
                                  " does not possess a gravity field" );
    }
    else
    {
        gravitationalParameterOfAttractingBodyFunction = std::bind( &gravitation::GravityFieldModel::getGravitationalParameter,
                                                                      gravityFieldModel );
    }
    std::function< Eigen::Matrix3d( ) > inertiaTensorOfRotatingBodyFunction  =
            std::bind( &simulation_setup::Body::getBodyInertiaTensor, bodyUndergoingTorque );
    std::function< Eigen::Quaterniond( ) > rotationToBodyFixedFrameFunction =
            std::bind( &simulation_setup::Body::getCurrentRotationToLocalFrame, bodyUndergoingTorque );
    return std::make_shared<gravitation::SecondDegreeGravitationalTorqueModel >(
                positionOfBodySubjectToTorqueFunction, gravitationalParameterOfAttractingBodyFunction,
                inertiaTensorOfRotatingBodyFunction, positionOfBodyExertingTorqueFunction, rotationToBodyFixedFrameFunction );
}
std :: shared_ptr < gravitation :: SecondDegreeGravitationalTorqueModel > createSecondDegreeGravitationalTorqueModel ( const std :: shared_ptr < simulation_setup :: Body > bodyUndergoingTorque , const std :: shared_ptr < simulation_setup :: Body > bodyExertingTorque , const std :: string & nameOfBodyUndergoingTorque , const std :: string & nameOfBodyExertingTorque ) { std :: function < Eigen :: Vector3d ( ) > positionOfBodySubjectToTorqueFunction = std :: bind ( & simulation_setup :: Body :: getPosition , bodyUndergoingTorque ) ; std :: function < Eigen :: Vector3d ( ) > positionOfBodyExertingTorqueFunction = std :: bind ( & simulation_setup :: Body :: getPosition , bodyExertingTorque ) ; std :: shared_ptr < gravitation :: GravityFieldModel > gravityFieldModel = bodyExertingTorque -> getGravityFieldModel ( ) ; std :: function < double ( ) > gravitationalParameterOfAttractingBodyFunction ; if ( gravityFieldModel == nullptr ) { throw std :: runtime_error ( " " + nameOfBodyExertingTorque + " " ) ; } else { gravitationalParameterOfAttractingBodyFunction = std :: bind ( & gravitation :: GravityFieldModel :: getGravitationalParameter , gravityFieldModel ) ; } std :: function < Eigen :: Matrix3d ( ) > inertiaTensorOfRotatingBodyFunction = std :: bind ( & simulation_setup :: Body :: getBodyInertiaTensor , bodyUndergoingTorque ) ; std :: function < Eigen :: Quaterniond ( ) > rotationToBodyFixedFrameFunction = std :: bind ( & simulation_setup :: Body :: getCurrentRotationToLocalFrame , bodyUndergoingTorque ) ; return std :: make_shared < gravitation :: SecondDegreeGravitationalTorqueModel > ( positionOfBodySubjectToTorqueFunction , gravitationalParameterOfAttractingBodyFunction , inertiaTensorOfRotatingBodyFunction , positionOfBodyExertingTorqueFunction , rotationToBodyFixedFrameFunction ) ; }
Function to create a second-degree gravitational torque.
Function to create a second - degree gravitational torque .
// Retrieve state functions // Check model availability // Retrieve environment parameters