mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 05:07:54 +00:00
Neaten and fix warnings in files created in Tutorial section 8.
This commit is contained in:
parent
2683c17e0e
commit
77c8cd656f
@ -1,12 +1,13 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: (Test Baseball)
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: ( Define CANNON_AERO type. )
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef CANNON_AERO_H
|
||||
#define CANNON_AERO_H
|
||||
|
||||
#include "sim_services/Integrator/include/regula_falsi.h"
|
||||
#include "sim_services/include/Flag.h"
|
||||
#include "sim_services/include/Flag.h"
|
||||
|
||||
typedef enum {
|
||||
Hard_Coded_Coefficient_Lift, /* You come up with Cl */
|
||||
@ -16,9 +17,9 @@ typedef enum {
|
||||
} Lift_Estimation_Method ;
|
||||
|
||||
typedef struct {
|
||||
double pos[3] ; /* M position */
|
||||
double vel[3] ; /* M/s velocity */
|
||||
double acc[3] ; /* M/s2 acceleration */
|
||||
double pos[3] ; /* m position */
|
||||
double vel[3] ; /* m/s velocity */
|
||||
double acc[3] ; /* m/s2 acceleration */
|
||||
double omega[3] ; /* r/s Angular velocity of cannonball */
|
||||
|
||||
double theta ; /* r Angle from x-axis to axis rotation */
|
||||
@ -28,7 +29,7 @@ typedef struct {
|
||||
/* Impact */
|
||||
REGULA_FALSI rf ; /* -- Dynamic event params for impact */
|
||||
int impact ; /* -- Has impact occured */
|
||||
double impact_pos ; /* M How far ball lands in field */
|
||||
double impact_pos ; /* m How far ball lands in field */
|
||||
|
||||
/* Forces */
|
||||
double force_gravity[3] ; /* N Gravitational force */
|
||||
@ -47,11 +48,11 @@ typedef struct {
|
||||
|
||||
/* Environment and Properties */
|
||||
double mass ; /* kg Mass of cannonball */
|
||||
double air_density ; /* kg/M3 Air density at 20C */
|
||||
double ball_radius ; /* M Radius of cannonball */
|
||||
double ball_area ; /* M2 Cross sectional area of ball */
|
||||
double air_density ; /* kg/m3 Air density at 20C */
|
||||
double ball_radius ; /* m Radius of cannonball */
|
||||
double ball_area ; /* m2 Cross sectional area of ball */
|
||||
double spin_parameter ; /* -- S=r*omega/speed */
|
||||
double g ; /* M/s2 Gravitational acceleration */
|
||||
double g ; /* m/s2 Gravitational acceleration */
|
||||
|
||||
/* Coefficients drag, lift and cross */
|
||||
Lift_Estimation_Method lift_method ; /* -- How to find lift force */
|
||||
@ -64,7 +65,7 @@ typedef struct {
|
||||
int jet_count ; /* -- How many jet firings? */
|
||||
double force_jet[3] ; /* N Jet force per firing */
|
||||
double force_jet_Z_plus ; /* N Configurable force of jet in Z+ direction */
|
||||
|
||||
|
||||
/* Firing the Jet for Monte Carlo Runs */
|
||||
double time_to_fire_jet_1 ; /* s First jet firing time */
|
||||
double time_to_fire_jet_2 ; /* s Second jet firing time */
|
||||
|
@ -1,10 +1,9 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: (Test Baseball)
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Cannon_aero Prototypes)
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef CANNON_AERO_PROTO_H
|
||||
#define CANNON_AERO_PROTO_H
|
||||
|
||||
#include "cannon_aero.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,12 +1,12 @@
|
||||
/*********************************************************
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Set the default data values)
|
||||
LIBRARY_DEPENDENCY: ((cannon_aero_default_data.o))
|
||||
*********************************************************/
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
|
||||
#include "../include/cannon_aero.h"
|
||||
int cannon_aero_default_data(CANNON_AERO* C) {
|
||||
|
||||
int cannon_aero_default_data(CANNON_AERO* C)
|
||||
{
|
||||
double const newton = 4.44822162 ;
|
||||
|
||||
/* Initialize cannon ball shot */
|
||||
@ -22,7 +22,6 @@ int cannon_aero_default_data(CANNON_AERO* C)
|
||||
|
||||
|
||||
/* Regula Falsi impact critter setup */
|
||||
#define BIG_TGO 10000
|
||||
C->rf.lower_set = No ;
|
||||
C->rf.upper_set = No ;
|
||||
C->rf.iterations = 0 ;
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: (Collect all forces and calculate acceleration)
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Collect all forces and calculate acceleration)
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
#include "../include/cannon_aero.h"
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
#include "sim_services/include/collect_macros.h"
|
||||
|
||||
int cannon_collect_forces(
|
||||
CANNON_AERO *C )
|
||||
{
|
||||
int cannon_collect_forces( CANNON_AERO *C ) {
|
||||
|
||||
double **collected_forces ;
|
||||
int ii ;
|
||||
|
||||
|
||||
/* Collect external forces on the ball */
|
||||
collected_forces = (double**)(C->force_collect) ;
|
||||
C->force_total[0] = 0.0 ;
|
||||
@ -20,12 +20,12 @@ int cannon_collect_forces(
|
||||
C->force_total[1] += collected_forces[ii][1] ;
|
||||
C->force_total[2] += collected_forces[ii][2] ;
|
||||
}
|
||||
|
||||
|
||||
/* Solve for xyz acceleration */
|
||||
C->acc[0] = C->force_total[0] / C->mass ;
|
||||
C->acc[1] = C->force_total[1] / C->mass ;
|
||||
C->acc[2] = C->force_total[2] / C->mass ;
|
||||
|
||||
C->acc[0] = C->force_total[0] / C->mass ;
|
||||
C->acc[1] = C->force_total[1] / C->mass ;
|
||||
C->acc[2] = C->force_total[2] / C->mass ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: (Cross Force or Side Force )
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Cross Force or Side Force )
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
#include "../include/cannon_aero.h"
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
#include "trick_utils/math/include/trick_math.h"
|
||||
|
||||
int cannon_force_cross(
|
||||
CANNON_AERO *C )
|
||||
{
|
||||
int cannon_force_cross( CANNON_AERO *C ) {
|
||||
|
||||
double magnus_cross_drag[3] ;
|
||||
double norm_magnus_cross_drag[3] ;
|
||||
double k, speed ;
|
||||
|
@ -1,16 +1,16 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: (Drag force)
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Drag force)
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
#include "../include/cannon_aero.h"
|
||||
#include "trick_utils/math/include/trick_math.h"
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
#include "trick_utils/math/include/trick_math.h"
|
||||
|
||||
int cannon_force_drag( CANNON_AERO *C ) {
|
||||
|
||||
int cannon_force_drag(
|
||||
CANNON_AERO *C )
|
||||
{
|
||||
double k ;
|
||||
double speed ;
|
||||
|
||||
speed = V_MAG( C->vel ) ;
|
||||
speed = V_MAG( C->vel ) ;
|
||||
|
||||
/* k = -1/2*rho*Cd*A*|V| */
|
||||
k = (-0.5)*C->air_density*C->coefficient_drag*C->ball_area*speed ;
|
||||
|
@ -1,7 +1,8 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: ( Gravitational force on cannonball )
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Gravitational force on cannonball)
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
#include "../include/cannon_aero.h"
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
|
||||
int cannon_force_gravity(
|
||||
CANNON_AERO *C )
|
||||
|
@ -1,12 +1,12 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: (Lift-Magnus Force)
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Lift-Magnus Force)
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
#include "../include/cannon_aero.h"
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
#include "trick_utils/math/include/trick_math.h"
|
||||
|
||||
int cannon_force_lift(
|
||||
CANNON_AERO *C )
|
||||
{
|
||||
int cannon_force_lift( CANNON_AERO *C ) {
|
||||
|
||||
double w_cross_v[3] ; double norm_w_cross_v[3] ;
|
||||
double k, speed ;
|
||||
|
||||
@ -25,13 +25,13 @@ int cannon_force_lift(
|
||||
if ( C->lift_method == Tombras ) {
|
||||
C->coefficient_lift = 1/( 2.022 + 0.981*speed/V_MAG( C->omega));
|
||||
}
|
||||
|
||||
|
||||
switch ( C->lift_method ) {
|
||||
|
||||
case Hard_Coded_Coefficient_Lift:
|
||||
case Smits_Smith:
|
||||
case Tombras:
|
||||
|
||||
case Smits_Smith:
|
||||
case Tombras:
|
||||
|
||||
/* k = 1/2*rho*Cl*A*V^2 */
|
||||
k = (0.5)*C->air_density*C->coefficient_lift*
|
||||
C->ball_area*speed*speed ;
|
||||
|
@ -1,8 +1,10 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: (Kaboom!!!)
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Kaboom!!!)
|
||||
PURPOSE: ()
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include "../include/cannon_aero.h"
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
#include "sim_services/Integrator/include/integrator_c_intf.h"
|
||||
|
||||
double cannon_impact_aero( CANNON_AERO* C)
|
||||
@ -15,11 +17,11 @@ double cannon_impact_aero( CANNON_AERO* C)
|
||||
|
||||
tgo = regula_falsi( get_integ_time() , &(C->rf) ) ;
|
||||
if (tgo == 0.0) {
|
||||
|
||||
now = get_integ_time() ;
|
||||
|
||||
now = get_integ_time() ;
|
||||
/* Ball impact */
|
||||
reset_regula_falsi( now , &(C->rf) ) ;
|
||||
|
||||
|
||||
C->vel[0] = 0.0 ; C->vel[1] = 0.0 ; C->vel[2] = 0.0 ;
|
||||
C->acc[0] = 0.0 ; C->acc[1] = 0.0 ; C->acc[2] = 0.0 ;
|
||||
C->g = 0.0 ;
|
||||
|
@ -1,19 +1,17 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: ( Cannon initialization )
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: ( Cannon initialization )
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
#include "trick_utils/math/include/trick_math.h"
|
||||
|
||||
#include "../include/cannon_aero.h"
|
||||
#include "trick_utils/math/include/trick_math.h"
|
||||
int cannon_init_aero( CANNON_AERO* C) {
|
||||
|
||||
int cannon_init_aero(
|
||||
CANNON_AERO* C)
|
||||
{
|
||||
/* Convert omega from spherical (almost) to rectangular */
|
||||
C->omega[0] = C->omega0*sin(M_PI/2.0 - C->phi)*cos(C->theta) ;
|
||||
C->omega[1] = C->omega0*sin(M_PI/2.0 - C->phi)*sin(C->theta) ;
|
||||
C->omega[2] = C->omega0*cos(M_PI/2.0 - C->phi) ;
|
||||
|
||||
return ( 0 );
|
||||
return ( 0 );
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*********************************** TRICK HEADER **************************
|
||||
PURPOSE: (Cannon integration)
|
||||
/****************************** TRICK HEADER ******************************
|
||||
PURPOSE: (Cannon integration)
|
||||
Tutorial Section 8
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "sim_services/Integrator/include/integrator_c_intf.h"
|
||||
#include "../include/cannon_aero.h"
|
||||
#include "../include/cannon_aero_proto.h"
|
||||
|
||||
int cannon_integ_aero(
|
||||
CANNON_AERO* C)
|
||||
|
Loading…
Reference in New Issue
Block a user