Update SIM_cannon_analytic and add ability to launch new graphics client. Ref #320

This commit is contained in:
John M. Penn 2016-10-19 17:39:47 -05:00
parent 2fb06cf133
commit 9b1ef5404a
6 changed files with 62 additions and 35 deletions

View File

@ -0,0 +1,19 @@
execfile("Modified_data/realtime.py")
#==========================================
# Start the display VarServer 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('==================================================================================')

View File

@ -1,5 +1,5 @@
execfile("Modified_data/cannon.dr")
execfile("Modified_data/realtime.py")
trick.exec_set_terminate_time(5.2)

View File

@ -16,18 +16,20 @@ typedef struct {
double vel0[2] ; /* *i m Init velocity of cannonball */
double acc0[2] ; /* *i m Init acceleration of cannonball */
double init_speed ; /* *i m/s Init barrel speed */
double init_angle ; /* *i rad Angle of cannon */
double pos[2] ; /* m xy-position */
double vel[2] ; /* m/s xy-velocity */
double acc[2] ; /* m/s2 xy-acceleration */
double init_speed ; /* *i m/s Init barrel speed */
double init_angle ; /* *i rad Angle of cannon */
double impactTime;
double time;
/* Impact */
REGULA_FALSI rf ; /* -- Dynamic event params for impact */
int impact ; /* -- Has impact occured? */
FILE *fp ; /* -- file pointer */
/* Communication Connection */
TCDevice connection ; /* -- Socket connection for sending position */
} CANNON ;

View File

@ -5,26 +5,29 @@ PURPOSE: ( Analytical Cannon )
#include "../include/cannon.h"
#include "../include/cannon_analytic_proto.h"
int cannon_analytic(
CANNON* C )
int cannon_analytic( CANNON* C )
{
static double time = 0.0 ;
C->acc[0] = 0.0 ;
C->acc[0] = 0.00;
C->acc[1] = -9.81 ;
C->vel[0] = C->vel0[0] + C->acc0[0]*time ;
C->vel[1] = C->vel0[1] + C->acc0[1]*time ;
C->pos[0] = C->pos0[0] + C->vel0[0]*time + (0.5)*C->acc0[0]*time*time ;
C->pos[1] = C->pos0[1] + C->vel0[1]*time + (0.5)*C->acc0[1]*time*time ;
C->vel[0] = C->vel0[0] + C->acc0[0] * C->time ;
C->vel[1] = C->vel0[1] + C->acc0[1] * C->time ;
C->pos[0] = C->pos0[0] + (C->vel0[0] + (0.5) * C->acc0[0] * C->time) * C->time ;
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->pos[0] = C->impactTime * C->vel0[0];
C->pos[1] = 0.0;
C->vel[0] = 0.0;
C->vel[1] = 0.0;
}
/*
* Increment time by the time delta associated with this job
* Note that the 0.01 matches the frequency of this job
* as specified in the S_define.
*/
time += 0.01 ;
C->time += 0.01 ;
return 0 ;
}

View File

@ -9,16 +9,18 @@ LIBRARY_DEPENDENCY: ((cannon_default_data.o))
#include "sim_services/include/Flag.h"
/* Entry Point */
int cannon_default_data(CANNON* C)
int cannon_default_data( CANNON* C )
{
const double PI = 3.141592 ;
C->pos[0] = 0.0 ;
C->pos[1] = 0.0 ;
C->acc[0] = 0.0 ;
C->acc[1] = -9.81 ;
C->pos0[0] = 0.0 ;
C->pos0[1] = 0.0 ;
C->acc0[0] = 0.0 ;
C->acc0[1] = -9.81 ;
C->init_angle = PI/6 ;
C->init_speed = 50.0 ;
C->impactTime = 0.0 ;
C->time = 0.0 ;
/*
* Regula falsi dynamic event impact setup

View File

@ -6,22 +6,23 @@ PURPOSE: (Initialize the cannonball)
#include "../include/cannon.h"
#include "../include/cannon_integ_proto.h"
int cannon_init(
CANNON* C )
{
int cannon_init( CANNON* C) {
C->fp = fopen("/users/dpanter/trunk/trick_sims/SIM_cannon/output.d", "w");
C->pos0[0] = C->pos[0] ;
C->pos0[1] = C->pos[1] ;
C->pos[0] = C->pos0[0] ;
C->pos[1] = C->pos0[1] ;
C->vel[0] = C->init_speed*cos(C->init_angle);
C->vel[1] = C->init_speed*sin(C->init_angle);
C->vel0[0] = C->vel[0] ;
C->vel0[1] = C->vel[1] ;
C->vel0[0] = C->init_speed*cos(C->init_angle);
C->vel0[1] = C->init_speed*sin(C->init_angle);
C->acc0[0] = C->acc[0] ;
C->acc0[1] = C->acc[1] ;
C->vel[0] = C->vel0[0] ;
C->vel[1] = C->vel0[1] ;
C->acc[0] = C->acc0[0] ;
C->acc[1] = C->acc0[1] ;
C->impactTime = 0;
C->impact = 0;
return 0 ;
}