diff --git a/simulator/pom.xml b/simulator/pom.xml
index f7a240f4..47fb9ec5 100644
--- a/simulator/pom.xml
+++ b/simulator/pom.xml
@@ -31,8 +31,6 @@
net.spy
spymemcached
2.12.3
- system
- ${project.basedir}/src/main/resources/jar/spymemcached-2.12.3.jar
@@ -56,4 +54,4 @@
msp.simulator
-
\ No newline at end of file
+
diff --git a/simulator/src/main/java/msp/simulator/Main.java b/simulator/src/main/java/msp/simulator/Main.java
index baf1b10f..f19fbab5 100644
--- a/simulator/src/main/java/msp/simulator/Main.java
+++ b/simulator/src/main/java/msp/simulator/Main.java
@@ -40,13 +40,16 @@ public static void main(String[] args) {
Dashboard.setSimulationDuration(1000000);
Dashboard.setIntegrationTimeStep(0.1);
- Dashboard.setEphemerisTimeStep(1.0);
- Dashboard.setSatelliteInertiaMatrix(SatelliteBody.satInertiaMatrix);
+ Dashboard.setEphemerisTimeStep(0.1);
+ Dashboard.setStepDelay(0.1);
Dashboard.setInitialAttitudeQuaternion(new Quaternion(1, 0, 0, 0));
- Dashboard.setInitialSpin(new Vector3D(0.5, 0.5, 0.5));
+ Dashboard.setInitialSpin(new Vector3D(0.05, 0.05, 0.05));
Dashboard.setInitialRotAcceleration(new Vector3D(0,0,0));
- Dashboard.setTorqueDisturbances(true);
+ Dashboard.setTorqueDisturbances(false);
+ //Dashboard.setSatelliteInertiaMatrix(SatelliteBody.satInertiaMatrix);
+ Dashboard.setSatelliteInertiaMatrix(SatelliteBody.ACRUX1InertiaMatrix);
+ //Dashboard.setSatelliteInertiaMatrix(SatelliteBody.simpleBalancedInertiaMatrix);
Dashboard.setCommandTorqueProvider(TorqueProviderEnum.MEMCACHED);
Dashboard.setMemCachedConnection(true, "127.0.0.1:11211");
diff --git a/simulator/src/main/java/msp/simulator/NumericalSimulator.java b/simulator/src/main/java/msp/simulator/NumericalSimulator.java
index 83cae2f6..49a8c7e1 100644
--- a/simulator/src/main/java/msp/simulator/NumericalSimulator.java
+++ b/simulator/src/main/java/msp/simulator/NumericalSimulator.java
@@ -49,6 +49,9 @@ public class NumericalSimulator {
* Default value is Long.MAX_VALUE. */
public static long simulationDuration = Long.MAX_VALUE;
+ /** Wall clock time between computing steps of the simulation. */
+ public static double stepDelay = 0.1;
+
/** Real-time processing flag. */
public static boolean realTimeUserFlag = false;
@@ -215,8 +218,7 @@ public void process() {
scheduler.scheduleAtFixedRate(
mainSimulationTask,
0,
- (long) (this.dynamic.getPropagation().getIntegrationManager()
- .getStepSize() * 1000),
+ (long) (stepDelay * 1000),
TimeUnit.MILLISECONDS);
diff --git a/simulator/src/main/java/msp/simulator/dynamic/propagation/integration/RotAccProvider.java b/simulator/src/main/java/msp/simulator/dynamic/propagation/integration/RotAccProvider.java
index 8b0b3c9a..8e4dc34a 100644
--- a/simulator/src/main/java/msp/simulator/dynamic/propagation/integration/RotAccProvider.java
+++ b/simulator/src/main/java/msp/simulator/dynamic/propagation/integration/RotAccProvider.java
@@ -138,8 +138,8 @@ public static double[] computeEulerEquations(
* the Euler Equations of motion for a rotating rigid body.
*/
rotAcc[0] = (M1 - (I3 - I2) * W2 * W3) / I1 ;
- rotAcc[1] = (M2 - (I1 - I3) * W3 * W1) / I1 ;
- rotAcc[2] = (M3 - (I2 - I1) * W1 * W2) / I1 ;
+ rotAcc[1] = (M2 - (I1 - I3) * W3 * W1) / I2 ;
+ rotAcc[2] = (M3 - (I2 - I1) * W1 * W2) / I3 ;
return rotAcc;
}
diff --git a/simulator/src/main/java/msp/simulator/dynamic/torques/MemCachedTorqueProvider.java b/simulator/src/main/java/msp/simulator/dynamic/torques/MemCachedTorqueProvider.java
index c7a616b8..a58dc469 100644
--- a/simulator/src/main/java/msp/simulator/dynamic/torques/MemCachedTorqueProvider.java
+++ b/simulator/src/main/java/msp/simulator/dynamic/torques/MemCachedTorqueProvider.java
@@ -170,7 +170,7 @@ public Vector3D getTorque(AbsoluteDate date) {
}
/* Debug Information */
- logger.debug("Torque Provider (Acquisition): " + date.toString() +" - " +
+ logger.info("Torque Provider (Acquisition): " + date.toString() +" - " +
this.stepTorque.toString());
} else {
diff --git a/simulator/src/main/java/msp/simulator/groundStation/GroundStation.java b/simulator/src/main/java/msp/simulator/groundStation/GroundStation.java
index 83042569..6ae7825c 100644
--- a/simulator/src/main/java/msp/simulator/groundStation/GroundStation.java
+++ b/simulator/src/main/java/msp/simulator/groundStation/GroundStation.java
@@ -158,7 +158,7 @@ public void executeMission(AbsoluteDate date) {
byte[] raan = MemcachedRawTranscoder.toRawByteArray(
Double.valueOf(tle.getLine2().substring(17, 25)));
- byte[] eccentricity = MemcachedRawTranscoder.toRawByteArray(
+ byte[] eccentricity1e7 = MemcachedRawTranscoder.toRawByteArray(
Double.valueOf(tle.getLine2().substring(26, 33)));
byte[] argPerigee = MemcachedRawTranscoder.toRawByteArray(
@@ -175,7 +175,7 @@ public void executeMission(AbsoluteDate date) {
memcached.set("Simulation_TLE_Mean_Motion_First_Deriv" , 0, meanMotionFirstDerivative);
memcached.set("Simulation_TLE_Mean_Motion" , 0, meanMotion);
memcached.set("Simulation_TLE_Argument_Perigee" , 0, argPerigee);
- memcached.set("Simulation_TLE_Eccentricity" , 0, eccentricity);
+ memcached.set("Simulation_TLE_Eccentricity_1e7" , 0, eccentricity1e7);
memcached.set("Simulation_TLE_Mean_Anomaly" , 0, meanAnomaly);
memcached.set("Simulation_TLE_Inclination" , 0, inclination);
memcached.set("Simulation_TLE_Bstar" , 0, bStar);
@@ -213,15 +213,15 @@ public void executeMission(AbsoluteDate date) {
+ "TLE_Epoch: " +
+ ByteBuffer.wrap(epoch).getDouble()
+ "\n"
- + "TLE_Eccentricity: " +
- + ByteBuffer.wrap(eccentricity).getDouble()
+ + "TLE_Eccentricity_1e7: " +
+ + ByteBuffer.wrap(eccentricity1e7).getDouble()
+ "\n"
+ "TLE_Argument_Perigee: " +
+ ByteBuffer.wrap(argPerigee).getDouble()
+ "\n"
- + "Raw : " + tle.getLine1()
+ + "Raw: " + tle.getLine1()
+ "\n"
- + "Raw : " + tle.getLine2()
+ + "Raw: " + tle.getLine2()
;
logger.info(tleUpdate);
diff --git a/simulator/src/main/java/msp/simulator/satellite/Satellite.java b/simulator/src/main/java/msp/simulator/satellite/Satellite.java
index f5e5b2d1..89ac9a71 100644
--- a/simulator/src/main/java/msp/simulator/satellite/Satellite.java
+++ b/simulator/src/main/java/msp/simulator/satellite/Satellite.java
@@ -75,7 +75,7 @@ public Satellite(Environment environment) {
*/
public void executeStepMission() {
AbsoluteDate date = this.getStates().getCurrentState().getDate();
-
+
/* Export Sensor Measurements */
if (this.io.isConnectedToMemCached()) {
@@ -105,7 +105,7 @@ public void executeStepMission() {
);
/* Gyrometer Sensor Measurement */
- Vector3D gyroMeasure = this.getSensors().getGyrometer().getData_rotAcc();
+ Vector3D gyroMeasure = this.getSensors().getGyrometer().getData_angularVelocity();
byte[] rawGyro_x = MemcachedRawTranscoder.toRawByteArray(gyroMeasure.getX());
byte[] rawGyro_y = MemcachedRawTranscoder.toRawByteArray(gyroMeasure.getY());
byte[] rawGyro_z = MemcachedRawTranscoder.toRawByteArray(gyroMeasure.getZ());
diff --git a/simulator/src/main/java/msp/simulator/satellite/assembly/Assembly.java b/simulator/src/main/java/msp/simulator/satellite/assembly/Assembly.java
index ed27dd00..bb422f8d 100644
--- a/simulator/src/main/java/msp/simulator/satellite/assembly/Assembly.java
+++ b/simulator/src/main/java/msp/simulator/satellite/assembly/Assembly.java
@@ -37,7 +37,7 @@ public class Assembly {
/** Logger of the class */
private static final Logger logger = LoggerFactory.getLogger(Assembly.class);
-
+
/** Earth instance of the simulation. */
private Earth earth;
@@ -46,9 +46,6 @@ public class Assembly {
/** Instance of the satellite initial state in space. */
private SatelliteStates satelliteStates;
-
- /** Satellite frame. */
- private Frame satelliteFrame;
/**
* Build the satellite as a body and a state vector.
@@ -62,11 +59,6 @@ public Assembly(Environment environment) {
this.satelliteBody = new SatelliteBody(environment);
this.satelliteStates = new SatelliteStates(environment, satelliteBody);
- this.satelliteFrame = new Frame (
- FramesFactory.getEME2000(),
- this.getStates().getCurrentState().toTransform(),
- "SatelliteFrame"
- );
this.earth = environment.getSolarSystem().getEarth();
}
@@ -95,7 +87,11 @@ public SatelliteStates getStates() {
* frame fixed with the axis body.
*/
public Frame getSatelliteFrame() {
- return this.satelliteFrame;
+ return new Frame (
+ FramesFactory.getEME2000(),
+ this.getStates().getCurrentState().toTransform(),
+ "SatelliteFrame"
+ );
}
/**
@@ -105,7 +101,7 @@ public Frame getSatelliteFrame() {
public Vector3D getAngularMomentum() {
Vector3D rotationRate = this.satelliteStates
.getCurrentState().getAttitude().getSpin();
-
+
double[][] inertiaMatrix = this.satelliteBody.getInertiaMatrix();
Vector3D row0 = new Vector3D(inertiaMatrix[0]);
@@ -130,13 +126,13 @@ public Transform getItrf2body(AbsoluteDate date) {
Transform itrf2body = null;
try {
itrf2body = this.earth.getRotatingFrame().getTransformTo(
- this.satelliteFrame,
+ this.getSatelliteFrame(),
date
);
} catch (OrekitException e) {
e.printStackTrace();
}
-
+
return itrf2body;
}
diff --git a/simulator/src/main/java/msp/simulator/satellite/assembly/SatelliteBody.java b/simulator/src/main/java/msp/simulator/satellite/assembly/SatelliteBody.java
index a9a310ff..9b9e7a19 100644
--- a/simulator/src/main/java/msp/simulator/satellite/assembly/SatelliteBody.java
+++ b/simulator/src/main/java/msp/simulator/satellite/assembly/SatelliteBody.java
@@ -33,26 +33,33 @@ public class SatelliteBody extends BoxAndSolarArraySpacecraft {
/* ******* Public Static Attributes ******* */
/** Size of the satellite box in meters - (x, y, z) */
- public static double[] satBoxSizeWithNoSolarPanel = new double[] {0.01, 0.01, 0.01} ;
+ public static final double[] satBoxSizeWithNoSolarPanel = new double[] {0.01, 0.01, 0.01} ;
/* Note that the size of the solar panels is set to zero in the class constructor.*/
/** Mass of the satellite in kilogram. */
- public static double satelliteMass = 1.04;
+ public static final double satelliteMass = 1.04;
- /* TODO(rskew) update inertia matrix. */
- /** Inertia matrix of the satellite. */
+ /** Default inertia matrix, set by the Dashboard. */
public static double[][] satInertiaMatrix = /* kg.m^2 */ {
{1191.648 * 1.3e-6, 0 , 0 },
{ 0 , 1169.506 * 1.3e-6, 0 },
{ 0 , 0 , 1203.969 * 1.3e-6 },
};
+ /* TODO(rskew) update inertia matrix. */
+ /** Inertia matrix of ACRUX1. */
+ public static final double[][] ACRUX1InertiaMatrix = /* kg.m^2 */ {
+ {1191.648 * 1.3e-6, 0 , 0 },
+ { 0 , 1169.506 * 1.3e-6, 0 },
+ { 0 , 0 , 1203.969 * 1.3e-6 },
+ };
+
/** Simple balance inertia matrix (Unit matrix). */
public static final double[][] simpleBalancedInertiaMatrix = {
- { 1, 0, 0 },
- { 0, 1, 0 },
- { 0, 0, 1 }
+ { 1e-3, 0 , 0 },
+ { 0 , 1e-3, 0 },
+ { 0 , 0 , 1e-3 }
};
/* **************************************** */
@@ -102,6 +109,7 @@ public SatelliteBody(Environment environment) {
this.satBoxSize = SatelliteBody.satBoxSizeWithNoSolarPanel;
this.satMass = SatelliteBody.satelliteMass;
this.inertiaMatrix = SatelliteBody.satInertiaMatrix;
+ //this.inertiaMatrix = SatelliteBody.simpleBalancedInertiaMatrix;
SatelliteBody.logger.info(CustomLoggingTools.indentMsg(SatelliteBody.logger,
" -> Building the CubeSat body: Success."));
diff --git a/simulator/src/main/java/msp/simulator/satellite/sensors/Gyrometer.java b/simulator/src/main/java/msp/simulator/satellite/sensors/Gyrometer.java
index ef1131fd..c5f86919 100644
--- a/simulator/src/main/java/msp/simulator/satellite/sensors/Gyrometer.java
+++ b/simulator/src/main/java/msp/simulator/satellite/sensors/Gyrometer.java
@@ -34,7 +34,8 @@ public class Gyrometer {
/** This intensity is used to generate a random number to be
* added to each components of the sensor data.
*/
- public static double defaultGyroNoiseIntensity = 1e-3;
+ //public static double defaultGyroNoiseIntensity = 1e-3;
+ public static double defaultGyroNoiseIntensity = 0;
/* **************************************** */
@@ -65,13 +66,13 @@ public Gyrometer(Environment environment, Assembly assembly) {
* Retrieve the data from the sensor.
* @return Rotational Acceleration
*/
- public Vector3D getData_rotAcc() {
- /* Get the acceleration from the satellite state. */
+ public Vector3D getData_angularVelocity() {
+ /* Get the angular velocity from the satellite state. */
/* Note that these data are already in the satellite
* body frame!
*/
Vector3D data = this.assembly.getStates()
- .getCurrentState().getAttitude().getRotationAcceleration();
+ .getCurrentState().getAttitude().getSpin();
/* Add the noise contribution. */
Vector3D noise = new Vector3D(
diff --git a/simulator/src/main/java/msp/simulator/satellite/sensors/Magnetometer.java b/simulator/src/main/java/msp/simulator/satellite/sensors/Magnetometer.java
index 5b26a0d1..e6866c19 100644
--- a/simulator/src/main/java/msp/simulator/satellite/sensors/Magnetometer.java
+++ b/simulator/src/main/java/msp/simulator/satellite/sensors/Magnetometer.java
@@ -146,24 +146,32 @@ public GeoMagneticElements retrievePerfectField() {
* the altitude of the satellite is slightly shifted from the true
* one.
*/
+// GeoMagneticElements trueField_itrf = this.geomagField.getField().calculateField(
+// FastMath.toDegrees(geodeticPosition.getLatitude()), /* decimal deg */
+// FastMath.toDegrees(geodeticPosition.getLongitude()), /* decimal deg */
+// (satState.getA() - this.earth.getRadius()) / 1e3 /* km */
+// );
+
GeoMagneticElements trueField_itrf = this.geomagField.getField().calculateField(
- FastMath.toDegrees(geodeticPosition.getLatitude()), /* decimal deg */
- FastMath.toDegrees(geodeticPosition.getLongitude()), /* decimal deg */
- (satState.getA() - this.earth.getRadius()) / 1e3 /* km */
+ 0.007707323868690944, /* decimal deg */
+ -156.00687854677085, /* decimal deg */
+ 574.9999944513394/* km */
);
logger.debug("Magnetometer Measurement: \n" +
"Latitude: " + FastMath.toDegrees(geodeticPosition.getLatitude()) + " °\n" +
"Longitud: " + FastMath.toDegrees(geodeticPosition.getLongitude()) + " °\n" +
"Altitude: " + (satState.getA() - this.earth.getRadius()) / 1e3 + " km\n" +
- "True Geo ITRF" + trueField_itrf.toString()
+ "(ITRF): " + trueField_itrf.toString()
);
/* Rotate the magnetic field reading into the body frame */
Vector3D trueField_body = this.assembly.getItrf2body(satState.getDate())
.transformVector(trueField_itrf.getFieldVector());
- return new GeoMagneticElements(trueField_body);
+ GeoMagneticElements trueGeoMag_body = new GeoMagneticElements(trueField_body);
+
+ return trueGeoMag_body;
}
/**
diff --git a/simulator/src/main/java/msp/simulator/user/Dashboard.java b/simulator/src/main/java/msp/simulator/user/Dashboard.java
index 681253b1..06941e72 100644
--- a/simulator/src/main/java/msp/simulator/user/Dashboard.java
+++ b/simulator/src/main/java/msp/simulator/user/Dashboard.java
@@ -119,9 +119,9 @@ public static void setDefaultConfiguration() {
Dashboard.setTorqueDisturbances(true);
/* **** Structure Settings **** */
- Dashboard.setSatBoxSizeWithNoSolarPanel(new double[]{0.01, 0.01, 0.01});
- Dashboard.setSatelliteMass(1.0);
- Dashboard.setSatelliteInertiaMatrix(SatelliteBody.simpleBalancedInertiaMatrix);
+ //Dashboard.setSatBoxSizeWithNoSolarPanel(new double[]{0.01, 0.01, 0.01});
+ //Dashboard.setSatelliteMass(1.0);
+ //Dashboard.setSatelliteInertiaMatrix(SatelliteBody.simpleBalancedInertiaMatrix);
/* **** Structure Settings **** */
Dashboard.setMagnetometerNoiseIntensity(1e2);
@@ -232,6 +232,14 @@ public static void setSimulationDuration(long duration) {
NumericalSimulator.simulationDuration = duration ; /* s. */
}
+ /**
+ * Set the wall clock time daley between comuting steps
+ * @param stepDelay in seconds
+ */
+ public static void setStepDelay(double stepDelay) {
+ NumericalSimulator.stepDelay = stepDelay;
+ }
+
/**
* Set the period of work of the ground station, i.e. the time without
* any update.
@@ -256,9 +264,9 @@ public static void setOrbitalParameters(OrbitalParameters param) {
* Set the size of the satellite box without solar panel.
* @param xyzSize a three-dimension array (x, y, z) in meter.
*/
- public static void setSatBoxSizeWithNoSolarPanel(double[] xyzSize) {
- SatelliteBody.satBoxSizeWithNoSolarPanel = xyzSize;
- }
+ //public static void setSatBoxSizeWithNoSolarPanel(double[] xyzSize) {
+ // SatelliteBody.satBoxSizeWithNoSolarPanel = xyzSize;
+ //}
/**
* Set the initial attitude quaternion. (Representing the rotation
@@ -298,9 +306,9 @@ public static void setTorqueDisturbances(boolean flag) {
* Set the user-defined satellite mass.
* @param mass in kilogram
*/
- public static void setSatelliteMass(double mass) {
- SatelliteBody.satelliteMass = mass;
- }
+ //public static void setSatelliteMass(double mass) {
+ // SatelliteBody.satelliteMass = mass;
+ //}
/**
* Set the user-specified inertia matrix of the satellite.
diff --git a/simulator/src/main/java/msp/simulator/utils/logs/ephemeris/EphemerisGenerator.java b/simulator/src/main/java/msp/simulator/utils/logs/ephemeris/EphemerisGenerator.java
index dd440d68..9cd0fd75 100644
--- a/simulator/src/main/java/msp/simulator/utils/logs/ephemeris/EphemerisGenerator.java
+++ b/simulator/src/main/java/msp/simulator/utils/logs/ephemeris/EphemerisGenerator.java
@@ -254,14 +254,16 @@ public void writeStep(Satellite satellite) {
"Attitude: [{}, {}, {}, {}] \n" +
"Spin : {} \n" +
"RotAcc : {}\n" +
- "Momentum: {}",
+ "Momentum: {}\n" +
+ "Momentum Norm: {}",
newState.getAttitude().getRotation().getQ0(),
newState.getAttitude().getRotation().getQ1(),
newState.getAttitude().getRotation().getQ2(),
newState.getAttitude().getRotation().getQ3(),
newState.getAttitude().getSpin().toString(),
newState.getAttitude().getRotationAcceleration().toString(),
- satellite.getAssembly().getAngularMomentum()
+ satellite.getAssembly().getAngularMomentum(),
+ satellite.getAssembly().getAngularMomentum().getNorm()
);
} catch (OrekitException | IOException e) {