mirror of
https://github.com/nasa/trick.git
synced 2025-02-20 17:22:52 +00:00
Merge branch 'experiment'
Organize and update the Cannon Sims for Trick Tutorial Changes Ref#338
This commit is contained in:
commit
3511800234
@ -1,6 +0,0 @@
|
||||
|
||||
#execfile("Modified_data/realtime.py")
|
||||
execfile("Modified_data/cannon.dr")
|
||||
|
||||
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4)
|
||||
trick.exec_set_terminate_time(5.2)
|
@ -1,3 +0,0 @@
|
||||
|
||||
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4)
|
||||
trick.exec_set_terminate_time(5.2)
|
@ -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,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,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
|
||||
|
21
trick_sims/Cannon/SIM_cannon_numeric/RUN_graphics/input.py
Normal file
21
trick_sims/Cannon/SIM_cannon_numeric/RUN_graphics/input.py
Normal file
@ -0,0 +1,21 @@
|
||||
execfile("Modified_data/realtime.py")
|
||||
|
||||
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 5)
|
||||
|
||||
#==========================================
|
||||
# Start the Cannonball Graphics Client
|
||||
#==========================================
|
||||
varServerPort = trick.var_server_get_port();
|
||||
CannonDisplay_path = "../models/graphics/dist/CannonDisplay.jar"
|
||||
|
||||
if (os.path.isfile(CannonDisplay_path)) :
|
||||
CannonDisplay_cmd = "java -jar " \
|
||||
+ CannonDisplay_path \
|
||||
+ " " + str(varServerPort) + " &" ;
|
||||
print(CannonDisplay_cmd)
|
||||
os.system( CannonDisplay_cmd);
|
||||
else :
|
||||
print('==================================================================================')
|
||||
print('CannonDisplay needs to be built. Please \"cd\" into ../models/graphics and type \"make\".')
|
||||
print('==================================================================================')
|
||||
|
@ -2,4 +2,4 @@
|
||||
execfile("Modified_data/realtime.py")
|
||||
execfile("Modified_data/cannon.dr")
|
||||
|
||||
trick.exec_set_terminate_time(5.2)
|
||||
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 5)
|
@ -0,0 +1,3 @@
|
||||
|
||||
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 5)
|
||||
trick.exec_set_terminate_time(5.2)
|
@ -1,11 +1,11 @@
|
||||
/************************TRICK HEADER*************************
|
||||
PURPOSE:
|
||||
(This S_define is used with RUN_integ input file)
|
||||
(Cannon Numeric)
|
||||
LIBRARY DEPENDENCIES:
|
||||
(
|
||||
(cannon/gravity/src/cannon_default_data.c)
|
||||
(cannon/gravity/src/cannon_init.c)
|
||||
(cannon/gravity/src/cannon_deriv_impact.c)
|
||||
(cannon/gravity/src/cannon_deriv.c)
|
||||
(cannon/gravity/src/cannon_integ.c)
|
||||
(cannon/gravity/src/cannon_impact.c)
|
||||
)
|
||||
@ -23,12 +23,9 @@ class CannonSimObject : public Trick::SimObject {
|
||||
|
||||
CannonSimObject() {
|
||||
("default_data") cannon_default_data( &cannon ) ;
|
||||
|
||||
("initialization") cannon_init( &cannon ) ;
|
||||
|
||||
("derivative") cannon_deriv_impact( &cannon ) ;
|
||||
("derivative") cannon_deriv( &cannon ) ;
|
||||
("integration") trick_ret = cannon_integ( &cannon ) ;
|
||||
|
||||
("dynamic_event") cannon_impact( &cannon) ;
|
||||
}
|
||||
} ;
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@ -23,12 +23,13 @@ typedef struct {
|
||||
double vel[2] ; /* m/s xy-velocity */
|
||||
double acc[2] ; /* m/s2 xy-acceleration */
|
||||
|
||||
double impactTime;
|
||||
double time;
|
||||
double timeRate;
|
||||
|
||||
/* Impact */
|
||||
REGULA_FALSI rf ; /* -- Dynamic event params for impact */
|
||||
int impact ; /* -- Has impact occured? */
|
||||
double impactTime;
|
||||
|
||||
/* Communication Connection */
|
||||
TCDevice connection ; /* -- Socket connection for sending position */
|
||||
|
@ -13,8 +13,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
int cannon_integ(CANNON*) ;
|
||||
int cannon_deriv_impact(CANNON*) ;
|
||||
double cannon_impact(CANNON*) ;
|
||||
double cannon_deriv(CANNON*) ;
|
||||
int cannon_init(CANNON*) ;
|
||||
int cannon_default_data(CANNON*) ;
|
||||
|
||||
|
@ -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
|
@ -2,6 +2,7 @@
|
||||
PURPOSE: ( Analytical Cannon )
|
||||
*****************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "../include/cannon.h"
|
||||
#include "../include/cannon_analytic_proto.h"
|
||||
|
||||
@ -15,11 +16,12 @@ int cannon_analytic( CANNON* C )
|
||||
C->pos[1] = C->pos0[1] + (C->vel0[1] + (0.5) * C->acc0[1] * C->time) * C->time ;
|
||||
if (C->pos[1] < 0.0) {
|
||||
C->impact = 1;
|
||||
C->impactTime = -(2 * C->vel0[1] / C->acc0[1]);
|
||||
C->impactTime = (- C->vel0[1] - sqrt( C->vel0[1] * C->vel0[1] - 2 * C->pos0[1]))/C->acc[1];
|
||||
C->pos[0] = C->impactTime * C->vel0[0];
|
||||
C->pos[1] = 0.0;
|
||||
C->vel[0] = 0.0;
|
||||
C->vel[1] = 0.0;
|
||||
fprintf(stderr, "\n\nIMPACT: ModelTime = %.9f, pos = %.9f\n\n", C->impactTime, C->pos[0] ) ;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4,11 +4,12 @@ PURPOSE: ( Try Trick integration )
|
||||
#include "../include/cannon.h"
|
||||
#include "../include/cannon_integ_proto.h"
|
||||
|
||||
int cannon_deriv(
|
||||
CANNON* C )
|
||||
{
|
||||
C->acc[0] = 0.0 ;
|
||||
C->acc[1] = -9.81 ;
|
||||
int cannon_deriv( CANNON* C ) {
|
||||
|
||||
return 0 ;
|
||||
if (!C->impact) {
|
||||
C->acc[0] = 0.00 ;
|
||||
C->acc[1] = -9.81 ;
|
||||
C->timeRate = 1.00;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
@ -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 ;
|
||||
}
|
@ -26,8 +26,9 @@ double cannon_impact( CANNON* C )
|
||||
|
||||
C->vel[0] = 0.0 ; C->vel[1] = 0.0 ;
|
||||
C->acc[0] = 0.0 ; C->acc[1] = 0.0 ;
|
||||
C->impactTime = C->time;
|
||||
|
||||
fprintf(stderr, "\n\nIMPACT: time = %.9f, pos = %.9f\n\n", now, C->pos[0] ) ;
|
||||
fprintf(stderr, "\n\nIMPACT: SimTime = %.9f, ModelTime = %.9f, pos = %.9f\n\n", now, C->impactTime, C->pos[0] ) ;
|
||||
}
|
||||
|
||||
return ( tgo ) ;
|
||||
|
@ -20,8 +20,8 @@ int cannon_init( CANNON* C) {
|
||||
C->acc[0] = C->acc0[0] ;
|
||||
C->acc[1] = C->acc0[1] ;
|
||||
|
||||
C->impactTime = 0;
|
||||
C->impact = 0;
|
||||
C->impactTime = 1.0;
|
||||
C->impact = 0.0;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ int cannon_integ(
|
||||
&C->pos[1] ,
|
||||
&C->vel[0] ,
|
||||
&C->vel[1] ,
|
||||
&C->time ,
|
||||
NULL
|
||||
);
|
||||
|
||||
@ -28,6 +29,7 @@ int cannon_integ(
|
||||
&C->vel[1] ,
|
||||
&C->acc[0] ,
|
||||
&C->acc[1] ,
|
||||
&C->timeRate ,
|
||||
NULL
|
||||
);
|
||||
|
||||
@ -40,6 +42,7 @@ int cannon_integ(
|
||||
&C->pos[1] ,
|
||||
&C->vel[0] ,
|
||||
&C->vel[1] ,
|
||||
&C->time ,
|
||||
NULL
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user