Skip to content

Commit

Permalink
geostationary satellites, footprint, client side pass calculation, up…
Browse files Browse the repository at this point in the history
…dated rotator control, node-red info
  • Loading branch information
tomvdb committed Feb 26, 2022
1 parent 9290c37 commit 08e2aef
Show file tree
Hide file tree
Showing 7 changed files with 638 additions and 194 deletions.
6 changes: 1 addition & 5 deletions app/routes_jsapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ def satellite_data(collection_id):
for sat in satCollection:
satellite = sat.Satellite
satObject = {}
satObject['dbid'] = satellite.satellite_id
satObject['title'] = satellite.satellite_tle0
satObject['tle1'] = satellite.satellite_tle1
satObject['tle2'] = satellite.satellite_tle2

next_pass = get_next_pass(satellite.satellite_tle0, satellite.satellite_tle1, satellite.satellite_tle2, float(config.config_data['qth_latitude']), float(config.config_data['qth_longitude']), 0)
satObject['next_pass'] = next_pass


data['satellites'].append(satObject)

data['success'] = True
Expand Down
138 changes: 86 additions & 52 deletions app/static/js/polar_svg.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function calcPolarPlotSVG(timeframe, groundstation, tleLine1, tleLine2) {
function calcPolarPlotSVG(timeframe, groundstation, tleLine1, tleLine2, geo, rotatorValues) {
'use strict';

const pi = Math.PI;
Expand All @@ -13,7 +13,7 @@ function calcPolarPlotSVG(timeframe, groundstation, tleLine1, tleLine2) {
height: 0
};

var polarGetXY = function(az, el) {
var polarGetXY = function (az, el) {
var ret = new Object();
ret.x = (90 - el) * Math.sin(az * deg2rad);
ret.y = (el - 90) * Math.cos(az * deg2rad);
Expand All @@ -35,79 +35,113 @@ function calcPolarPlotSVG(timeframe, groundstation, tleLine1, tleLine2) {
var positionAndVelocity = satellite.propagate(satrec, t.toDate());

var gmst = satellite.gstime(t.toDate());
var positionEci = positionAndVelocity.position;
var positionEcf = satellite.eciToEcf(positionEci, gmst);
var positionEci = positionAndVelocity.position;
var positionEcf = satellite.eciToEcf(positionEci, gmst);

var lookAngles = satellite.ecfToLookAngles(observerGd, positionEcf);
var lookAngles = satellite.ecfToLookAngles(observerGd, positionEcf);

return {'azimuth': lookAngles.azimuth * rad2deg,
'elevation': lookAngles.elevation * rad2deg};
return {
'azimuth': lookAngles.azimuth * rad2deg,
'elevation': lookAngles.elevation * rad2deg
};
}

if (geo == false) {
// Draw the orbit pass on the polar az/el plot
var g = '';

// Draw the orbit pass on the polar az/el plot
var g = '';

for (var t = timeframe.start; t < timeframe.end; t = t.add(20, 's')) {
var sky_position = polarGetAzEl(t);
var coord = polarGetXY(sky_position.azimuth, sky_position.elevation);

if (g == '') {
g += 'M';
} else {
g += ' L';
for (var t = timeframe.start; t < timeframe.end; t = t.add(20, 's')) {
var sky_position = polarGetAzEl(t);
var coord = polarGetXY(sky_position.azimuth, sky_position.elevation);

if (g == '') {
g += 'M';
} else {
g += ' L';
}
g += coord.x + ' ' + coord.y;
}
g += coord.x + ' ' + coord.y;
}

polarOrbit.setAttribute('d', g);

// Draw observation start
var point_start = document.createElementNS(svg_namespace, 'circle');
point_start.setAttributeNS(null, 'fill', 'blue');
point_start.setAttributeNS(null, 'stroke', 'black');
point_start.setAttributeNS(null, 'stroke-width', '1');

var sky_position_rise = polarGetAzEl(timeframe.start);
var coord_rise = polarGetXY(sky_position_rise.azimuth, sky_position_rise.elevation);

point_start.setAttribute('cx', coord_rise.x);
point_start.setAttribute('cy', coord_rise.y);
point_start.setAttribute('r', 2);

polarOrbit.setAttribute('d', g);
// Draw oberservation end
var point_end = document.createElementNS(svg_namespace, 'circle');
point_end.setAttributeNS(null, 'fill', 'blue');
point_end.setAttributeNS(null, 'stroke', 'black');
point_end.setAttributeNS(null, 'stroke-width', '1');

var sky_position_set = polarGetAzEl(timeframe.end);
var coord_set = polarGetXY(sky_position_set.azimuth, sky_position_set.elevation);

point_end.setAttribute('cx', coord_set.x);
point_end.setAttribute('cy', coord_set.y);
point_end.setAttribute('r', 2);

}

// Draw observation start
var point_start = document.createElementNS(svg_namespace, 'circle');
point_start.setAttributeNS(null, 'fill', 'blue');
point_start.setAttributeNS(null, 'stroke', 'black');
point_start.setAttributeNS(null, 'stroke-width', '1');
// draw rotator
if (rotatorValues.az >= 0 && rotatorValues.el >= 0)
{

var point_rotator = document.createElementNS(svg_namespace, 'circle');
var coord_rotator = polarGetXY(rotatorValues.az, rotatorValues.el);
point_rotator.setAttribute('cx', coord_rotator.x);
point_rotator.setAttribute('cy', coord_rotator.y);
point_rotator.setAttribute('r', 9);
//point_end.setAttributeNS(null, 'fill', 'blue');
point_rotator.setAttributeNS(null, 'stroke', 'purple');
point_rotator.setAttributeNS(null, 'stroke-width', '1');
point_rotator.setAttributeNS(null, 'fill-opacity', '0.1');

/*
var point_crosshair = document.createElementNS(svg_namespace, 'path');
point_crosshair.setAttributeNS(null, 'stroke', 1)
point_crosshair.setAttributeNS(null, 'stroke-width', 1)
var pathdata = "M" + coord_rotator.x + " " + coord_rotator.y + " L" + (coord_rotator.x + 10) + " " + coord_rotator.y
console.log(pathdata)
point_crosshair.setAttribute('d', "M" + coord_rotator.x + " " + coord_rotator.y + " L" + (coord_rotator.x + 10) + " " + coord_rotator.y)
*/

}

var sky_position_rise = polarGetAzEl(timeframe.start);
var coord_rise = polarGetXY(sky_position_rise.azimuth, sky_position_rise.elevation);

// sat visible now ?
var sky_position_current = polarGetAzEl(new dayjs(new Date()));
if (sky_position_current.elevation > 0 )
{
if (sky_position_current.elevation > 0) {
var point_current = document.createElementNS(svg_namespace, 'circle');
point_current.setAttributeNS(null, 'fill', 'green');
point_current.setAttributeNS(null, 'stroke', 'black');
point_current.setAttributeNS(null, 'stroke-width', '1');

var coord_set = polarGetXY(sky_position_current.azimuth, sky_position_current.elevation);

point_current.setAttribute('cx', coord_set.x);
point_current.setAttribute('cy', coord_set.y);
point_current.setAttribute('r', 7);
}

point_start.setAttribute('cx', coord_rise.x);
point_start.setAttribute('cy', coord_rise.y);
point_start.setAttribute('r', 2);

// Draw oberservation end
var point_end = document.createElementNS(svg_namespace, 'circle');
point_end.setAttributeNS(null, 'fill', 'blue');
point_end.setAttributeNS(null, 'stroke', 'black');
point_end.setAttributeNS(null, 'stroke-width', '1');

var sky_position_set = polarGetAzEl(timeframe.end);
var coord_set = polarGetXY(sky_position_set.azimuth, sky_position_set.elevation);

point_end.setAttribute('cx', coord_set.x);
point_end.setAttribute('cy', coord_set.y);
point_end.setAttribute('r', 2);
var drawObjects = [polarOrbit, point_start, point_end];

if (point_current != null)
drawObjects.push(point_current)
if (point_rotator != null)
{
drawObjects.push(point_rotator)
}

if ( point_current == null)
return [polarOrbit, point_start, point_end];
else
return [polarOrbit, point_start, point_end, point_current];
return drawObjects

}
55 changes: 45 additions & 10 deletions app/static/js/rotator.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,50 @@
function rotatorConnectionOpen(event) {
console.log("Rotator Connected");
var rotatorConnected = false;
var azActual = -1
var elActual = -1

function connectRotator()
{
if ( rotatorConnected == true )
{
return;
}

function rotatorConnectionClosed(event) {
console.log("Rotator Disconnected");
try {

rotator_header.innerHTML = "Rotator Control <span class='badge bg-danger'>Connecting</span>";

connectWS("ws://192.168.0.250:1880/ws/rotator", rotatorConnectionOpen, rotatorConnectionClosed, rotatorConnectionMessageReceived);
}
catch (err) {
console.log("Couldn't connect to rotator websocket")
}

}

function rotatorConnectionOpen(event) {
console.log("Rotator Connected");

rotator_header.innerHTML = "Rotator Control <span class='badge bg-success'>Connected</span>";

rotatorConnected = true;
$("#rotatorEnabled").attr("disabled", false);
}

function rotatorConnectionClosed(event) {
rotator_header.innerHTML = "Rotator Control <a onClick='connectRotator()'><span class='badge bg-danger'>Disconnected</span></a>";

$("#rotatorEnabled").attr("disabled", true);

console.log("Rotator Disconnected");
rotatorConnected = false;
}

function rotatorConnectionMessageReceived(event) {
console.log(JSON.parse(event.data))
function rotatorConnectionMessageReceived(event) {
console.log(JSON.parse(event.data))

rotatorData = JSON.parse(event.data)
rot_actual_el.innerHTML = rotatorData.el;
rot_actual_az.innerHTML = rotatorData.az;
}
rotatorData = JSON.parse(event.data)
azActual = rotatorData.az;
elActual = rotatorData.el;
rot_actual_el.innerHTML = rotatorData.el;
rot_actual_az.innerHTML = rotatorData.az;
}
Loading

0 comments on commit 08e2aef

Please sign in to comment.