Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b256bf1
Set torque disturbances as optional - Fix scenario torque provider.
florian-chaubeyre Apr 19, 2018
85d28d5
Fix transformation from ITRF to Body frame.
florian-chaubeyre Apr 20, 2018
2df495d
init
JmcRobbie Sep 24, 2018
aa23021
Writing Header for Magnetic field vector recordings
JmcRobbie Sep 24, 2018
5e833e2
Added header generating function
JmcRobbie Sep 24, 2018
0ea6e6c
magnetic field writing to log files - untested in vts
JmcRobbie Sep 24, 2018
f024b90
asdf
JmcRobbie Sep 24, 2018
208d1e4
Logging angular velocity and angular momentum
JmcRobbie Sep 24, 2018
94b15b0
Added angular acceleration logging
JmcRobbie Sep 24, 2018
54552d7
Hackish calculation of torque added to logging
JmcRobbie Sep 24, 2018
52e18f8
Added comment to action review
JmcRobbie Sep 24, 2018
89509a1
Merge pull request #7 from MelbourneSpaceProgram/feature-vector_logging
JmcRobbie Sep 24, 2018
9f20a35
Hot-fix working in vts
JmcRobbie Sep 24, 2018
2d4e64e
Merge pull request #8 from MelbourneSpaceProgram/Hotfix-VTS_Compatibi…
JmcRobbie Sep 24, 2018
c4407eb
asdf
JmcRobbie Sep 24, 2018
61c2a1a
Add BDot ephemeris log
rskew Sep 28, 2018
15a0cdf
Merge pull request #9 from MelbourneSpaceProgram/log_bdot
rskew Sep 28, 2018
bd00ccc
One line commit :P
JmcRobbie Sep 28, 2018
5852246
Merge pull request #10 from MelbourneSpaceProgram/feature-add_real_noise
JmcRobbie Sep 28, 2018
c468624
added noise to sim
JmcRobbie Sep 28, 2018
c974bad
Merge pull request #11 from MelbourneSpaceProgram/hotfix-gaussian
JmcRobbie Sep 28, 2018
51a73fe
updated noise
JmcRobbie Sep 28, 2018
9d46dde
updated intertia tensor
JmcRobbie Oct 3, 2018
f92a22b
removed TODO message
JmcRobbie Oct 3, 2018
c728792
Merge pull request #12 from MelbourneSpaceProgram/feature-new_Inertia…
JmcRobbie Oct 3, 2018
3f8d414
Remove system path for spymemcached dependency in pom
rskew Oct 18, 2018
76b3de9
Merge pull request #14 from MelbourneSpaceProgram/fix_pom
JmcRobbie Oct 18, 2018
216e07d
implemented torque from pwm
JmcRobbie Oct 20, 2018
e3721ca
fixed
JmcRobbie Nov 8, 2018
e45d7ac
fixed euler equations and logged torques directly for debugging
JmcRobbie Nov 8, 2018
d300deb
removed misleading and useless line from main
JmcRobbie Nov 8, 2018
934bc07
fix
JmcRobbie Nov 8, 2018
59e23a3
fixed itrf to body conversions
JmcRobbie Nov 8, 2018
65458b0
Applied a fix for standinmemcached pop and logged some more info
JmcRobbie Nov 8, 2018
d61a40c
fixed gyro reads
JmcRobbie Nov 8, 2018
0c45c6f
fix
JmcRobbie Nov 8, 2018
6be764d
asd
JmcRobbie Nov 8, 2018
ecb8ffe
init
JmcRobbie Feb 5, 2019
6e2fe74
asf:
JmcRobbie Feb 5, 2019
0ef553a
fixed
JmcRobbie Feb 5, 2019
68383b5
init
JmcRobbie Feb 5, 2019
268acd9
Begun major refactoring to create ADCS feature!
JmcRobbie Feb 12, 2019
9b9a3f0
Constructed Low pass filter class for sensor use
JmcRobbie Feb 12, 2019
3933988
Tidied up some bugs and continued restructuring
JmcRobbie Feb 12, 2019
9cb0fdb
Added Bdot estimator class
JmcRobbie Feb 12, 2019
76a1b2f
Began constructing adcs and Controller classes
JmcRobbie Feb 12, 2019
907a029
Continued Constructing ADCS Package
JmcRobbie Feb 14, 2019
2e4c901
Added torque physics to adcs module
JmcRobbie Feb 14, 2019
1ab8a06
Update README.md
JmcRobbie Feb 14, 2019
8661fc2
asdf
JmcRobbie Feb 14, 2019
e45ec5d
Detumbling appears to be running correctly
JmcRobbie Feb 15, 2019
92b8f57
Fixed silly bug in LPF
JmcRobbie Feb 16, 2019
bb105ee
Bugs fixed, bdot implemented and running
JmcRobbie Feb 16, 2019
2d8d355
detumbling running and some quality of life usability addidtions
JmcRobbie Feb 25, 2019
c04d5c7
reverted some unecessary changes to eclipse autoconfigs
JmcRobbie Feb 25, 2019
8021557
Merge branch 'develop' into feature/Controller
JmcRobbie Sep 25, 2019
07b6b0e
Merge pull request #1 from JmcRobbie/feature/Controller
JmcRobbie Sep 25, 2019
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ Optional, but advised:
- Right click on simulator project > Maven > Update Project... > Select all > Force Update of Snapchots/Releases > OK

The simulator project is now set up. You can launch the main method and some tests.

## Command Line Execution of Simulation
### Linux
- cd into /simulator
- $mvn compile
- $mvn mvn exec:java -D"exec.mainClass"="msp.simulator.Main"
- OR simply use bash runSim.sh
- $mvn exec:java -D"exec.mainClass"="msp.simulator.Main"
## Simple Test Execution:
- In Eclipse, select the test to run in src/test/java/msp/simulator
- Run As > JUnit Test
Expand Down
4 changes: 1 addition & 3 deletions simulator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
<groupId>net.spy</groupId>
<artifactId>spymemcached</artifactId>
<version>2.12.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/jar/spymemcached-2.12.3.jar</systemPath>
</dependency>
</dependencies>
<issueManagement>
Expand All @@ -56,4 +54,4 @@
</pluginManagement>
</build>
<groupId>msp.simulator</groupId>
</project>
</project>
2 changes: 2 additions & 0 deletions simulator/runSim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mvn compile;
mvn exec:java -D"exec.mainClass"="msp.simulator.Main"
11 changes: 5 additions & 6 deletions simulator/src/main/java/msp/simulator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +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.setInitialAttitudeQuaternion(new Quaternion(1, 0, 0, 0));
Dashboard.setInitialSpin(new Vector3D(0.5, 0.5, 0.5));
Dashboard.setInitialSpin(new Vector3D(0.3, 0.3, 0.3)); // tip off 30 degrees per second
Dashboard.setInitialRotAcceleration(new Vector3D(0,0,0));
Dashboard.setTorqueDisturbances(false);

Dashboard.setCommandTorqueProvider(TorqueProviderEnum.MEMCACHED);
Dashboard.setMemCachedConnection(true, "127.0.0.1:11211");
Dashboard.setCommandTorqueProvider(TorqueProviderEnum.CONTROLLER);

//Dashboard.setVtsConnection(true);
Dashboard.setVtsConnection(false);

/* *** Creating and launching the simulation. *** */
NumericalSimulator simulator = new NumericalSimulator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Copyright 20017-2018 Melbourne Space Program
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package msp.simulator.dynamic.torques;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.orekit.time.AbsoluteDate;

import msp.simulator.NumericalSimulator;
import msp.simulator.dynamic.torques.TorqueOverTimeScenarioProvider.Step;
import msp.simulator.environment.Environment;
import msp.simulator.satellite.Satellite;
/**
*
* @author Jack McRobbie
* This class represents the satellites own method
* for providing stabilization and control
*/
public class ControllerTorqueProvider implements TorqueProvider{
private Satellite sat;
private Vector3D steptorque;
public ControllerTorqueProvider(Satellite satellite, AbsoluteDate date, Environment environment) {
this.sat = satellite;
this.steptorque = Vector3D.ZERO;
}
/** {@inheritDoc} */
@Override
public Vector3D getTorque(AbsoluteDate date) {
this.steptorque = sat.getADCS().ComputeTorque();
/* Finally returns the torque of the step (updated if needed). */
return this.steptorque;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
* limitations under the License.
*/

package msp.simulator.dynamic.torques;
package msp.simulator.dynamic.torques;

import java.nio.ByteBuffer;

import java.nio.ByteBuffer;

import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.orekit.time.AbsoluteDate;
Expand All @@ -28,7 +29,7 @@
import msp.simulator.satellite.io.MemcachedRawTranscoder;
import msp.simulator.utils.logs.CustomLoggingTools;
import net.spy.memcached.MemcachedClient;

import msp.simulator.satellite.ADACS.sensors.*;;
/**
*
* @author Florian CHAUBEYRE <chaubeyre.f@gmail.com>
Expand All @@ -39,12 +40,12 @@ public class MemCachedTorqueProvider implements TorqueProvider {

/** Public key to access the MemCached hash table. */
public static String torqueCommandKey = "Simulation_Torque_";

public static String pwmCommandKey = "Satellite_PWM_";
/* **************************************** */

/** Private Key to store the public key. */
private String torqueKey;

private String pwmKey;
/** Logger of the class */
private static final Logger logger = LoggerFactory.getLogger(
MemCachedTorqueProvider.class);
Expand All @@ -70,7 +71,25 @@ public class MemCachedTorqueProvider implements TorqueProvider {
private Vector3D stepTorque;

/** Copy of the fixed integration time step. */
private final double stepSize = Integration.integrationTimeStep;
private static final double stepSize = Integration.integrationTimeStep;

/* Copy of the magnetic field*/
private Vector3D b_field;
/* Copy of the sensor object*/
private Magnetometer magnetometer;

private final double[] magnetorquerMaxDipole = {0.2,0.2,0.2};

private Vector3D Pwm2Torque(Vector3D pwm) {
double x = pwm.getX() * magnetorquerMaxDipole[0];
double y = pwm.getY() * magnetorquerMaxDipole[1];
double z = pwm.getZ() * magnetorquerMaxDipole[2];
Vector3D dipole = new Vector3D(x,y,z);
Vector3D torque;
logger.info("PWM SIGNAL:"+dipole.toString());
torque = Vector3D.crossProduct(dipole,this.b_field);
return torque;
}

/**
* Create the instance of memcached torque provider.
Expand All @@ -88,9 +107,12 @@ public MemCachedTorqueProvider(Satellite satellite) {
this.satState = satellite.getStates();
this.stepStart = this.satState.getCurrentState().getDate();
this.nextAcquisitionDate = this.satState.getInitialState().getDate();
this.stepTorque = Vector3D.ZERO;

this.torqueKey = MemCachedTorqueProvider.torqueCommandKey;
this.stepTorque = Vector3D.ZERO;
this.b_field = satellite.getADCS().getSensors().getMagnetometer().retrievePerfectField().getFieldVector();
this.magnetometer = satellite.getADCS().getSensors().getMagnetometer();
this.torqueKey = MemCachedTorqueProvider.torqueCommandKey;
this.pwmKey = MemCachedTorqueProvider.pwmCommandKey;

this.memcached = satellite.getIO().getMemcached();
this.memcachedTranscoder = satellite.getIO().getRawTranscoder();

Expand All @@ -114,7 +136,7 @@ public MemCachedTorqueProvider(Satellite satellite) {
public Vector3D getTorque(AbsoluteDate date) {
/* Flag to enable the acquisition of the torque for the step. */
boolean acquisition;

this.b_field = magnetometer.retrievePerfectField().getFieldVector().scalarMultiply(1E-9); // gets magnetic field (nT) then converts to SI
/* As the torque is considered constant over a step, we only need
* to acquire the torque once at the very beginning of the step. */
this.stepStart = this.satState.getCurrentState().getDate();
Expand All @@ -130,31 +152,32 @@ public Vector3D getTorque(AbsoluteDate date) {

/* Reading the torque command from MemCached. */
try {
Vector3D torqueCommand;
Vector3D pwmCommand;

double torque_x = ByteBuffer.wrap(
double pwm_x = ByteBuffer.wrap(
this.memcached.get(
this.torqueKey + "X",
this.pwmKey + "X",
this.memcachedTranscoder))
.getDouble();

double torque_y = ByteBuffer.wrap(
double pwm_y = ByteBuffer.wrap(
this.memcached.get(
this.torqueKey + "Y",
this.pwmKey + "Y",
this.memcachedTranscoder))
.getDouble();

double torque_z = ByteBuffer.wrap(
double pwm_z = ByteBuffer.wrap(
this.memcached.get(
this.torqueKey + "Z",
this.pwmKey + "Z",
this.memcachedTranscoder))
.getDouble();

torqueCommand = new Vector3D(
torque_x,
torque_y,
torque_z
);
pwmCommand = new Vector3D(
pwm_x,
pwm_y,
pwm_z
);
Vector3D torqueCommand = this.Pwm2Torque(pwmCommand);

/* Checking the data transmission. */
if (torqueCommand.isNaN() || torqueCommand.isInfinite()) {
Expand All @@ -170,7 +193,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 {
Expand Down
Loading