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

Added graphics client for SIM rigid body. #1779

Merged
merged 41 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
18efd05
added SIM_singlerigidbody
Aug 15, 2024
ba03212
Added matrix operations file.
Aug 22, 2024
9f17942
Imported libraries and declared variables.
Aug 22, 2024
95d81a4
New objects and more defined values.
Aug 22, 2024
208e3c2
Declared more variables and added AzElRot. function.
Aug 23, 2024
5b11d7f
Sockets and file connections 1
Aug 23, 2024
4b1292f
Adding to variable server.
Aug 23, 2024
f5d9cb1
Variables for the variable server.
Aug 26, 2024
88c167b
Variable parsing added.
Aug 26, 2024
394637a
Vertex model for crewModule; need to change to sphere later.
Aug 26, 2024
4f1a215
Body and vantage positioning functions.
Aug 26, 2024
6c577c8
Drawing functions to create the model.
Aug 26, 2024
4e25925
Finished drawing functions for world.
Aug 26, 2024
a0c0afd
Changed some of the object names and variable names for sync.
Aug 26, 2024
88c85ef
Added Makefile.
Aug 26, 2024
9533db0
Added POM file.
Aug 26, 2024
45c12b9
Graphics client starter added to input file.
Aug 26, 2024
60bfbc4
Changed paths in S_define to reflect current file structure.
Aug 27, 2024
0bd8835
More accurate cd error message in input file.
Aug 27, 2024
f67b5b8
Color hardcoded for testing purposes and getting the sim running.
Aug 28, 2024
63cfea5
S_overrides changed to include graphics cleaning for each sim execution.
Aug 28, 2024
ed8bce2
S_define formatted for better readability.
Aug 28, 2024
4168e31
Changed shape to a dodecahedron.
Aug 29, 2024
a9be32f
Path changed for input file.
Aug 29, 2024
f3a27a5
Airport commit
Aug 29, 2024
1bf43ac
New edges for dodecahedron.
Sep 3, 2024
34d4835
Triangle normals for the dodecahedron changed.
Sep 3, 2024
c0c826e
Sim variable parsing fixed for functionality.
Sep 3, 2024
28d62b8
Edges of dodecahedron fixed.
Sep 3, 2024
0ed8118
Changed paint color for the shape to change based on location.
Sep 3, 2024
d5d1509
Deleted unnecessary JViewport library.
Sep 4, 2024
4559736
Increased length of x, y, and z axis lines.
Sep 4, 2024
fdf29f0
Increased vantage distance.
Sep 4, 2024
ad53246
Fixed triangles and normals.
Sep 4, 2024
5259f5f
Commented on the edges.
Sep 4, 2024
12087da
Deleted the notes file.
Sep 18, 2024
b183bd4
Merge latest trick master into rigidbodygraphicsbranch
Oct 23, 2024
c9d85c2
Removed trick.frame_long_on() from splashdown SIM's realtime.py in mo…
Oct 29, 2024
10aa6f7
Deleted sims directory (including images sub directory).
Oct 29, 2024
621e2ca
Removed unnecessary body.hh and body.cpp from subdirectory.
Oct 30, 2024
0ad2ff8
Removed unnecessary files.
Oct 30, 2024
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
12 changes: 12 additions & 0 deletions trick_sims/SIM_singlerigidbody/S_overrides.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
TRICK_CFLAGS += -Imodels
TRICK_CXXFLAGS += -Imodels

.PHONY: clean_graphics

all: models/singlerigidbodygraphics/build/SingleRigidBodyDisplay.jar

spotless: clean_graphics

models/singlerigidbodygraphics/build/SingleRigidBodyDisplay.jar:
${MAKE} -C ./models/singlerigidbodygraphics

clean_graphics:
${MAKE} -C ./models/singlerigidbodygraphics clean
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_singlerigidbody/models/singlerigidbodygraphics/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>SingleRigidBodyDisplay</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>trick.SRBDisplay</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// This file contains helper functions for the matrix operations necessary for the graphics to be generated.

package trick.matrixOps;



public class MatrixOps { // Defines the matrix operation class.

public static void printMatrix(double M[][]) { // Prints out the matrix.
int M_rows = M.length;
int M_cols = M[0].length;
for (int i = 0; i < M_rows; i++) {
for (int j = 0; j < M_cols; j++)
System.out.print(" " + M[i][j]);
System.out.println();
}
}

public static void printDVector(double V[]) { // Prints out a vector passed as a double.
System.out.print("(");
for (int i = 0; i < V.length; i++) {
System.out.print(" " + V[i]);
}
System.out.println(")");
}

public static void printIVector(int V[]) { // Prints out a vector passed as an integer.
System.out.print("(");
for (int i = 0; i < V.length; i++) {
System.out.print(" " + V[i]);
}
System.out.println(")");
}

public static void MtimesM( double R[][], double A[][], double B[][]) { // Multiplies two matrices together.
int A_rows = A.length;
int A_cols = A[0].length;
int B_rows = B.length;
int B_cols = B[0].length;
int R_rows = R.length;
int R_cols = R[0].length;

if (A_cols != B_rows) { // Checks if the matrices can be multiplied.
System.out.println( "\nNot possible to multiply matrixes,");
System.out.println("where the first has " + A_cols + " columns,");
System.out.println("and the second has " + B_rows + "rows.");
return;
}
if ((R_rows != A_rows) || (R_cols != B_cols)) { // Checks if the defined result matrix is the wrong size.
System.out.println( "\n Result matrix is wrong size.");
return;
}

for (int i = 0; i < A_rows; i++) { // Multiplies the two matrices together.
for (int j = 0; j < B_cols; j++) {
R[i][j] = 0.0;
for (int k = 0; k < B_rows; k++)
R[i][j] += A[i][k] * B[k][j];
}
}
}

public static void MtimesV( double R[], double M[][], double V[]) { // Multiplies a matrix with a vector.
int M_rows = M.length;
int M_cols = M[0].length;
int V_rows = V.length;

if (M_cols != V_rows) { // Checks if the matrix and the vector can be multiplied together.
System.out.println( "\nNot possible to multiply matrix and vector,");
System.out.println( "where the matrix has " + M_cols + " columns,");
System.out.println("and the vector has " + V_rows + " elements.");
return;
}

if (R.length != M.length) { // Checks if the defined result vector is the wrong size.
System.out.println( "\n Result vector is wrong size.");
return;
}

for (int i =0; i < M_rows ; i++) { // Multiplies the vector with the matrix.
R[i] = 0.0;
for (int j =0; j < M_cols ; j++) {
R[i] += M[i][j] * V[j];
}
}
return;
}

public static void VplusV(double R[], double A[], double B[]) { // Adds two matrices together.
if ((A.length != B.length) || (A.length != R.length)) {
System.out.println( "\n MatrixOps::VplusV : Vectors are not the same size.");
}
for (int i=0; i<A.length ; i++) {
R[i] = A[i] + B[i];
}
}

public static void VminusV(double R[], double A[], double B[]) { // Subtracts two matrices together.
if ((A.length != B.length) || (A.length != R.length)) {
System.out.println( "\n MatrixOps::VminusV : Vectors are not the same size.");
return;
}
for (int i=0; i<A.length ; i++) {
R[i] = A[i] - B[i];
}
}

public static void VcrossV(double R[], double A[], double B[]) { // Finds the cross product of two matrices.
if ((R.length != 3) || (A.length != 3) || (B.length != 3)) {
System.out.println( "\n MatrixOps::VcrossV : All vector args must be length 3.");
return;
}
R[0] = A[1] * B[2] - A[2] * B[1];
R[1] = A[2] * B[0] - A[0] * B[2];
R[2] = A[0] * B[1] - A[1] * B[0];
}

public static double VdotV(double A[], double B[]) { // Finds the dot product of two matrices.
if (A.length != B.length) {
System.out.println( "\n MatrixOps::VdotV : Vectors are not the same size.");
return 0.0;
}
double R = 0.0;
for (int i=0; i<A.length ; i++) {
R += A[i] * B[i];
}
return R;
}

public static void Vscale(double R[], double A[], double S) { // Scales a vector (Multiplies by a given number).
if (A.length != R.length) {
System.out.println( "\n MatrixOps::Vscale : Input and output vectors are not the same size.");
return;
}
for (int i=0; i<A.length ; i++) {
R[i] = A[i] * S;
}
}

public static double Vmagnitude (double V[]) { // Returns the magnitude of a vector (Length of a vector).
double S = 0;
for (int i =0; i < V.length ; i++) {
S += V[i]*V[i];
}
return Math.sqrt(S);
}

}




Loading
Loading