trick/trick_sims/SIM_target/S_define
2015-02-26 09:02:31 -06:00

164 lines
7.5 KiB
Plaintext

/*****************************************************************************
PURPOSE: ( This is Zach's test simulation )
LIBRARY_DEPENDENCIES:
(
(target/src/target_data_default_data.c)
(target/src/target_delta_v.c)
(target/src/target_earth_default_data.c)
(target/src/target_eom.c)
(target/src/target_integ.c)
(target/src/target_iterate_default_data.c)
(target/src/target_master_init.c)
(target/src/target_master_post.c)
(target/src/target_master_pre.c)
(target/src/target_master_shutdown.c)
(target/src/target_print.c)
(target/src/target_slave_init.c)
(target/src/target_slave_post.c)
(target/src/target_slave_pre.c)
(target/src/target_slave_shutdown.c)
(target/src/target_state_init.c)
)
****************************************************************************/
#include "sim_objects/default_trick_sys.sm"
##include "target/include/target_body.h"
##include "target/include/target_proto.h"
#define DYNAMICS 0.1
/*****************************************************************************
* SIM_OBJECT: target - The simple targeting algorithm. *
*****************************************************************************/
class TargetSimObject : public Trick::SimObject {
public:
TargetBodyInit target_init;
TargetBodyPlanet target_planet;
TargetBodyState target_state;
TargetBodyData target_data;
TargetBodyIteration *iterate_data ;
TargetSimObject() {
/*=====================================================================
= Target Default Data Routines: =
= These are the default data routines to set the default data for =
= the target.data. =
=====================================================================*/
("default_data") target_earth_default_data(&target_planet);
("default_data") target_data_default_data(&target_data);
/*=====================================================================
= Target Initialization Routine: =
= This is an initialization routine that computes the initial state =
= of the target.data. =
=====================================================================*/
("initialization") target_state_init( &target_init, &target_planet, &target_state );
/*=====================================================================
= Orbital Dynamics Docking/Grapple Transition Routine: =
= This is a derviative class routine that processes any pending =
= dockings, separations, grapples or releases. =
=====================================================================*/
("derivative") target_eom( &target_planet, &target_state, &target_data );
/*=====================================================================
= Target Body Integration Routine: =
= This routine propagates the state of the target.data using the =
= accelerations and time derivative of the state transition matrix =
= computed in the preceeding derivative class routines. The =
= integator type (Euler, RK4 ...) is selected through data input. =
=====================================================================*/
("integration") trick_ret = target_integ( &target_state, &target_data ) ;
/*=====================================================================
= Target Delta V Computation Routine: =
= This is a shutdown routine that computes the final targeting end =
= point conditions and the required change in intial state. =
=====================================================================*/
("shutdown") target_delta_v( &target_state, &target_data, iterate_data ) ;
/*=====================================================================
= Target Print Routine: =
= This is an initialization routine that computes the initial state =
= of the target.data and the state transition matrix. =
=====================================================================*/
("shutdown") target_print( exec_get_sim_time(), &target_init, &target_state, iterate_data );
}
} ;
TargetSimObject target;
/*****************************************************************************
* SIM_OBJECT: iterate - The simple iteration algorithm. *
*****************************************************************************/
class IterateSimObject : public Trick::SimObject {
public:
TargetBodyIteration iterate_data;
TargetBodyInit *target_init;
TargetBodyPlanet *target_planet;
TargetBodyState *target_state;
TargetBodyData *target_data;
IterateSimObject() {
("default_data") target_iterate_default_data( &iterate_data ) ;
("monte_master_init") target_master_init( &iterate_data ) ;
("monte_slave_init") target_slave_init( &iterate_data ) ;
("monte_master_pre") target_master_pre( target_init,
target_state,
target_data,
&iterate_data );
("monte_slave_pre") target_slave_pre( target_init,
target_state,
target_data,
&iterate_data );
("monte_slave_post") target_slave_post( mc_get_connection_device(),
target_init,
target_state,
target_data,
&iterate_data );
("monte_master_post") target_master_post( mc_get_connection_device(),
target_init,
target_state,
target_data,
&iterate_data );
("monte_master_shutdown") target_master_shutdown( mc_get_connection_device(),
target_data,
&iterate_data );
("monte_slave_shutdown") target_slave_shutdown( mc_get_connection_device(),
target_data );
}
} ;
IterateSimObject iterate ;
/*****************************************************************************
* INTEGRATE: List the sim_objects with orbtial dynamics derviative and *
* integration class routines. *
*****************************************************************************/
IntegLoop target_integloop (DYNAMICS) target;
void create_connections() {
target.iterate_data = &iterate.iterate_data;
iterate.target_init = &target.target_init;
iterate.target_planet = &target.target_planet;
iterate.target_state = &target.target_state;
iterate.target_data = &target.target_data;
}