mirror of
https://github.com/nasa/trick.git
synced 2025-05-13 14:02:50 +00:00
Some checks failed
Linux Python 2 / build (clang-devel gcc gcc-c++ java-11-openjdk-devel libxml2-devel llvm-devel llvm-static ncurses-devel openmotif openmotif-devel perl perl-Digest-MD5 udunits2 udunits2-devel which zlib-devel python2-devel python3-devel, map[arch:rhel]) (push) Has been cancelled
Linux Python 2 / build (map[], echo package manager already configured, bison clang flex git llvm make maven cmake zip, install -y, echo gtest already installed) (push) Has been cancelled
Linux Python 2 / build (map[arch:debian arch_ver:12 os:ubuntu tag:22.04], 2) (push) Has been cancelled
Linux Python 2 / build (map[arch:rhel arch_ver:7], yum -y install epel-release
yum -y update
, libX11-devel libXt-devel swig3 gtest-devel, yum) (push) Has been cancelled
Linux Python 2 / build (map[arch:rhel arch_ver:8 os:oraclelinux tag:8], 2) (push) Has been cancelled
Linux Python 2 / build (map[arch:rhel arch_ver:8 os:rockylinux tag:8], 2) (push) Has been cancelled
Linux Python 2 / build (map[arch:rhel arch_ver:8], dnf -y install epel-release
dnf -y update
dnf install -y 'dnf-command(config-manager)'
, dnf config-manager --enable powertools
dnf install -y gtest-devel
, dnf, swig diffutils) (push) Has been cancelled
Linux Python 2 / build (map[os:oraclelinux], dnf config-manager --enable ol8_codeready_builder
dnf install -y gtest-devel
) (push) Has been cancelled
Linux Python 2 / build (swig curl g++ libx11-dev libxml2-dev libxt-dev libmotif-common libmotif-dev zlib1g-dev llvm-dev libclang-dev libudunits2-dev libgtest-dev default-jdk python2.7-dev python3-dev python3-pip python3-venv, map[arch:debian], apt-get update, apt-get i… (push) Has been cancelled
32-bit Oracle / trick_32bit_oracle (push) Has been cancelled
Test Docker Hub Images / latest (trick_ubuntu1804) (push) Has been cancelled
More Linux / build (clang-devel gcc gcc-c++ java-11-openjdk-devel libxml2-devel llvm-devel llvm-static ncurses-devel openmotif openmotif-devel perl perl-Digest-MD5 udunits2 udunits2-devel which zlib-devel python2-devel python3-devel, map[arch:rhel]) (push) Has been cancelled
More Linux / build (map[], echo package manager already configured, bison clang flex git llvm make maven cmake zip, install -y, echo gtest already installed) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:10 os:debian tag:10], 2) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:10 os:debian tag:10], 3) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:10], apt-get install -y libgtest-dev
cd /usr/src/gtest
cmake .
make
cp libgtest* /usr/lib/
) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11 os:debian tag:11], 2) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11 os:debian tag:11], 3) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11 os:ubuntu tag:20.04], 2) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11 os:ubuntu tag:20.04], 3) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:11], export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y tzdata
) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:12 os:debian tag:bookworm], 2) (push) Has been cancelled
More Linux / build (map[arch:debian arch_ver:12 os:debian tag:bookworm], 3) (push) Has been cancelled
More Linux / build (map[arch:debian], 2, python2.7-dev) (push) Has been cancelled
More Linux / build (map[arch:rhel arch_ver:8 os:almalinux tag:8], 2) (push) Has been cancelled
More Linux / build (map[arch:rhel arch_ver:8 os:almalinux tag:8], 3) (push) Has been cancelled
More Linux / build (map[arch:rhel arch_ver:8], dnf -y install epel-release
dnf -y update
dnf install -y 'dnf-command(config-manager)'
, dnf config-manager --enable powertools
dnf install -y gtest-devel
, dnf, swig diffutils) (push) Has been cancelled
More Linux / build (swig curl g++ libx11-dev libxml2-dev libxt-dev libmotif-common libmotif-dev zlib1g-dev llvm-dev libclang-dev libudunits2-dev libgtest-dev default-jdk python3-dev python3-pip python3-venv, map[arch:debian], apt-get update, apt-get install -y libg… (push) Has been cancelled
* Integrated MultiDtInteg classes into Trick build. * Corrected some comments * Cleaned up version and added test * Small fixes and more interesting test case * Added MultiDt integration User's Guide section. * Correct numbered solutions * Newline fix * Added check that an integration rate can be represented in trick tics * Fixed doc comment and added baseline sat2d_multidt sim. Need to add specific rates. * Fixed some tics vs doubles issues. Added testing and comparison vs single rate. exact match * cleaned up unit test input files and prevent both realtime and any guis if unit tests are enabled * Fix input file syntax error
192 lines
5.2 KiB
Plaintext
192 lines
5.2 KiB
Plaintext
/************************TRICK HEADER*************************
|
|
PURPOSE:
|
|
(This comment lists out the other object files that are not included from c++ headers)
|
|
LIBRARY DEPENDENCIES:
|
|
(
|
|
)
|
|
*************************************************************/
|
|
|
|
#include "sim_objects/default_trick_sys.sm"
|
|
|
|
|
|
##include <math.h>
|
|
##include "sim_services/Message/include/message_proto.h"
|
|
##include "sim_services/Integrator/include/Integrator.hh"
|
|
##include "sim_services/Integrator/include/integrator_c_intf.h"
|
|
|
|
/* base ball... get it? :) */
|
|
class ballSimObject : public Trick::SimObject {
|
|
|
|
public:
|
|
double mass;
|
|
double input_position[2];
|
|
double speed;
|
|
double elevation;
|
|
|
|
double output_position[2];
|
|
double output_velocity[2];
|
|
double output_acceleration[2];
|
|
double output_external_force[2];
|
|
|
|
double origin[2];
|
|
double input_force;
|
|
double output_force[2];
|
|
|
|
|
|
int force_default_data () {
|
|
|
|
origin[0] = 0.0 ;
|
|
origin[1] = 2.0 ;
|
|
input_force = 8.0 ;
|
|
|
|
return(0) ;
|
|
} ;
|
|
|
|
int state_default_data () {
|
|
mass = 10.0 ;
|
|
speed = 3.5 ;
|
|
elevation = 0.785398163 ;
|
|
input_position[0] = 5.0 ;
|
|
input_position[1] = 5.0 ;
|
|
|
|
return(0) ;
|
|
} ;
|
|
|
|
int state_init() {
|
|
/* TRANSFER INPUT POSITION STATES TO OUTPUT POSITION STATES */
|
|
output_position[0] = input_position[0]; /* X state */
|
|
output_position[1] = input_position[1]; /* Y state */
|
|
|
|
/* TRANSFER INPUT SPEED AND ELEVATION INTO THE VELOCITY VECTOR */
|
|
output_velocity[0] = speed * cos( elevation ); /* X velocity */
|
|
output_velocity[1] = speed * sin( elevation ); /* Y velocity */
|
|
|
|
return(0) ;
|
|
} ;
|
|
|
|
int force_field() {
|
|
/* LOCAL VARIABLE DECLARATIONS */
|
|
double mag;
|
|
double rel_pos[2];
|
|
double unit[2];
|
|
|
|
/* GET RELATIVE VECTOR FROM BALL TO FORCE ORIGIN */
|
|
rel_pos[0] = origin[0] - output_position[0];
|
|
rel_pos[1] = origin[1] - output_position[1];
|
|
|
|
/* GET UNIT VECTOR AND POSITION MAGNITUDE FROM BALL TO FORCE ORIGIN */
|
|
/* Note sigularity when ball position = force origin. */
|
|
mag = sqrt( rel_pos[0]*rel_pos[0] + rel_pos[1]*rel_pos[1] );
|
|
unit[0] = rel_pos[0] / mag;
|
|
unit[1] = rel_pos[1] / mag;
|
|
|
|
/* COMPUTE EXTERNAL FORCE ON BALL IN THE DIRECTION OF THE UNIT VECTOR */
|
|
output_force[0] = input_force * (unit[0]);
|
|
output_force[1] = input_force * (unit[1]);
|
|
|
|
return(0) ;
|
|
} ;
|
|
|
|
int state_deriv() {
|
|
|
|
output_external_force[0] = output_force[0] ;
|
|
output_external_force[1] = output_force[1] ;
|
|
|
|
/* SOLVE FOR THE X AND Y ACCELERATIONS OF THE BALL */
|
|
output_acceleration[0] = output_external_force[0] / mass;
|
|
output_acceleration[1] = output_external_force[1] / mass;
|
|
|
|
return(0) ;
|
|
};
|
|
|
|
int state_integ() {
|
|
|
|
int ipass;
|
|
|
|
/* LOAD THE POSITION AND VELOCITY STATES */
|
|
load_state(
|
|
&output_position[0] ,
|
|
&output_position[1] ,
|
|
&output_velocity[0] ,
|
|
&output_velocity[1] ,
|
|
NULL
|
|
);
|
|
|
|
/* LOAD THE POSITION AND VELOCITY STATE DERIVATIVES */
|
|
load_deriv(
|
|
&output_velocity[0] ,
|
|
&output_velocity[1] ,
|
|
&output_acceleration[0] ,
|
|
&output_acceleration[1] ,
|
|
NULL
|
|
);
|
|
|
|
/* CALL THE TRICK INTEGRATION SERVICE */
|
|
ipass = integrate();
|
|
|
|
/* UNLOAD THE NEW POSITION AND VELOCITY STATES */
|
|
unload_state(
|
|
&output_position[0] ,
|
|
&output_position[1] ,
|
|
&output_velocity[0] ,
|
|
&output_velocity[1] ,
|
|
NULL
|
|
);
|
|
|
|
/* RETURN */
|
|
return( ipass );
|
|
|
|
} ;
|
|
|
|
int state_print() {
|
|
message_publish(8, "time = %f , position = %f , %f\n" , exec_get_sim_time() , output_position[0] , output_position[1]) ;
|
|
return 0 ;
|
|
} ;
|
|
|
|
ballSimObject() {
|
|
("default_data") force_default_data() ;
|
|
("default_data") state_default_data() ;
|
|
|
|
("initialization") state_init() ;
|
|
|
|
("derivative") force_field() ;
|
|
("derivative") state_deriv() ;
|
|
("integration") trick_ret = state_integ() ;
|
|
|
|
(0.015625, "scheduled") example_64Hz() ;
|
|
(0.025, "scheduled") example_40Hz() ;
|
|
(10.0, "scheduled") trick_ret = state_print() ;
|
|
|
|
("freeze") state_print() ;
|
|
}
|
|
|
|
void example_64Hz()
|
|
{
|
|
state_print();
|
|
}
|
|
|
|
void example_40Hz()
|
|
{
|
|
state_print();
|
|
}
|
|
|
|
} ;
|
|
|
|
// Instantiations
|
|
ballSimObject ball ;
|
|
|
|
MultiDtIntegLoopSimObject my_integ_loop(0.01, 0, &ball, (void *)NULL);
|
|
|
|
|
|
// Connect objects
|
|
void create_connections() {
|
|
|
|
// Set the default termination time
|
|
exec_set_terminate_time(300.0) ;
|
|
exec_set_freeze_frame(0.10) ;
|
|
|
|
my_integ_loop.getIntegrator(Runge_Kutta_2, 4);
|
|
|
|
}
|
|
|