Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Submarine simulation #1629

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions trick_sims/SIM_submarine/Modified_data/Submarine.dr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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("Submarine"))
drg[DR_GROUP_ID].set_freq(trick.DR_Always)
drg[DR_GROUP_ID].set_cycle(0.1)
drg[DR_GROUP_ID].set_single_prec_only(False)
drg[DR_GROUP_ID].add_variable("dyn.submarine.pos[0]")
drg[DR_GROUP_ID].add_variable("dyn.submarine.pos[1]")
drg[DR_GROUP_ID].add_variable("dyn.submarine.vel[0]")
drg[DR_GROUP_ID].add_variable("dyn.submarine.vel[1]")
drg[DR_GROUP_ID].set_max_file_size(1 * 1073741824) # multiply converts GiB to B --Dr. Dre
trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer)
drg[DR_GROUP_ID].enable()
10 changes: 10 additions & 0 deletions trick_sims/SIM_submarine/Modified_data/realtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

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)
23 changes: 23 additions & 0 deletions trick_sims/SIM_submarine/RUN_test/input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
exec(open("./Modified_data/realtime.py").read())

dyn.submarine.pos[0] = 0.0
dyn.submarine.pos[1] = -0.5
dyn.submarine.vel[0] = 0.0
dyn.submarine.vel[1] = 0.0

# ==========================================
# Start the Satellite Graphics Client
# ==========================================
varServerPort = trick.var_server_get_port();
SubmarineDisplay_path = "models/graphics/build/SubmarineDisplay.jar"

if (os.path.isfile(SubmarineDisplay_path)) :
SubmarineDisplay_cmd = "java -jar " \
+ SubmarineDisplay_path \
+ " " + str(varServerPort) + " &" ;
print(SubmarineDisplay_cmd)
os.system( SubmarineDisplay_cmd);
else :
print('==================================================================================')
print('SubmarineDisplay needs to be built. Please \"cd\" into ../models/graphics and type \"mvn package\".')
print('==================================================================================')
29 changes: 29 additions & 0 deletions trick_sims/SIM_submarine/S_define
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/************************************************************
PURPOSE:
( Simulate a submarine. )
LIBRARY DEPENDENCIES:
((submarine/src/Submarine.cpp))
*************************************************************/
#include "sim_objects/default_trick_sys.sm"
##include "submarine/include/Submarine.hh"

class SubmarineSimObject : public Trick::SimObject {
public:
Submarine submarine;

SubmarineSimObject() {
("default_data") submarine.default_data() ;
("initialization") submarine.state_init() ;
("derivative") submarine.state_deriv() ;
(0.1, "scheduled") submarine.control() ;
("integration") trick_ret = submarine.state_integ() ;
("post_integration") submarine.state_post_integ() ;
}
};

SubmarineSimObject dyn;
IntegLoop dyn_integloop(0.1) dyn;

void create_connections() {
dyn_integloop.getIntegrator(Runge_Kutta_4, 6);
}
2 changes: 2 additions & 0 deletions trick_sims/SIM_submarine/S_overrides.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TRICK_CFLAGS += -Imodels
TRICK_CXXFLAGS += -Imodels
Binary file added trick_sims/SIM_submarine/Submarine.pdf
Binary file not shown.
Binary file added trick_sims/SIM_submarine/Submarine.pptx
Binary file not shown.
1 change: 1 addition & 0 deletions trick_sims/SIM_submarine/models/graphics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!\makefile
6 changes: 6 additions & 0 deletions trick_sims/SIM_submarine/models/graphics/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

all:
mvn package

clean:
rm -rf build
121 changes: 121 additions & 0 deletions trick_sims/SIM_submarine/models/graphics/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>trick-java</groupId>
<artifactId>trick-java</artifactId>
<version>23.0.0-beta</version>

<name>trick-java</name>

<url>https://github.com/nasa/trick</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>

<finalName>SubmarineDisplay</finalName>

<directory>build</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
<destDir>../../share/doc/trick/java</destDir>
</configuration>
</plugin>
</plugins>

<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->

<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>

<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgs>
<arg>-g</arg>
<arg>-Xlint:unchecked</arg>
<arg>-Xlint:deprecation</arg>
</compilerArgs>
</configuration>
</plugin>

<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>SubmarineDisplay</mainClass>
</manifest>
</archive>
</configuration>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

<!--
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
-->

</plugins>
</pluginManagement>
</build>
</project>
Loading