Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The simulator project is now set up. You can launch the main method and some tes
- cd into /simulator
- $mvn compile
- $mvn mvn exec:java -D"exec.mainClass"="msp.simulator.Main"
- OR simply use bash runSim.sh
## Simple Test Execution:
- In Eclipse, select the test to run in src/test/java/msp/simulator
- Run As > JUnit Test
Expand Down
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"
3 changes: 1 addition & 2 deletions simulator/src/main/java/msp/simulator/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public static void main(String[] args) {
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(false);

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 @@ -29,7 +29,7 @@
import msp.simulator.satellite.io.MemcachedRawTranscoder;
import msp.simulator.utils.logs.CustomLoggingTools;
import net.spy.memcached.MemcachedClient;
import msp.simulator.satellite.sensors.Magnetometer;
import msp.simulator.satellite.ADACS.sensors.*;;
/**
*
* @author Florian CHAUBEYRE <chaubeyre.f@gmail.com>
Expand Down Expand Up @@ -108,8 +108,8 @@ public MemCachedTorqueProvider(Satellite satellite) {
this.stepStart = this.satState.getCurrentState().getDate();
this.nextAcquisitionDate = this.satState.getInitialState().getDate();
this.stepTorque = Vector3D.ZERO;
this.b_field = satellite.getSensors().getMagnetometer().retrievePerfectField().getFieldVector();
this.magnetometer = satellite.getSensors().getMagnetometer();
this.b_field = satellite.getADCS().getSensors().getMagnetometer().retrievePerfectField().getFieldVector();
this.magnetometer = satellite.getADCS().getSensors().getMagnetometer();
this.torqueKey = MemCachedTorqueProvider.torqueCommandKey;
this.pwmKey = MemCachedTorqueProvider.pwmCommandKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum TorqueProviderEnum {
/* Command torque provider. */
MEMCACHED(0),
SCENARIO(0),

CONTROLLER(0),
/* Disturbances. */
GRAVITY(1),
ATMOSPHERIC(2),
Expand Down
12 changes: 10 additions & 2 deletions simulator/src/main/java/msp/simulator/dynamic/torques/Torques.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Torques {
/* ******* Public Static Attributes ******* */

/** Set the torque provider in use by the simulator. */
public static TorqueProviderEnum commandTorqueProvider = TorqueProviderEnum.SCENARIO;
public static TorqueProviderEnum commandTorqueProvider = TorqueProviderEnum.CONTROLLER;

/** Allow the torque disturbances in the simulation. */
public static boolean allowDisturbances = true;
Expand Down Expand Up @@ -69,7 +69,15 @@ public Torques (Environment environment, Satellite satellite) {
this.isDisturbances = Torques.allowDisturbances;

/* - Register the command provider. */
switch (Torques.commandTorqueProvider) {
switch (Torques.commandTorqueProvider) {
case CONTROLLER:
this.torqueProviders.add(
TorqueProviderEnum.CONTROLLER.getIndex(), new ControllerTorqueProvider(
satellite,
satellite.getAssembly().getStates().getInitialState().getDate(),
environment
));
break;
case MEMCACHED:
this.torqueProviders.add(
TorqueProviderEnum.MEMCACHED.getIndex(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package msp.simulator.satellite.sensors;
package msp.simulator.satellite.ADACS.sensors;

import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package msp.simulator.satellite.sensors;
package msp.simulator.satellite.ADACS.sensors;

import org.hipparchus.geometry.euclidean.threed.*;
import org.hipparchus.util.FastMath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* limitations under the License.
*/

package msp.simulator.satellite.sensors;
package msp.simulator.satellite.ADACS.sensors;

import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.util.FastMath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* limitations under the License.
*/

package msp.simulator.satellite.sensors;
package msp.simulator.satellite.ADACS.sensors;

import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
* @author Florian CHAUBEYRE <chaubeyre.f@gmail.com>
* @author Braeden BORG
*/
package msp.simulator.satellite.sensors;
package msp.simulator.satellite.ADACS.sensors;
63 changes: 63 additions & 0 deletions simulator/src/main/java/msp/simulator/satellite/ADCS/ADCS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* 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.satellite.ADCS;

import java.util.function.Consumer;

import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import msp.simulator.environment.Environment;
import msp.simulator.satellite.Satellite;
import msp.simulator.satellite.ADACS.sensors.Sensors;
import msp.simulator.satellite.ADCS.ADCSPhysics.ADCSPhysics;
import msp.simulator.satellite.ADCS.Actuators.Actuators;
import msp.simulator.satellite.ADCS.Controller.Controller;
import msp.simulator.satellite.ADCS.Estimators.Estimators;
import msp.simulator.utils.logs.CustomLoggingTools;
/**
*
* @author Jack McRobbie
*/
public class ADCS {
private static final Logger logger = LoggerFactory.getLogger(ADCS.class);
private Sensors sensors;
private Estimators estimators;
private Controller controllers;
private Actuators actuators;
private ADCSPhysics physics;


public ADCS(Satellite sat,Environment environment) {
this.sensors = new Sensors(environment, sat.getAssembly());
this.estimators = new Estimators(sat);
this.controllers = new Controller(sat);
this.physics = new ADCSPhysics(sat, environment);
ADCS.logger.info(CustomLoggingTools.indentMsg(ADCS.logger,
"Building the ADCS Module: Success..."));
}
public Vector3D ComputeTorque() {
Vector3D magneticDipole = this.controllers.getDipole();

return this.physics.ComputeMagnetorquerTorque(magneticDipole);
// return new Vector3D(0.01,0.01,0.01);
}
/**
* @return
*/
public Sensors getSensors() {
return sensors;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* 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.satellite.ADCS.ADCSPhysics;

import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import msp.simulator.environment.Environment;
import msp.simulator.satellite.Satellite;
import msp.simulator.satellite.ADACS.sensors.Sensors;
import msp.simulator.satellite.ADCS.Actuators.MagnetoTorquers;
import msp.simulator.satellite.assembly.SatelliteBody;
import msp.simulator.utils.logs.CustomLoggingTools;

/**
*
* @author Jack McRobbie
*/
public class ADCSPhysics {

/** Logger of the class. */
private static final Logger logger =
LoggerFactory.getLogger(ADCSPhysics.class);

private Satellite satellite;
private Environment environment;
private Sensors sensor;
public ADCSPhysics(Satellite satellite, Environment environemt) {
this.satellite = satellite;
this.environment = environment;
ADCSPhysics.logger.info(CustomLoggingTools.indentMsg(ADCSPhysics.logger,
" -> Building the ADCS Physics engine: Success."));
}
public Vector3D ComputeMagnetorquerTorque(Vector3D magneticDipole) {
Vector3D magfield = this.satellite.getADCS().getSensors().getMagnetometer()
.retrievePerfectField().getFieldVector().scalarMultiply(0.000000001);
Vector3D result = Vector3D.crossProduct(magneticDipole,magfield );
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* limitations under the License.
*/

package msp.simulator.satellite.actuators;
package msp.simulator.satellite.ADCS.Actuators;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -27,13 +27,20 @@ public class Actuators {

/** Logger of the class */
private static final Logger logger = LoggerFactory.getLogger(Actuators.class);

private MagnetoTorquers magnetorquer;
/**
*
*/
public Actuators() {
logger.info(CustomLoggingTools.indentMsg(logger,
this.magnetorquer = new MagnetoTorquers();
Actuators.logger.info(CustomLoggingTools.indentMsg(Actuators.logger,
"Building the Actuators..."));
}

/**
* @return
*/
public MagnetoTorquers getMagnetorquers() {
return this.magnetorquer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* 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.satellite.ADCS.Actuators;

import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import msp.simulator.utils.logs.CustomLoggingTools;

/**
*
* @author Florian CHAUBEYRE <chaubeyre.f@gmail.com>
* @author Jack McRobbie
*/
public class MagnetoTorquers {
private Vector3D orientation;
private Vector3D MaxDipole;


/** Logger of the class */
private static final Logger logger = LoggerFactory.getLogger(MagnetoTorquers.class);

/**
*
*/
public MagnetoTorquers() {
MagnetoTorquers.logger.info(CustomLoggingTools.indentMsg(logger,
"Building the MagnetoTorquers..."));
this.orientation = new Vector3D(1,1,1);
this.MaxDipole = new Vector3D(0.1,0.1,0.1); //TODO make configurable from simulation initialization

}
public Vector3D computeDipole(Vector3D dutyCycle) {
return this.constrainDipole(dutyCycle);
}
/**
* @param dutyCycle requested duty cycle for the magnetorquers
*/
private Vector3D constrainDipole(Vector3D dutyCycle) {
double x = dutyCycle.getX();
double y = dutyCycle.getY();
double z = dutyCycle.getZ();
int sign;
Vector3D result = new Vector3D(x,y,z);
if(Math.abs(x)>this.MaxDipole.getX()) {
sign = (0 > dutyCycle.getX())?-1:1;
x = this.MaxDipole.getX() * sign;
}
if(Math.abs(y)>this.MaxDipole.getY()) {
sign = (0 > dutyCycle.getY())?-1:1;
y = this.MaxDipole.getY() * sign;
}
if(Math.abs(z)>this.MaxDipole.getZ()) {
sign = (0 > dutyCycle.getZ())?-1:1;
z = this.MaxDipole.getZ() * sign;
}
result = new Vector3D(x,y,z);
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
*
* @author Florian CHAUBEYRE <chaubeyre.f@gmail.com>
*/
package msp.simulator.satellite.actuators;
package msp.simulator.satellite.ADCS.Actuators;
Loading