Skip to content

Commit

Permalink
feat: ✨ add forces and propagators
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Feb 19, 2024
1 parent def01c6 commit 177c88b
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 52 deletions.
34 changes: 34 additions & 0 deletions examples/integrator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { RungeKutta4Propagator, RungeKutta89Propagator, ForceModel } from '../src/main';
import { EpochUTC, Satellite, TleLine1, TleLine2 } from 'ootk-core';

const start = new Date(2024, 0, 28, 0, 0, 0, 0);
const stop = new Date(2024, 0, 29, 0, 0, 0, 0);
// const startEpoch = EpochUTC.fromDateTime(start);
const stopEpoch = EpochUTC.fromDateTime(stop);
const sat = new Satellite({
tle1: '1 25544U 98067A 24028.54545847 .00031576 00000-0 57240-3 0 9991' as TleLine1,
tle2: '2 25544 51.6418 292.2590 0002595 167.5319 252.0460 15.49326324436741' as TleLine2,
});

// eslint-disable-next-line no-console
console.log(sat.eci(stop));

const forceModel = new ForceModel();

forceModel.setEarthGravity(8, 8);
forceModel.setThirdBodyGravity({
moon: true,
sun: true,
});
forceModel.setSolarRadiationPressure(1000, 400);
forceModel.setAtmosphericDrag(1000, 400);

const rk4 = new RungeKutta4Propagator(sat.toJ2000(start), forceModel);

// eslint-disable-next-line no-console
console.log(rk4.propagate(stopEpoch));

const rkA = new RungeKutta89Propagator(sat.toJ2000(start), forceModel);

// eslint-disable-next-line no-console
console.log(rkA.propagate(stopEpoch));
7 changes: 7 additions & 0 deletions src/enums/CommLink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum CommLink {
AEHF = 'AEHF',
GALILEO = 'Galileo',
IRIDIUM = 'Iridium',
STARLINK = 'Starlink',
WGS = 'WGS'
}
1 change: 1 addition & 0 deletions src/enums/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { CatalogSource } from './CatalogSource';
export { CommLink } from './CommLink';
1 change: 1 addition & 0 deletions src/force/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ForceModel } from './ForceModel';
5 changes: 4 additions & 1 deletion src/interfaces/RfSensorParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import { Degrees, SensorParams } from 'ootk-core';

export interface RfSensorParams extends SensorParams {
coneHalfAngle: Degrees;
boresightAz: Degrees;
boresightEl: Degrees;
/** For radars, this is the width of the beam */
beamwidth: Degrees;
/** For radar sensors, what frequency does this sensor operate in? */
freqBand?: string;
}
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ export * from './interfaces';
export * from './coordinate';
export * from './objects';
export * from './operations';
export * from './force';
export * from './propagator';
export * from './transforms';
export * from './utils';
57 changes: 23 additions & 34 deletions src/objects/DetailedSensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,43 @@
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
*/

import { BaseObjectParams, Degrees, Milliseconds, Radians, Sensor, SensorParams } from 'ootk-core';
import { BaseObjectParams, Milliseconds, Sensor, SensorParams } from 'ootk-core';
import { DetailedSensorParams, ZoomValue } from '../types/types';
import { CommLink } from '../enums/CommLink';

export class DetailedSensor extends Sensor {
country?: string;
latRad: Radians;
lonRad: Radians;
shortName?: string;
beamwidth?: Degrees;
changeObjectInterval?: Milliseconds;
linkAehf?: boolean;
linkGalileo?: boolean;
linkIridium?: boolean;
linkStarlink?: boolean;
linkWgs?: boolean;
static?: boolean;
sensorId?: number;
url?: string;
volume?: boolean;
zoom: ZoomValue;
band?: string;
objName?: string;
shortName?: string;
uiName?: string;
country?: string;
dwellTime?: Milliseconds;
commLinks: CommLink[];
/** Is this sensor volumetric? */
isVolumetric?: boolean;
/** The ideal zoom to see the sensor's full FOV */
zoom: ZoomValue | number;
system?: string;
operator?: string;
url?: string;

constructor(info: DetailedSensorParams & SensorParams & BaseObjectParams) {
super(info);
this.commLinks = info.commLinks ?? [];
this.country = info.country;
this.latRad = (info.lat * (Math.PI / 180)) as Radians;
this.lonRad = (info.lon * (Math.PI / 180)) as Radians;
this.shortName = info.shortName;
this.beamwidth = info.beamwidth;
this.changeObjectInterval = info.changeObjectInterval;
this.linkAehf = info.linkAehf;
this.linkGalileo = info.linkGalileo;
this.linkIridium = info.linkIridium;
this.linkStarlink = info.linkStarlink;
this.linkWgs = info.linkWgs;
this.static = info.static;
this.dwellTime = info.changeObjectInterval;
this.isVolumetric = info.volume;
this.objName = info.objName;
this.operator = info.operator;
this.sensorId = info.sensorId;
this.shortName = info.shortName;
this.system = info.system;
this.uiName = info.uiName;
this.url = info.url;
this.volume = info.volume;
this.zoom = info.zoom;
this.band = info.band;
this.objName = info.objName;
this.uiName = info.uiName;
this.system = info.system;
this.operator = info.operator;
}

isStatic(): boolean {
return true;
}
}
14 changes: 8 additions & 6 deletions src/objects/RfSensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import { DEG2RAD, Degrees, RAD2DEG, Radians, Sensor, SpaceObjectType } from 'oot
import { azel2uv, uv2azel, RfSensorParams } from '../main';

export class RfSensor extends Sensor {
coneHalfAngle: Degrees;
boresightAz: Degrees;
boresightEl: Degrees;
freqBand?: string;
beamwidth: Degrees;

constructor(info: RfSensorParams) {
super(info);
Expand All @@ -41,9 +42,10 @@ export class RfSensor extends Sensor {
throw new Error('Invalid sensor type');
}

this.coneHalfAngle = info.coneHalfAngle;
this.boresightAz = info.boresightAz;
this.boresightEl = info.boresightEl;
this.beamwidth = info.beamwidth;
this.freqBand = info.freqBand;
}

uvFromAzEl(az: Degrees, el: Degrees) {
Expand All @@ -52,11 +54,11 @@ export class RfSensor extends Sensor {
const azDiff = (azRad - this.boresightAzRad) as Radians;
const elDiff = (elRad - this.boresightElRad) as Radians;

return azel2uv(azDiff, elDiff, this.coneHalfAngleRad);
return azel2uv(azDiff, elDiff, this.beamwidthRad);
}

azElFromUV(u: number, v: number) {
const { az, el } = uv2azel(u, v, this.coneHalfAngleRad);
const { az, el } = uv2azel(u, v, this.beamwidthRad);

return {
az: ((az + this.boresightAz) * RAD2DEG) as Degrees,
Expand All @@ -72,7 +74,7 @@ export class RfSensor extends Sensor {
return (this.boresightEl * DEG2RAD) as Radians;
}

get coneHalfAngleRad() {
return (this.coneHalfAngle * DEG2RAD) as Radians;
get beamwidthRad() {
return (this.beamwidth * DEG2RAD) as Radians;
}
}
3 changes: 3 additions & 0 deletions src/propagator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { RungeKutta4Propagator } from './RungeKutta4Propagator';
export { RungeKutta89Propagator } from './RungeKutta89Propagator';
export { Sgp4Propagator } from './Sgp4Propagator';
2 changes: 1 addition & 1 deletion src/transforms/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function rae2raeOffBoresight(
*/
export function rae2ruv(rae: RaeVec3, sensor: RfSensor, maxSensorAz: Degrees): RuvVec3 {
const { az, el } = rae2raeOffBoresight(rae, sensor, maxSensorAz);
const { u, v } = azel2uv(az, el, sensor.coneHalfAngleRad);
const { u, v } = azel2uv(az, el, sensor.beamwidthRad);

return { rng: rae.rng, u, v };
}
Expand Down
13 changes: 3 additions & 10 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
*/

import { Degrees, Kilometers, Milliseconds, SatelliteParams, Vec3 } from 'ootk-core';
import { Kilometers, Milliseconds, SatelliteParams, Vec3 } from 'ootk-core';
import { CommLink } from '../main';

export enum ZoomValue {
LEO = 0.45,
Expand Down Expand Up @@ -61,23 +62,15 @@ export interface DetailedSensorParams {
country?: string;
/** 3 Letter Designation */
shortName?: string;
/** For radars, this is the width of the beam */
beamwidth?: Degrees;
changeObjectInterval?: Milliseconds;
linkAehf?: boolean;
linkGalileo?: boolean;
linkIridium?: boolean;
linkStarlink?: boolean;
linkWgs?: boolean;
commLinks?: CommLink[];
static?: boolean;
sensorId?: number;
url?: string;
/** Does this sensor use a volumetric search pattern? */
volume?: boolean;
/** How far away should we zoom when selecting this sensor? */
zoom: ZoomValue;
/** For radar sensors, what frequency does this sensor operate in? */
band?: string;
/** This is the name of the object in the array */
objName?: string;
/** This is the name of the object in the UI */
Expand Down

0 comments on commit 177c88b

Please sign in to comment.