mirror of
https://github.com/nasa/trick.git
synced 2025-04-07 19:34:23 +00:00
Get rid of SIM_cannon_dt and combine Sim_cannon_contact and SIM_cannon_integ
This commit is contained in:
parent
8f585baae2
commit
4f9c1cdc0b
@ -1,17 +0,0 @@
|
||||
global DR_GROUP_ID
|
||||
global drg
|
||||
try:
|
||||
if DR_GROUP_ID >= 0:
|
||||
DR_GROUP_ID += 1
|
||||
except NameError:
|
||||
DR_GROUP_ID = 0
|
||||
drg = []
|
||||
|
||||
drg.append(trick.DRAscii("cannon"))
|
||||
drg[DR_GROUP_ID].set_freq(trick.DR_Always)
|
||||
drg[DR_GROUP_ID].set_cycle(0.01)
|
||||
drg[DR_GROUP_ID].set_single_prec_only(False)
|
||||
drg[DR_GROUP_ID].add_variable("dyn.cannon.pos[0]")
|
||||
drg[DR_GROUP_ID].add_variable("dyn.cannon.pos[1]")
|
||||
trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer)
|
||||
drg[DR_GROUP_ID].enable()
|
@ -1,11 +0,0 @@
|
||||
|
||||
trick.frame_log_on()
|
||||
trick.real_time_enable()
|
||||
trick.exec_set_software_frame(0.1)
|
||||
trick.itimer_enable()
|
||||
|
||||
trick.exec_set_enable_freeze(True)
|
||||
trick.exec_set_freeze_command(True)
|
||||
|
||||
simControlPanel = trick.SimControlPanel()
|
||||
trick.add_external_application(simControlPanel)
|
@ -1,5 +0,0 @@
|
||||
|
||||
execfile("Modified_data/realtime.py")
|
||||
execfile("Modified_data/cannon.dr")
|
||||
|
||||
trick.exec_set_terminate_time(5.2)
|
@ -1,2 +0,0 @@
|
||||
|
||||
trick.exec_set_terminate_time(5.2)
|
@ -1,34 +0,0 @@
|
||||
/************************TRICK HEADER*************************
|
||||
PURPOSE:
|
||||
(This S_define is used with the RUN_dt input file)
|
||||
LIBRARY_DEPENDENCY:
|
||||
(
|
||||
(cannon/gravity/src/cannon_dt.c)
|
||||
(cannon/gravity/src/cannon_init.c)
|
||||
(cannon/gravity/src/cannon_default_data.c)
|
||||
)
|
||||
*************************************************************/
|
||||
|
||||
#include "sim_objects/default_trick_sys.sm"
|
||||
|
||||
|
||||
##include "cannon/gravity/include/cannon.h"
|
||||
##include "cannon/gravity/include/cannon_dt_proto.h"
|
||||
|
||||
class CannonSimObject : public Trick::SimObject {
|
||||
|
||||
public:
|
||||
CANNON cannon ;
|
||||
|
||||
CannonSimObject() {
|
||||
("default_data") cannon_default_data( &cannon ) ;
|
||||
|
||||
("initialization") cannon_init( &cannon ) ;
|
||||
|
||||
(0.01, "scheduled") cannon_dt( &cannon ) ;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
// Instantiations
|
||||
CannonSimObject dyn ;
|
@ -1,4 +0,0 @@
|
||||
|
||||
TRICK_CFLAGS += -I../models
|
||||
TRICK_CXXFLAGS += -I../models
|
||||
|
@ -1,9 +0,0 @@
|
||||
Stripchart:
|
||||
title = "Cannon Trajectory"
|
||||
geometry = 800x800+300+0
|
||||
x_min = 0.0
|
||||
x_max = 250.0
|
||||
y_min = 0.0
|
||||
y_max = 40.0
|
||||
x_variable = dyn.cannon.pos[0]
|
||||
dyn.cannon.pos[1]
|
@ -1,3 +0,0 @@
|
||||
dyn.baseball.pos[0] 16 m NUMBER
|
||||
dyn.baseball.pos[1] 0.1 m NUMBER
|
||||
dyn.baseball.pos[2] 2 m NUMBER
|
@ -1,17 +0,0 @@
|
||||
global DR_GROUP_ID
|
||||
global drg
|
||||
try:
|
||||
if DR_GROUP_ID >= 0:
|
||||
DR_GROUP_ID += 1
|
||||
except NameError:
|
||||
DR_GROUP_ID = 0
|
||||
drg = []
|
||||
|
||||
drg.append(trick.DRAscii("cannon"))
|
||||
drg[DR_GROUP_ID].set_freq(trick.DR_Always)
|
||||
drg[DR_GROUP_ID].set_cycle(0.01)
|
||||
drg[DR_GROUP_ID].set_single_prec_only(False)
|
||||
drg[DR_GROUP_ID].add_variable("dyn.cannon.pos[0]")
|
||||
drg[DR_GROUP_ID].add_variable("dyn.cannon.pos[1]")
|
||||
trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer)
|
||||
drg[DR_GROUP_ID].enable()
|
@ -1,15 +0,0 @@
|
||||
#SIM\_cannon\_integ
|
||||
|
||||

|
||||
|
||||
###The Simulation
|
||||
|
||||
This is a simulation of a cannon shooting a cannonball. Given the initial position of the cannon ball, the muzzle velocity (speed) of the cannon ball, and the elevation angle of the cannon barrel the simulation computes the cannon ball's trajectory and time of impact with the ground.
|
||||
|
||||
The acceleration of gravity is assumed to be -9.81 m/s<sup>2</sup>.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
|
||||
#execfile("Modified_data/realtime.py")
|
||||
execfile("Modified_data/cannon.dr")
|
||||
|
||||
trick.TMM_reduced_checkpoint(0)
|
||||
|
||||
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4)
|
||||
|
||||
trick.stop(6)
|
@ -1,3 +0,0 @@
|
||||
|
||||
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4)
|
||||
trick.exec_set_terminate_time(5.2)
|
@ -1,36 +0,0 @@
|
||||
/************************TRICK HEADER*************************
|
||||
PURPOSE:
|
||||
(This S_define is used with RUN_integ input file)
|
||||
LIBRARY DEPENDENCIES:
|
||||
(
|
||||
(cannon/gravity/src/cannon_default_data.c)
|
||||
(cannon/gravity/src/cannon_init.c)
|
||||
(cannon/gravity/src/cannon_deriv.c)
|
||||
(cannon/gravity/src/cannon_integ.c)
|
||||
)
|
||||
*************************************************************/
|
||||
|
||||
#include "sim_objects/default_trick_sys.sm"
|
||||
|
||||
##include "cannon/gravity/include/cannon.h"
|
||||
##include "cannon/gravity/include/cannon_integ_proto.h"
|
||||
|
||||
class CannonSimObject : public Trick::SimObject {
|
||||
|
||||
public:
|
||||
CANNON cannon ;
|
||||
|
||||
CannonSimObject() {
|
||||
("default_data") cannon_default_data( &cannon ) ;
|
||||
|
||||
("initialization") cannon_init( &cannon ) ;
|
||||
|
||||
("derivative") cannon_deriv( &cannon ) ;
|
||||
("integration") trick_ret = cannon_integ( &cannon ) ;
|
||||
}
|
||||
} ;
|
||||
|
||||
// Instantiations
|
||||
CannonSimObject dyn ;
|
||||
|
||||
IntegLoop dyn_integloop (0.01) dyn;
|
@ -1,4 +0,0 @@
|
||||
|
||||
TRICK_CFLAGS += -I../models
|
||||
TRICK_CXXFLAGS += -I../models
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 44 KiB |
@ -1,23 +0,0 @@
|
||||
|
||||
/*************************************************************************
|
||||
PURPOSE: (Cannonball Prototypes)
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CANNON_DT_PROTO
|
||||
#define CANNON_DT_PROTO
|
||||
#include <stdio.h>
|
||||
#include "cannon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int cannon_dt(CANNON*) ;
|
||||
int cannon_init(CANNON*) ;
|
||||
int cannon_default_data(CANNON*) ;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,16 +0,0 @@
|
||||
/*****************************************************************************
|
||||
PURPOSE: ( Adding contact)
|
||||
*****************************************************************************/
|
||||
#include "../include/cannon.h"
|
||||
#include "../include/cannon_contact_proto.h"
|
||||
|
||||
int cannon_deriv_impact( CANNON* C )
|
||||
{
|
||||
if ( ! C->impact ) {
|
||||
/* Still above ground and flying */
|
||||
C->acc[0] = 0.0 ;
|
||||
C->acc[1] = -9.81 ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*****************************************************************************
|
||||
PURPOSE: ( Try dt )
|
||||
*****************************************************************************/
|
||||
#include "../include/cannon.h"
|
||||
#include "../include/cannon_dt_proto.h"
|
||||
|
||||
int cannon_dt(
|
||||
CANNON* C )
|
||||
{
|
||||
double dt ;
|
||||
double pos0[2] ;
|
||||
double vel0[2] ;
|
||||
double acc0[2] ;
|
||||
|
||||
/* This dt matches the frequency of this job */
|
||||
dt = 0.01 ;
|
||||
|
||||
/* Save off last state */
|
||||
pos0[0] = C->pos[0] ; pos0[1] = C->pos[1] ;
|
||||
vel0[0] = C->vel[0] ; vel0[1] = C->vel[1] ;
|
||||
acc0[0] = C->acc[0] ; acc0[1] = C->acc[1] ;
|
||||
|
||||
/* Calculate new state based on last state */
|
||||
C->acc[0] = acc0[0] ;
|
||||
C->acc[1] = acc0[1] ;
|
||||
|
||||
C->vel[0] = vel0[0] + acc0[0]*dt ;
|
||||
C->vel[1] = vel0[1] + acc0[1]*dt ;
|
||||
|
||||
C->pos[0] = pos0[0] + vel0[0]*dt + (0.5)*acc0[0]*dt*dt ;
|
||||
C->pos[1] = pos0[1] + vel0[1]*dt + (0.5)*acc0[1]*dt*dt ;
|
||||
|
||||
return 0 ;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user