diff --git a/Debugging Arduino Sketches/sysInfo/sysInfo.ino b/Arduino/Debugging Arduino Sketches/sysInfo/sysInfo.ino similarity index 100% rename from Debugging Arduino Sketches/sysInfo/sysInfo.ino rename to Arduino/Debugging Arduino Sketches/sysInfo/sysInfo.ino diff --git a/Debugging Arduino Sketches/test_serial/test_serial.ino b/Arduino/Debugging Arduino Sketches/test_serial/test_serial.ino similarity index 100% rename from Debugging Arduino Sketches/test_serial/test_serial.ino rename to Arduino/Debugging Arduino Sketches/test_serial/test_serial.ino diff --git a/Ground Station Test Arduino Sketch/FOSSAGS/FOSSAGS.ino b/Arduino/Ground Station Test Arduino Sketch/FOSSAGS/FOSSAGS.ino similarity index 100% rename from Ground Station Test Arduino Sketch/FOSSAGS/FOSSAGS.ino rename to Arduino/Ground Station Test Arduino Sketch/FOSSAGS/FOSSAGS.ino diff --git a/FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.h similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.h diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gException.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gException.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gException.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gException.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.h similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.h diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.h similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.h diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.h similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.h diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/stdsat.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/stdsat.h similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/stdsat.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/stdsat.h diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.hpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.hpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.hpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.hpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.cpp diff --git a/FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.h similarity index 100% rename from FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.h diff --git a/FOSSA-GroundStationControlPanel/DopplerShiftCorrector.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/DopplerShiftCorrector.h similarity index 100% rename from FOSSA-GroundStationControlPanel/DopplerShiftCorrector.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/DopplerShiftCorrector.h diff --git a/FOSSA-GroundStationControlPanel/FOSSA-GroundStationControlPanel.pro b/Desktop/Sources/FOSSA-GroundStationControlPanel/FOSSA-GroundStationControlPanel.pro similarity index 100% rename from FOSSA-GroundStationControlPanel/FOSSA-GroundStationControlPanel.pro rename to Desktop/Sources/FOSSA-GroundStationControlPanel/FOSSA-GroundStationControlPanel.pro diff --git a/FOSSA-GroundStationControlPanel/SerialPortThread.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/SerialPortThread.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/SerialPortThread.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/SerialPortThread.cpp diff --git a/FOSSA-GroundStationControlPanel/SerialPortThread.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/SerialPortThread.h similarity index 100% rename from FOSSA-GroundStationControlPanel/SerialPortThread.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/SerialPortThread.h diff --git a/FOSSA-GroundStationControlPanel/Settings.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/Settings.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/Settings.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/Settings.cpp diff --git a/FOSSA-GroundStationControlPanel/Settings.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/Settings.h similarity index 100% rename from FOSSA-GroundStationControlPanel/Settings.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/Settings.h diff --git a/FOSSA-GroundStationControlPanel/main.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/main.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/main.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/main.cpp diff --git a/FOSSA-GroundStationControlPanel/mainwindow.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/mainwindow.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/mainwindow.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/mainwindow.cpp diff --git a/FOSSA-GroundStationControlPanel/mainwindow.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/mainwindow.h similarity index 100% rename from FOSSA-GroundStationControlPanel/mainwindow.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/mainwindow.h diff --git a/FOSSA-GroundStationControlPanel/mainwindow.ui b/Desktop/Sources/FOSSA-GroundStationControlPanel/mainwindow.ui similarity index 100% rename from FOSSA-GroundStationControlPanel/mainwindow.ui rename to Desktop/Sources/FOSSA-GroundStationControlPanel/mainwindow.ui diff --git a/FOSSA-GroundStationControlPanel/messagelogframe.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/messagelogframe.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/messagelogframe.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/messagelogframe.cpp diff --git a/FOSSA-GroundStationControlPanel/messagelogframe.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/messagelogframe.h similarity index 100% rename from FOSSA-GroundStationControlPanel/messagelogframe.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/messagelogframe.h diff --git a/FOSSA-GroundStationControlPanel/messagelogframe.ui b/Desktop/Sources/FOSSA-GroundStationControlPanel/messagelogframe.ui similarity index 100% rename from FOSSA-GroundStationControlPanel/messagelogframe.ui rename to Desktop/Sources/FOSSA-GroundStationControlPanel/messagelogframe.ui diff --git a/FOSSA-GroundStationControlPanel/systeminformationpane.cpp b/Desktop/Sources/FOSSA-GroundStationControlPanel/systeminformationpane.cpp similarity index 100% rename from FOSSA-GroundStationControlPanel/systeminformationpane.cpp rename to Desktop/Sources/FOSSA-GroundStationControlPanel/systeminformationpane.cpp diff --git a/FOSSA-GroundStationControlPanel/systeminformationpane.h b/Desktop/Sources/FOSSA-GroundStationControlPanel/systeminformationpane.h similarity index 100% rename from FOSSA-GroundStationControlPanel/systeminformationpane.h rename to Desktop/Sources/FOSSA-GroundStationControlPanel/systeminformationpane.h diff --git a/FOSSA-GroundStationControlPanel/systeminformationpane.ui b/Desktop/Sources/FOSSA-GroundStationControlPanel/systeminformationpane.ui similarity index 100% rename from FOSSA-GroundStationControlPanel/systeminformationpane.ui rename to Desktop/Sources/FOSSA-GroundStationControlPanel/systeminformationpane.ui diff --git a/Desktop/Windows/GroundStationControlPanel/GroundStationControlPanel.pro b/Desktop/Windows/GroundStationControlPanel/GroundStationControlPanel.pro new file mode 100644 index 0000000..d5017ac --- /dev/null +++ b/Desktop/Windows/GroundStationControlPanel/GroundStationControlPanel.pro @@ -0,0 +1,78 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.cpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.cpp \ + ../../../FOSSA-GroundStationControlPanel/SerialPortThread.cpp \ + ../../../FOSSA-GroundStationControlPanel/Settings.cpp \ + ../../../FOSSA-GroundStationControlPanel/main.cpp \ + ../../../FOSSA-GroundStationControlPanel/mainwindow.cpp \ + ../../../FOSSA-GroundStationControlPanel/messagelogframe.cpp \ + ../../../FOSSA-GroundStationControlPanel/systeminformationpane.cpp + +HEADERS += \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/FOSSA-Comms/FOSSA-Comms.h \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gException.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrix.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gObserver.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gSatTEME.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTime.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gTleParser.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVector.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/mathUtils.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4ext.h \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4io.h \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/sgp4unit.h \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/solarProcedures.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/libs/gsat-r11-fixed/src/stdsat.h \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/ObserverInformation.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteInformation.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SatelliteSimulation.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/SimulationResult.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/fossasattracker/src/TLE.hpp \ + ../../../FOSSA-GroundStationControlPanel/3rdparty/tiny-aes/aes.h \ + ../../../FOSSA-GroundStationControlPanel/DopplerShiftCorrector.h \ + ../../../FOSSA-GroundStationControlPanel/SerialPortThread.h \ + ../../../FOSSA-GroundStationControlPanel/Settings.h \ + ../../../FOSSA-GroundStationControlPanel/mainwindow.h \ + ../../../FOSSA-GroundStationControlPanel/messagelogframe.h \ + ../../../FOSSA-GroundStationControlPanel/systeminformationpane.h + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +FORMS += \ + ../../../FOSSA-GroundStationControlPanel/mainwindow.ui \ + ../../../FOSSA-GroundStationControlPanel/messagelogframe.ui \ + ../../../FOSSA-GroundStationControlPanel/systeminformationpane.ui diff --git a/Desktop/Windows/build-GroundStationControlPanel-Desktop_Qt_5_15_1_MSVC2019_32bit-Debug/.qmake.stash b/Desktop/Windows/build-GroundStationControlPanel-Desktop_Qt_5_15_1_MSVC2019_32bit-Debug/.qmake.stash new file mode 100644 index 0000000..097ed4a --- /dev/null +++ b/Desktop/Windows/build-GroundStationControlPanel-Desktop_Qt_5_15_1_MSVC2019_32bit-Debug/.qmake.stash @@ -0,0 +1,22 @@ +QMAKE_CXX.QT_COMPILER_STDCXX = 199711L +QMAKE_CXX.QMAKE_MSC_VER = 1928 +QMAKE_CXX.QMAKE_MSC_FULL_VER = 192829213 +QMAKE_CXX.COMPILER_MACROS = \ + QT_COMPILER_STDCXX \ + QMAKE_MSC_VER \ + QMAKE_MSC_FULL_VER +QMAKE_CXX.INCDIRS = \ + "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\VC\\Tools\\MSVC\\14.28.29213\\ATLMFC\\include" \ + "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\VC\\Tools\\MSVC\\14.28.29213\\include" \ + "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\ucrt" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\cppwinrt" +QMAKE_CXX.LIBDIRS = \ + "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\VC\\Tools\\MSVC\\14.28.29213\\ATLMFC\\lib\\x86" \ + "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\VC\\Tools\\MSVC\\14.28.29213\\lib\\x86" \ + "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\lib\\um\\x86" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\ucrt\\x86" \ + "C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.19041.0\\um\\x86" diff --git a/FOSSACommsInterpreter/.gitignore b/FOSSACommsInterpreter/.gitignore deleted file mode 100644 index 0691b4b..0000000 --- a/FOSSACommsInterpreter/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -cmake-* -.idea -.DS_STORE -# Prerequisites -*.d - -*.autosave - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app diff --git a/FOSSACommsInterpreter/CMakeLists.txt b/FOSSACommsInterpreter/CMakeLists.txt deleted file mode 100644 index c63043a..0000000 --- a/FOSSACommsInterpreter/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -cmake_minimum_required(VERSION 3.17) -project(FOSSACommsInterpreter CXX) - -set(CMAKE_CXX_STANDARD 11) -# set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O0") - - -######################################### -# Add the FOSSACommsInterpreter sources # -######################################### -file(GLOB_RECURSE ALL_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/src/*.*") - -####################################### -# Add the FOSSA-Comms library sources # -####################################### -file(GLOB_RECURSE FOSSACOMMSLIB_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/libs/FOSSA-Comms/*.c*") -file(GLOB_RECURSE FOSSACOMMSLIB_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/libs/FOSSA-Comms/*.h*") - - -#################################### -# Add the tiny-aes library sources # -#################################### -file(GLOB_RECURSE TINYAES_SRCS - "${CMAKE_CURRENT_SOURCE_DIR}/libs/tiny-aes/*.c*") -file(GLOB_RECURSE TINYAES_HEADERS - "${CMAKE_CURRENT_SOURCE_DIR}/libs/tiny-aes/*.h*") - -add_executable(FOSSACommsInterpreter - main.cpp - ${ALL_SRCS} - ${FOSSACOMMSLIB_SRCS} ${FOSSACOMMSLIB_HEADERS} - ${TINYAES_SRCS} ${TINYAES_HEADERS}) - -####################################### -# Add the library include directories # -####################################### -target_include_directories(FOSSACommsInterpreter PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libs/tiny-aes/") -target_include_directories(FOSSACommsInterpreter PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libs/FOSSA-Comms/") diff --git a/FOSSACommsInterpreter/LICENSE b/FOSSACommsInterpreter/LICENSE deleted file mode 100644 index 5078e30..0000000 --- a/FOSSACommsInterpreter/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Richard Bamford - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/FOSSACommsInterpreter/libs/FOSSA-Comms/FOSSA-Comms.cpp b/FOSSACommsInterpreter/libs/FOSSA-Comms/FOSSA-Comms.cpp deleted file mode 100644 index cf23928..0000000 --- a/FOSSACommsInterpreter/libs/FOSSA-Comms/FOSSA-Comms.cpp +++ /dev/null @@ -1,381 +0,0 @@ -#include "FOSSA-Comms.h" - -int16_t FCP_Get_Frame_Length(char* callsign, uint8_t optDataLen, const char* password) { - // check callsign - if(callsign == NULL) { - return(ERR_CALLSIGN_INVALID); - } - - // callsign and function ID fields are always present - int16_t frameLen = strlen(callsign) + 1; - - // optDataLen and optData might be present - if(optDataLen > 0) { - frameLen += 1 + optDataLen; - } - - // check if the frame is encrpyted - if(password != NULL) { - frameLen += strlen(password); - if(optDataLen == 0) { - frameLen++; - } - frameLen += 16 - ((1 + optDataLen + strlen(password)) % 16); - } - - return(frameLen); -} - -int16_t FCP_Get_OptData_Length(char* callsign, uint8_t* frame, uint8_t frameLen, const uint8_t* key, const char* password) { - // check callsign - if(callsign == NULL) { - return(ERR_CALLSIGN_INVALID); - } - - // check frame buffer - if(frame == NULL) { - return(ERR_FRAME_INVALID); - } - - // check frame length - if(frameLen < strlen(callsign) + 1) { - return(ERR_FRAME_INVALID); - } else if(frameLen == strlen(callsign) + 1) { - return(0); - } - - // check encryption - if((key != NULL) && (password != NULL)) { - // encrypted frame - - // extract encrypted section - uint8_t encSectionLen = frameLen - strlen(callsign) - 1; - uint8_t* encSection = new uint8_t[encSectionLen]; - memcpy(encSection, frame + strlen(callsign) + 1, encSectionLen); - - // decrypt - struct AES_ctx ctx; - AES_init_ctx(&ctx, key); - uint8_t numBlocks = encSectionLen / 16; - for(uint8_t i = 0; i < numBlocks; i++) { - AES_ECB_decrypt(&ctx, encSection + (i * 16)); - } - - // check password - if(memcmp(encSection + 1, password, strlen(password)) == 0) { - // check passed - int16_t optDataLen = encSection[0] - strlen(password); - - // deallocate memory - delete[] encSection; - return(optDataLen); - } - - // deallocate memory - delete[] encSection; - - } else { - // unencrypted frame - int16_t optDataLen = frame[strlen(callsign) + 1]; - - // check if optDataLen field matches the expected length - if(optDataLen != (uint8_t)(frameLen - strlen(callsign) - 2)) { - // length mismatch - return(ERR_LENGTH_MISMATCH); - } - - return(optDataLen); - } - - return(ERR_INCORRECT_PASSWORD); -} - -int16_t FCP_Get_FunctionID(char* callsign, uint8_t* frame, uint8_t frameLen) { - // check callsign - if(callsign == NULL) { - return(ERR_CALLSIGN_INVALID); - } - - // check frame buffer - if(frame == NULL) { - return(ERR_FRAME_INVALID); - } - - // check frame length - if(frameLen < strlen(callsign) + 1) { - return(ERR_FRAME_INVALID); - } - - return((int16_t)frame[strlen(callsign)]); -} - -int16_t FCP_Get_OptData(char* callsign, uint8_t* frame, uint8_t frameLen, uint8_t* optData, const uint8_t* key, const char* password) { - // check callsign - if(callsign == NULL) { - return(ERR_CALLSIGN_INVALID); - } - - // check frame - if(frame == NULL) { - return(ERR_FRAME_INVALID); - } - - // get frame pointer - uint8_t* framePtr = frame; - - // check callsign - if(memcmp(framePtr, callsign, strlen(callsign)) != 0) { - // incorrect callsign - return(ERR_CALLSIGN_INVALID); - } - framePtr += strlen(callsign); - - // skip function ID - framePtr += 1; - - // check encryption - if((key != NULL) && (password != NULL)) { - // encrypted frame - - // extract encrypted section - uint8_t encSectionLen = frameLen - strlen(callsign) - 1; - uint8_t* encSection = new uint8_t[encSectionLen]; - memcpy(encSection, framePtr, encSectionLen); - - // decrypt - struct AES_ctx ctx; - AES_init_ctx(&ctx, key); - uint8_t numBlocks = encSectionLen / 16; - for(uint8_t i = 0; i < numBlocks; i++) { - AES_ECB_decrypt(&ctx, encSection + (i * 16)); - } - uint8_t* encSectionPtr = encSection; - - // get optional data length - uint8_t optDataLen = *encSectionPtr; - encSectionPtr += 1; - - // check password - if(memcmp(encSectionPtr, password, strlen(password)) == 0) { - // check passed - - // get optional data - encSectionPtr += strlen(password); - memcpy(optData, encSectionPtr, optDataLen - strlen(password)); - - // deallocate memory - delete[] encSection; - return(ERR_NONE); - } - - // deallocate memory - delete[] encSection; - - } else { - // unencrypted frame - - // get optional data (if present) - if(frameLen > strlen(callsign) + 1) { - if(optData == NULL) { - return(ERR_FRAME_INVALID); - } - - // get option data length - uint8_t optDataLen = *framePtr; - framePtr += 1; - - // get optional data - memcpy(optData, framePtr, optDataLen); - framePtr += optDataLen; - } - - return(ERR_NONE); - } - - return(ERR_INCORRECT_PASSWORD); -} - -int16_t FCP_Encode(uint8_t* frame, char* callsign, uint8_t functionId, uint8_t optDataLen, uint8_t* optData, const uint8_t* key, const char* password) { - // check callsign - if(callsign == NULL) { - return(ERR_CALLSIGN_INVALID); - } - - // check some optional data are provided when optional data length is not 0 (and vice versa) - if(((optDataLen > 0) && (optData == NULL)) || ((optData != NULL) && (optDataLen == 0))) { - return(ERR_FRAME_INVALID); - } - - // check frame buffer - if(frame == NULL) { - return(ERR_FRAME_INVALID); - } - - // get frame pointer - uint8_t* framePtr = frame; - - // set callsign - memcpy(framePtr, callsign, strlen(callsign)); - framePtr += strlen(callsign); - - // set function ID - *framePtr = functionId; - framePtr += 1; - - // check encryption - if((key != NULL) && (password != NULL)) { - // encrypted frame - - // create encrypted section - uint8_t encSectionLen = 1 + strlen(password) + optDataLen; - uint8_t paddingLen = 16 - (encSectionLen % 16); - uint8_t* encSection = new uint8_t[encSectionLen + paddingLen]; - uint8_t* encSectionPtr = encSection; - - // set optional data length - *encSectionPtr = optDataLen + strlen(password); - encSectionPtr += 1; - - // set password - memcpy(encSectionPtr, password, strlen(password)); - encSectionPtr += strlen(password); - - // set optional data - if(optData != NULL) { - memcpy(encSectionPtr, optData, optDataLen); - encSectionPtr += optDataLen; - } - - // add padding - for(uint8_t i = 0; i < paddingLen; i++) { - *(encSectionPtr + i) = (uint8_t)rand() % 256;; - } - - // encrypt - struct AES_ctx ctx; - AES_init_ctx(&ctx, key); - uint8_t numBlocks = (encSectionLen + paddingLen) / 16; - for(uint8_t i = 0; i < numBlocks; i++) { - AES_ECB_encrypt(&ctx, encSection + (i * 16)); - } - - // copy encrypted section into frame buffer - memcpy(framePtr, encSection, encSectionLen + paddingLen); - - // deallocate memory - delete[] encSection; - return(ERR_NONE); - - } else { - // unencrypted frame - - // check option data presence - if(optDataLen > 0) { - // set optional data length - *framePtr = optDataLen; - framePtr += 1; - - // set optional data - memcpy(framePtr, optData, optDataLen); - framePtr += optDataLen; - } - - return(ERR_NONE); - } - - return(ERR_FRAME_INVALID); -} - -float FCP_Get_Battery_Voltage(uint8_t* optData) { - return(FCP_System_Info_Get_Voltage(optData, 0)); -} - -float FCP_Get_Battery_Charging_Current(uint8_t* optData) { - return(FCP_System_Info_Get_Current(optData, 1)); -} - -float FCP_Get_Battery_Charging_Voltage(uint8_t* optData) { - return(FCP_System_Info_Get_Voltage(optData, 3)); -} - -uint32_t FCP_Get_Uptime_Counter(uint8_t* optData) { - if(optData == NULL) { - return(0); - } - - uint32_t val; - memcpy(&val, optData + 4, sizeof(uint32_t)); - return(val); -} - -uint8_t FCP_Get_Power_Configuration(uint8_t* optData) { - if(optData == NULL) { - return(0); - } - - return(optData[8]); -} - -uint16_t FCP_Get_Reset_Counter(uint8_t* optData) { - if(optData == NULL) { - return(0); - } - - uint16_t val; - memcpy(&val, optData + 9, sizeof(uint16_t)); - return(val); -} - -float FCP_Get_Solar_Cell_Voltage(uint8_t cell, uint8_t* optData) { - if(cell > 2) { - return(0); - } - - return(FCP_System_Info_Get_Voltage(optData, 11 + cell)); -} - -float FCP_Get_Battery_Temperature(uint8_t* optData) { - return(FCP_System_Info_Get_Temperature(optData, 14)); -} - -float FCP_Get_Board_Temperature(uint8_t* optData) { - return(FCP_System_Info_Get_Temperature(optData, 16)); -} - -int8_t FCP_Get_MCU_Temperature(uint8_t* optData) { - if(optData == NULL) { - return(0); - } - - int8_t val; - memcpy(&val, optData + 18, sizeof(int8_t)); - return(val); -} - -float FCP_System_Info_Get_Voltage(uint8_t* optData, uint8_t pos) { - if(optData == NULL) { - return(0); - } - - return((float)optData[pos] * ((float)VOLTAGE_MULTIPLIER / (float)VOLTAGE_UNIT)); -} - -float FCP_System_Info_Get_Temperature(uint8_t* optData, uint8_t pos) { - if(optData == NULL) { - return(0); - } - - int16_t raw; - memcpy(&raw, optData + pos, sizeof(int16_t)); - return((float)raw * ((float)TEMPERATURE_MULTIPLIER / (float)TEMPERATURE_UNIT)); -} - -float FCP_System_Info_Get_Current(uint8_t* optData, uint8_t pos) { - if(optData == NULL) { - return(0); - } - - int16_t raw; - memcpy(&raw, optData + pos, sizeof(int16_t)); - return((float)raw * ((float)CURRENT_MULTIPLIER / (float)CURRENT_UNIT)); -} diff --git a/FOSSACommsInterpreter/libs/FOSSA-Comms/FOSSA-Comms.h b/FOSSACommsInterpreter/libs/FOSSA-Comms/FOSSA-Comms.h deleted file mode 100644 index aefd0d9..0000000 --- a/FOSSACommsInterpreter/libs/FOSSA-Comms/FOSSA-Comms.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef _FOSSA_COMMS_H -#define _FOSSA_COMMS_H - -#include -#include -#include - - -// version definitions -#define FCP_VERSION_MAJOR (0x01) -#define FCP_VERSION_MINOR (0x00) -#define FCP_VERSION_PATCH (0x00) -#define FCP_VERSION_EXTRA (0x00) - -#define FCP_VERSION ((FCP_VERSION_MAJOR << 24) | (FCP_VERSION_MINOR << 16) | (FCP_VERSION_PATCH << 8) | (FCP_VERSION_EXTRA)) - -// constants -#define VOLTAGE_MULTIPLIER 20 // 20 mV resolution -#define VOLTAGE_UNIT 1000 -#define CURRENT_MULTIPLIER 10 // 10 uA resolution -#define CURRENT_UNIT 1000000 -#define TEMPERATURE_MULTIPLIER 10 // 0.01 deg C resolution -#define TEMPERATURE_UNIT 1000 - -// RESP_STATISTICS flags -#define STATS_FLAGS_TEMPERATURES 0b00000001 -#define STATS_FLAGS_CURRENTS 0b00000010 -#define STATS_FLAGS_VOLTAGES 0b00000100 -#define STATS_FLAGS_LIGHT 0b00001000 -#define STATS_FLAGS_IMU 0b00010000 -#define STATS_FLAGS_POWER 0b00100000 - -// status codes -#define ERR_NONE 0 -#define ERR_CALLSIGN_INVALID -1 -#define ERR_FRAME_INVALID -2 -#define ERR_INCORRECT_PASSWORD -3 -#define ERR_LENGTH_MISMATCH -4 - -// communication protocol definitions -#define RESPONSE_OFFSET 0x20 -#define PRIVATE_OFFSET 0x40 - -// public commands (unencrypted uplink messages) -#define CMD_PING (0x00) -#define CMD_RETRANSMIT (0x01) -#define CMD_RETRANSMIT_CUSTOM (0x02) -#define CMD_TRANSMIT_SYSTEM_INFO (0x03) -#define CMD_GET_PACKET_INFO (0x04) -#define CMD_GET_STATISTICS (0x05) -#define CMD_GET_FULL_SYSTEM_INFO (0x06) -#define CMD_STORE_AND_FORWARD_ADD (0x07) -#define CMD_STORE_AND_FORWARD_REQUEST (0x08) -#define CMD_REQUEST_PUBLIC_PICTURE (0x09) - -#define NUM_PUBLIC_COMMANDS (0x0A) - -// public responses (unencrypted downlink messages) -#define RESP_PONG (CMD_PING + RESPONSE_OFFSET) -#define RESP_REPEATED_MESSAGE (CMD_RETRANSMIT + RESPONSE_OFFSET) -#define RESP_REPEATED_MESSAGE_CUSTOM (CMD_RETRANSMIT_CUSTOM + RESPONSE_OFFSET) -#define RESP_SYSTEM_INFO (CMD_TRANSMIT_SYSTEM_INFO + RESPONSE_OFFSET) -#define RESP_PACKET_INFO (CMD_GET_PACKET_INFO + RESPONSE_OFFSET) -#define RESP_STATISTICS (CMD_GET_STATISTICS + RESPONSE_OFFSET) -#define RESP_FULL_SYSTEM_INFO (CMD_GET_FULL_SYSTEM_INFO + RESPONSE_OFFSET) -#define RESP_STORE_AND_FORWARD_ASSIGNED_SLOT (CMD_STORE_AND_FORWARD_ADD + RESPONSE_OFFSET) -#define RESP_FORWARDED_MESSAGE (CMD_STORE_AND_FORWARD_REQUEST + RESPONSE_OFFSET) -#define RESP_PUBLIC_PICTURE (CMD_REQUEST_PUBLIC_PICTURE + RESPONSE_OFFSET) -#define RESP_DEPLOYMENT_STATE (NUM_PUBLIC_COMMANDS + RESPONSE_OFFSET) -#define RESP_RECORDED_SOLAR_CELLS (NUM_PUBLIC_COMMANDS + 1 + RESPONSE_OFFSET) -#define RESP_CAMERA_STATE (NUM_PUBLIC_COMMANDS + 2 + RESPONSE_OFFSET) -#define RESP_RECORDED_IMU (NUM_PUBLIC_COMMANDS + 3 + RESPONSE_OFFSET) -#define RESP_MANUAL_ACS_RESULT (NUM_PUBLIC_COMMANDS + 4 + RESPONSE_OFFSET) -#define RESP_GPS_LOG (NUM_PUBLIC_COMMANDS + 5 + RESPONSE_OFFSET) -#define RESP_GPS_LOG_STATE (NUM_PUBLIC_COMMANDS + 6 + RESPONSE_OFFSET) -#define RESP_FLASH_CONTENTS (NUM_PUBLIC_COMMANDS + 7 + RESPONSE_OFFSET) -#define RESP_CAMERA_PICTURE (NUM_PUBLIC_COMMANDS + 8 + RESPONSE_OFFSET) -#define RESP_CAMERA_PICTURE_LENGTH (NUM_PUBLIC_COMMANDS + 9 + RESPONSE_OFFSET) -#define RESP_GPS_COMMAND_RESPONSE (NUM_PUBLIC_COMMANDS + 10 + RESPONSE_OFFSET) - -// ACK is the last public function ID -#define RESP_ACKNOWLEDGE (PRIVATE_OFFSET - 1) - -// private commands (encrypted uplink messages) -#define CMD_DEPLOY (0x00 + PRIVATE_OFFSET) -#define CMD_RESTART (0x01 + PRIVATE_OFFSET) -#define CMD_WIPE_EEPROM (0x02 + PRIVATE_OFFSET) -#define CMD_SET_TRANSMIT_ENABLE (0x03 + PRIVATE_OFFSET) -#define CMD_SET_CALLSIGN (0x04 + PRIVATE_OFFSET) -#define CMD_SET_SF_MODE (0x05 + PRIVATE_OFFSET) -#define CMD_SET_MPPT_MODE (0x06 + PRIVATE_OFFSET) -#define CMD_SET_LOW_POWER_ENABLE (0x07 + PRIVATE_OFFSET) -#define CMD_SET_RECEIVE_WINDOWS (0x08 + PRIVATE_OFFSET) -#define CMD_RECORD_SOLAR_CELLS (0x09 + PRIVATE_OFFSET) -#define CMD_CAMERA_CAPTURE (0x0A + PRIVATE_OFFSET) -#define CMD_SET_POWER_LIMITS (0x0B + PRIVATE_OFFSET) -#define CMD_SET_RTC (0x0C + PRIVATE_OFFSET) -#define CMD_RECORD_IMU (0x0D + PRIVATE_OFFSET) -#define CMD_RUN_MANUAL_ACS (0x0E + PRIVATE_OFFSET) -#define CMD_LOG_GPS (0x0F + PRIVATE_OFFSET) -#define CMD_GET_GPS_LOG (0x10 + PRIVATE_OFFSET) -#define CMD_GET_FLASH_CONTENTS (0x11 + PRIVATE_OFFSET) -#define CMD_GET_PICTURE_LENGTH (0x12 + PRIVATE_OFFSET) -#define CMD_GET_PICTURE_BURST (0x13 + PRIVATE_OFFSET) -#define CMD_ROUTE (0x14 + PRIVATE_OFFSET) -#define CMD_SET_FLASH_CONTENTS (0x15 + PRIVATE_OFFSET) -#define CMD_SET_TLE (0x16 + PRIVATE_OFFSET) -#define CMD_GET_GPS_LOG_STATE (0x17 + PRIVATE_OFFSET) -#define CMD_RUN_GPS_COMMAND (0x18 + PRIVATE_OFFSET) -#define CMD_SET_SLEEP_INTERVALS (0x19 + PRIVATE_OFFSET) -#define CMD_ABORT (0x1A + PRIVATE_OFFSET) -#define CMD_MANEUVER (0x1B + PRIVATE_OFFSET) -#define CMD_SET_ADCS_PARAMETERS (0x1C + PRIVATE_OFFSET) -#define CMD_ERASE_FLASH (0x1D + PRIVATE_OFFSET) -#define CMD_SET_ADCS_CONTROLLER (0x1E + PRIVATE_OFFSET) -#define CMD_SET_ADCS_EPHEMERIDES (0x1F + PRIVATE_OFFSET) -#define CMD_DETUMBLE (0x20 + PRIVATE_OFFSET) -#define CMD_SET_IMU_OFFSET (0x21 + PRIVATE_OFFSET) -#define CMD_SET_IMU_CALIBRATION (0x22 + PRIVATE_OFFSET) - -#define NUM_PRIVATE_COMMANDS (0x23) - -#define PRINT_BUFF(BUFF, LEN) { \ - for(size_t i = 0; i < LEN; i++) { \ - Serial.print(F("0x")); \ - Serial.print(BUFF[i], HEX); \ - Serial.print('\t'); \ - Serial.write(BUFF[i]); \ - Serial.println(); \ - } } - -int16_t FCP_Get_Frame_Length(char* callsign, uint8_t optDataLen = 0, const char* password = NULL); -int16_t FCP_Get_FunctionID(char* callsign, uint8_t* frame, uint8_t frameLen); -int16_t FCP_Get_OptData_Length(char* callsign, uint8_t* frame, uint8_t frameLen, const uint8_t* key = NULL, const char* password = NULL); -int16_t FCP_Get_OptData(char* callsign, uint8_t* frame, uint8_t frameLen, uint8_t* optData, const uint8_t* key = NULL, const char* password = NULL); - -int16_t FCP_Encode(uint8_t* frame, char* callsign, uint8_t functionId, uint8_t optDataLen = 0, uint8_t* optData = NULL, const uint8_t* key = NULL, const char* password = NULL); - -float FCP_Get_Battery_Voltage(uint8_t* optData); -float FCP_Get_Battery_Charging_Current(uint8_t* optData); -float FCP_Get_Battery_Charging_Voltage(uint8_t* optData); -uint32_t FCP_Get_Uptime_Counter(uint8_t* optData); -uint8_t FCP_Get_Power_Configuration(uint8_t* optData); -uint16_t FCP_Get_Reset_Counter(uint8_t* optData); -float FCP_Get_Solar_Cell_Voltage(uint8_t cell, uint8_t* optData); -float FCP_Get_Battery_Temperature(uint8_t* optData); -float FCP_Get_Board_Temperature(uint8_t* optData); -int8_t FCP_Get_MCU_Temperature(uint8_t* optData); - -float FCP_System_Info_Get_Voltage(uint8_t* optData, uint8_t pos); -float FCP_System_Info_Get_Temperature(uint8_t* optData, uint8_t pos); -float FCP_System_Info_Get_Current(uint8_t* optData, uint8_t pos); - -#endif diff --git a/FOSSACommsInterpreter/libs/tiny-aes/aes.cpp b/FOSSACommsInterpreter/libs/tiny-aes/aes.cpp deleted file mode 100644 index 99a39ea..0000000 --- a/FOSSACommsInterpreter/libs/tiny-aes/aes.cpp +++ /dev/null @@ -1,570 +0,0 @@ -/* - -This is an implementation of the AES algorithm, specifically ECB, CTR and CBC mode. -Block size can be chosen in aes.h - available choices are AES128, AES192, AES256. - -The implementation is verified against the test vectors in: - National Institute of Standards and Technology Special Publication 800-38A 2001 ED - -ECB-AES128 ----------- - - plain-text: - 6bc1bee22e409f96e93d7e117393172a - ae2d8a571e03ac9c9eb76fac45af8e51 - 30c81c46a35ce411e5fbc1191a0a52ef - f69f2445df4f9b17ad2b417be66c3710 - - key: - 2b7e151628aed2a6abf7158809cf4f3c - - resulting cipher - 3ad77bb40d7a3660a89ecaf32466ef97 - f5d3d58503b9699de785895a96fdbaaf - 43b1cd7f598ece23881b00e3ed030688 - 7b0c785e27e8ad3f8223207104725dd4 - - -NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0) - You should pad the end of the string with zeros if this is not the case. - For AES192/256 the key size is proportionally larger. - -*/ - - -/*****************************************************************************/ -/* Includes: */ -/*****************************************************************************/ -#include // CBC mode, for memset -#include "aes.h" - -/*****************************************************************************/ -/* Defines: */ -/*****************************************************************************/ -// The number of columns comprising a state in AES. This is a constant in AES. Value=4 -#define Nb 4 - -#if defined(AES256) && (AES256 == 1) - #define Nk 8 - #define Nr 14 -#elif defined(AES192) && (AES192 == 1) - #define Nk 6 - #define Nr 12 -#else - #define Nk 4 // The number of 32 bit words in a key. - #define Nr 10 // The number of rounds in AES Cipher. -#endif - -// jcallan@github points out that declaring Multiply as a function -// reduces code size considerably with the Keil ARM compiler. -// See this link for more information: https://github.com/kokke/tiny-AES-C/pull/3 -#ifndef MULTIPLY_AS_A_FUNCTION - #define MULTIPLY_AS_A_FUNCTION 0 -#endif - - - - -/*****************************************************************************/ -/* Private variables: */ -/*****************************************************************************/ -// state - array holding the intermediate results during decryption. -typedef uint8_t state_t[4][4]; - - - -// The lookup-tables are marked const so they can be placed in read-only storage instead of RAM -// The numbers below can be computed dynamically trading ROM for RAM - -// This can be useful in (embedded) bootloader applications, where ROM is often limited. -static const uint8_t sbox[256] = { - //0 1 2 3 4 5 6 7 8 9 A B C D E F - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; - -static const uint8_t rsbox[256] = { - 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, - 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, - 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, - 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, - 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, - 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, - 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, - 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, - 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, - 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, - 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, - 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, - 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, - 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, - 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, - 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d }; - -// The round constant word array, Rcon[i], contains the values given by -// x to the power (i-1) being powers of x (x is denoted as {02}) in the field GF(2^8) -static const uint8_t Rcon[11] = { - 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 }; - -/* - * Jordan Goulder points out in PR #12 (https://github.com/kokke/tiny-AES-C/pull/12), - * that you can remove most of the elements in the Rcon array, because they are unused. - * - * From Wikipedia's article on the Rijndael key schedule @ https://en.wikipedia.org/wiki/Rijndael_key_schedule#Rcon - * - * "Only the first some of these constants are actually used – up to rcon[10] for AES-128 (as 11 round keys are needed), - * up to rcon[8] for AES-192, up to rcon[7] for AES-256. rcon[0] is not used in AES algorithm." - */ - - -/*****************************************************************************/ -/* Private functions: */ -/*****************************************************************************/ - -static uint8_t getSBoxValue(uint8_t num) -{ - return sbox[num]; -} - -//#define getSBoxValue(num) (pgm_read_byte(&sbox[(num)])) - -static uint8_t getSBoxInvert(uint8_t num) -{ - return rsbox[num]; -} - -//#define getSBoxInvert(num) (pgm_read_byte(&rsbox[(num)])) - -// This function produces Nb(Nr+1) round keys. The round keys are used in each round to decrypt the states. -static void KeyExpansion(uint8_t* RoundKey, const uint8_t* Key) -{ - unsigned i, j, k; - uint8_t tempa[4]; // Used for the column/row operations - - // The first round key is the key itself. - for (i = 0; i < Nk; ++i) - { - RoundKey[(i * 4) + 0] = Key[(i * 4) + 0]; - RoundKey[(i * 4) + 1] = Key[(i * 4) + 1]; - RoundKey[(i * 4) + 2] = Key[(i * 4) + 2]; - RoundKey[(i * 4) + 3] = Key[(i * 4) + 3]; - } - - // All other round keys are found from the previous round keys. - for (i = Nk; i < Nb * (Nr + 1); ++i) - { - { - k = (i - 1) * 4; - tempa[0]=RoundKey[k + 0]; - tempa[1]=RoundKey[k + 1]; - tempa[2]=RoundKey[k + 2]; - tempa[3]=RoundKey[k + 3]; - - } - - if (i % Nk == 0) - { - // This function shifts the 4 bytes in a word to the left once. - // [a0,a1,a2,a3] becomes [a1,a2,a3,a0] - - // Function RotWord() - { - const uint8_t u8tmp = tempa[0]; - tempa[0] = tempa[1]; - tempa[1] = tempa[2]; - tempa[2] = tempa[3]; - tempa[3] = u8tmp; - } - - // SubWord() is a function that takes a four-byte input word and - // applies the S-box to each of the four bytes to produce an output word. - - // Function Subword() - { - tempa[0] = getSBoxValue(tempa[0]); - tempa[1] = getSBoxValue(tempa[1]); - tempa[2] = getSBoxValue(tempa[2]); - tempa[3] = getSBoxValue(tempa[3]); - } - - tempa[0] = tempa[0] ^ Rcon[i/Nk]; - } -#if defined(AES256) && (AES256 == 1) - if (i % Nk == 4) - { - // Function Subword() - { - tempa[0] = getSBoxValue(tempa[0]); - tempa[1] = getSBoxValue(tempa[1]); - tempa[2] = getSBoxValue(tempa[2]); - tempa[3] = getSBoxValue(tempa[3]); - } - } -#endif - j = i * 4; k=(i - Nk) * 4; - RoundKey[j + 0] = RoundKey[k + 0] ^ tempa[0]; - RoundKey[j + 1] = RoundKey[k + 1] ^ tempa[1]; - RoundKey[j + 2] = RoundKey[k + 2] ^ tempa[2]; - RoundKey[j + 3] = RoundKey[k + 3] ^ tempa[3]; - } -} - -void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key) -{ - KeyExpansion(ctx->RoundKey, key); -} -#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1)) -void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv) -{ - KeyExpansion(ctx->RoundKey, key); - memcpy (ctx->Iv, iv, AES_BLOCKLEN); -} -void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv) -{ - memcpy (ctx->Iv, iv, AES_BLOCKLEN); -} -#endif - -// This function adds the round key to state. -// The round key is added to the state by an XOR function. -static void AddRoundKey(uint8_t round, state_t* state, const uint8_t* RoundKey) -{ - uint8_t i,j; - for (i = 0; i < 4; ++i) - { - for (j = 0; j < 4; ++j) - { - (*state)[i][j] ^= RoundKey[(round * Nb * 4) + (i * Nb) + j]; - } - } -} - -// The SubBytes Function Substitutes the values in the -// state matrix with values in an S-box. -static void SubBytes(state_t* state) -{ - uint8_t i, j; - for (i = 0; i < 4; ++i) - { - for (j = 0; j < 4; ++j) - { - (*state)[j][i] = getSBoxValue((*state)[j][i]); - } - } -} - -// The ShiftRows() function shifts the rows in the state to the left. -// Each row is shifted with different offset. -// Offset = Row number. So the first row is not shifted. -static void ShiftRows(state_t* state) -{ - uint8_t temp; - - // Rotate first row 1 columns to left - temp = (*state)[0][1]; - (*state)[0][1] = (*state)[1][1]; - (*state)[1][1] = (*state)[2][1]; - (*state)[2][1] = (*state)[3][1]; - (*state)[3][1] = temp; - - // Rotate second row 2 columns to left - temp = (*state)[0][2]; - (*state)[0][2] = (*state)[2][2]; - (*state)[2][2] = temp; - - temp = (*state)[1][2]; - (*state)[1][2] = (*state)[3][2]; - (*state)[3][2] = temp; - - // Rotate third row 3 columns to left - temp = (*state)[0][3]; - (*state)[0][3] = (*state)[3][3]; - (*state)[3][3] = (*state)[2][3]; - (*state)[2][3] = (*state)[1][3]; - (*state)[1][3] = temp; -} - -static uint8_t xtime(uint8_t x) -{ - return ((x<<1) ^ (((x>>7) & 1) * 0x1b)); -} - -// MixColumns function mixes the columns of the state matrix -static void MixColumns(state_t* state) -{ - uint8_t i; - uint8_t Tmp, Tm, t; - for (i = 0; i < 4; ++i) - { - t = (*state)[i][0]; - Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3] ; - Tm = (*state)[i][0] ^ (*state)[i][1] ; Tm = xtime(Tm); (*state)[i][0] ^= Tm ^ Tmp ; - Tm = (*state)[i][1] ^ (*state)[i][2] ; Tm = xtime(Tm); (*state)[i][1] ^= Tm ^ Tmp ; - Tm = (*state)[i][2] ^ (*state)[i][3] ; Tm = xtime(Tm); (*state)[i][2] ^= Tm ^ Tmp ; - Tm = (*state)[i][3] ^ t ; Tm = xtime(Tm); (*state)[i][3] ^= Tm ^ Tmp ; - } -} - -// Multiply is used to multiply numbers in the field GF(2^8) -// Note: The last call to xtime() is unneeded, but often ends up generating a smaller binary -// The compiler seems to be able to vectorize the operation better this way. -// See https://github.com/kokke/tiny-AES-c/pull/34 -#if MULTIPLY_AS_A_FUNCTION -static uint8_t Multiply(uint8_t x, uint8_t y) -{ - return (((y & 1) * x) ^ - ((y>>1 & 1) * xtime(x)) ^ - ((y>>2 & 1) * xtime(xtime(x))) ^ - ((y>>3 & 1) * xtime(xtime(xtime(x)))) ^ - ((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))); /* this last call to xtime() can be omitted */ - } -#else -#define Multiply(x, y) \ - ( ((y & 1) * x) ^ \ - ((y>>1 & 1) * xtime(x)) ^ \ - ((y>>2 & 1) * xtime(xtime(x))) ^ \ - ((y>>3 & 1) * xtime(xtime(xtime(x)))) ^ \ - ((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))) \ - -#endif - -#if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1) -// MixColumns function mixes the columns of the state matrix. -// The method used to multiply may be difficult to understand for the inexperienced. -// Please use the references to gain more information. -static void InvMixColumns(state_t* state) -{ - int i; - uint8_t a, b, c, d; - for (i = 0; i < 4; ++i) - { - a = (*state)[i][0]; - b = (*state)[i][1]; - c = (*state)[i][2]; - d = (*state)[i][3]; - - (*state)[i][0] = Multiply(a, 0x0e) ^ Multiply(b, 0x0b) ^ Multiply(c, 0x0d) ^ Multiply(d, 0x09); - (*state)[i][1] = Multiply(a, 0x09) ^ Multiply(b, 0x0e) ^ Multiply(c, 0x0b) ^ Multiply(d, 0x0d); - (*state)[i][2] = Multiply(a, 0x0d) ^ Multiply(b, 0x09) ^ Multiply(c, 0x0e) ^ Multiply(d, 0x0b); - (*state)[i][3] = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e); - } -} - - -// The SubBytes Function Substitutes the values in the -// state matrix with values in an S-box. -static void InvSubBytes(state_t* state) -{ - uint8_t i, j; - for (i = 0; i < 4; ++i) - { - for (j = 0; j < 4; ++j) - { - (*state)[j][i] = getSBoxInvert((*state)[j][i]); - } - } -} - -static void InvShiftRows(state_t* state) -{ - uint8_t temp; - - // Rotate first row 1 columns to right - temp = (*state)[3][1]; - (*state)[3][1] = (*state)[2][1]; - (*state)[2][1] = (*state)[1][1]; - (*state)[1][1] = (*state)[0][1]; - (*state)[0][1] = temp; - - // Rotate second row 2 columns to right - temp = (*state)[0][2]; - (*state)[0][2] = (*state)[2][2]; - (*state)[2][2] = temp; - - temp = (*state)[1][2]; - (*state)[1][2] = (*state)[3][2]; - (*state)[3][2] = temp; - - // Rotate third row 3 columns to right - temp = (*state)[0][3]; - (*state)[0][3] = (*state)[1][3]; - (*state)[1][3] = (*state)[2][3]; - (*state)[2][3] = (*state)[3][3]; - (*state)[3][3] = temp; -} -#endif // #if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1) - -// Cipher is the main function that encrypts the PlainText. -static void Cipher(state_t* state, const uint8_t* RoundKey) -{ - uint8_t round = 0; - - // Add the First round key to the state before starting the rounds. - AddRoundKey(0, state, RoundKey); - - // There will be Nr rounds. - // The first Nr-1 rounds are identical. - // These Nr-1 rounds are executed in the loop below. - for (round = 1; round < Nr; ++round) - { - SubBytes(state); - ShiftRows(state); - MixColumns(state); - AddRoundKey(round, state, RoundKey); - } - - // The last round is given below. - // The MixColumns function is not here in the last round. - SubBytes(state); - ShiftRows(state); - AddRoundKey(Nr, state, RoundKey); -} - -#if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1) -static void InvCipher(state_t* state, const uint8_t* RoundKey) -{ - uint8_t round = 0; - - // Add the First round key to the state before starting the rounds. - AddRoundKey(Nr, state, RoundKey); - - // There will be Nr rounds. - // The first Nr-1 rounds are identical. - // These Nr-1 rounds are executed in the loop below. - for (round = (Nr - 1); round > 0; --round) - { - InvShiftRows(state); - InvSubBytes(state); - AddRoundKey(round, state, RoundKey); - InvMixColumns(state); - } - - // The last round is given below. - // The MixColumns function is not here in the last round. - InvShiftRows(state); - InvSubBytes(state); - AddRoundKey(0, state, RoundKey); -} -#endif // #if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1) - -/*****************************************************************************/ -/* Public functions: */ -/*****************************************************************************/ -#if defined(ECB) && (ECB == 1) - - -void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf) -{ - // The next function call encrypts the PlainText with the Key using AES algorithm. - Cipher((state_t*)buf, ctx->RoundKey); -} - -void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf) -{ - // The next function call decrypts the PlainText with the Key using AES algorithm. - InvCipher((state_t*)buf, ctx->RoundKey); -} - - -#endif // #if defined(ECB) && (ECB == 1) - - - - - -#if defined(CBC) && (CBC == 1) - - -static void XorWithIv(uint8_t* buf, const uint8_t* Iv) -{ - uint8_t i; - for (i = 0; i < AES_BLOCKLEN; ++i) // The block in AES is always 128bit no matter the key size - { - buf[i] ^= Iv[i]; - } -} - -void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t* buf, uint32_t length) -{ - uintptr_t i; - uint8_t *Iv = ctx->Iv; - for (i = 0; i < length; i += AES_BLOCKLEN) - { - XorWithIv(buf, Iv); - Cipher((state_t*)buf, ctx->RoundKey); - Iv = buf; - buf += AES_BLOCKLEN; - //printf("Step %d - %d", i/16, i); - } - /* store Iv in ctx for next call */ - memcpy(ctx->Iv, Iv, AES_BLOCKLEN); -} - -void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length) -{ - uintptr_t i; - uint8_t storeNextIv[AES_BLOCKLEN]; - for (i = 0; i < length; i += AES_BLOCKLEN) - { - memcpy(storeNextIv, buf, AES_BLOCKLEN); - InvCipher((state_t*)buf, ctx->RoundKey); - XorWithIv(buf, ctx->Iv); - memcpy(ctx->Iv, storeNextIv, AES_BLOCKLEN); - buf += AES_BLOCKLEN; - } - -} - -#endif // #if defined(CBC) && (CBC == 1) - - - -#if defined(CTR) && (CTR == 1) - -/* Symmetrical operation: same function for encrypting as for decrypting. Note any IV/nonce should never be reused with the same key */ -void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length) -{ - uint8_t buffer[AES_BLOCKLEN]; - - unsigned i; - int bi; - for (i = 0, bi = AES_BLOCKLEN; i < length; ++i, ++bi) - { - if (bi == AES_BLOCKLEN) /* we need to regen xor compliment in buffer */ - { - - memcpy(buffer, ctx->Iv, AES_BLOCKLEN); - Cipher((state_t*)buffer,ctx->RoundKey); - - /* Increment Iv and handle overflow */ - for (bi = (AES_BLOCKLEN - 1); bi >= 0; --bi) - { - /* inc will overflow */ - if (ctx->Iv[bi] == 255) - { - ctx->Iv[bi] = 0; - continue; - } - ctx->Iv[bi] += 1; - break; - } - bi = 0; - } - - buf[i] = (buf[i] ^ buffer[bi]); - } -} - -#endif // #if defined(CTR) && (CTR == 1) diff --git a/FOSSACommsInterpreter/libs/tiny-aes/aes.h b/FOSSACommsInterpreter/libs/tiny-aes/aes.h deleted file mode 100644 index 4804388..0000000 --- a/FOSSACommsInterpreter/libs/tiny-aes/aes.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef _AES_H_ -#define _AES_H_ - -#include -#include - -// #define the macros below to 1/0 to enable/disable the mode of operation. -// -// CBC enables AES encryption in CBC-mode of operation. -// CTR enables encryption in counter-mode. -// ECB enables the basic ECB 16-byte block algorithm. All can be enabled simultaneously. - -// The #ifndef-guard allows it to be configured before #include'ing or at compile time. -#ifndef CBC - #define CBC 1 -#endif - -#ifndef ECB - #define ECB 1 -#endif - -#ifndef CTR - #define CTR 1 -#endif - - -#define AES128 1 -//#define AES192 1 -//#define AES256 1 - -#define AES_BLOCKLEN 16 //Block length in bytes AES is 128b block only - -#if defined(AES256) && (AES256 == 1) - #define AES_KEYLEN 32 - #define AES_keyExpSize 240 -#elif defined(AES192) && (AES192 == 1) - #define AES_KEYLEN 24 - #define AES_keyExpSize 208 -#else - #define AES_KEYLEN 16 // Key length in bytes - #define AES_keyExpSize 176 -#endif - -struct AES_ctx -{ - uint8_t RoundKey[AES_keyExpSize]; -#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1)) - uint8_t Iv[AES_BLOCKLEN]; -#endif -}; - -void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key); -#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1)) -void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv); -void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv); -#endif - -#if defined(ECB) && (ECB == 1) -// buffer size is exactly AES_BLOCKLEN bytes; -// you need only AES_init_ctx as IV is not used in ECB -// NB: ECB is considered insecure for most uses -void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf); -void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf); - -#endif // #if defined(ECB) && (ECB == !) - - -#if defined(CBC) && (CBC == 1) -// buffer size MUST be mutile of AES_BLOCKLEN; -// Suggest https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme -// NOTES: you need to set IV in ctx via AES_init_ctx_iv() or AES_ctx_set_iv() -// no IV should ever be reused with the same key -void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length); -void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length); - -#endif // #if defined(CBC) && (CBC == 1) - - -#if defined(CTR) && (CTR == 1) - -// Same function for encrypting as for decrypting. -// IV is incremented for every block, and used after encryption as XOR-compliment for output -// Suggesting https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme -// NOTES: you need to set IV in ctx with AES_init_ctx_iv() or AES_ctx_set_iv() -// no IV should ever be reused with the same key -void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, uint32_t length); - -#endif // #if defined(CTR) && (CTR == 1) - - -#endif //_AES_H_ diff --git a/FOSSACommsInterpreter/main.cpp b/FOSSACommsInterpreter/main.cpp deleted file mode 100644 index 73236e4..0000000 --- a/FOSSACommsInterpreter/main.cpp +++ /dev/null @@ -1,6 +0,0 @@ - - -int main() -{ - return 0; -} diff --git a/FOSSACommsInterpreter/src/Datagram.cpp b/FOSSACommsInterpreter/src/Datagram.cpp deleted file mode 100644 index dfa6bfc..0000000 --- a/FOSSACommsInterpreter/src/Datagram.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "Datagram.h" - - -Datagram::Datagram(SatVersion satVersion, std::string callsign, std::vector data, bool inbound) { - this->satVersion = satVersion; - this->inbound = inbound; - this->callsign = callsign; - - this->controlByte = data[0]; - this->lengthByte = data[1]; - this->operationId = (OperationID)(this->controlByte & 0b01111111); - - switch (this->operationId) { - case OperationID::HANDSHAKE: - break; - case OperationID::FRAME: - this->ExtractRadiolibStatusCode(data); - this->ExtractFrame(callsign, data); - break; - case OperationID::CONFIG: - this->ExtractRadiolibStatusCode(data); - break; - case OperationID::CARRIER: - this->ExtractRadiolibStatusCode(data); - break; - default: - throw std::runtime_error("Datagram operation id invalid."); - break; - } -} - -int16_t Datagram::GetFrameFunctionID() -{ - return this->frame.GetFunctionID(); -} - -OperationID Datagram::GetOperationID() -{ - return this->operationId; -} - -Frame Datagram::GetFrame() -{ - return this->frame; -} - -std::string Datagram::ToString() -{ - throw "DATAGRAM TOSTRING NOT IMPLEMENTED YET"; - return ""; -} - -void Datagram::ExtractRadiolibStatusCode(std::vector data) { - this->radiolibStatusCode = data[2] | (data[3] << 8); -} - -void Datagram::ExtractFrame(std::string callsign, std::vector data) { - uint8_t frameLength = this->lengthByte - 2; - if (frameLength > 0) { - this->frameExists = true; - std::vector frameData; - frameData.insert(frameData.end(), data.begin() + 4, data.end()); - - this->frame = Frame(this->satVersion, callsign, frameData); - } - else { - this->frameExists = false; - } -} diff --git a/FOSSACommsInterpreter/src/Datagram.h b/FOSSACommsInterpreter/src/Datagram.h deleted file mode 100644 index 9e11073..0000000 --- a/FOSSACommsInterpreter/src/Datagram.h +++ /dev/null @@ -1,61 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef DATAGRAM_H -#define DATAGRAM_H - -#include "SatVersion.h" -#include "OperationID.h" -#include "Frame.h" - -#include -#include - -class Datagram { -public: - Datagram(SatVersion satVersion, std::string callsign, std::vector data, bool inbound); - int16_t GetFrameFunctionID(); - OperationID GetOperationID(); - Frame GetFrame(); - std::vector Serialize(); - std::string ToString(); -private: - void ExtractRadiolibStatusCode(std::vector data); - void ExtractFrame(std::string callsign, std::vector data); -private: - Frame frame; - bool frameExists = false; - - uint8_t controlByte; - uint8_t lengthByte; - OperationID operationId; - - int16_t radiolibStatusCode; - bool inbound; - - std::string callsign; - SatVersion satVersion; -}; - -#endif //DATAGRAM_H diff --git a/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT1B/FOSSASAT1B_DatagramEncoder.cpp b/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT1B/FOSSASAT1B_DatagramEncoder.cpp deleted file mode 100644 index 11e4650..0000000 --- a/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT1B/FOSSASAT1B_DatagramEncoder.cpp +++ /dev/null @@ -1,966 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "FOSSASAT1B_DatagramEncoder.h" - -#include - - -std::string FOSSASAT1B::DatagramEncoder::callsign; -std::string FOSSASAT1B::DatagramEncoder::password; -std::vector FOSSASAT1B::DatagramEncoder::key; - -Datagram FOSSASAT1B::DatagramEncoder::Encode(OperationID operationId, int16_t functionId, uint8_t optionalDataLength, char* optionalData) { - - const char *callsign = FOSSASAT1B::DatagramEncoder::callsign.c_str(); - const char *password = FOSSASAT1B::DatagramEncoder::password.c_str(); - uint8_t* key = FOSSASAT1B::DatagramEncoder::key.data(); - char directionBit = FCPI_DIR_TO_GROUND_STATION; - bool encrypt = functionId >= PRIVATE_OFFSET; - - uint8_t frameLength = 0; - std::vector frameData; - char controlByte = directionBit | operationId; - - if (encrypt) { - frameLength = FCP_Get_Frame_Length((char *) callsign, optionalDataLength, password); - } - else { - frameLength = FCP_Get_Frame_Length((char *) callsign, optionalDataLength); - } - - { - uint8_t *tempBuffer = new uint8_t[frameLength]; - if (encrypt) { - FCP_Encode(tempBuffer, (char *) callsign, functionId, optionalDataLength, (uint8_t *)optionalData, key, password); - } - else { - FCP_Encode(tempBuffer, (char *) callsign, functionId, optionalDataLength); - } - for (uint8_t i = 0; i < frameLength; i++) { - frameData.push_back(tempBuffer[i]); - } - delete[] tempBuffer; - } - - std::vector datagramData; - datagramData.push_back(controlByte); - datagramData.push_back(frameLength); - datagramData.insert(datagramData.end(), frameData.begin(), frameData.end()); - - return Datagram(SatVersion::V_FOSSASAT1B, FOSSASAT1B::DatagramEncoder::callsign, datagramData, false); -} - - - -Datagram FOSSASAT1B::DatagramEncoder::Ping() -{ - return FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_PING, 0, nullptr); -} - -Datagram FOSSASAT1B::DatagramEncoder::Retransmit(uint32_t senderId, char *message) -{ - int messageLen = strlen(message) + 1; - int optDataLen = messageLen + 4; - - if (optDataLen > 32) { - throw "transmit message too long (max 32)"; - } - - char *optData = new char[optDataLen]; - optData[0] = senderId; - optData[1] = senderId >> 8; - optData[2] = senderId >> 16; - optData[4] = senderId >> 24; - - strcpy(&(optData[5]), message); - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_RETRANSMIT, optDataLen, optData); - - delete[] optData; - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Retransmit_Custom(uint8_t bandwidth, - uint8_t spreadingFactor, - uint8_t codingRate, - uint16_t preambleSymbolLength, - uint8_t crcEnabled, - int8_t outputPower, - uint32_t senderId, - char *message) -{ - int messageLen = strlen(message) + 1; - int optDataLen = 11 + messageLen; - - if (optDataLen > 43) { - throw "transmit message too long (max 43)"; - } - - char *optData = new char[optDataLen]; - optData[0] = bandwidth; - optData[1] = spreadingFactor; - optData[2] = codingRate; - optData[3] = preambleSymbolLength; - optData[4] = preambleSymbolLength >> 8; - optData[5] = crcEnabled; - optData[6] = outputPower; - optData[7] = outputPower >> 8; - optData[8] = outputPower >> 16; - optData[9] = outputPower >> 24; - - strcpy(&(optData[10]), message); - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_RETRANSMIT_CUSTOM, optDataLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Transmit_System_Info() -{ - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_TRANSMIT_SYSTEM_INFO, 0, nullptr); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Get_Packet_Info() -{ - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_PACKET_INFO, 0, nullptr); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Get_Statistics(char flags) -{ - char optData[1]; // copy the parameter into this locally scoped variable for safety. - optData[0] = flags; - return FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_STATISTICS, 1, optData); -} - -Datagram FOSSASAT1B::DatagramEncoder::Deploy() -{ - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_DEPLOY, 0, nullptr); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Restart() -{ - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_RESTART, 0, nullptr); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Wipe_EEPROM() -{ - return FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_WIPE_EEPROM, 0, nullptr); -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_Transmit_Enable(char transmitEnabled) -{ - char optData[1]; - optData[0] = transmitEnabled; - - return FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_TRANSMIT_ENABLE, 1, optData); -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_Callsign(char *callsign) -{ - int callsignLen = strlen(callsign) + 1; - - if (callsignLen > 32) { - throw "callsign cannot be more than 32 characters"; - } - - char *optData = new char[callsignLen]; - - strcpy(&(optData[10]), callsign); - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_CALLSIGN, 0, nullptr); - - delete[] optData; - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_SF_Mode(uint8_t spreadingFactor) -{ - char optData[1]; - optData[0] = spreadingFactor; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_SF_MODE, 1, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_MPPT_Mode(uint8_t temperatureSwitchEnabled, uint8_t keepAliveEnabled) -{ - char optData[2]; - optData[0] = temperatureSwitchEnabled; - optData[1] = keepAliveEnabled; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_MPPT_MODE, 2, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_Low_Power_Mode_Enable(uint8_t lowPowerModeEnabled) -{ - char optData[1]; - optData[0] = lowPowerModeEnabled; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_LOW_POWER_ENABLE, 1, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_Receive_Windows(uint8_t fskReceiveWindowLength, - uint8_t loraReceiveWindowLength) -{ - char optData[2]; - optData[0] = fskReceiveWindowLength; - optData[1] = loraReceiveWindowLength; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_RECEIVE_WINDOWS, 2, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Record_Solar_Cells(char numSamples, uint16_t samplingPeriod) -{ - char optData[3]; - optData[0] = numSamples; - optData[1] = samplingPeriod; - optData[2] = samplingPeriod >> 8; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_RECORD_SOLAR_CELLS, 3, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Camera_Capture(char pictureSlot, - char lightMode, - char pictureSize, - char brightness, - char saturation, - char specialFilter, - char contrast) -{ - char optData[4]; - optData[0] = pictureSlot; - optData[1] = (pictureSize << 4) | lightMode; - optData[2] = (saturation << 4) | brightness; - optData[3] = (contrast << 4) | specialFilter; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_CAMERA_CAPTURE, 4, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_Power_Limits(int16_t deploymentVoltageLimit, - int16_t heaterVoltageLimit, - int16_t cwBeepVoltageLimit, - int16_t lowPowerVoltageLimit, - float heaterTemperatureLimit, - float mpptSwitchtemperatureLimit, - uint8_t heaterDutyCycle) -{ - char optData[17]; - optData[0] = deploymentVoltageLimit; - optData[1] = deploymentVoltageLimit >> 8; - optData[2] = heaterVoltageLimit; - optData[3] = heaterVoltageLimit >> 8; - optData[4] = cwBeepVoltageLimit; - optData[5] = cwBeepVoltageLimit >> 8; - optData[6] = lowPowerVoltageLimit; - optData[7] = lowPowerVoltageLimit >> 8; - char *heaterTemperatureArray = (char *) (&heaterTemperatureLimit); - optData[8] = heaterTemperatureArray[0]; - optData[9] = heaterTemperatureArray[1]; - optData[10] = heaterTemperatureArray[2]; - optData[11] = heaterTemperatureArray[3]; - char *mpptSwitchTemperatureArray = (char *) (&mpptSwitchtemperatureLimit); - optData[12] = mpptSwitchTemperatureArray[0]; - optData[13] = mpptSwitchTemperatureArray[1]; - optData[14] = mpptSwitchTemperatureArray[2]; - optData[15] = mpptSwitchTemperatureArray[3]; - optData[16] = heaterDutyCycle; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_POWER_LIMITS, 17, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_RTC(uint8_t year, - uint8_t month, - uint8_t day, - uint8_t dayOfWeek, - uint8_t hours, - uint8_t minutes, - uint8_t seconds) -{ - char optData[7]; - optData[0] = year; - optData[1] = month; - optData[2] = day; - optData[3] = dayOfWeek; - optData[4] = hours; - optData[5] = minutes; - optData[6] = seconds; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_RTC, 7, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Record_IMU(uint16_t sampleNumber, uint16_t samplingPeriod, uint8_t flags) -{ - char optData[5]; - optData[0] = sampleNumber; - optData[1] = sampleNumber >> 8; - optData[2] = samplingPeriod; - optData[3] = samplingPeriod >> 8; - optData[4] = flags; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_RECORD_IMU, 5, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Run_Manual_ACS(int8_t xHighBridgeMag, - int8_t xLowBridgeMag, - int8_t yHighBridgeMag, - int8_t yLowBrightMag, - int8_t zHBridgeHighMag, - int8_t zBridgeLowMag, - uint32_t xPulseLength, - uint32_t yPulseLength, - uint32_t zPulseLength, - uint32_t maneuverDuration, - uint8_t hbridgefaultFlags) -{ - char optData[23]; - optData[0] = xHighBridgeMag; - optData[1] = xLowBridgeMag; - optData[2] = yHighBridgeMag; - optData[3] = yLowBrightMag; - optData[4] = zHBridgeHighMag; - optData[5] = zBridgeLowMag; - optData[6] = xPulseLength; - optData[7] = xPulseLength >> 8; - optData[8] = xPulseLength >> 16; - optData[9] = xPulseLength >> 24; - optData[10] = yPulseLength; - optData[11] = yPulseLength >> 8; - optData[12] = yPulseLength >> 16; - optData[13] = yPulseLength >> 24; - optData[14] = zPulseLength; - optData[15] = zPulseLength >> 8; - optData[16] = zPulseLength >> 16; - optData[17] = zPulseLength >> 24; - optData[18] = maneuverDuration; - optData[19] = maneuverDuration >> 8; - optData[20] = maneuverDuration >> 16; - optData[21] = maneuverDuration >> 24; - optData[22] = hbridgefaultFlags; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_RUN_MANUAL_ACS, 23, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Log_GPS(uint32_t gpsLoggingDuration, uint32_t gpsLoggingStartOffset) -{ - char optData[8]; - optData[0] = gpsLoggingDuration; - optData[1] = gpsLoggingDuration >> 8; - optData[2] = gpsLoggingDuration >> 16; - optData[3] = gpsLoggingDuration >> 24; - optData[4] = gpsLoggingStartOffset; - optData[5] = gpsLoggingStartOffset >> 8; - optData[6] = gpsLoggingStartOffset >> 16; - optData[7] = gpsLoggingStartOffset >> 24; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_LOG_GPS, 8, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Get_GPS_Log(uint8_t newestEntriesFirst, - uint16_t gpsLogOffsetAsNMEASeq, - uint16_t NMEASentencesToDownlink) -{ - char optData[5]; - optData[0] = newestEntriesFirst; - optData[1] = gpsLogOffsetAsNMEASeq; - optData[2] = gpsLogOffsetAsNMEASeq >> 8; - optData[3] = NMEASentencesToDownlink; - optData[4] = NMEASentencesToDownlink >> 8; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_GPS_LOG, 5, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Get_Flash_Contents(uint32_t flashAddress, uint8_t numBytes) -{ - char optData[5]; - optData[0] = flashAddress; - optData[1] = flashAddress >> 8; - optData[2] = flashAddress >> 16; - optData[3] = flashAddress >> 24; - optData[4] = numBytes; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_FLASH_CONTENTS, 5, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Get_Picture_Length(uint8_t pictureSlot) -{ - char optData[1]; - optData[0] = pictureSlot; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_PICTURE_LENGTH, 1, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Get_Picture_Burst(char pictureSlot, uint16_t pictureId, char fullOrScandata) -{ - char optData[4]; - optData[0] = pictureSlot; - optData[1] = pictureId; - optData[2] = pictureId >> 8; - optData[3] = fullOrScandata; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_FULL_SYSTEM_INFO, 4, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Route(char *fcpFrame) -{ - int messageLen = strlen(fcpFrame) + 1; - - char *optData = new char[messageLen]; - strcpy(optData, fcpFrame); - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_ROUTE, messageLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_Flash_Contents(uint32_t flashAddress, char *data) -{ - int dataLen = strlen(data); // ignore the null terminator + 1; - int messageLen = dataLen + 4; - - char *optData = new char[messageLen]; - optData[0] = flashAddress; - optData[1] = flashAddress >> 8; - optData[2] = flashAddress >> 16; - - memcpy(&(optData[3]), data, dataLen); // copy to opt data without the null terminator. - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_FLASH_CONTENTS, messageLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_TLE(char *tle) -{ - int optDataLen = strlen(tle); - char *optData = new char[optDataLen]; - - memcpy(optData, tle, optDataLen); // no line endings. - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_TLE, optDataLen, optData); - - delete[] optData; - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Get_GPS_Log_State() -{ - int optDataLen = 0; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_GPS_LOG_STATE, optDataLen, nullptr); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Run_GPS_Command(char *skyTraqBinaryProtocolMessage) -{ - int optDataLen = strlen(skyTraqBinaryProtocolMessage); // without terminator. - - char *optData = new char[optDataLen]; - memcpy(optData, skyTraqBinaryProtocolMessage, optDataLen); - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_RUN_GPS_COMMAND, optDataLen, optData); - - delete optData; - - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_Sleep_Intervals(std::vector sleepIntervals) -{ - int numIntervals = sleepIntervals.size(); - int optDataLen = numIntervals * sizeof(SleepInterval); - - char *optData = new char[optDataLen]; - - int optDataIndex = 0; - for (int i = 0; i < numIntervals; i++) { - SleepInterval interval = sleepIntervals[i]; - - memcpy(&(optData[optDataIndex]), &interval, sizeof(SleepInterval)); - - optDataIndex += sizeof(SleepInterval); - } - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_SLEEP_INTERVALS, optDataLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Abort() -{ - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_ABORT, 0, nullptr); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Maneuver(uint8_t controlFlags, uint32_t maneuverLength) -{ - char optData[5]; - optData[0] = controlFlags; - optData[1] = maneuverLength; - optData[2] = maneuverLength >> 8; - optData[3] = maneuverLength >> 16; - optData[4] = maneuverLength >> 24; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_MANEUVER, 5, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_ADCS_Parameters(float maximumPulseIntensity, - float maximumPulseLength, - float detumblingAngularVelocity, - float minimumIntertialMoment, - float pulseAmplitude, - float calculationTolerance, - float activeControlEulerAngleChangeTolerance, - float activeControlAngularVelocityChangeTolerance, - float eclipseThreshold, - float rotationMatrixWeightRatio, - float rotationVerificationTriggerLevel, - float kalmanFilterDisturbanceCovariance, - float kalmanFilterNoiseCovariance, - uint32_t adcsUpdateTimeStepPeriod, - uint32_t hbridgeTimerUpdatePeriod, - int8_t hbridgeValueHighOutput, - int8_t hbridgeValueLowOutput, - uint8_t numControllers) -{ - char optData[63]; - - char *maximumPulseIntensityArray = (char *) (&maximumPulseIntensity); - char *maximumPulseLengthArray = (char *) (&maximumPulseLength); - char *detumblingAngularVelocityArray = (char *) (&detumblingAngularVelocity); - char *minimumIntertialMomentArray = (char *) (&minimumIntertialMoment); - char *pulseAmplitudeArray = (char *) (&pulseAmplitude); - char *calculationToleranceArray = (char *) (&calculationTolerance); - char *activeControlEulerAngleChangeToleranceArray = (char *) (&activeControlEulerAngleChangeTolerance); - char *activeControlAngularVelocityChangeToleranceArray = (char *) (&activeControlAngularVelocityChangeTolerance); - char *eclipseThresholdArray = (char *) (&eclipseThreshold); - char *rotationMatrixWeightRatioArray = (char *) (&rotationMatrixWeightRatio); - char *rotationVerificationTriggerLevelArray = (char *) (&rotationVerificationTriggerLevel); - char *kalmanFilterDisturbanceCovarianceArray = (char *) (&kalmanFilterDisturbanceCovariance); - char *kalmanFilterNoiseCovarianceArray = (char *) (&kalmanFilterNoiseCovariance); - - optData[0] = maximumPulseIntensityArray[0]; - optData[1] = maximumPulseIntensityArray[1]; - optData[2] = maximumPulseIntensityArray[2]; - optData[3] = maximumPulseIntensityArray[3]; - - optData[4] = maximumPulseLengthArray[0]; - optData[5] = maximumPulseLengthArray[1]; - optData[6] = maximumPulseLengthArray[2]; - optData[7] = maximumPulseLengthArray[3]; - - optData[8] = detumblingAngularVelocityArray[0]; - optData[9] = detumblingAngularVelocityArray[1]; - optData[10] = detumblingAngularVelocityArray[2]; - optData[11] = detumblingAngularVelocityArray[3]; - - optData[12] = minimumIntertialMomentArray[0]; - optData[13] = minimumIntertialMomentArray[1]; - optData[14] = minimumIntertialMomentArray[2]; - optData[15] = minimumIntertialMomentArray[3]; - - optData[16] = pulseAmplitudeArray[0]; - optData[17] = pulseAmplitudeArray[1]; - optData[18] = pulseAmplitudeArray[2]; - optData[19] = pulseAmplitudeArray[3]; - - optData[20] = calculationToleranceArray[0]; - optData[21] = calculationToleranceArray[1]; - optData[22] = calculationToleranceArray[2]; - optData[23] = calculationToleranceArray[3]; - - optData[24] = activeControlEulerAngleChangeToleranceArray[0]; - optData[25] = activeControlEulerAngleChangeToleranceArray[1]; - optData[26] = activeControlEulerAngleChangeToleranceArray[2]; - optData[27] = activeControlEulerAngleChangeToleranceArray[3]; - - optData[28] = activeControlAngularVelocityChangeToleranceArray[0]; - optData[29] = activeControlAngularVelocityChangeToleranceArray[1]; - optData[30] = activeControlAngularVelocityChangeToleranceArray[2]; - optData[31] = activeControlAngularVelocityChangeToleranceArray[3]; - - optData[32] = eclipseThresholdArray[0]; - optData[33] = eclipseThresholdArray[1]; - optData[34] = eclipseThresholdArray[2]; - optData[35] = eclipseThresholdArray[3]; - - optData[36] = rotationMatrixWeightRatioArray[0]; - optData[37] = rotationMatrixWeightRatioArray[1]; - optData[38] = rotationMatrixWeightRatioArray[2]; - optData[39] = rotationMatrixWeightRatioArray[3]; - - optData[40] = rotationVerificationTriggerLevelArray[0]; - optData[41] = rotationVerificationTriggerLevelArray[1]; - optData[42] = rotationVerificationTriggerLevelArray[2]; - optData[43] = rotationVerificationTriggerLevelArray[3]; - - optData[44] = kalmanFilterDisturbanceCovarianceArray[0]; - optData[45] = kalmanFilterDisturbanceCovarianceArray[1]; - optData[46] = kalmanFilterDisturbanceCovarianceArray[2]; - optData[47] = kalmanFilterDisturbanceCovarianceArray[3]; - - optData[48] = kalmanFilterNoiseCovarianceArray[0]; - optData[49] = kalmanFilterNoiseCovarianceArray[1]; - optData[50] = kalmanFilterNoiseCovarianceArray[2]; - optData[51] = kalmanFilterNoiseCovarianceArray[3]; - - optData[52] = adcsUpdateTimeStepPeriod; - optData[53] = adcsUpdateTimeStepPeriod >> 8; - optData[54] = adcsUpdateTimeStepPeriod >> 16; - optData[55] = adcsUpdateTimeStepPeriod >> 24; - - optData[56] = hbridgeTimerUpdatePeriod; - optData[57] = hbridgeTimerUpdatePeriod >> 8; - optData[58] = hbridgeTimerUpdatePeriod >> 16; - optData[59] = hbridgeTimerUpdatePeriod >> 24; - - optData[60] = hbridgeValueHighOutput; - optData[61] = hbridgeValueLowOutput; - optData[62] = numControllers; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_ADCS_PARAMETERS, 63, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Erase_Flash(uint32_t sectorAddress) -{ - char optData[4]; - optData[0] = sectorAddress; - optData[1] = sectorAddress >> 8; - optData[2] = sectorAddress >> 16; - optData[3] = sectorAddress >> 24; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_ERASE_FLASH, 4, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_ADCS_Controller(char controllerId, float controllerMatrix[3][6]) -{ - char optData[77]; - optData[0] = controllerId; - - int i = 1; - for (int x = 0; x < 3; x++) { - for (int y = 0; y < 6; y++) { - /// @todo check for endianess here. - float value = controllerMatrix[x][y]; - char *valueAsArray = (char *) &value; - - optData[i] = valueAsArray[0]; - optData[i + 1] = valueAsArray[1]; - optData[i + 2] = valueAsArray[2]; - optData[i + 3] = valueAsArray[3]; - - i += 4; - } - } - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_ADCS_CONTROLLER, 77, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_ADCS_Ephemerides(uint16_t chunkId, - std::vector ephemeridesDataQueue) -{ - size_t optDataLen = ephemeridesDataQueue.size() * sizeof(Ephemerides); - optDataLen += sizeof(uint16_t); - - if (optDataLen > 192) { - throw "too much data in ephemerides stack (max is 192 bytes)"; - } - - std::vector optData; - optData.push_back(chunkId); - optData.push_back(chunkId >> 8); - - for (int i = 0; i < ephemeridesDataQueue.size(); i++) { - Ephemerides ephemeridesStruct = ephemeridesDataQueue[i]; - - // convert the struct to a char* array - char *ephemeridesData = (char *) &ephemeridesStruct; - - // for each byte, push it to the optDataVector. - for (int k = 0; k < sizeof(Ephemerides); k++) { - optData.push_back(ephemeridesData[k]); - } - } - - // get the vector as char array. - char *data = optData.data(); - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_ADCS_EPHEMERIDES, optDataLen, data); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Detumble(uint8_t flags, uint32_t length) -{ - char optData[5]; - optData[0] = flags; - optData[1] = length; - optData[2] = length >> 8; - optData[3] = length >> 16; - optData[4] = length >> 24; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_DETUMBLE, 5, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_IMU_Offset(float xAxisGyroOffset, - float yAxisGyroOffset, - float zAxisGyroOffset, - float xAxisAcceleOffset, - float yAxisAcceleOffset, - float zAxisAcceleOffset, - float xAxisMagneticOffset, - float yAxisMagneticOffset, - float zAxisMagneticOffset) -{ - char *xAxisGyroOffsetArray = (char *) (&xAxisGyroOffset); - char *yAxisGyroOffsetArray = (char *) (&yAxisGyroOffset); - char *zAxisGyroOffsetArray = (char *) (&zAxisGyroOffset); - char *xAxisAcceleOffsetArray = (char *) (&xAxisAcceleOffset); - char *yAxisAcceleOffsetArray = (char *) (&yAxisAcceleOffset); - char *zAxisAcceleOffsetArray = (char *) (&zAxisAcceleOffset); - char *xAxisMagneticOffsetArray = (char *) (&xAxisMagneticOffset); - char *yAxisMagneticOffsetArray = (char *) (&yAxisMagneticOffset); - char *zAxisMagneticOffsetArray = (char *) (&zAxisMagneticOffset); - - char optData[36]; - optData[0] = xAxisGyroOffsetArray[0]; - optData[1] = xAxisGyroOffsetArray[1]; - optData[2] = xAxisGyroOffsetArray[2]; - optData[3] = xAxisGyroOffsetArray[3]; - - optData[4] = yAxisGyroOffsetArray[0]; - optData[5] = yAxisGyroOffsetArray[1]; - optData[6] = yAxisGyroOffsetArray[2]; - optData[7] = yAxisGyroOffsetArray[3]; - - optData[8] = zAxisGyroOffsetArray[0]; - optData[9] = zAxisGyroOffsetArray[1]; - optData[10] = zAxisGyroOffsetArray[2]; - optData[11] = zAxisGyroOffsetArray[3]; - - optData[12] = xAxisAcceleOffsetArray[0]; - optData[13] = xAxisAcceleOffsetArray[1]; - optData[14] = xAxisAcceleOffsetArray[2]; - optData[15] = xAxisAcceleOffsetArray[3]; - - optData[16] = yAxisAcceleOffsetArray[0]; - optData[17] = yAxisAcceleOffsetArray[1]; - optData[18] = yAxisAcceleOffsetArray[2]; - optData[19] = yAxisAcceleOffsetArray[3]; - - optData[20] = zAxisAcceleOffsetArray[0]; - optData[21] = zAxisAcceleOffsetArray[1]; - optData[22] = zAxisAcceleOffsetArray[2]; - optData[23] = zAxisAcceleOffsetArray[3]; - - optData[24] = xAxisMagneticOffsetArray[0]; - optData[25] = xAxisMagneticOffsetArray[1]; - optData[26] = xAxisMagneticOffsetArray[2]; - optData[27] = xAxisMagneticOffsetArray[3]; - - optData[28] = yAxisMagneticOffsetArray[0]; - optData[29] = yAxisMagneticOffsetArray[1]; - optData[30] = yAxisMagneticOffsetArray[2]; - optData[31] = yAxisMagneticOffsetArray[3]; - - optData[32] = zAxisMagneticOffsetArray[0]; - optData[33] = zAxisMagneticOffsetArray[1]; - optData[34] = zAxisMagneticOffsetArray[2]; - optData[35] = zAxisMagneticOffsetArray[3]; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_IMU_OFFSET, 36, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Set_IMU_Calibration(float transformationMatrix[9], float biasVector[3]) -{ - char *matrixA = (char *) (&transformationMatrix[0]); - char *matrixB = (char *) (&transformationMatrix[1]); - char *matrixC = (char *) (&transformationMatrix[2]); - char *matrixD = (char *) (&transformationMatrix[3]); - char *matrixE = (char *) (&transformationMatrix[4]); - char *matrixF = (char *) (&transformationMatrix[5]); - char *matrixG = (char *) (&transformationMatrix[6]); - char *matrixH = (char *) (&transformationMatrix[7]); - char *matrixI = (char *) (&transformationMatrix[8]); - - char *vectorA = (char *) (&biasVector[0]); - char *vectorB = (char *) (&biasVector[1]); - char *vectorC = (char *) (&biasVector[2]); - - char optData[47]; - optData[0] = matrixA[0]; - optData[1] = matrixA[1]; - optData[2] = matrixA[2]; - optData[3] = matrixA[3]; - - optData[4] = matrixB[0]; - optData[5] = matrixB[1]; - optData[6] = matrixB[2]; - optData[7] = matrixB[3]; - - optData[8] = matrixC[0]; - optData[9] = matrixC[1]; - optData[10] = matrixC[2]; - optData[11] = matrixC[3]; - - optData[12] = matrixD[0]; - optData[13] = matrixD[1]; - optData[14] = matrixD[2]; - optData[15] = matrixD[3]; - - optData[16] = matrixE[0]; - optData[17] = matrixE[1]; - optData[18] = matrixE[2]; - optData[19] = matrixE[3]; - - optData[20] = matrixF[0]; - optData[21] = matrixF[1]; - optData[22] = matrixF[2]; - optData[23] = matrixF[3]; - - optData[24] = matrixG[0]; - optData[25] = matrixG[1]; - optData[26] = matrixG[2]; - optData[27] = matrixG[3]; - - optData[28] = matrixH[0]; - optData[29] = matrixH[1]; - optData[30] = matrixH[2]; - optData[31] = matrixH[3]; - - optData[32] = matrixI[0]; - optData[33] = matrixI[1]; - optData[34] = matrixI[2]; - optData[35] = matrixI[3]; - - - optData[36] = vectorA[0]; - optData[37] = vectorA[1]; - optData[38] = vectorA[2]; - optData[39] = vectorA[3]; - - optData[40] = vectorB[0]; - optData[41] = vectorB[1]; - optData[42] = vectorB[2]; - optData[43] = vectorB[3]; - - optData[44] = vectorC[0]; - optData[45] = vectorC[1]; - optData[46] = vectorC[2]; - optData[47] = vectorC[3]; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_IMU_CALIBRATION, 47, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Get_Full_System_Info() -{ - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_FULL_SYSTEM_INFO, 0, nullptr); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Store_And_Forward_Add(uint32_t messageId, char *message) -{ - int messageLen = strlen(message) + 1; - int optDataLen = 4 + messageLen; - - if (optDataLen > 32) { - throw "store and forward message too long (max 32)"; - } - - char *optData = new char[optDataLen]; - optData[0] = messageId; - optData[1] = messageId >> 8; - optData[2] = messageId >> 16; - optData[3] = messageId >> 24; - - strcpy(&(optData[4]), message); - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_STORE_AND_FORWARD_ADD, optDataLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Store_And_Forward_Request(uint32_t messageId) -{ - char optData[4]; - optData[0] = messageId; - optData[1] = messageId >> 8; - optData[2] = messageId >> 16; - optData[3] = messageId >> 24; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_STORE_AND_FORWARD_REQUEST, 4, optData); - return msg; -} - -Datagram FOSSASAT1B::DatagramEncoder::Request_Public_Picture(uint8_t pictureSlot, uint16_t picturePacketId) -{ - if (pictureSlot < 80 || pictureSlot > 100) { - throw "only picture slots 80 <= id <= 100 are allowed"; - } - - char optData[3]; - optData[0] = pictureSlot; - optData[1] = picturePacketId; - optData[2] = picturePacketId >> 8; - - Datagram msg = FOSSASAT1B::DatagramEncoder::Encode(OperationID::FRAME, CMD_REQUEST_PUBLIC_PICTURE, 3, optData); - return msg; -} - - - diff --git a/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT1B/FOSSASAT1B_DatagramEncoder.h b/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT1B/FOSSASAT1B_DatagramEncoder.h deleted file mode 100644 index 1321cf1..0000000 --- a/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT1B/FOSSASAT1B_DatagramEncoder.h +++ /dev/null @@ -1,193 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSASAT1B_DATAGRAMDECODER_H -#define FOSSASAT1B_DATAGRAMDECODER_H - -#include "../../Frame.h" - -#include -#include -#include - -namespace FOSSASAT1B -{ - -class DatagramEncoder { -private: - static std::string callsign; - static std::string password; - static std::vector key; - - static Datagram Encode(OperationID operationId, int16_t functionId, uint8_t optionalDataLength, char* optionalData); -public: - static void SetCallsign(std::string callsign); - static void SetPassword(std::string password); - static void SetKey(std::vector key); - - /**-------------------------------------------------------- - * - * @name Public unencrypted uplink commands. - * - * @{ - * - --------------------------------------------------------*/ - static Datagram Ping(); - static Datagram Retransmit(uint32_t senderId, char *message); - static Datagram Retransmit_Custom(uint8_t bandwidth, - uint8_t spreadingFactor, - uint8_t codingRate, - uint16_t preambleSymbolLength, - uint8_t crcEnabled, - int8_t outputPower, - uint32_t senderId, - char *message); - static Datagram Transmit_System_Info(); - static Datagram Get_Packet_Info(); - static Datagram Get_Statistics(char flags); - static Datagram Get_Full_System_Info(); - static Datagram Store_And_Forward_Add(uint32_t messageId, char *message); - static Datagram Store_And_Forward_Request(uint32_t messageId); - static Datagram Request_Public_Picture(uint8_t pictureSlot, - uint16_t picturePacketId); // only 80-100 slot numbers. - - /**-------------------------------------------------------- - * - * @} - * - --------------------------------------------------------*/ - - - - - /**-------------------------------------------------------- - * - * @name Private encrypted uplink commands. - * - * @{ - * - --------------------------------------------------------*/ - static Datagram Deploy(); - static Datagram Restart(); - static Datagram Wipe_EEPROM(); - static Datagram Set_Transmit_Enable(char transmitEnabled); - static Datagram Set_Callsign(char *callsign); - static Datagram Set_SF_Mode(uint8_t spreadingFactor); - static Datagram Set_MPPT_Mode(uint8_t temperatureSwitchEnabled, uint8_t keepAliveEnabled); - static Datagram Set_Low_Power_Mode_Enable(uint8_t lowPowerModeEnabled); - static Datagram Set_Receive_Windows(uint8_t fskReceiveWindowLength, uint8_t loraReceiveWindowLength); - static Datagram Record_Solar_Cells(char numSamples, uint16_t samplingPeriod); - static Datagram Camera_Capture(char pictureSlot, - char lightMode, - char pictureSize, - char brightness, - char saturation, - char specialFilter, - char contrast); - static Datagram Set_Power_Limits(int16_t deploymentVoltageLimit, - int16_t heaterVoltageLimit, - int16_t cwBeepVoltageLimit, - int16_t lowPowerVoltageLimit, - float heaterTemperatureLimit, - float mpptSwitchtemperatureLimit, - uint8_t heaterDutyCycle); - static Datagram Set_RTC(uint8_t year, - uint8_t month, - uint8_t day, - uint8_t dayOfWeek, - uint8_t hours, - uint8_t minutes, - uint8_t seconds); // year is offset from 2000. - static Datagram Record_IMU(uint16_t sampleNumber, uint16_t samplingPeriod, uint8_t flags); - static Datagram Run_Manual_ACS(int8_t xHighBridgeMag, - int8_t xLowBridgeMag, - int8_t yHighBridgeMag, - int8_t yLowBrightMag, - int8_t zHBridgeHighMag, - int8_t zBridgeLowMag, - uint32_t xPulseLength, - uint32_t yPulseLength, - uint32_t zPulseLength, - uint32_t maneuverDuration, - uint8_t hbridgefaultFlags); - static Datagram Log_GPS(uint32_t gpsLoggingDuration, uint32_t gpsLoggingStartOffset); - static Datagram Get_GPS_Log(uint8_t newestEntriesFirst, - uint16_t gpsLogOffsetAsNMEASeq, - uint16_t NMEASentencesToDownlink); // NMEA sentences set to 0 means entire log. - static Datagram Get_Flash_Contents(uint32_t flashAddress, uint8_t numBytes); - static Datagram Get_Picture_Length(uint8_t pictureSlot); - static Datagram Get_Picture_Burst(char pictureSlot, uint16_t pictureId, char fullOrScandata); - static Datagram Route(char *fcpFrame); - static Datagram Set_Flash_Contents(uint32_t flashAddress, char *data); // data MUST include a null terminator - static Datagram Set_TLE(char *tle); // MUST include a null terminator. - static Datagram Get_GPS_Log_State(); - static Datagram Run_GPS_Command(char *skyTraqBinaryProtocolMessage); - static Datagram Set_Sleep_Intervals(std::vector sleepIntervals); - static Datagram Abort(); - static Datagram Maneuver(uint8_t controlFlags, uint32_t maneuverLength); - static Datagram Set_ADCS_Parameters(float maximumPulseIntensity, - float maximumPulseLength, - float detumblingAngularVelocity, - float minimumIntertialMoment, - float pulseAmplitude, - float calculationTolerance, - float activeControlEulerAngleChangeTolerance, - float activeControlAngularVelocityChangeTolerance, - float eclipseThreshold, - float rotationMatrixWeightRatio, - float rotationVerificationTriggerLevel, - float kalmanFilterDisturbanceCovariance, - float kalmanFilterNoiseCovariance, - uint32_t adcsUpdateTimeStepPeriod, - uint32_t hbridgeTimerUpdatePeriod, - int8_t hbridgeValueHighOutput, - int8_t hbridgeValueLowOutput, - uint8_t numControllers); - static Datagram Erase_Flash(uint32_t sectorAddress); - static Datagram Set_ADCS_Controller(char controllerId, float controllerMatrix[3][6]); - static Datagram Set_ADCS_Ephemerides(uint16_t chunkId, std::vector ephemeridesDataQueue); - static Datagram Detumble(uint8_t flags, uint32_t length); - static Datagram Set_IMU_Offset(float xAxisGyroOffset, - float yAxisGyroOffset, - float zAxisGyroOffset, - float xAxisAcceleOffset, - float yAxisAcceleOffset, - float zAxisAcceleOffset, - float xAxisMagneticOffset, - float yAxisMagneticOffset, - float zAxisMagneticOffset); - static Datagram Set_IMU_Calibration(float transformationMatrix[9], float biasVector[3]); - - /**-------------------------------------------------------- - * - * @} - * - --------------------------------------------------------*/ -}; - -} - - - -#endif //FOSSASAT1B_DATAGRAMDECODER_H diff --git a/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT2/FOSSASAT2_DatagramEncoder.cpp b/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT2/FOSSASAT2_DatagramEncoder.cpp deleted file mode 100644 index 447b06a..0000000 --- a/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT2/FOSSASAT2_DatagramEncoder.cpp +++ /dev/null @@ -1,960 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "FOSSASAT2_DatagramEncoder.h" - -#include - -std::string FOSSASAT2::DatagramEncoder::callsign; -std::string FOSSASAT2::DatagramEncoder::password; -std::vector FOSSASAT2::DatagramEncoder::key; - -Datagram FOSSASAT2::DatagramEncoder::Encode(OperationID operationId, int16_t functionId, uint8_t optionalDataLength, char* optionalData) { - - const char *callsign = FOSSASAT2::DatagramEncoder::callsign.c_str(); - const char *password = FOSSASAT2::DatagramEncoder::password.c_str(); - uint8_t* key = FOSSASAT2::DatagramEncoder::key.data(); - char directionBit = FCPI_DIR_TO_GROUND_STATION; - bool encrypt = functionId >= PRIVATE_OFFSET; - - uint8_t frameLength = 0; - std::vector frameData; - char controlByte = directionBit | operationId; - - if (encrypt) { - frameLength = FCP_Get_Frame_Length((char *) callsign, optionalDataLength, password); - } - else { - frameLength = FCP_Get_Frame_Length((char *) callsign, optionalDataLength); - } - - { - uint8_t *tempBuffer = new uint8_t[frameLength]; - if (encrypt) { - FCP_Encode(tempBuffer, (char *) callsign, functionId, optionalDataLength, (uint8_t *)optionalData, key, password); - } - else { - FCP_Encode(tempBuffer, (char *) callsign, functionId, optionalDataLength); - } - for (uint8_t i = 0; i < frameLength; i++) { - frameData.push_back(tempBuffer[i]); - } - delete[] tempBuffer; - } - - std::vector datagramData; - datagramData.push_back(controlByte); - datagramData.push_back(frameLength); - datagramData.insert(datagramData.end(), frameData.begin(), frameData.end()); - - return Datagram(SatVersion::V_FOSSASAT2, FOSSASAT2::DatagramEncoder::callsign, datagramData, false); -} - - - -Datagram FOSSASAT2::DatagramEncoder::Ping() -{ - return FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_PING, 0, nullptr); -} - -Datagram FOSSASAT2::DatagramEncoder::Retransmit(uint32_t senderId, char *message) -{ - int messageLen = strlen(message) + 1; - int optDataLen = messageLen + 4; - - if (optDataLen > 32) { - throw "transmit message too long (max 32)"; - } - - char *optData = new char[optDataLen]; - optData[0] = senderId; - optData[1] = senderId >> 8; - optData[2] = senderId >> 16; - optData[4] = senderId >> 24; - - strcpy(&(optData[5]), message); - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_RETRANSMIT, optDataLen, optData); - - delete[] optData; - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Retransmit_Custom(uint8_t bandwidth, - uint8_t spreadingFactor, - uint8_t codingRate, - uint16_t preambleSymbolLength, - uint8_t crcEnabled, - int8_t outputPower, - uint32_t senderId, - char *message) -{ - int messageLen = strlen(message) + 1; - int optDataLen = 11 + messageLen; - - if (optDataLen > 43) { - throw "transmit message too long (max 43)"; - } - - char *optData = new char[optDataLen]; - optData[0] = bandwidth; - optData[1] = spreadingFactor; - optData[2] = codingRate; - optData[3] = preambleSymbolLength; - optData[4] = preambleSymbolLength >> 8; - optData[5] = crcEnabled; - optData[6] = outputPower; - optData[7] = outputPower >> 8; - optData[8] = outputPower >> 16; - optData[9] = outputPower >> 24; - - strcpy(&(optData[10]), message); - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_RETRANSMIT_CUSTOM, optDataLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Transmit_System_Info() -{ - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_TRANSMIT_SYSTEM_INFO, 0, nullptr); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Get_Packet_Info() -{ - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_PACKET_INFO, 0, nullptr); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Get_Statistics(char flags) -{ - char optData[1]; // copy the parameter into this locally scoped variable for safety. - optData[0] = flags; - return FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_STATISTICS, 1, optData); -} - -Datagram FOSSASAT2::DatagramEncoder::Deploy() -{ - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_DEPLOY, 0, nullptr); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Restart() -{ - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_RESTART, 0, nullptr); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Wipe_EEPROM(char flags) -{ - char optData[1]; - optData[0] = flags; - return FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_WIPE_EEPROM, 1, optData); -} - -Datagram FOSSASAT2::DatagramEncoder::Set_Transmit_Enable(char transmitEnabled, - char autoStatsEnabled, - char fskMandatedEnabled) -{ - char optData[3]; - optData[0] = transmitEnabled; - optData[1] = autoStatsEnabled; - optData[2] = fskMandatedEnabled; - - return FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_TRANSMIT_ENABLE, 3, optData); -} - -Datagram FOSSASAT2::DatagramEncoder::Set_Callsign(char *callsign) -{ - int callsignLen = strlen(callsign) + 1; - - if (callsignLen > 32) { - throw "callsign cannot be more than 32 characters"; - } - - char *optData = new char[callsignLen]; - - strcpy(&(optData[10]), callsign); - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_CALLSIGN, 0, nullptr); - - delete[] optData; - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_SF_Mode(uint8_t spreadingFactor) -{ - char optData[1]; - optData[0] = spreadingFactor; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_SF_MODE, 1, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_MPPT_Mode(uint8_t temperatureSwitchEnabled, uint8_t keepAliveEnabled) -{ - char optData[2]; - optData[0] = temperatureSwitchEnabled; - optData[1] = keepAliveEnabled; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_MPPT_MODE, 2, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_Low_Power_Mode_Enable(uint8_t lowPowerModeEnabled) -{ - char optData[1]; - optData[0] = lowPowerModeEnabled; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_LOW_POWER_ENABLE, 1, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_Receive_Windows(uint8_t fskReceiveWindowLength, - uint8_t loraReceiveWindowLength) -{ - char optData[2]; - optData[0] = fskReceiveWindowLength; - optData[1] = loraReceiveWindowLength; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_RECEIVE_WINDOWS, 2, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Camera_Capture(char pictureSlot, - char lightMode, - char pictureSize, - char brightness, - char saturation, - char specialFilter, - char contrast) -{ - char optData[4]; - optData[0] = pictureSlot; - optData[1] = (pictureSize << 4) | lightMode; - optData[2] = (saturation << 4) | brightness; - optData[3] = (contrast << 4) | specialFilter; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_CAMERA_CAPTURE, 4, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_Power_Limits(int16_t deploymentVoltageLimit, - int16_t heaterVoltageLimit, - int16_t cwBeepVoltageLimit, - int16_t lowPowerVoltageLimit, - float heaterTemperatureLimit, - float mpptSwitchtemperatureLimit, - uint8_t heaterDutyCycle) -{ - char optData[17]; - optData[0] = deploymentVoltageLimit; - optData[1] = deploymentVoltageLimit >> 8; - optData[2] = heaterVoltageLimit; - optData[3] = heaterVoltageLimit >> 8; - optData[4] = cwBeepVoltageLimit; - optData[5] = cwBeepVoltageLimit >> 8; - optData[6] = lowPowerVoltageLimit; - optData[7] = lowPowerVoltageLimit >> 8; - char *heaterTemperatureArray = (char *) (&heaterTemperatureLimit); - optData[8] = heaterTemperatureArray[0]; - optData[9] = heaterTemperatureArray[1]; - optData[10] = heaterTemperatureArray[2]; - optData[11] = heaterTemperatureArray[3]; - char *mpptSwitchTemperatureArray = (char *) (&mpptSwitchtemperatureLimit); - optData[12] = mpptSwitchTemperatureArray[0]; - optData[13] = mpptSwitchTemperatureArray[1]; - optData[14] = mpptSwitchTemperatureArray[2]; - optData[15] = mpptSwitchTemperatureArray[3]; - optData[16] = heaterDutyCycle; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_POWER_LIMITS, 17, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_RTC(uint8_t year, - uint8_t month, - uint8_t day, - uint8_t dayOfWeek, - uint8_t hours, - uint8_t minutes, - uint8_t seconds) -{ - char optData[7]; - optData[0] = year; - optData[1] = month; - optData[2] = day; - optData[3] = dayOfWeek; - optData[4] = hours; - optData[5] = minutes; - optData[6] = seconds; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_RTC, 7, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Record_IMU(uint16_t sampleNumber, uint16_t samplingPeriod, uint8_t flags) -{ - char optData[5]; - optData[0] = sampleNumber; - optData[1] = sampleNumber >> 8; - optData[2] = samplingPeriod; - optData[3] = samplingPeriod >> 8; - optData[4] = flags; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_RECORD_IMU, 5, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Run_Manual_ACS(int8_t xHighBridgeMag, - int8_t xLowBridgeMag, - int8_t yHighBridgeMag, - int8_t yLowBrightMag, - int8_t zHBridgeHighMag, - int8_t zBridgeLowMag, - uint32_t xPulseLength, - uint32_t yPulseLength, - uint32_t zPulseLength, - uint32_t maneuverDuration, - uint8_t hbridgefaultFlags) -{ - char optData[23]; - optData[0] = xHighBridgeMag; - optData[1] = xLowBridgeMag; - optData[2] = yHighBridgeMag; - optData[3] = yLowBrightMag; - optData[4] = zHBridgeHighMag; - optData[5] = zBridgeLowMag; - optData[6] = xPulseLength; - optData[7] = xPulseLength >> 8; - optData[8] = xPulseLength >> 16; - optData[9] = xPulseLength >> 24; - optData[10] = yPulseLength; - optData[11] = yPulseLength >> 8; - optData[12] = yPulseLength >> 16; - optData[13] = yPulseLength >> 24; - optData[14] = zPulseLength; - optData[15] = zPulseLength >> 8; - optData[16] = zPulseLength >> 16; - optData[17] = zPulseLength >> 24; - optData[18] = maneuverDuration; - optData[19] = maneuverDuration >> 8; - optData[20] = maneuverDuration >> 16; - optData[21] = maneuverDuration >> 24; - optData[22] = hbridgefaultFlags; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_RUN_MANUAL_ACS, 23, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Log_GPS(uint32_t gpsLoggingDuration, uint32_t gpsLoggingStartOffset) -{ - char optData[8]; - optData[0] = gpsLoggingDuration; - optData[1] = gpsLoggingDuration >> 8; - optData[2] = gpsLoggingDuration >> 16; - optData[3] = gpsLoggingDuration >> 24; - optData[4] = gpsLoggingStartOffset; - optData[5] = gpsLoggingStartOffset >> 8; - optData[6] = gpsLoggingStartOffset >> 16; - optData[7] = gpsLoggingStartOffset >> 24; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_LOG_GPS, 8, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Get_GPS_Log(uint8_t newestEntriesFirst, - uint16_t gpsLogOffsetAsNMEASeq, - uint16_t NMEASentencesToDownlink) -{ - char optData[5]; - optData[0] = newestEntriesFirst; - optData[1] = gpsLogOffsetAsNMEASeq; - optData[2] = gpsLogOffsetAsNMEASeq >> 8; - optData[3] = NMEASentencesToDownlink; - optData[4] = NMEASentencesToDownlink >> 8; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_GPS_LOG, 5, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Get_Flash_Contents(uint32_t flashAddress, uint8_t numBytes) -{ - char optData[5]; - optData[0] = flashAddress; - optData[1] = flashAddress >> 8; - optData[2] = flashAddress >> 16; - optData[3] = flashAddress >> 24; - optData[4] = numBytes; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_FLASH_CONTENTS, 5, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Get_Picture_Length(uint8_t pictureSlot) -{ - char optData[1]; - optData[0] = pictureSlot; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_PICTURE_LENGTH, 1, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Get_Picture_Burst(char pictureSlot, uint16_t pictureId, char fullOrScandata) -{ - char optData[4]; - optData[0] = pictureSlot; - optData[1] = pictureId; - optData[2] = pictureId >> 8; - optData[3] = fullOrScandata; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_FULL_SYSTEM_INFO, 4, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Route(char *fcpFrame) -{ - int messageLen = strlen(fcpFrame) + 1; - - char *optData = new char[messageLen]; - strcpy(optData, fcpFrame); - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_ROUTE, messageLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_Flash_Contents(uint32_t flashAddress, char *data) -{ - int dataLen = strlen(data); // ignore the null terminator + 1; - int messageLen = dataLen + 4; - - char *optData = new char[messageLen]; - optData[0] = flashAddress; - optData[1] = flashAddress >> 8; - optData[2] = flashAddress >> 16; - - memcpy(&(optData[3]), data, dataLen); // copy to opt data without the null terminator. - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_FLASH_CONTENTS, messageLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_TLE(char *tle) -{ - int optDataLen = strlen(tle); - char *optData = new char[optDataLen]; - - memcpy(optData, tle, optDataLen); // no line endings. - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_TLE, optDataLen, optData); - - delete[] optData; - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Get_GPS_Log_State() -{ - int optDataLen = 0; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_GPS_LOG_STATE, optDataLen, nullptr); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Run_GPS_Command(char *skyTraqBinaryProtocolMessage) -{ - int optDataLen = strlen(skyTraqBinaryProtocolMessage); // without terminator. - - char *optData = new char[optDataLen]; - memcpy(optData, skyTraqBinaryProtocolMessage, optDataLen); - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_RUN_GPS_COMMAND, optDataLen, optData); - - delete optData; - - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_Sleep_Intervals(std::vector sleepIntervals) -{ - int numIntervals = sleepIntervals.size(); - int optDataLen = numIntervals * sizeof(SleepInterval); - - char *optData = new char[optDataLen]; - - int optDataIndex = 0; - for (int i = 0; i < numIntervals; i++) { - SleepInterval interval = sleepIntervals[i]; - - memcpy(&(optData[optDataIndex]), &interval, sizeof(SleepInterval)); - - optDataIndex += sizeof(SleepInterval); - } - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_SLEEP_INTERVALS, optDataLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Abort() -{ - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_ABORT, 0, nullptr); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Maneuver(uint8_t controlFlags, uint32_t maneuverLength) -{ - char optData[5]; - optData[0] = controlFlags; - optData[1] = maneuverLength; - optData[2] = maneuverLength >> 8; - optData[3] = maneuverLength >> 16; - optData[4] = maneuverLength >> 24; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_MANEUVER, 5, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_ADCS_Parameters(float maximumPulseIntensity, - float maximumPulseLength, - float detumblingAngularVelocity, - float minimumIntertialMoment, - float pulseAmplitude, - float calculationTolerance, - float activeControlEulerAngleChangeTolerance, - float activeControlAngularVelocityChangeTolerance, - float eclipseThreshold, - float rotationMatrixWeightRatio, - float rotationVerificationTriggerLevel, - float kalmanFilterDisturbanceCovariance, - float kalmanFilterNoiseCovariance, - uint32_t adcsUpdateTimeStepPeriod, - uint32_t hbridgeTimerUpdatePeriod, - int8_t hbridgeValueHighOutput, - int8_t hbridgeValueLowOutput, - uint8_t numControllers) -{ - char optData[63]; - - char *maximumPulseIntensityArray = (char *) (&maximumPulseIntensity); - char *maximumPulseLengthArray = (char *) (&maximumPulseLength); - char *detumblingAngularVelocityArray = (char *) (&detumblingAngularVelocity); - char *minimumIntertialMomentArray = (char *) (&minimumIntertialMoment); - char *pulseAmplitudeArray = (char *) (&pulseAmplitude); - char *calculationToleranceArray = (char *) (&calculationTolerance); - char *activeControlEulerAngleChangeToleranceArray = (char *) (&activeControlEulerAngleChangeTolerance); - char *activeControlAngularVelocityChangeToleranceArray = (char *) (&activeControlAngularVelocityChangeTolerance); - char *eclipseThresholdArray = (char *) (&eclipseThreshold); - char *rotationMatrixWeightRatioArray = (char *) (&rotationMatrixWeightRatio); - char *rotationVerificationTriggerLevelArray = (char *) (&rotationVerificationTriggerLevel); - char *kalmanFilterDisturbanceCovarianceArray = (char *) (&kalmanFilterDisturbanceCovariance); - char *kalmanFilterNoiseCovarianceArray = (char *) (&kalmanFilterNoiseCovariance); - - optData[0] = maximumPulseIntensityArray[0]; - optData[1] = maximumPulseIntensityArray[1]; - optData[2] = maximumPulseIntensityArray[2]; - optData[3] = maximumPulseIntensityArray[3]; - - optData[4] = maximumPulseLengthArray[0]; - optData[5] = maximumPulseLengthArray[1]; - optData[6] = maximumPulseLengthArray[2]; - optData[7] = maximumPulseLengthArray[3]; - - optData[8] = detumblingAngularVelocityArray[0]; - optData[9] = detumblingAngularVelocityArray[1]; - optData[10] = detumblingAngularVelocityArray[2]; - optData[11] = detumblingAngularVelocityArray[3]; - - optData[12] = minimumIntertialMomentArray[0]; - optData[13] = minimumIntertialMomentArray[1]; - optData[14] = minimumIntertialMomentArray[2]; - optData[15] = minimumIntertialMomentArray[3]; - - optData[16] = pulseAmplitudeArray[0]; - optData[17] = pulseAmplitudeArray[1]; - optData[18] = pulseAmplitudeArray[2]; - optData[19] = pulseAmplitudeArray[3]; - - optData[20] = calculationToleranceArray[0]; - optData[21] = calculationToleranceArray[1]; - optData[22] = calculationToleranceArray[2]; - optData[23] = calculationToleranceArray[3]; - - optData[24] = activeControlEulerAngleChangeToleranceArray[0]; - optData[25] = activeControlEulerAngleChangeToleranceArray[1]; - optData[26] = activeControlEulerAngleChangeToleranceArray[2]; - optData[27] = activeControlEulerAngleChangeToleranceArray[3]; - - optData[28] = activeControlAngularVelocityChangeToleranceArray[0]; - optData[29] = activeControlAngularVelocityChangeToleranceArray[1]; - optData[30] = activeControlAngularVelocityChangeToleranceArray[2]; - optData[31] = activeControlAngularVelocityChangeToleranceArray[3]; - - optData[32] = eclipseThresholdArray[0]; - optData[33] = eclipseThresholdArray[1]; - optData[34] = eclipseThresholdArray[2]; - optData[35] = eclipseThresholdArray[3]; - - optData[36] = rotationMatrixWeightRatioArray[0]; - optData[37] = rotationMatrixWeightRatioArray[1]; - optData[38] = rotationMatrixWeightRatioArray[2]; - optData[39] = rotationMatrixWeightRatioArray[3]; - - optData[40] = rotationVerificationTriggerLevelArray[0]; - optData[41] = rotationVerificationTriggerLevelArray[1]; - optData[42] = rotationVerificationTriggerLevelArray[2]; - optData[43] = rotationVerificationTriggerLevelArray[3]; - - optData[44] = kalmanFilterDisturbanceCovarianceArray[0]; - optData[45] = kalmanFilterDisturbanceCovarianceArray[1]; - optData[46] = kalmanFilterDisturbanceCovarianceArray[2]; - optData[47] = kalmanFilterDisturbanceCovarianceArray[3]; - - optData[48] = kalmanFilterNoiseCovarianceArray[0]; - optData[49] = kalmanFilterNoiseCovarianceArray[1]; - optData[50] = kalmanFilterNoiseCovarianceArray[2]; - optData[51] = kalmanFilterNoiseCovarianceArray[3]; - - optData[52] = adcsUpdateTimeStepPeriod; - optData[53] = adcsUpdateTimeStepPeriod >> 8; - optData[54] = adcsUpdateTimeStepPeriod >> 16; - optData[55] = adcsUpdateTimeStepPeriod >> 24; - - optData[56] = hbridgeTimerUpdatePeriod; - optData[57] = hbridgeTimerUpdatePeriod >> 8; - optData[58] = hbridgeTimerUpdatePeriod >> 16; - optData[59] = hbridgeTimerUpdatePeriod >> 24; - - optData[60] = hbridgeValueHighOutput; - optData[61] = hbridgeValueLowOutput; - optData[62] = numControllers; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_ADCS_PARAMETERS, 63, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Erase_Flash(uint32_t sectorAddress) -{ - char optData[4]; - optData[0] = sectorAddress; - optData[1] = sectorAddress >> 8; - optData[2] = sectorAddress >> 16; - optData[3] = sectorAddress >> 24; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_ERASE_FLASH, 4, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_ADCS_Controller(char controllerId, float controllerMatrix[3][6]) -{ - char optData[77]; - optData[0] = controllerId; - - int i = 1; - for (int x = 0; x < 3; x++) { - for (int y = 0; y < 6; y++) { - /// @todo check for endianess here. - float value = controllerMatrix[x][y]; - char *valueAsArray = (char *) &value; - - optData[i] = valueAsArray[0]; - optData[i + 1] = valueAsArray[1]; - optData[i + 2] = valueAsArray[2]; - optData[i + 3] = valueAsArray[3]; - - i += 4; - } - } - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_ADCS_CONTROLLER, 77, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_ADCS_Ephemerides(uint16_t chunkId, - std::vector ephemeridesDataQueue) -{ - size_t optDataLen = ephemeridesDataQueue.size() * sizeof(Ephemerides); - optDataLen += sizeof(uint16_t); - - if (optDataLen > 192) { - throw "too much data in ephemerides stack (max is 192 bytes)"; - } - - std::vector optData; - optData.push_back(chunkId); - optData.push_back(chunkId >> 8); - - for (int i = 0; i < ephemeridesDataQueue.size(); i++) { - Ephemerides ephemeridesStruct = ephemeridesDataQueue[i]; - - // convert the struct to a char* array - char *ephemeridesData = (char *) &ephemeridesStruct; - - // for each byte, push it to the optDataVector. - for (int k = 0; k < sizeof(Ephemerides); k++) { - optData.push_back(ephemeridesData[k]); - } - } - - // get the vector as char array. - char *data = optData.data(); - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_ADCS_EPHEMERIDES, optDataLen, data); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Detumble(uint8_t flags, uint32_t length) -{ - char optData[5]; - optData[0] = flags; - optData[1] = length; - optData[2] = length >> 8; - optData[3] = length >> 16; - optData[4] = length >> 24; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_DETUMBLE, 5, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_IMU_Offset(float xAxisGyroOffset, - float yAxisGyroOffset, - float zAxisGyroOffset, - float xAxisAcceleOffset, - float yAxisAcceleOffset, - float zAxisAcceleOffset, - float xAxisMagneticOffset, - float yAxisMagneticOffset, - float zAxisMagneticOffset) -{ - char *xAxisGyroOffsetArray = (char *) (&xAxisGyroOffset); - char *yAxisGyroOffsetArray = (char *) (&yAxisGyroOffset); - char *zAxisGyroOffsetArray = (char *) (&zAxisGyroOffset); - char *xAxisAcceleOffsetArray = (char *) (&xAxisAcceleOffset); - char *yAxisAcceleOffsetArray = (char *) (&yAxisAcceleOffset); - char *zAxisAcceleOffsetArray = (char *) (&zAxisAcceleOffset); - char *xAxisMagneticOffsetArray = (char *) (&xAxisMagneticOffset); - char *yAxisMagneticOffsetArray = (char *) (&yAxisMagneticOffset); - char *zAxisMagneticOffsetArray = (char *) (&zAxisMagneticOffset); - - char optData[36]; - optData[0] = xAxisGyroOffsetArray[0]; - optData[1] = xAxisGyroOffsetArray[1]; - optData[2] = xAxisGyroOffsetArray[2]; - optData[3] = xAxisGyroOffsetArray[3]; - - optData[4] = yAxisGyroOffsetArray[0]; - optData[5] = yAxisGyroOffsetArray[1]; - optData[6] = yAxisGyroOffsetArray[2]; - optData[7] = yAxisGyroOffsetArray[3]; - - optData[8] = zAxisGyroOffsetArray[0]; - optData[9] = zAxisGyroOffsetArray[1]; - optData[10] = zAxisGyroOffsetArray[2]; - optData[11] = zAxisGyroOffsetArray[3]; - - optData[12] = xAxisAcceleOffsetArray[0]; - optData[13] = xAxisAcceleOffsetArray[1]; - optData[14] = xAxisAcceleOffsetArray[2]; - optData[15] = xAxisAcceleOffsetArray[3]; - - optData[16] = yAxisAcceleOffsetArray[0]; - optData[17] = yAxisAcceleOffsetArray[1]; - optData[18] = yAxisAcceleOffsetArray[2]; - optData[19] = yAxisAcceleOffsetArray[3]; - - optData[20] = zAxisAcceleOffsetArray[0]; - optData[21] = zAxisAcceleOffsetArray[1]; - optData[22] = zAxisAcceleOffsetArray[2]; - optData[23] = zAxisAcceleOffsetArray[3]; - - optData[24] = xAxisMagneticOffsetArray[0]; - optData[25] = xAxisMagneticOffsetArray[1]; - optData[26] = xAxisMagneticOffsetArray[2]; - optData[27] = xAxisMagneticOffsetArray[3]; - - optData[28] = yAxisMagneticOffsetArray[0]; - optData[29] = yAxisMagneticOffsetArray[1]; - optData[30] = yAxisMagneticOffsetArray[2]; - optData[31] = yAxisMagneticOffsetArray[3]; - - optData[32] = zAxisMagneticOffsetArray[0]; - optData[33] = zAxisMagneticOffsetArray[1]; - optData[34] = zAxisMagneticOffsetArray[2]; - optData[35] = zAxisMagneticOffsetArray[3]; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_IMU_OFFSET, 36, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Set_IMU_Calibration(float transformationMatrix[9], float biasVector[3]) -{ - char *matrixA = (char *) (&transformationMatrix[0]); - char *matrixB = (char *) (&transformationMatrix[1]); - char *matrixC = (char *) (&transformationMatrix[2]); - char *matrixD = (char *) (&transformationMatrix[3]); - char *matrixE = (char *) (&transformationMatrix[4]); - char *matrixF = (char *) (&transformationMatrix[5]); - char *matrixG = (char *) (&transformationMatrix[6]); - char *matrixH = (char *) (&transformationMatrix[7]); - char *matrixI = (char *) (&transformationMatrix[8]); - - char *vectorA = (char *) (&biasVector[0]); - char *vectorB = (char *) (&biasVector[1]); - char *vectorC = (char *) (&biasVector[2]); - - char optData[47]; - optData[0] = matrixA[0]; - optData[1] = matrixA[1]; - optData[2] = matrixA[2]; - optData[3] = matrixA[3]; - - optData[4] = matrixB[0]; - optData[5] = matrixB[1]; - optData[6] = matrixB[2]; - optData[7] = matrixB[3]; - - optData[8] = matrixC[0]; - optData[9] = matrixC[1]; - optData[10] = matrixC[2]; - optData[11] = matrixC[3]; - - optData[12] = matrixD[0]; - optData[13] = matrixD[1]; - optData[14] = matrixD[2]; - optData[15] = matrixD[3]; - - optData[16] = matrixE[0]; - optData[17] = matrixE[1]; - optData[18] = matrixE[2]; - optData[19] = matrixE[3]; - - optData[20] = matrixF[0]; - optData[21] = matrixF[1]; - optData[22] = matrixF[2]; - optData[23] = matrixF[3]; - - optData[24] = matrixG[0]; - optData[25] = matrixG[1]; - optData[26] = matrixG[2]; - optData[27] = matrixG[3]; - - optData[28] = matrixH[0]; - optData[29] = matrixH[1]; - optData[30] = matrixH[2]; - optData[31] = matrixH[3]; - - optData[32] = matrixI[0]; - optData[33] = matrixI[1]; - optData[34] = matrixI[2]; - optData[35] = matrixI[3]; - - - optData[36] = vectorA[0]; - optData[37] = vectorA[1]; - optData[38] = vectorA[2]; - optData[39] = vectorA[3]; - - optData[40] = vectorB[0]; - optData[41] = vectorB[1]; - optData[42] = vectorB[2]; - optData[43] = vectorB[3]; - - optData[44] = vectorC[0]; - optData[45] = vectorC[1]; - optData[46] = vectorC[2]; - optData[47] = vectorC[3]; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_SET_IMU_CALIBRATION, 47, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Get_Full_System_Info() -{ - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_GET_FULL_SYSTEM_INFO, 0, nullptr); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Store_And_Forward_Add(uint32_t messageId, char *message) -{ - int messageLen = strlen(message) + 1; - int optDataLen = 4 + messageLen; - - if (optDataLen > 32) { - throw "store and forward message too long (max 32)"; - } - - char *optData = new char[optDataLen]; - optData[0] = messageId; - optData[1] = messageId >> 8; - optData[2] = messageId >> 16; - optData[3] = messageId >> 24; - - strcpy(&(optData[4]), message); - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_STORE_AND_FORWARD_ADD, optDataLen, optData); - - delete[] optData; - - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Store_And_Forward_Request(uint32_t messageId) -{ - char optData[4]; - optData[0] = messageId; - optData[1] = messageId >> 8; - optData[2] = messageId >> 16; - optData[3] = messageId >> 24; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_STORE_AND_FORWARD_REQUEST, 4, optData); - return msg; -} - -Datagram FOSSASAT2::DatagramEncoder::Request_Public_Picture(uint8_t pictureSlot, uint16_t picturePacketId) -{ - if (pictureSlot < 80 || pictureSlot > 100) { - throw "only picture slots 80 <= id <= 100 are allowed"; - } - - char optData[3]; - optData[0] = pictureSlot; - optData[1] = picturePacketId; - optData[2] = picturePacketId >> 8; - - Datagram msg = FOSSASAT2::DatagramEncoder::Encode(OperationID::FRAME, CMD_REQUEST_PUBLIC_PICTURE, 3, optData); - return msg; -} - - - diff --git a/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT2/FOSSASAT2_DatagramEncoder.h b/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT2/FOSSASAT2_DatagramEncoder.h deleted file mode 100644 index 134a83c..0000000 --- a/FOSSACommsInterpreter/src/DatagramEncoder/FOSSASAT2/FOSSASAT2_DatagramEncoder.h +++ /dev/null @@ -1,192 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSASAT2_DATAGRAMDECODER_H -#define FOSSASAT2_DATAGRAMDECODER_H - -#include "../../Frame.h" - -#include -#include -#include - -namespace FOSSASAT2 -{ - -class DatagramEncoder { -private: - static std::string callsign; - static std::string password; - static std::vector key; - - static Datagram Encode(OperationID operationId, int16_t functionId, uint8_t optionalDataLength, char* optionalData); -public: - static void SetCallsign(std::string callsign); - static void SetPassword(std::string password); - static void SetKey(std::vector key); - - /**-------------------------------------------------------- - * - * @name Public unencrypted uplink commands. - * - * @{ - * - --------------------------------------------------------*/ - static Datagram Ping(); - static Datagram Retransmit(uint32_t senderId, char *message); - static Datagram Retransmit_Custom(uint8_t bandwidth, - uint8_t spreadingFactor, - uint8_t codingRate, - uint16_t preambleSymbolLength, - uint8_t crcEnabled, - int8_t outputPower, - uint32_t senderId, - char *message); - static Datagram Transmit_System_Info(); - static Datagram Get_Packet_Info(); - static Datagram Get_Statistics(char flags); - static Datagram Get_Full_System_Info(); - static Datagram Store_And_Forward_Add(uint32_t messageId, char *message); - static Datagram Store_And_Forward_Request(uint32_t messageId); - static Datagram Request_Public_Picture(uint8_t pictureSlot, - uint16_t picturePacketId); // only 80-100 slot numbers. - - /**-------------------------------------------------------- - * - * @} - * - --------------------------------------------------------*/ - - - - - /**-------------------------------------------------------- - * - * @name Private encrypted uplink commands. - * - * @{ - * - --------------------------------------------------------*/ - static Datagram Deploy(); - static Datagram Restart(); - static Datagram Wipe_EEPROM(char flags); - static Datagram Set_Transmit_Enable(char transmitEnabled, char autoStatsEnabled, char fskMandatedEnabled); - static Datagram Set_Callsign(char *callsign); - static Datagram Set_SF_Mode(uint8_t spreadingFactor); - static Datagram Set_MPPT_Mode(uint8_t temperatureSwitchEnabled, uint8_t keepAliveEnabled); - static Datagram Set_Low_Power_Mode_Enable(uint8_t lowPowerModeEnabled); - static Datagram Set_Receive_Windows(uint8_t fskReceiveWindowLength, uint8_t loraReceiveWindowLength); - static Datagram Camera_Capture(char pictureSlot, - char lightMode, - char pictureSize, - char brightness, - char saturation, - char specialFilter, - char contrast); - static Datagram Set_Power_Limits(int16_t deploymentVoltageLimit, - int16_t heaterVoltageLimit, - int16_t cwBeepVoltageLimit, - int16_t lowPowerVoltageLimit, - float heaterTemperatureLimit, - float mpptSwitchtemperatureLimit, - uint8_t heaterDutyCycle); - static Datagram Set_RTC(uint8_t year, - uint8_t month, - uint8_t day, - uint8_t dayOfWeek, - uint8_t hours, - uint8_t minutes, - uint8_t seconds); // year is offset from 2000. - static Datagram Record_IMU(uint16_t sampleNumber, uint16_t samplingPeriod, uint8_t flags); - static Datagram Run_Manual_ACS(int8_t xHighBridgeMag, - int8_t xLowBridgeMag, - int8_t yHighBridgeMag, - int8_t yLowBrightMag, - int8_t zHBridgeHighMag, - int8_t zBridgeLowMag, - uint32_t xPulseLength, - uint32_t yPulseLength, - uint32_t zPulseLength, - uint32_t maneuverDuration, - uint8_t hbridgefaultFlags); - static Datagram Log_GPS(uint32_t gpsLoggingDuration, uint32_t gpsLoggingStartOffset); - static Datagram Get_GPS_Log(uint8_t newestEntriesFirst, - uint16_t gpsLogOffsetAsNMEASeq, - uint16_t NMEASentencesToDownlink); // NMEA sentences set to 0 means entire log. - static Datagram Get_Flash_Contents(uint32_t flashAddress, uint8_t numBytes); - static Datagram Get_Picture_Length(uint8_t pictureSlot); - static Datagram Get_Picture_Burst(char pictureSlot, uint16_t pictureId, char fullOrScandata); - static Datagram Route(char *fcpFrame); - static Datagram Set_Flash_Contents(uint32_t flashAddress, char *data); // data MUST include a null terminator - static Datagram Set_TLE(char *tle); // MUST include a null terminator. - static Datagram Get_GPS_Log_State(); - static Datagram Run_GPS_Command(char *skyTraqBinaryProtocolMessage); - static Datagram Set_Sleep_Intervals(std::vector sleepIntervals); - static Datagram Abort(); - static Datagram Maneuver(uint8_t controlFlags, uint32_t maneuverLength); - static Datagram Set_ADCS_Parameters(float maximumPulseIntensity, - float maximumPulseLength, - float detumblingAngularVelocity, - float minimumIntertialMoment, - float pulseAmplitude, - float calculationTolerance, - float activeControlEulerAngleChangeTolerance, - float activeControlAngularVelocityChangeTolerance, - float eclipseThreshold, - float rotationMatrixWeightRatio, - float rotationVerificationTriggerLevel, - float kalmanFilterDisturbanceCovariance, - float kalmanFilterNoiseCovariance, - uint32_t adcsUpdateTimeStepPeriod, - uint32_t hbridgeTimerUpdatePeriod, - int8_t hbridgeValueHighOutput, - int8_t hbridgeValueLowOutput, - uint8_t numControllers); - static Datagram Erase_Flash(uint32_t sectorAddress); - static Datagram Set_ADCS_Controller(char controllerId, float controllerMatrix[3][6]); - static Datagram Set_ADCS_Ephemerides(uint16_t chunkId, std::vector ephemeridesDataQueue); - static Datagram Detumble(uint8_t flags, uint32_t length); - static Datagram Set_IMU_Offset(float xAxisGyroOffset, - float yAxisGyroOffset, - float zAxisGyroOffset, - float xAxisAcceleOffset, - float yAxisAcceleOffset, - float zAxisAcceleOffset, - float xAxisMagneticOffset, - float yAxisMagneticOffset, - float zAxisMagneticOffset); - static Datagram Set_IMU_Calibration(float transformationMatrix[9], float biasVector[3]); - - /**-------------------------------------------------------- - * - * @} - * - --------------------------------------------------------*/ -}; - -} - - - -#endif //FOSSASAT1B_DATAGRAMDECODER_H diff --git a/FOSSACommsInterpreter/src/DatagramEncoder/GroundStation/GroundStation_DatagramEncoder.cpp b/FOSSACommsInterpreter/src/DatagramEncoder/GroundStation/GroundStation_DatagramEncoder.cpp deleted file mode 100644 index c56a5db..0000000 --- a/FOSSACommsInterpreter/src/DatagramEncoder/GroundStation/GroundStation_DatagramEncoder.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "GroundStation_DatagramEncoder.h" - -#include diff --git a/FOSSACommsInterpreter/src/DatagramEncoder/GroundStation/GroundStation_DatagramEncoder.h b/FOSSACommsInterpreter/src/DatagramEncoder/GroundStation/GroundStation_DatagramEncoder.h deleted file mode 100644 index 01a6e8c..0000000 --- a/FOSSACommsInterpreter/src/DatagramEncoder/GroundStation/GroundStation_DatagramEncoder.h +++ /dev/null @@ -1,44 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef GROUNDSTATION_DATAGRAMDECODER_H -#define GROUNDSTATION_DATAGRAMDECODER_H - -#include "../../Frame.h" - -#include - -namespace GroundStation -{ - -class DatagramEncoder { -public: - -}; - -} - - - -#endif //GROUNDSTATION_DATAGRAMDECODER_H diff --git a/FOSSACommsInterpreter/src/DirectionBits.h b/FOSSACommsInterpreter/src/DirectionBits.h deleted file mode 100644 index d71635e..0000000 --- a/FOSSACommsInterpreter/src/DirectionBits.h +++ /dev/null @@ -1,46 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSACOMMSINTERPRETER_DIRECTIONBITS_H -#define FOSSACOMMSINTERPRETER_DIRECTIONBITS_H - -/**---------------------------------------------------------- - * - * Direction bits - * - to or from ground station. - * - -----------------------------------------------------------*/ - -#define FCPI_DIR_TO_GROUND_STATION 0 - -#define FCPI_DIR_FROM_GROUND_STATION 1 - -/**---------------------------------------------------------- - * - * End of direction bits. - * - ----------------------------------------------------------*/ - - -#endif //FOSSACOMMSINTERPRETER_DIRECTIONBITS_H diff --git a/FOSSACommsInterpreter/src/Ephemerides.h b/FOSSACommsInterpreter/src/Ephemerides.h deleted file mode 100644 index a14d6ab..0000000 --- a/FOSSACommsInterpreter/src/Ephemerides.h +++ /dev/null @@ -1,41 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef EPHEMERIDES_H -#define EPHEMERIDES_H - -#include - -struct Ephemerides -{ - float solar_x; - float solar_y; - float solar_z; - float magnetic_x; - float magnetic_y; - float magnetic_z; - uint8_t controllerId; -}; - -#endif //EPHEMERIDES_H diff --git a/FOSSACommsInterpreter/src/Frame.cpp b/FOSSACommsInterpreter/src/Frame.cpp deleted file mode 100644 index e732860..0000000 --- a/FOSSACommsInterpreter/src/Frame.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "Frame.h" - -Frame::Frame() { - -} - -Frame::~Frame() { - -} - -Frame::Frame(SatVersion satVersion, std::string callsign, std::vector data) { - this->satVersion = satVersion; - this->functionId = FCP_Get_FunctionID((char *)callsign.c_str(), data.data(), data.size()); - - int16_t optionalDataLength = FCP_Get_OptData_Length((char *)callsign.c_str(), data.data(), data.size()); - if (optionalDataLength > 0) { - this->hasOptionalData = true; - this->ExtractOptionalData(callsign, data, optionalDataLength); - } - else { - this->hasOptionalData = false; - } -} - -uint8_t Frame::GetByteAt(uint32_t index) { - return this->optionalData[index]; -} - -int16_t Frame::GetFunctionID() -{ - return this->functionId; -} - - -void Frame::ExtractOptionalData(std::string callsign, std::vector &data, int16_t optionalDataLength) { - uint8_t *tempBuffer = new uint8_t[optionalDataLength]; - FCP_Get_OptData((char *)callsign.c_str(), data.data(), data.size(), tempBuffer, NULL, NULL); - - for (int16_t i = 0; i < optionalDataLength; i++) { - optionalData.push_back(tempBuffer[i]); - } - - delete[] tempBuffer; -} diff --git a/FOSSACommsInterpreter/src/Frame.h b/FOSSACommsInterpreter/src/Frame.h deleted file mode 100644 index e09b329..0000000 --- a/FOSSACommsInterpreter/src/Frame.h +++ /dev/null @@ -1,54 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FRAME_H -#define FRAME_H - -#include "SatVersion.h" - -#include - -#include -#include - -class Frame { -public: - Frame(); - ~Frame(); - Frame(SatVersion satVersion, std::string callsign, std::vector data); - - uint8_t GetByteAt(uint32_t index); - - int16_t GetFunctionID(); -private: - void ExtractOptionalData(std::string callsign, std::vector &data, int16_t optionalDataLength); -private: - SatVersion satVersion; - int16_t functionId; - std::vector optionalData; - bool hasOptionalData; -}; - - -#endif //FRAME_H diff --git a/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT1B/FOSSASAT1B_FrameDecoder.cpp b/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT1B/FOSSASAT1B_FrameDecoder.cpp deleted file mode 100644 index d53eea5..0000000 --- a/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT1B/FOSSASAT1B_FrameDecoder.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "FOSSASAT1B_FrameDecoder.h" - -FOSSASAT1B::Messages::SystemInfo FOSSASAT1B::FrameDecoder::DecodeSystemInfo(Frame &frame) { - return FOSSASAT1B::Messages::SystemInfo(frame); -} diff --git a/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT1B/FOSSASAT1B_FrameDecoder.h b/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT1B/FOSSASAT1B_FrameDecoder.h deleted file mode 100644 index bf2fc2c..0000000 --- a/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT1B/FOSSASAT1B_FrameDecoder.h +++ /dev/null @@ -1,44 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSASAT1B_FRAMEDECODER_H -#define FOSSASAT1B_FRAMEDECODER_H - -#include "../../Frame.h" - -#include "../../Message/FOSSASAT1B/FOSSASAT1B_SystemInfo.h" - -namespace FOSSASAT1B -{ - -class FrameDecoder { -public: - static FOSSASAT1B::Messages::SystemInfo DecodeSystemInfo(Frame &frame); -}; - -} - - - -#endif //FOSSASAT1B_FRAMEDECODER_H diff --git a/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT2/FOSSASAT2_FrameDecoder.cpp b/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT2/FOSSASAT2_FrameDecoder.cpp deleted file mode 100644 index 0bdfa16..0000000 --- a/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT2/FOSSASAT2_FrameDecoder.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "FOSSASAT2_FrameDecoder.h" - -FOSSASAT2::Messages::SystemInfo FOSSASAT2::FrameDecoder::DecodeSystemInfo(Frame &frame) { - return FOSSASAT2::Messages::SystemInfo(frame); -} diff --git a/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT2/FOSSASAT2_FrameDecoder.h b/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT2/FOSSASAT2_FrameDecoder.h deleted file mode 100644 index 65d41e0..0000000 --- a/FOSSACommsInterpreter/src/FrameDecoder/FOSSASAT2/FOSSASAT2_FrameDecoder.h +++ /dev/null @@ -1,43 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSASAT2_FRAMEDECODER_H -#define FOSSASAT2_FRAMEDECODER_H - -#include "../../Frame.h" - -#include "../../Message/FOSSASAT2/FOSSASAT2_SystemInfo.h" - -namespace FOSSASAT2 -{ - -class FrameDecoder { -public: - static FOSSASAT2::Messages::SystemInfo DecodeSystemInfo(Frame &frame); -}; - -} - - -#endif //FOSSASAT2_FRAMEDECODER_H diff --git a/FOSSACommsInterpreter/src/FrameDecoder/GroundStation/GroundStation_FrameDecoder.cpp b/FOSSACommsInterpreter/src/FrameDecoder/GroundStation/GroundStation_FrameDecoder.cpp deleted file mode 100644 index 7a1f943..0000000 --- a/FOSSACommsInterpreter/src/FrameDecoder/GroundStation/GroundStation_FrameDecoder.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "GroundStation_FrameDecoder.h" diff --git a/FOSSACommsInterpreter/src/FrameDecoder/GroundStation/GroundStation_FrameDecoder.h b/FOSSACommsInterpreter/src/FrameDecoder/GroundStation/GroundStation_FrameDecoder.h deleted file mode 100644 index 3352346..0000000 --- a/FOSSACommsInterpreter/src/FrameDecoder/GroundStation/GroundStation_FrameDecoder.h +++ /dev/null @@ -1,47 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef GROUNDSTATION_FRAMEDECODER_H -#define GROUNDSTATION_FRAMEDECODER_H - -#include "../../Frame.h" - -#include "../../Message/GroundStation/GroundStation_CarrierChangeResult.h" -#include "../../Message/GroundStation/GroundStation_ConfigurationChangeResult.h" -#include "../../Message/GroundStation/GroundStation_HandshakeResult.h" - -namespace GroundStation -{ - -class FrameDecoder { -public: - static GroundStation::Messages::HandshakeResult DecodeHandshakeResult(Frame &frame); - static GroundStation::Messages::CarrierChangeResult DecodeCarrierChangeResult(Frame &frame); - static GroundStation::Messages::ConfigurationChangeResult DecodeConfigurationChangeResult(Frame &frame); -}; - -} - - -#endif //FOSSASAT2_FRAMEDECODER_H diff --git a/FOSSACommsInterpreter/src/Interpreter.h b/FOSSACommsInterpreter/src/Interpreter.h deleted file mode 100644 index f6f0667..0000000 --- a/FOSSACommsInterpreter/src/Interpreter.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef INTERPRETER_MODULE_H -#define INTERPRETER_MODULE_H - -#include "Interpreters/FOSSASAT1B.h" -#include "Interpreters/FOSSASAT2.h" - -#endif // INTERPRETER_H diff --git a/FOSSACommsInterpreter/src/Interpreters/FOSSASAT1B.h b/FOSSACommsInterpreter/src/Interpreters/FOSSASAT1B.h deleted file mode 100644 index 668eaa0..0000000 --- a/FOSSACommsInterpreter/src/Interpreters/FOSSASAT1B.h +++ /dev/null @@ -1,33 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSASAT1B_INTERPRETER_MODULE_H -#define FOSSASAT1B_INTERPRETER_MODULE_H - -#include "../DatagramEncoder/FOSSASAT1B/FOSSASAT1B_DatagramEncoder.h" -#include "../FrameDecoder/FOSSASAT1B/FOSSASAT1B_FrameDecoder.h" - -#include "../Message/FOSSASAT1B/FOSSASAT1B_SystemInfo.h" - -#endif //FOSSASAT1B_INTERPRETER_MODULE_H diff --git a/FOSSACommsInterpreter/src/Interpreters/FOSSASAT2.h b/FOSSACommsInterpreter/src/Interpreters/FOSSASAT2.h deleted file mode 100644 index 5bc127c..0000000 --- a/FOSSACommsInterpreter/src/Interpreters/FOSSASAT2.h +++ /dev/null @@ -1,35 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSASAT2_INTERPRETER_MODULE_H -#define FOSSASAT2_INTERPRETER_MODULE_H - -#include "../DatagramEncoder/FOSSASAT2/FOSSASAT2_DatagramEncoder.h" -#include "../FrameDecoder/FOSSASAT2/FOSSASAT2_FrameDecoder.h" - -#include "../Message/FOSSASAT2/FOSSASAT2_SystemInfo.h" - - - -#endif //FOSSASAT2_INTERPRETER_MODULE_H diff --git a/FOSSACommsInterpreter/src/Message/FOSSASAT1B/FOSSASAT1B_SystemInfo.cpp b/FOSSACommsInterpreter/src/Message/FOSSASAT1B/FOSSASAT1B_SystemInfo.cpp deleted file mode 100644 index bc7e018..0000000 --- a/FOSSACommsInterpreter/src/Message/FOSSASAT1B/FOSSASAT1B_SystemInfo.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "FOSSASAT1B_SystemInfo.h" - -FOSSASAT1B::Messages::SystemInfo::SystemInfo(Frame &frame) { - this->batteryVoltage = frame.GetByteAt(0); - this->batteryVoltage *= 20; - - this->batteryChargingCurrent = frame.GetByteAt(1) | (frame.GetByteAt(2) << 8); - this->batteryChargingCurrent *= 10; - - this->batteryChargingVoltage = frame.GetByteAt(3); - this->batteryChargingVoltage *= 20; - - this->timeSinceLastReset = frame.GetByteAt(4); - timeSinceLastReset |= (frame.GetByteAt(5) << 8); - timeSinceLastReset |= (frame.GetByteAt(6) << 16); - timeSinceLastReset |= (frame.GetByteAt(7) << 24); - - this->powerConfiguration = frame.GetByteAt(8); - this->lowPowerModeActive = powerConfiguration & 0b00000001; - this->lowPowerModeEnabled = (powerConfiguration & 0b00000010) >> 1; - this->mpptTemperatureSwitchEnabled = (powerConfiguration & 0b00000100) >> 2; - this->mpptKeepAliveEnabled = (powerConfiguration & 0b00001000) >> 3; - this->transmissionsEnabled = (powerConfiguration & 0b00010000) >> 4; - - this->resetCounter = frame.GetByteAt(9) | (frame.GetByteAt(10) << 8); - - this->solarCellAVoltage = frame.GetByteAt(11); - this->solarCellAVoltage *= 20; - - this->solarCellBVoltage = frame.GetByteAt(12); - this->solarCellBVoltage *= 20; - - this->solarCellCVoltage = frame.GetByteAt(13); - this->solarCellCVoltage *= 20; - - { - int16_t t = frame.GetByteAt(14) | (frame.GetByteAt(15) << 8); - this->batteryTemperature = t * 0.01f; - } - - { - int16_t t = frame.GetByteAt(16) | (frame.GetByteAt(17) << 8); - this->obcBoardTemperature = t * 0.01f; - } - - this-> mcuTemperature = frame.GetByteAt(18); -} diff --git a/FOSSACommsInterpreter/src/Message/FOSSASAT1B/FOSSASAT1B_SystemInfo.h b/FOSSACommsInterpreter/src/Message/FOSSASAT1B/FOSSASAT1B_SystemInfo.h deleted file mode 100644 index cc21767..0000000 --- a/FOSSACommsInterpreter/src/Message/FOSSASAT1B/FOSSASAT1B_SystemInfo.h +++ /dev/null @@ -1,70 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSASAT1B_SYSTEMINFO_H -#define FOSSASAT1B_SYSTEMINFO_H - -#include "../../Frame.h" - -namespace FOSSASAT1B -{ - -namespace Messages -{ - -class SystemInfo { -public: - explicit SystemInfo(Frame& frame); -private: - uint32_t batteryVoltage; - int32_t batteryChargingCurrent; - uint32_t batteryChargingVoltage; - - uint32_t timeSinceLastReset; - - uint8_t powerConfiguration; - bool lowPowerModeActive; - bool lowPowerModeEnabled; - bool mpptTemperatureSwitchEnabled; - bool mpptKeepAliveEnabled; - bool transmissionsEnabled; - - uint16_t resetCounter; - - uint32_t solarCellAVoltage; - uint32_t solarCellBVoltage; - uint32_t solarCellCVoltage; - - float batteryTemperature; - float obcBoardTemperature; - int8_t mcuTemperature; -}; - -} - -} - - - -#endif //FOSSASAT1_SYSTEMINFO_H diff --git a/FOSSACommsInterpreter/src/Message/FOSSASAT2/FOSSASAT2_SystemInfo.cpp b/FOSSACommsInterpreter/src/Message/FOSSASAT2/FOSSASAT2_SystemInfo.cpp deleted file mode 100644 index 6f9fb32..0000000 --- a/FOSSACommsInterpreter/src/Message/FOSSASAT2/FOSSASAT2_SystemInfo.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "FOSSASAT2_SystemInfo.h" - -FOSSASAT2::Messages::SystemInfo::SystemInfo(Frame &frame) { - this->mpptOutputVoltage = frame.GetByteAt(0); - this->mpptOutputVoltage *= 20; - - this->mpptOutputCurrent = frame.GetByteAt(1) | (frame.GetByteAt(2) << 8); - this->mpptOutputCurrent *= 20; - - this->unixTimestamp = frame.GetByteAt(3); - this->unixTimestamp |= (frame.GetByteAt(4) << 8); - this->unixTimestamp |= (frame.GetByteAt(5) << 16); - this->unixTimestamp |= (frame.GetByteAt(6) << 24); - - this->powerConfiguration = frame.GetByteAt(7); - this->transmissionsEnabled = powerConfiguration & 0b00000001; // bit 0 - this->lowPowerModeEnabled = (powerConfiguration & 0b00000010) >> 1; // bit 1 - - this->currentlyActivePowerModeLSB = (powerConfiguration & 0b00000100) >> 2; // bit 2 - this->currentlyActivePowerModeA = (powerConfiguration & 0b00001000) >> 3; // bit 3 - this->currentlyActivePowerModeMSB = (powerConfiguration & 0b00010000) >> 4; // bit 4 - this->currentlyActivePowerMode = currentlyActivePowerModeLSB; - this->currentlyActivePowerMode |= (currentlyActivePowerModeA << 1); - this->currentlyActivePowerMode |= (currentlyActivePowerModeMSB << 2); - - this->lowPowerModeActive = currentlyActivePowerMode == 0; - this->sleepMode = currentlyActivePowerMode == 2; - - - this->mpptTemperatureSwitchEnabled = (powerConfiguration & 0b00100000) >> 5; // bit 5 - this->mpptKeepAliveEnabled = (powerConfiguration & 0b01000000) >> 6; // bit 6 - - this->resetCounter = frame.GetByteAt(8) | (frame.GetByteAt(9) << 8); - - this->solarPanel_XA_Voltage = frame.GetByteAt(10); - this->solarPanel_XB_Voltage = frame.GetByteAt(11); - this->solarPanel_ZA_Voltage = frame.GetByteAt(12); - this->solarPanel_ZB_Voltage = frame.GetByteAt(13); - this->solarPanel_Y_Voltage = frame.GetByteAt(14); - - { - int16_t t = frame.GetByteAt(15) | (frame.GetByteAt(16) << 8); - this->batteryTemperature = t * 0.01f; - } - - { - int16_t t = frame.GetByteAt(17) | (frame.GetByteAt(18) << 8); - this->obcBoardTemperature = t * 0.01f; - } - - this->flashSystemInfoPageCRCErrorCounter = frame.GetByteAt(19); - this->flashSystemInfoPageCRCErrorCounter |= (frame.GetByteAt(20) << 8); - this->flashSystemInfoPageCRCErrorCounter |= (frame.GetByteAt(21) << 16); - this->flashSystemInfoPageCRCErrorCounter |= (frame.GetByteAt(22) << 24); -} - - - -uint32_t FOSSASAT2::Messages::SystemInfo::getMpptOutputVoltage() const { - return mpptOutputVoltage; -} -int32_t FOSSASAT2::Messages::SystemInfo::getMpptOutputCurrent() const { - return mpptOutputCurrent; -} -uint32_t FOSSASAT2::Messages::SystemInfo::getUnixTimestamp() const { - return unixTimestamp; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getPowerConfiguration() const { - return powerConfiguration; -} -bool FOSSASAT2::Messages::SystemInfo::isTransmissionsEnabled() const { - return transmissionsEnabled; -} -bool FOSSASAT2::Messages::SystemInfo::isLowPowerModeEnabled() const { - return lowPowerModeEnabled; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getCurrentlyActivePowerModeLSB() const { - return currentlyActivePowerModeLSB; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getCurrentlyActivePowerModeA() const { - return currentlyActivePowerModeA; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getCurrentlyActivePowerModeMSB() const { - return currentlyActivePowerModeMSB; -} -uint32_t FOSSASAT2::Messages::SystemInfo::getCurrentlyActivePowerMode() const { - return currentlyActivePowerMode; -} -bool FOSSASAT2::Messages::SystemInfo::isLowPowerModeActive() const { - return lowPowerModeActive; -} -bool FOSSASAT2::Messages::SystemInfo::isSleepMode() const { - return sleepMode; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getMpptTemperatureSwitchEnabled() const { - return mpptTemperatureSwitchEnabled; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getMpptKeepAliveEnabled() const { - return mpptKeepAliveEnabled; -} -uint16_t FOSSASAT2::Messages::SystemInfo::getResetCounter() const { - return resetCounter; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getSolarPanel_XA_Voltage() const { - return solarPanel_XA_Voltage; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getSolarPanel_XB_Voltage() const { - return solarPanel_XB_Voltage; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getSolarPanel_ZA_Voltage() const { - return solarPanel_ZA_Voltage; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getSolarPanel_ZB_Voltage() const { - return solarPanel_ZB_Voltage; -} -uint8_t FOSSASAT2::Messages::SystemInfo::getSolarPanel_Y_Voltage() const { - return solarPanel_Y_Voltage; -} -float FOSSASAT2::Messages::SystemInfo::getBatteryTemperature() const { - return batteryTemperature; -} -float FOSSASAT2::Messages::SystemInfo::getObcBoardTemperature() const { - return obcBoardTemperature; -} -int32_t FOSSASAT2::Messages::SystemInfo::getFlashSystemInfoPageCRCErrorCounter() const { - return flashSystemInfoPageCRCErrorCounter; -} diff --git a/FOSSACommsInterpreter/src/Message/FOSSASAT2/FOSSASAT2_SystemInfo.h b/FOSSACommsInterpreter/src/Message/FOSSASAT2/FOSSASAT2_SystemInfo.h deleted file mode 100644 index 99e7883..0000000 --- a/FOSSACommsInterpreter/src/Message/FOSSASAT2/FOSSASAT2_SystemInfo.h +++ /dev/null @@ -1,106 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSASAT2_SYSTEMINFO_H -#define FOSSASAT2_SYSTEMINFO_H - -#include "../../Frame.h" - -namespace FOSSASAT2 -{ - -namespace Messages -{ - -class SystemInfo { -public: - explicit SystemInfo(Frame& frame); - - uint32_t getMpptOutputVoltage() const; - int32_t getMpptOutputCurrent() const; - uint32_t getUnixTimestamp() const; - uint8_t getPowerConfiguration() const; - bool isTransmissionsEnabled() const; - bool isLowPowerModeEnabled() const; - uint8_t getCurrentlyActivePowerModeLSB() const; - uint8_t getCurrentlyActivePowerModeA() const; - uint8_t getCurrentlyActivePowerModeMSB() const; - uint32_t getCurrentlyActivePowerMode() const; - bool isLowPowerModeActive() const; - bool isSleepMode() const; - uint8_t getMpptTemperatureSwitchEnabled() const; - uint8_t getMpptKeepAliveEnabled() const; - uint16_t getResetCounter() const; - uint8_t getSolarPanel_XA_Voltage() const; - uint8_t getSolarPanel_XB_Voltage() const; - uint8_t getSolarPanel_ZA_Voltage() const; - uint8_t getSolarPanel_ZB_Voltage() const; - uint8_t getSolarPanel_Y_Voltage() const; - float getBatteryTemperature() const; - float getObcBoardTemperature() const; - int32_t getFlashSystemInfoPageCRCErrorCounter() const; -private: - uint32_t mpptOutputVoltage; - int32_t mpptOutputCurrent; - - uint32_t unixTimestamp; - - uint8_t powerConfiguration; - bool transmissionsEnabled; - bool lowPowerModeEnabled; - - uint8_t currentlyActivePowerModeLSB; - uint8_t currentlyActivePowerModeA; - uint8_t currentlyActivePowerModeMSB; - uint32_t currentlyActivePowerMode; - - bool lowPowerModeActive; - bool sleepMode; - - - uint8_t mpptTemperatureSwitchEnabled; - uint8_t mpptKeepAliveEnabled; - - uint16_t resetCounter; - - uint8_t solarPanel_XA_Voltage; - uint8_t solarPanel_XB_Voltage; - uint8_t solarPanel_ZA_Voltage; - uint8_t solarPanel_ZB_Voltage; - uint8_t solarPanel_Y_Voltage; - - float batteryTemperature; - float obcBoardTemperature; - - int32_t flashSystemInfoPageCRCErrorCounter; -}; - -} - -} - - - - -#endif //FOSSASAT2_SYSTEMINFO_H diff --git a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_CarrierChangeResult.cpp b/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_CarrierChangeResult.cpp deleted file mode 100644 index db5cdbf..0000000 --- a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_CarrierChangeResult.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "GroundStation_CarrierChangeResult.h" - -GroundStation::Messages::CarrierChangeResult::CarrierChangeResult(Frame &frame) -{ - -} diff --git a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_CarrierChangeResult.h b/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_CarrierChangeResult.h deleted file mode 100644 index f5b551a..0000000 --- a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_CarrierChangeResult.h +++ /dev/null @@ -1,48 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef GroundStation_CARRIER_CHANGE_RESULT_H -#define GroundStation_CARRIER_CHANGE_RESULT_H - -#include "../../Frame.h" - -namespace GroundStation -{ - -namespace Messages -{ - -class CarrierChangeResult { -public: - explicit CarrierChangeResult(Frame& frame); -}; - -} - -} - - - - -#endif //GroundStation_CARRIER_CHANGE_RESULT_H diff --git a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_ConfigurationChangeResult.cpp b/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_ConfigurationChangeResult.cpp deleted file mode 100644 index 4524471..0000000 --- a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_ConfigurationChangeResult.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "GroundStation_ConfigurationChangeResult.h" - -GroundStation::Messages::ConfigurationChangeResult::ConfigurationChangeResult(Frame &frame) -{ - this->modemType = frame.GetByteAt(0); - - { - uint32_t temp = frame.GetByteAt(1); - temp |= (frame.GetByteAt(2) << 8); - temp |= (frame.GetByteAt(3) << 16); - temp |= (frame.GetByteAt(4) << 24); - - float tempFloat = 0.0f; - memcpy(&tempFloat, &temp, 4); - - this->carrierFrequency = tempFloat; - } - - - int8_t outputPower = frame.GetByteAt(5); - - { - uint32_t temp = frame.GetByteAt(6); - temp |= (frame.GetByteAt(7) << 8); - temp |= (frame.GetByteAt(8) << 16); - temp |= (frame.GetByteAt(9) << 24); - - float tempFloat = 0.0f; - memcpy(&tempFloat, &temp, 4); - - this->currentLimit = tempFloat; - } - - { - uint32_t temp = frame.GetByteAt(10); - temp |= (frame.GetByteAt(11) << 8); - temp |= (frame.GetByteAt(12) << 16); - temp |= (frame.GetByteAt(13) << 24); - - float tempFloat = 0.0f; - memcpy(&tempFloat, &temp, 4); - - this->loraBandwidth = tempFloat; - } - - - this->loraSpreadingFactor = frame.GetByteAt(14); - this->loraCodingRate = frame.GetByteAt(15); - this->loraPreambleLength = frame.GetByteAt(16) | (frame.GetByteAt(17) << 8); - - { - uint32_t temp = frame.GetByteAt(18); - temp |= (frame.GetByteAt(19) << 8); - temp |= (frame.GetByteAt(20) << 16); - temp |= (frame.GetByteAt(21) << 24); - - float tempFloat = 0.0f; - memcpy(&tempFloat, &temp, 4); - - this->gfskBitRate = tempFloat; - } - - - { - uint32_t temp = frame.GetByteAt(22); - temp |= (frame.GetByteAt(23) << 8); - temp |= (frame.GetByteAt(24) << 16); - temp |= (frame.GetByteAt(25) << 24); - - float tempFloat = 0.0f; - memcpy(&tempFloat, &temp, 4); - - this->gfskFrequencyDeviation = tempFloat; - } - - { - uint32_t temp = frame.GetByteAt(26); - temp |= (frame.GetByteAt(27) << 8); - temp |= (frame.GetByteAt(28) << 16); - temp |= (frame.GetByteAt(29) << 24); - - float tempFloat = 0.0f; - memcpy(&tempFloat, &temp, 4); - - this->gfskRxBandwidth = tempFloat; - } - - this->gfskPreambleLength = frame.GetByteAt(30) | (frame.GetByteAt(31) << 8); - - this->gfskDataShapingBTProduct = frame.GetByteAt(32); -} diff --git a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_ConfigurationChangeResult.h b/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_ConfigurationChangeResult.h deleted file mode 100644 index 5191fab..0000000 --- a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_ConfigurationChangeResult.h +++ /dev/null @@ -1,65 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef GroundStation_CONFIG_CHANGE_H -#define GroundStation_CONFIG_CHANGE_H - -#include "../../Frame.h" - -namespace GroundStation -{ - -namespace Messages -{ - -class ConfigurationChangeResult { -public: - explicit ConfigurationChangeResult(Frame& frame); -private: - uint8_t modemType; - - float carrierFrequency; - - int8_t outputPower; - float currentLimit; - - float loraBandwidth; - uint8_t loraSpreadingFactor; - uint8_t loraCodingRate; - uint16_t loraPreambleLength; - float gfskBitRate; - float gfskFrequencyDeviation; - float gfskRxBandwidth; - uint16_t gfskPreambleLength; - int8_t gfskDataShapingBTProduct; -}; - -} - -} - - - - -#endif //FOSSASAT2_SYSTEMINFO_H diff --git a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_HandshakeResult.cpp b/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_HandshakeResult.cpp deleted file mode 100644 index e8652a5..0000000 --- a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_HandshakeResult.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#include "GroundStation_HandshakeResult.h" diff --git a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_HandshakeResult.h b/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_HandshakeResult.h deleted file mode 100644 index d9a35f7..0000000 --- a/FOSSACommsInterpreter/src/Message/GroundStation/GroundStation_HandshakeResult.h +++ /dev/null @@ -1,48 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef GroundStation_HANDSHAKE_RESULT_H -#define GroundStation_HANDSHAKE_RESULT_H - -#include "../../Frame.h" - -namespace GroundStation -{ - -namespace Messages -{ - -class HandshakeResult { -public: - explicit HandshakeResult(Frame& frame); -}; - -} - -} - - - - -#endif //GroundStation_HANDSHAKE_RESULT_H diff --git a/FOSSACommsInterpreter/src/OperationID.h b/FOSSACommsInterpreter/src/OperationID.h deleted file mode 100644 index 9f8ed19..0000000 --- a/FOSSACommsInterpreter/src/OperationID.h +++ /dev/null @@ -1,49 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef FOSSACOMMSINTERPRETER_OPERATIONID_H -#define FOSSACOMMSINTERPRETER_OPERATIONID_H - -/**---------------------------------------------------------- - * - * Operation IDs - * - What type of request/response has been sent/received. - * - -----------------------------------------------------------*/ - -enum OperationID { - HANDSHAKE, - FRAME, - CONFIG, - CARRIER -}; - - -/**---------------------------------------------------------- - * - * End of operation IDs - * - ----------------------------------------------------------*/ - -#endif //FOSSACOMMSINTERPRETER_OPERATIONID_H diff --git a/FOSSACommsInterpreter/src/SatVersion.h b/FOSSACommsInterpreter/src/SatVersion.h deleted file mode 100644 index 78170df..0000000 --- a/FOSSACommsInterpreter/src/SatVersion.h +++ /dev/null @@ -1,36 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef SATVERSION_H -#define SATVERSION_H - -#include - -enum SatVersion { - V_FOSSASAT1B, - V_FOSSASAT2 -}; - - -#endif //SATVERSION_H diff --git a/FOSSACommsInterpreter/src/SleepInterval.h b/FOSSACommsInterpreter/src/SleepInterval.h deleted file mode 100644 index d584e22..0000000 --- a/FOSSACommsInterpreter/src/SleepInterval.h +++ /dev/null @@ -1,37 +0,0 @@ -// MIT LICENSE -// -// Copyright (c) 2020 FOSSA Systems -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -#ifndef SLEEPINTERVAL_H -#define SLEEPINTERVAL_H - -#include - -struct SleepInterval { - int16_t firstSleepIntervalVoltageLevel; - int16_t firstSleepIntervalLength; - int16_t secondSleepIntervalLength; - int16_t thirdSleepIntervalLength; -}; - -#endif //SLEEPINTERVAL_H diff --git a/FOSSASatTracker/FOSSASatTracker/.gitignore b/Misc/FOSSASatTracker/FOSSASatTracker/.gitignore similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/.gitignore rename to Misc/FOSSASatTracker/FOSSASatTracker/.gitignore diff --git a/FOSSASatTracker/FOSSASatTracker/Cmakelists.txt b/Misc/FOSSASatTracker/FOSSASatTracker/Cmakelists.txt similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/Cmakelists.txt rename to Misc/FOSSASatTracker/FOSSASatTracker/Cmakelists.txt diff --git a/FOSSASatTracker/FOSSASatTracker/example/main.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/example/main.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/example/main.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/example/main.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/examples/satAndObserverInfo.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/examples/satAndObserverInfo.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/examples/satAndObserverInfo.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/examples/satAndObserverInfo.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/Cmakelists.txt b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/Cmakelists.txt similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/Cmakelists.txt rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/Cmakelists.txt diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gException.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gException.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gException.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gException.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrix.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrix.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrix.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrix.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrix.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrix.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrix.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrix.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gMatrixTempl.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gObserver.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gObserver.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gObserver.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gObserver.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gObserver.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gObserver.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gObserver.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gObserver.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gSatTEME.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gSatTEME.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gSatTEME.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gSatTEME.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gSatTEME.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gSatTEME.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gSatTEME.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gSatTEME.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTime.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTime.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTime.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTime.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTime.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTime.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTime.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTime.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTimeSpan.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleFileAccessor.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleFileAccessor.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleParser.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleParser.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleParser.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleParser.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleParser.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleParser.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleParser.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gTleParser.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVector.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVector.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVector.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVector.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVector.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVector.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVector.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVector.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/gVectorTempl.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/mathUtils.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/mathUtils.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/mathUtils.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/mathUtils.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/mathUtils.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/mathUtils.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/mathUtils.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/mathUtils.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.cpp similarity index 96% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.cpp index afc479a..edd1757 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.cpp +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.cpp @@ -1,724 +1,724 @@ -/* ---------------------------------------------------------------- -* -* sgp4ext.cpp -* -* this file contains extra routines needed for the main test program for sgp4. -* these routines are derived from the astro libraries. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 7 may 08 david vallado -* fix sgn -* changes : -* 2 apr 07 david vallado -* fix jday floor and str lengths -* updates for constants -* 14 aug 06 david vallado -* original baseline -* ---------------------------------------------------------------- */ - -#include "sgp4ext.h" - - -double sgn - ( - double x - ) - { - if (x < 0.0) - { - return -1.0; - } - else - { - return 1.0; - } - - } // end sgn - -/* ----------------------------------------------------------------------------- -* -* function mag -* -* this procedure finds the magnitude of a vector. the tolerance is set to -* 0.000001, thus the 1.0e-12 for the squared test of underflows. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* vec - vector -* -* outputs : -* vec - answer stored in fourth component -* -* locals : -* none. -* -* coupling : -* none. -* --------------------------------------------------------------------------- */ - -double mag - ( - double x[3] - ) - { - return sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]); - } // end mag - -/* ----------------------------------------------------------------------------- -* -* procedure cross -* -* this procedure crosses two vectors. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* vec1 - vector number 1 -* vec2 - vector number 2 -* -* outputs : -* outvec - vector result of a x b -* -* locals : -* none. -* -* coupling : -* mag magnitude of a vector - ---------------------------------------------------------------------------- */ - -void cross - ( - double vec1[3], double vec2[3], double outvec[3] - ) - { - outvec[0]= vec1[1]*vec2[2] - vec1[2]*vec2[1]; - outvec[1]= vec1[2]*vec2[0] - vec1[0]*vec2[2]; - outvec[2]= vec1[0]*vec2[1] - vec1[1]*vec2[0]; - } // end cross - - -/* ----------------------------------------------------------------------------- -* -* function dot -* -* this function finds the dot product of two vectors. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* vec1 - vector number 1 -* vec2 - vector number 2 -* -* outputs : -* dot - result -* -* locals : -* none. -* -* coupling : -* none. -* -* --------------------------------------------------------------------------- */ - -double dot - ( - double x[3], double y[3] - ) - { - return (x[0]*y[0] + x[1]*y[1] + x[2]*y[2]); - } // end dot - -/* ----------------------------------------------------------------------------- -* -* procedure angle -* -* this procedure calculates the angle between two vectors. the output is -* set to 999999.1 to indicate an undefined value. be sure to check for -* this at the output phase. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* vec1 - vector number 1 -* vec2 - vector number 2 -* -* outputs : -* theta - angle between the two vectors -pi to pi -* -* locals : -* temp - temporary real variable -* -* coupling : -* dot dot product of two vectors -* --------------------------------------------------------------------------- */ - -double angle - ( - double vec1[3], - double vec2[3] - ) - { - double small, undefined, magv1, magv2, temp; - small = 0.00000001; - undefined = 999999.1; - - magv1 = mag(vec1); - magv2 = mag(vec2); - - if (magv1*magv2 > small*small) - { - temp= dot(vec1,vec2) / (magv1*magv2); - if (fabs( temp ) > 1.0) - temp= sgn(temp) * 1.0; - return acos( temp ); - } - else - return undefined; - } // end angle - - -/* ----------------------------------------------------------------------------- -* -* function asinh -* -* this function evaluates the inverse hyperbolic sine function. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* xval - angle value any real -* -* outputs : -* arcsinh - result any real -* -* locals : -* none. -* -* coupling : -* none. -* -* --------------------------------------------------------------------------- */ - -double asinh - ( - double xval - ) - { - return log( xval + sqrt( xval*xval + 1.0 ) ); - } // end asinh - - -/* ----------------------------------------------------------------------------- -* -* function newtonnu -* -* this function solves keplers equation when the true anomaly is known. -* the mean and eccentric, parabolic, or hyperbolic anomaly is also found. -* the parabolic limit at 168ø is arbitrary. the hyperbolic anomaly is also -* limited. the hyperbolic sine is used because it's not double valued. -* -* author : david vallado 719-573-2600 27 may 2002 -* -* revisions -* vallado - fix small 24 sep 2002 -* -* inputs description range / units -* ecc - eccentricity 0.0 to -* nu - true anomaly -2pi to 2pi rad -* -* outputs : -* e0 - eccentric anomaly 0.0 to 2pi rad 153.02 ø -* m - mean anomaly 0.0 to 2pi rad 151.7425 ø -* -* locals : -* e1 - eccentric anomaly, next value rad -* sine - sine of e -* cose - cosine of e -* ktr - index -* -* coupling : -* asinh - arc hyperbolic sine -* -* references : -* vallado 2007, 85, alg 5 -* --------------------------------------------------------------------------- */ - -void newtonnu - ( - double ecc, double nu, - double& e0, double& m - ) - { - double small, sine, cose; - - // --------------------- implementation --------------------- - e0= 999999.9; - m = 999999.9; - small = 0.00000001; - - // --------------------------- circular ------------------------ - if ( fabs( ecc ) < small ) - { - m = nu; - e0= nu; - } - else - // ---------------------- elliptical ----------------------- - if ( ecc < 1.0-small ) - { - sine= ( sqrt( 1.0 -ecc*ecc ) * sin(nu) ) / ( 1.0 +ecc*cos(nu) ); - cose= ( ecc + cos(nu) ) / ( 1.0 + ecc*cos(nu) ); - e0 = atan2( sine,cose ); - m = e0 - ecc*sin(e0); - } - else - // -------------------- hyperbolic -------------------- - if ( ecc > 1.0 + small ) - { - if ((ecc > 1.0 ) && (fabs(nu)+0.00001 < pi-acos(1.0 /ecc))) - { - sine= ( sqrt( ecc*ecc-1.0 ) * sin(nu) ) / ( 1.0 + ecc*cos(nu) ); - e0 = asinh( sine ); - m = ecc*sinh(e0) - e0; - } - } - else - // ----------------- parabolic --------------------- - if ( fabs(nu) < 168.0*pi/180.0 ) - { - e0= tan( nu*0.5 ); - m = e0 + (e0*e0*e0)/3.0; - } - - if ( ecc < 1.0 ) - { - m = fmod( m,2.0 *pi ); - if ( m < 0.0 ) - m = m + 2.0 *pi; - e0 = fmod( e0,2.0 *pi ); - } - } // end newtonnu - - -/* ----------------------------------------------------------------------------- -* -* function rv2coe -* -* this function finds the classical orbital elements given the geocentric -* equatorial position and velocity vectors. -* -* author : david vallado 719-573-2600 21 jun 2002 -* -* revisions -* vallado - fix special cases 5 sep 2002 -* vallado - delete extra check in inclination code 16 oct 2002 -* vallado - add constant file use 29 jun 2003 -* vallado - add mu 2 apr 2007 -* -* inputs description range / units -* r - ijk position vector km -* v - ijk velocity vector km / s -* mu - gravitational parameter km3 / s2 -* -* outputs : -* p - semilatus rectum km -* a - semimajor axis km -* ecc - eccentricity -* incl - inclination 0.0 to pi rad -* omega - longitude of ascending node 0.0 to 2pi rad -* argp - argument of perigee 0.0 to 2pi rad -* nu - true anomaly 0.0 to 2pi rad -* m - mean anomaly 0.0 to 2pi rad -* arglat - argument of latitude (ci) 0.0 to 2pi rad -* truelon - true longitude (ce) 0.0 to 2pi rad -* lonper - longitude of periapsis (ee) 0.0 to 2pi rad -* -* locals : -* hbar - angular momentum h vector km2 / s -* ebar - eccentricity e vector -* nbar - line of nodes n vector -* c1 - v**2 - u/r -* rdotv - r dot v -* hk - hk unit vector -* sme - specfic mechanical energy km2 / s2 -* i - index -* e - eccentric, parabolic, -* hyperbolic anomaly rad -* temp - temporary variable -* typeorbit - type of orbit ee, ei, ce, ci -* -* coupling : -* mag - magnitude of a vector -* cross - cross product of two vectors -* angle - find the angle between two vectors -* newtonnu - find the mean anomaly -* -* references : -* vallado 2007, 126, alg 9, ex 2-5 -* --------------------------------------------------------------------------- */ - -void rv2coe - ( - double r[3], double v[3], double mu, - double& p, double& a, double& ecc, double& incl, double& omega, double& argp, - double& nu, double& m, double& arglat, double& truelon, double& lonper - ) - { - double undefined, small, hbar[3], nbar[3], magr, magv, magn, ebar[3], sme, - rdotv, infinite, temp, c1, hk, twopi, magh, halfpi, e; - - int i; - char typeorbit[3]; - - twopi = 2.0 * pi; - halfpi = 0.5 * pi; - small = 0.00000001; - undefined = 999999.1; - infinite = 999999.9; - - // ------------------------- implementation ----------------- - magr = mag( r ); - magv = mag( v ); - - // ------------------ find h n and e vectors ---------------- - cross( r,v, hbar ); - magh = mag( hbar ); - if ( magh > small ) - { - nbar[0]= -hbar[1]; - nbar[1]= hbar[0]; - nbar[2]= 0.0; - magn = mag( nbar ); - c1 = magv*magv - mu /magr; - rdotv = dot( r,v ); - for (i= 0; i <= 2; i++) - ebar[i]= (c1*r[i] - rdotv*v[i])/mu; - ecc = mag( ebar ); - - // ------------ find a e and semi-latus rectum ---------- - sme= ( magv*magv*0.5 ) - ( mu /magr ); - if ( fabs( sme ) > small ) - a= -mu / (2.0 *sme); - else - a= infinite; - p = magh*magh/mu; - - // ----------------- find inclination ------------------- - hk= hbar[2]/magh; - incl= acos( hk ); - - // -------- determine type of orbit for later use -------- - // ------ elliptical, parabolic, hyperbolic inclined ------- - strcpy(typeorbit,"ei"); - if ( ecc < small ) - { - // ---------------- circular equatorial --------------- - if ((incl small ) - { - temp= nbar[0] / magn; - if ( fabs(temp) > 1.0 ) - temp= sgn(temp); - omega= acos( temp ); - if ( nbar[1] < 0.0 ) - omega= twopi - omega; - } - else - omega= undefined; - - // ---------------- find argument of perigee --------------- - if ( strcmp(typeorbit,"ei") == 0 ) - { - argp = angle( nbar,ebar); - if ( ebar[2] < 0.0 ) - argp= twopi - argp; - } - else - argp= undefined; - - // ------------ find true anomaly at epoch ------------- - if ( typeorbit[0] == 'e' ) - { - nu = angle( ebar,r); - if ( rdotv < 0.0 ) - nu= twopi - nu; - } - else - nu= undefined; - - // ---- find argument of latitude - circular inclined ----- - if ( strcmp(typeorbit,"ci") == 0 ) - { - arglat = angle( nbar,r ); - if ( r[2] < 0.0 ) - arglat= twopi - arglat; - m = arglat; - } - else - arglat= undefined; - - // -- find longitude of perigee - elliptical equatorial ---- - if (( ecc>small ) && (strcmp(typeorbit,"ee") == 0)) - { - temp= ebar[0]/ecc; - if ( fabs(temp) > 1.0 ) - temp= sgn(temp); - lonper= acos( temp ); - if ( ebar[1] < 0.0 ) - lonper= twopi - lonper; - if ( incl > halfpi ) - lonper= twopi - lonper; - } - else - lonper= undefined; - - // -------- find true longitude - circular equatorial ------ - if (( magr>small ) && ( strcmp(typeorbit,"ce") == 0 )) - { - temp= r[0]/magr; - if ( fabs(temp) > 1.0 ) - temp= sgn(temp); - truelon= acos( temp ); - if ( r[1] < 0.0 ) - truelon= twopi - truelon; - if ( incl > halfpi ) - truelon= twopi - truelon; - m = truelon; - } - else - truelon= undefined; - - // ------------ find mean anomaly for all orbits ----------- - if ( typeorbit[0] == 'e' ) - newtonnu(ecc,nu, e, m); - } - else - { - p = undefined; - a = undefined; - ecc = undefined; - incl = undefined; - omega= undefined; - argp = undefined; - nu = undefined; - m = undefined; - arglat = undefined; - truelon= undefined; - lonper = undefined; - } - } // end rv2coe - -/* ----------------------------------------------------------------------------- -* -* procedure jday -* -* this procedure finds the julian date given the year, month, day, and time. -* the julian date is defined by each elapsed day since noon, jan 1, 4713 bc. -* -* algorithm : calculate the answer in one step for efficiency -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* year - year 1900 .. 2100 -* mon - month 1 .. 12 -* day - day 1 .. 28,29,30,31 -* hr - universal time hour 0 .. 23 -* min - universal time min 0 .. 59 -* sec - universal time sec 0.0 .. 59.999 -* -* outputs : -* jd - julian date days from 4713 bc -* -* locals : -* none. -* -* coupling : -* none. -* -* references : -* vallado 2007, 189, alg 14, ex 3-14 -* -* --------------------------------------------------------------------------- */ - -void jday - ( - int year, int mon, int day, int hr, int minute, double sec, - double& jd - ) - { - jd = 367.0 * year - - floor((7 * (year + floor((mon + 9) / 12.0))) * 0.25) + - floor( 275 * mon / 9.0 ) + - day + 1721013.5 + - ((sec / 60.0 + minute) / 60.0 + hr) / 24.0; // ut in days - // - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5; - } // end jday - -/* ----------------------------------------------------------------------------- -* -* procedure days2mdhms -* -* this procedure converts the day of the year, days, to the equivalent month -* day, hour, minute and second. -* -* algorithm : set up array for the number of days per month -* find leap year - use 1900 because 2000 is a leap year -* loop through a temp value while the value is < the days -* perform int conversions to the correct day and month -* convert remainder into h m s using type conversions -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* year - year 1900 .. 2100 -* days - julian day of the year 0.0 .. 366.0 -* -* outputs : -* mon - month 1 .. 12 -* day - day 1 .. 28,29,30,31 -* hr - hour 0 .. 23 -* min - minute 0 .. 59 -* sec - second 0.0 .. 59.999 -* -* locals : -* dayofyr - day of year -* temp - temporary extended values -* inttemp - temporary int value -* i - index -* lmonth[12] - int array containing the number of days per month -* -* coupling : -* none. -* --------------------------------------------------------------------------- */ - -void days2mdhms - ( - int year, double days, - int& mon, int& day, int& hr, int& minute, double& sec - ) - { - int i, inttemp, dayofyr; - double temp; - int lmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - - dayofyr = (int)floor(days); - /* ----------------- find month and day of month ---------------- */ - if ( (year % 4) == 0 ) - lmonth[1] = 29; - - i = 1; - inttemp = 0; - while ((dayofyr > inttemp + lmonth[i-1]) && (i < 12)) - { - inttemp = inttemp + lmonth[i-1]; - i++; - } - mon = i; - day = dayofyr - inttemp; - - /* ----------------- find hours minutes and seconds ------------- */ - temp = (days - dayofyr) * 24.0; - hr = (int)floor(temp); - temp = (temp - hr) * 60.0; - minute = (int)floor(temp); - sec = (temp - minute) * 60.0; - } // end days2mdhms - -/* ----------------------------------------------------------------------------- -* -* procedure invjday -* -* this procedure finds the year, month, day, hour, minute and second -* given the julian date. tu can be ut1, tdt, tdb, etc. -* -* algorithm : set up starting values -* find leap year - use 1900 because 2000 is a leap year -* find the elapsed days through the year in a loop -* call routine to find each individual value -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* jd - julian date days from 4713 bc -* -* outputs : -* year - year 1900 .. 2100 -* mon - month 1 .. 12 -* day - day 1 .. 28,29,30,31 -* hr - hour 0 .. 23 -* min - minute 0 .. 59 -* sec - second 0.0 .. 59.999 -* -* locals : -* days - day of year plus fractional -* portion of a day days -* tu - julian centuries from 0 h -* jan 0, 1900 -* temp - temporary double values -* leapyrs - number of leap years from 1900 -* -* coupling : -* days2mdhms - finds month, day, hour, minute and second given days and year -* -* references : -* vallado 2007, 208, alg 22, ex 3-13 -* --------------------------------------------------------------------------- */ - -void invjday - ( - double jd, - int& year, int& mon, int& day, - int& hr, int& minute, double& sec - ) - { - int leapyrs; - double days, tu, temp; - - /* --------------- find year and days of the year --------------- */ - temp = jd - 2415019.5; - tu = temp / 365.25; - year = 1900 + (int)floor(tu); - leapyrs = (int)floor((year - 1901) * 0.25); - - // optional nudge by 8.64x10-7 sec to get even outputs - days = temp - ((year - 1900) * 365.0 + leapyrs) + 0.00000000001; - - /* ------------ check for case of beginning of a year ----------- */ - if (days < 1.0) - { - year = year - 1; - leapyrs = (int)floor((year - 1901) * 0.25); - days = temp - ((year - 1900) * 365.0 + leapyrs); - } - - /* ----------------- find remaing data ------------------------- */ - days2mdhms(year, days, mon, day, hr, minute, sec); - sec = sec - 0.00000086400; - } // end invjday - - - - - +/* ---------------------------------------------------------------- +* +* sgp4ext.cpp +* +* this file contains extra routines needed for the main test program for sgp4. +* these routines are derived from the astro libraries. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 7 may 08 david vallado +* fix sgn +* changes : +* 2 apr 07 david vallado +* fix jday floor and str lengths +* updates for constants +* 14 aug 06 david vallado +* original baseline +* ---------------------------------------------------------------- */ + +#include "sgp4ext.h" + + +double sgn + ( + double x + ) + { + if (x < 0.0) + { + return -1.0; + } + else + { + return 1.0; + } + + } // end sgn + +/* ----------------------------------------------------------------------------- +* +* function mag +* +* this procedure finds the magnitude of a vector. the tolerance is set to +* 0.000001, thus the 1.0e-12 for the squared test of underflows. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* vec - vector +* +* outputs : +* vec - answer stored in fourth component +* +* locals : +* none. +* +* coupling : +* none. +* --------------------------------------------------------------------------- */ + +double mag + ( + double x[3] + ) + { + return sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]); + } // end mag + +/* ----------------------------------------------------------------------------- +* +* procedure cross +* +* this procedure crosses two vectors. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* vec1 - vector number 1 +* vec2 - vector number 2 +* +* outputs : +* outvec - vector result of a x b +* +* locals : +* none. +* +* coupling : +* mag magnitude of a vector + ---------------------------------------------------------------------------- */ + +void cross + ( + double vec1[3], double vec2[3], double outvec[3] + ) + { + outvec[0]= vec1[1]*vec2[2] - vec1[2]*vec2[1]; + outvec[1]= vec1[2]*vec2[0] - vec1[0]*vec2[2]; + outvec[2]= vec1[0]*vec2[1] - vec1[1]*vec2[0]; + } // end cross + + +/* ----------------------------------------------------------------------------- +* +* function dot +* +* this function finds the dot product of two vectors. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* vec1 - vector number 1 +* vec2 - vector number 2 +* +* outputs : +* dot - result +* +* locals : +* none. +* +* coupling : +* none. +* +* --------------------------------------------------------------------------- */ + +double dot + ( + double x[3], double y[3] + ) + { + return (x[0]*y[0] + x[1]*y[1] + x[2]*y[2]); + } // end dot + +/* ----------------------------------------------------------------------------- +* +* procedure angle +* +* this procedure calculates the angle between two vectors. the output is +* set to 999999.1 to indicate an undefined value. be sure to check for +* this at the output phase. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* vec1 - vector number 1 +* vec2 - vector number 2 +* +* outputs : +* theta - angle between the two vectors -pi to pi +* +* locals : +* temp - temporary real variable +* +* coupling : +* dot dot product of two vectors +* --------------------------------------------------------------------------- */ + +double angle + ( + double vec1[3], + double vec2[3] + ) + { + double small, undefined, magv1, magv2, temp; + small = 0.00000001; + undefined = 999999.1; + + magv1 = mag(vec1); + magv2 = mag(vec2); + + if (magv1*magv2 > small*small) + { + temp= dot(vec1,vec2) / (magv1*magv2); + if (fabs( temp ) > 1.0) + temp= sgn(temp) * 1.0; + return acos( temp ); + } + else + return undefined; + } // end angle + + +/* ----------------------------------------------------------------------------- +* +* function asinh +* +* this function evaluates the inverse hyperbolic sine function. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* xval - angle value any real +* +* outputs : +* arcsinh - result any real +* +* locals : +* none. +* +* coupling : +* none. +* +* --------------------------------------------------------------------------- */ + +double asinh + ( + double xval + ) + { + return log( xval + sqrt( xval*xval + 1.0 ) ); + } // end asinh + + +/* ----------------------------------------------------------------------------- +* +* function newtonnu +* +* this function solves keplers equation when the true anomaly is known. +* the mean and eccentric, parabolic, or hyperbolic anomaly is also found. +* the parabolic limit at 168ø is arbitrary. the hyperbolic anomaly is also +* limited. the hyperbolic sine is used because it's not double valued. +* +* author : david vallado 719-573-2600 27 may 2002 +* +* revisions +* vallado - fix small 24 sep 2002 +* +* inputs description range / units +* ecc - eccentricity 0.0 to +* nu - true anomaly -2pi to 2pi rad +* +* outputs : +* e0 - eccentric anomaly 0.0 to 2pi rad 153.02 ø +* m - mean anomaly 0.0 to 2pi rad 151.7425 ø +* +* locals : +* e1 - eccentric anomaly, next value rad +* sine - sine of e +* cose - cosine of e +* ktr - index +* +* coupling : +* asinh - arc hyperbolic sine +* +* references : +* vallado 2007, 85, alg 5 +* --------------------------------------------------------------------------- */ + +void newtonnu + ( + double ecc, double nu, + double& e0, double& m + ) + { + double small, sine, cose; + + // --------------------- implementation --------------------- + e0= 999999.9; + m = 999999.9; + small = 0.00000001; + + // --------------------------- circular ------------------------ + if ( fabs( ecc ) < small ) + { + m = nu; + e0= nu; + } + else + // ---------------------- elliptical ----------------------- + if ( ecc < 1.0-small ) + { + sine= ( sqrt( 1.0 -ecc*ecc ) * sin(nu) ) / ( 1.0 +ecc*cos(nu) ); + cose= ( ecc + cos(nu) ) / ( 1.0 + ecc*cos(nu) ); + e0 = atan2( sine,cose ); + m = e0 - ecc*sin(e0); + } + else + // -------------------- hyperbolic -------------------- + if ( ecc > 1.0 + small ) + { + if ((ecc > 1.0 ) && (fabs(nu)+0.00001 < pi-acos(1.0 /ecc))) + { + sine= ( sqrt( ecc*ecc-1.0 ) * sin(nu) ) / ( 1.0 + ecc*cos(nu) ); + e0 = asinh( sine ); + m = ecc*sinh(e0) - e0; + } + } + else + // ----------------- parabolic --------------------- + if ( fabs(nu) < 168.0*pi/180.0 ) + { + e0= tan( nu*0.5 ); + m = e0 + (e0*e0*e0)/3.0; + } + + if ( ecc < 1.0 ) + { + m = fmod( m,2.0 *pi ); + if ( m < 0.0 ) + m = m + 2.0 *pi; + e0 = fmod( e0,2.0 *pi ); + } + } // end newtonnu + + +/* ----------------------------------------------------------------------------- +* +* function rv2coe +* +* this function finds the classical orbital elements given the geocentric +* equatorial position and velocity vectors. +* +* author : david vallado 719-573-2600 21 jun 2002 +* +* revisions +* vallado - fix special cases 5 sep 2002 +* vallado - delete extra check in inclination code 16 oct 2002 +* vallado - add constant file use 29 jun 2003 +* vallado - add mu 2 apr 2007 +* +* inputs description range / units +* r - ijk position vector km +* v - ijk velocity vector km / s +* mu - gravitational parameter km3 / s2 +* +* outputs : +* p - semilatus rectum km +* a - semimajor axis km +* ecc - eccentricity +* incl - inclination 0.0 to pi rad +* omega - longitude of ascending node 0.0 to 2pi rad +* argp - argument of perigee 0.0 to 2pi rad +* nu - true anomaly 0.0 to 2pi rad +* m - mean anomaly 0.0 to 2pi rad +* arglat - argument of latitude (ci) 0.0 to 2pi rad +* truelon - true longitude (ce) 0.0 to 2pi rad +* lonper - longitude of periapsis (ee) 0.0 to 2pi rad +* +* locals : +* hbar - angular momentum h vector km2 / s +* ebar - eccentricity e vector +* nbar - line of nodes n vector +* c1 - v**2 - u/r +* rdotv - r dot v +* hk - hk unit vector +* sme - specfic mechanical energy km2 / s2 +* i - index +* e - eccentric, parabolic, +* hyperbolic anomaly rad +* temp - temporary variable +* typeorbit - type of orbit ee, ei, ce, ci +* +* coupling : +* mag - magnitude of a vector +* cross - cross product of two vectors +* angle - find the angle between two vectors +* newtonnu - find the mean anomaly +* +* references : +* vallado 2007, 126, alg 9, ex 2-5 +* --------------------------------------------------------------------------- */ + +void rv2coe + ( + double r[3], double v[3], double mu, + double& p, double& a, double& ecc, double& incl, double& omega, double& argp, + double& nu, double& m, double& arglat, double& truelon, double& lonper + ) + { + double undefined, small, hbar[3], nbar[3], magr, magv, magn, ebar[3], sme, + rdotv, infinite, temp, c1, hk, twopi, magh, halfpi, e; + + int i; + char typeorbit[3]; + + twopi = 2.0 * pi; + halfpi = 0.5 * pi; + small = 0.00000001; + undefined = 999999.1; + infinite = 999999.9; + + // ------------------------- implementation ----------------- + magr = mag( r ); + magv = mag( v ); + + // ------------------ find h n and e vectors ---------------- + cross( r,v, hbar ); + magh = mag( hbar ); + if ( magh > small ) + { + nbar[0]= -hbar[1]; + nbar[1]= hbar[0]; + nbar[2]= 0.0; + magn = mag( nbar ); + c1 = magv*magv - mu /magr; + rdotv = dot( r,v ); + for (i= 0; i <= 2; i++) + ebar[i]= (c1*r[i] - rdotv*v[i])/mu; + ecc = mag( ebar ); + + // ------------ find a e and semi-latus rectum ---------- + sme= ( magv*magv*0.5 ) - ( mu /magr ); + if ( fabs( sme ) > small ) + a= -mu / (2.0 *sme); + else + a= infinite; + p = magh*magh/mu; + + // ----------------- find inclination ------------------- + hk= hbar[2]/magh; + incl= acos( hk ); + + // -------- determine type of orbit for later use -------- + // ------ elliptical, parabolic, hyperbolic inclined ------- + strcpy(typeorbit,"ei"); + if ( ecc < small ) + { + // ---------------- circular equatorial --------------- + if ((incl small ) + { + temp= nbar[0] / magn; + if ( fabs(temp) > 1.0 ) + temp= sgn(temp); + omega= acos( temp ); + if ( nbar[1] < 0.0 ) + omega= twopi - omega; + } + else + omega= undefined; + + // ---------------- find argument of perigee --------------- + if ( strcmp(typeorbit,"ei") == 0 ) + { + argp = angle( nbar,ebar); + if ( ebar[2] < 0.0 ) + argp= twopi - argp; + } + else + argp= undefined; + + // ------------ find true anomaly at epoch ------------- + if ( typeorbit[0] == 'e' ) + { + nu = angle( ebar,r); + if ( rdotv < 0.0 ) + nu= twopi - nu; + } + else + nu= undefined; + + // ---- find argument of latitude - circular inclined ----- + if ( strcmp(typeorbit,"ci") == 0 ) + { + arglat = angle( nbar,r ); + if ( r[2] < 0.0 ) + arglat= twopi - arglat; + m = arglat; + } + else + arglat= undefined; + + // -- find longitude of perigee - elliptical equatorial ---- + if (( ecc>small ) && (strcmp(typeorbit,"ee") == 0)) + { + temp= ebar[0]/ecc; + if ( fabs(temp) > 1.0 ) + temp= sgn(temp); + lonper= acos( temp ); + if ( ebar[1] < 0.0 ) + lonper= twopi - lonper; + if ( incl > halfpi ) + lonper= twopi - lonper; + } + else + lonper= undefined; + + // -------- find true longitude - circular equatorial ------ + if (( magr>small ) && ( strcmp(typeorbit,"ce") == 0 )) + { + temp= r[0]/magr; + if ( fabs(temp) > 1.0 ) + temp= sgn(temp); + truelon= acos( temp ); + if ( r[1] < 0.0 ) + truelon= twopi - truelon; + if ( incl > halfpi ) + truelon= twopi - truelon; + m = truelon; + } + else + truelon= undefined; + + // ------------ find mean anomaly for all orbits ----------- + if ( typeorbit[0] == 'e' ) + newtonnu(ecc,nu, e, m); + } + else + { + p = undefined; + a = undefined; + ecc = undefined; + incl = undefined; + omega= undefined; + argp = undefined; + nu = undefined; + m = undefined; + arglat = undefined; + truelon= undefined; + lonper = undefined; + } + } // end rv2coe + +/* ----------------------------------------------------------------------------- +* +* procedure jday +* +* this procedure finds the julian date given the year, month, day, and time. +* the julian date is defined by each elapsed day since noon, jan 1, 4713 bc. +* +* algorithm : calculate the answer in one step for efficiency +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* year - year 1900 .. 2100 +* mon - month 1 .. 12 +* day - day 1 .. 28,29,30,31 +* hr - universal time hour 0 .. 23 +* min - universal time min 0 .. 59 +* sec - universal time sec 0.0 .. 59.999 +* +* outputs : +* jd - julian date days from 4713 bc +* +* locals : +* none. +* +* coupling : +* none. +* +* references : +* vallado 2007, 189, alg 14, ex 3-14 +* +* --------------------------------------------------------------------------- */ + +void jday + ( + int year, int mon, int day, int hr, int minute, double sec, + double& jd + ) + { + jd = 367.0 * year - + floor((7 * (year + floor((mon + 9) / 12.0))) * 0.25) + + floor( 275 * mon / 9.0 ) + + day + 1721013.5 + + ((sec / 60.0 + minute) / 60.0 + hr) / 24.0; // ut in days + // - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5; + } // end jday + +/* ----------------------------------------------------------------------------- +* +* procedure days2mdhms +* +* this procedure converts the day of the year, days, to the equivalent month +* day, hour, minute and second. +* +* algorithm : set up array for the number of days per month +* find leap year - use 1900 because 2000 is a leap year +* loop through a temp value while the value is < the days +* perform int conversions to the correct day and month +* convert remainder into h m s using type conversions +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* year - year 1900 .. 2100 +* days - julian day of the year 0.0 .. 366.0 +* +* outputs : +* mon - month 1 .. 12 +* day - day 1 .. 28,29,30,31 +* hr - hour 0 .. 23 +* min - minute 0 .. 59 +* sec - second 0.0 .. 59.999 +* +* locals : +* dayofyr - day of year +* temp - temporary extended values +* inttemp - temporary int value +* i - index +* lmonth[12] - int array containing the number of days per month +* +* coupling : +* none. +* --------------------------------------------------------------------------- */ + +void days2mdhms + ( + int year, double days, + int& mon, int& day, int& hr, int& minute, double& sec + ) + { + int i, inttemp, dayofyr; + double temp; + int lmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + dayofyr = (int)floor(days); + /* ----------------- find month and day of month ---------------- */ + if ( (year % 4) == 0 ) + lmonth[1] = 29; + + i = 1; + inttemp = 0; + while ((dayofyr > inttemp + lmonth[i-1]) && (i < 12)) + { + inttemp = inttemp + lmonth[i-1]; + i++; + } + mon = i; + day = dayofyr - inttemp; + + /* ----------------- find hours minutes and seconds ------------- */ + temp = (days - dayofyr) * 24.0; + hr = (int)floor(temp); + temp = (temp - hr) * 60.0; + minute = (int)floor(temp); + sec = (temp - minute) * 60.0; + } // end days2mdhms + +/* ----------------------------------------------------------------------------- +* +* procedure invjday +* +* this procedure finds the year, month, day, hour, minute and second +* given the julian date. tu can be ut1, tdt, tdb, etc. +* +* algorithm : set up starting values +* find leap year - use 1900 because 2000 is a leap year +* find the elapsed days through the year in a loop +* call routine to find each individual value +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* jd - julian date days from 4713 bc +* +* outputs : +* year - year 1900 .. 2100 +* mon - month 1 .. 12 +* day - day 1 .. 28,29,30,31 +* hr - hour 0 .. 23 +* min - minute 0 .. 59 +* sec - second 0.0 .. 59.999 +* +* locals : +* days - day of year plus fractional +* portion of a day days +* tu - julian centuries from 0 h +* jan 0, 1900 +* temp - temporary double values +* leapyrs - number of leap years from 1900 +* +* coupling : +* days2mdhms - finds month, day, hour, minute and second given days and year +* +* references : +* vallado 2007, 208, alg 22, ex 3-13 +* --------------------------------------------------------------------------- */ + +void invjday + ( + double jd, + int& year, int& mon, int& day, + int& hr, int& minute, double& sec + ) + { + int leapyrs; + double days, tu, temp; + + /* --------------- find year and days of the year --------------- */ + temp = jd - 2415019.5; + tu = temp / 365.25; + year = 1900 + (int)floor(tu); + leapyrs = (int)floor((year - 1901) * 0.25); + + // optional nudge by 8.64x10-7 sec to get even outputs + days = temp - ((year - 1900) * 365.0 + leapyrs) + 0.00000000001; + + /* ------------ check for case of beginning of a year ----------- */ + if (days < 1.0) + { + year = year - 1; + leapyrs = (int)floor((year - 1901) * 0.25); + days = temp - ((year - 1900) * 365.0 + leapyrs); + } + + /* ----------------- find remaing data ------------------------- */ + days2mdhms(year, days, mon, day, hr, minute, sec); + sec = sec - 0.00000086400; + } // end invjday + + + + + diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.h similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.h diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.cpp similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.cpp index 0316087..0b3418f 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.cpp +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.cpp @@ -1,208 +1,208 @@ -/* ---------------------------------------------------------------- -* -* sgp4io.cpp -* -* this file contains a function to read two line element sets. while -* not formerly part of the sgp4 mathematical theory, it is -* required for practical implemenation. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* Note: Deleted code related with command line inputs. That implementation -* is not a god way to build a library. It's better to aisle logic and interface. -* J.L. Canales 20/11/2010 -* -* current : -* 3 sep 08 david vallado -* add operationmode for afspc (a) or improved (i) -* changes : -* 9 may 07 david vallado -* fix year correction to 57 -* 27 mar 07 david vallado -* misc fixes to manual inputs -* 14 aug 06 david vallado -* original baseline -* ---------------------------------------------------------------- */ - -#include "sgp4io.h" - -/* ----------------------------------------------------------------------------- -* -* function twoline2rv -* -* this function converts the two line element set character string data to -* variables and initializes the sgp4 variables. several intermediate varaibles -* and quantities are determined. note that the result is a structure so multiple -* satellites can be processed simultaneously without having to reinitialize. the -* verification mode is an important option that permits quick checks of any -* changes to the underlying technical theory. this option works using a -* modified tle file in which the start, stop, and delta time values are -* included at the end of the second line of data. this only works with the -* verification mode. the catalog mode simply propagates from -1440 to 1440 min -* from epoch and is useful when performing entire catalog runs. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs : -* longstr1 - first line of the tle -* longstr2 - second line of the tle -* typerun - type of run verification 'v', catalog 'c', -* manual 'm' -* typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd' -* opsmode - mode of operation afspc or improved 'a', 'i' -* whichconst - which set of constants to use 72, 84 -* -* outputs : -* satrec - structure containing all the sgp4 satellite information -* -* coupling : -* getgravconst- -* days2mdhms - conversion of days to month, day, hour, minute, second -* jday - convert day month year hour minute second into julian date -* sgp4init - initialize the sgp4 variables -* -* references : -* norad spacetrack report #3 -* vallado, crawford, hujsak, kelso 2006 - --------------------------------------------------------------------------- */ - -void twoline2rv - ( - char longstr1[130], char longstr2[130], - char typerun, char typeinput, char opsmode, - gravconsttype whichconst, - double& startmfe, double& stopmfe, double& deltamin, - elsetrec& satrec - ) - { - const double deg2rad = pi / 180.0; // 0.0174532925199433 - const double xpdotp = 1440.0 / (2.0 *pi); // 229.1831180523293 - - double sec, mu, radiusearthkm, tumin, xke, j2, j3, j4, j3oj2; - int cardnumb, numb, j; - long revnum = 0, elnum = 0; - char classification, intldesg[11]; - int year = 0; - int mon, day, hr, minute, nexp, ibexp; - - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - - satrec.error = 0; - - // set the implied decimal points since doing a formated read - // fixes for bad input data values (missing, ...) - for (j = 10; j <= 15; j++) - if (longstr1[j] == ' ') - longstr1[j] = '_'; - - if (longstr1[44] != ' ') - longstr1[43] = longstr1[44]; - longstr1[44] = '.'; - if (longstr1[7] == ' ') - longstr1[7] = 'U'; - if (longstr1[9] == ' ') - longstr1[9] = '.'; - for (j = 45; j <= 49; j++) - if (longstr1[j] == ' ') - longstr1[j] = '0'; - if (longstr1[51] == ' ') - longstr1[51] = '0'; - if (longstr1[53] != ' ') - longstr1[52] = longstr1[53]; - longstr1[53] = '.'; - longstr2[25] = '.'; - for (j = 26; j <= 32; j++) - if (longstr2[j] == ' ') - longstr2[j] = '0'; - if (longstr1[62] == ' ') - longstr1[62] = '0'; - if (longstr1[68] == ' ') - longstr1[68] = '0'; - - sscanf(longstr1,"%2d %5ld %1c %10s %2d %12lf %11lf %7lf %2d %7lf %2d %2d %6ld ", - &cardnumb,&satrec.satnum,&classification, intldesg, &satrec.epochyr, - &satrec.epochdays,&satrec.ndot, &satrec.nddot, &nexp, &satrec.bstar, - &ibexp, &numb, &elnum ); - - if (typerun == 'v') // run for specified times from the file - { - if (longstr2[52] == ' ') - sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld %lf %lf %lf \n", - &cardnumb,&satrec.satnum, &satrec.inclo, - &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, - &revnum, &startmfe, &stopmfe, &deltamin ); - else - sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld %lf %lf %lf \n", - &cardnumb,&satrec.satnum, &satrec.inclo, - &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, - &revnum, &startmfe, &stopmfe, &deltamin ); - } - else // simply run -1 day to +1 day or user input times - { - if (longstr2[52] == ' ') - sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld \n", - &cardnumb,&satrec.satnum, &satrec.inclo, - &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, - &revnum ); - else - sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld \n", - &cardnumb,&satrec.satnum, &satrec.inclo, - &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, - &revnum ); - } - - // ---- find no, ndot, nddot ---- - satrec.no = satrec.no / xpdotp; //* rad/min - satrec.nddot= satrec.nddot * pow(10.0, nexp); - satrec.bstar= satrec.bstar * pow(10.0, ibexp); - - // ---- convert to sgp4 units ---- - satrec.a = pow( satrec.no*tumin , (-2.0/3.0) ); - satrec.ndot = satrec.ndot / (xpdotp*1440.0); //* ? * minperday - satrec.nddot= satrec.nddot / (xpdotp*1440.0*1440); - - // ---- find standard orbital elements ---- - satrec.inclo = satrec.inclo * deg2rad; - satrec.nodeo = satrec.nodeo * deg2rad; - satrec.argpo = satrec.argpo * deg2rad; - satrec.mo = satrec.mo * deg2rad; - - satrec.alta = satrec.a*(1.0 + satrec.ecco) - 1.0; - satrec.altp = satrec.a*(1.0 - satrec.ecco) - 1.0; - - // ---------------------------------------------------------------- - // find sgp4epoch time of element set - // remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch) - // and minutes from the epoch (time) - // ---------------------------------------------------------------- - - // ---------------- temp fix for years from 1957-2056 ------------------- - // --------- correct fix will occur when year is 4-digit in tle --------- - if (satrec.epochyr < 57) - year= satrec.epochyr + 2000; - else - year= satrec.epochyr + 1900; - - days2mdhms ( year,satrec.epochdays, mon,day,hr,minute,sec ); - jday( year,mon,day,hr,minute,sec, satrec.jdsatepoch ); - - // ------------ perform complete catalog evaluation, -+ 1 day ----------- - if (typerun == 'c') - { - startmfe = -1440.0; - stopmfe = 1440.0; - deltamin = 10.0; - } - - // ---------------- initialize the orbit at sgp4epoch ------------------- - sgp4init( whichconst, opsmode, satrec.satnum, satrec.jdsatepoch-2433281.5, satrec.bstar, - satrec.ecco, satrec.argpo, satrec.inclo, satrec.mo, satrec.no, - satrec.nodeo, satrec); - } // end twoline2rv - - +/* ---------------------------------------------------------------- +* +* sgp4io.cpp +* +* this file contains a function to read two line element sets. while +* not formerly part of the sgp4 mathematical theory, it is +* required for practical implemenation. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* Note: Deleted code related with command line inputs. That implementation +* is not a god way to build a library. It's better to aisle logic and interface. +* J.L. Canales 20/11/2010 +* +* current : +* 3 sep 08 david vallado +* add operationmode for afspc (a) or improved (i) +* changes : +* 9 may 07 david vallado +* fix year correction to 57 +* 27 mar 07 david vallado +* misc fixes to manual inputs +* 14 aug 06 david vallado +* original baseline +* ---------------------------------------------------------------- */ + +#include "sgp4io.h" + +/* ----------------------------------------------------------------------------- +* +* function twoline2rv +* +* this function converts the two line element set character string data to +* variables and initializes the sgp4 variables. several intermediate varaibles +* and quantities are determined. note that the result is a structure so multiple +* satellites can be processed simultaneously without having to reinitialize. the +* verification mode is an important option that permits quick checks of any +* changes to the underlying technical theory. this option works using a +* modified tle file in which the start, stop, and delta time values are +* included at the end of the second line of data. this only works with the +* verification mode. the catalog mode simply propagates from -1440 to 1440 min +* from epoch and is useful when performing entire catalog runs. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs : +* longstr1 - first line of the tle +* longstr2 - second line of the tle +* typerun - type of run verification 'v', catalog 'c', +* manual 'm' +* typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd' +* opsmode - mode of operation afspc or improved 'a', 'i' +* whichconst - which set of constants to use 72, 84 +* +* outputs : +* satrec - structure containing all the sgp4 satellite information +* +* coupling : +* getgravconst- +* days2mdhms - conversion of days to month, day, hour, minute, second +* jday - convert day month year hour minute second into julian date +* sgp4init - initialize the sgp4 variables +* +* references : +* norad spacetrack report #3 +* vallado, crawford, hujsak, kelso 2006 + --------------------------------------------------------------------------- */ + +void twoline2rv + ( + char longstr1[130], char longstr2[130], + char typerun, char typeinput, char opsmode, + gravconsttype whichconst, + double& startmfe, double& stopmfe, double& deltamin, + elsetrec& satrec + ) + { + const double deg2rad = pi / 180.0; // 0.0174532925199433 + const double xpdotp = 1440.0 / (2.0 *pi); // 229.1831180523293 + + double sec, mu, radiusearthkm, tumin, xke, j2, j3, j4, j3oj2; + int cardnumb, numb, j; + long revnum = 0, elnum = 0; + char classification, intldesg[11]; + int year = 0; + int mon, day, hr, minute, nexp, ibexp; + + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + + satrec.error = 0; + + // set the implied decimal points since doing a formated read + // fixes for bad input data values (missing, ...) + for (j = 10; j <= 15; j++) + if (longstr1[j] == ' ') + longstr1[j] = '_'; + + if (longstr1[44] != ' ') + longstr1[43] = longstr1[44]; + longstr1[44] = '.'; + if (longstr1[7] == ' ') + longstr1[7] = 'U'; + if (longstr1[9] == ' ') + longstr1[9] = '.'; + for (j = 45; j <= 49; j++) + if (longstr1[j] == ' ') + longstr1[j] = '0'; + if (longstr1[51] == ' ') + longstr1[51] = '0'; + if (longstr1[53] != ' ') + longstr1[52] = longstr1[53]; + longstr1[53] = '.'; + longstr2[25] = '.'; + for (j = 26; j <= 32; j++) + if (longstr2[j] == ' ') + longstr2[j] = '0'; + if (longstr1[62] == ' ') + longstr1[62] = '0'; + if (longstr1[68] == ' ') + longstr1[68] = '0'; + + sscanf(longstr1,"%2d %5ld %1c %10s %2d %12lf %11lf %7lf %2d %7lf %2d %2d %6ld ", + &cardnumb,&satrec.satnum,&classification, intldesg, &satrec.epochyr, + &satrec.epochdays,&satrec.ndot, &satrec.nddot, &nexp, &satrec.bstar, + &ibexp, &numb, &elnum ); + + if (typerun == 'v') // run for specified times from the file + { + if (longstr2[52] == ' ') + sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld %lf %lf %lf \n", + &cardnumb,&satrec.satnum, &satrec.inclo, + &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, + &revnum, &startmfe, &stopmfe, &deltamin ); + else + sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld %lf %lf %lf \n", + &cardnumb,&satrec.satnum, &satrec.inclo, + &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, + &revnum, &startmfe, &stopmfe, &deltamin ); + } + else // simply run -1 day to +1 day or user input times + { + if (longstr2[52] == ' ') + sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld \n", + &cardnumb,&satrec.satnum, &satrec.inclo, + &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, + &revnum ); + else + sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld \n", + &cardnumb,&satrec.satnum, &satrec.inclo, + &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, + &revnum ); + } + + // ---- find no, ndot, nddot ---- + satrec.no = satrec.no / xpdotp; //* rad/min + satrec.nddot= satrec.nddot * pow(10.0, nexp); + satrec.bstar= satrec.bstar * pow(10.0, ibexp); + + // ---- convert to sgp4 units ---- + satrec.a = pow( satrec.no*tumin , (-2.0/3.0) ); + satrec.ndot = satrec.ndot / (xpdotp*1440.0); //* ? * minperday + satrec.nddot= satrec.nddot / (xpdotp*1440.0*1440); + + // ---- find standard orbital elements ---- + satrec.inclo = satrec.inclo * deg2rad; + satrec.nodeo = satrec.nodeo * deg2rad; + satrec.argpo = satrec.argpo * deg2rad; + satrec.mo = satrec.mo * deg2rad; + + satrec.alta = satrec.a*(1.0 + satrec.ecco) - 1.0; + satrec.altp = satrec.a*(1.0 - satrec.ecco) - 1.0; + + // ---------------------------------------------------------------- + // find sgp4epoch time of element set + // remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch) + // and minutes from the epoch (time) + // ---------------------------------------------------------------- + + // ---------------- temp fix for years from 1957-2056 ------------------- + // --------- correct fix will occur when year is 4-digit in tle --------- + if (satrec.epochyr < 57) + year= satrec.epochyr + 2000; + else + year= satrec.epochyr + 1900; + + days2mdhms ( year,satrec.epochdays, mon,day,hr,minute,sec ); + jday( year,mon,day,hr,minute,sec, satrec.jdsatepoch ); + + // ------------ perform complete catalog evaluation, -+ 1 day ----------- + if (typerun == 'c') + { + startmfe = -1440.0; + stopmfe = 1440.0; + deltamin = 10.0; + } + + // ---------------- initialize the orbit at sgp4epoch ------------------- + sgp4init( whichconst, opsmode, satrec.satnum, satrec.jdsatepoch-2433281.5, satrec.bstar, + satrec.ecco, satrec.argpo, satrec.inclo, satrec.mo, satrec.no, + satrec.nodeo, satrec); + } // end twoline2rv + + diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.h similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.h diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.cpp similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.cpp index 86072d2..3ddec87 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.cpp +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.cpp @@ -1,2119 +1,2119 @@ -/* ---------------------------------------------------------------- -* -* sgp4unit.cpp -* -* this file contains the sgp4 procedures for analytical propagation -* of a satellite. the code was originally released in the 1980 and 1986 -* spacetrack papers. a detailed discussion of the theory and history -* may be found in the 2006 aiaa paper by vallado, crawford, hujsak, -* and kelso. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 3 Nov 08 david vallado -* put returns in for error codes -* changes : -* 29 sep 08 david vallado -* fix atime for faster operation in dspace -* add operationmode for afspc (a) or improved (i) -* performance mode -* 16 jun 08 david vallado -* update small eccentricity check -* 16 nov 07 david vallado -* misc fixes for better compliance -* 20 apr 07 david vallado -* misc fixes for constants -* 11 aug 06 david vallado -* chg lyddane choice back to strn3, constants, misc doc -* 15 dec 05 david vallado -* misc fixes -* 26 jul 05 david vallado -* fixes for paper -* note that each fix is preceded by a -* comment with "sgp4fix" and an explanation of -* what was changed -* 10 aug 04 david vallado -* 2nd printing baseline working -* 14 may 01 david vallado -* 2nd edition baseline -* 80 norad -* original baseline -* ---------------------------------------------------------------- */ - -#include "sgp4unit.h" - -const char help = 'n'; -FILE *dbgfile; - - -/* ----------- local functions - only ever used internally by sgp4 ---------- */ -static void dpper - ( - double e3, double ee2, double peo, double pgho, double pho, - double pinco, double plo, double se2, double se3, double sgh2, - double sgh3, double sgh4, double sh2, double sh3, double si2, - double si3, double sl2, double sl3, double sl4, double t, - double xgh2, double xgh3, double xgh4, double xh2, double xh3, - double xi2, double xi3, double xl2, double xl3, double xl4, - double zmol, double zmos, double inclo, - char init, - double& ep, double& inclp, double& nodep, double& argpp, double& mp, - char opsmode - ); - -static void dscom - ( - double epoch, double ep, double argpp, double tc, double inclp, - double nodep, double np, - double& snodm, double& cnodm, double& sinim, double& cosim, double& sinomm, - double& cosomm,double& day, double& e3, double& ee2, double& em, - double& emsq, double& gam, double& peo, double& pgho, double& pho, - double& pinco, double& plo, double& rtemsq, double& se2, double& se3, - double& sgh2, double& sgh3, double& sgh4, double& sh2, double& sh3, - double& si2, double& si3, double& sl2, double& sl3, double& sl4, - double& s1, double& s2, double& s3, double& s4, double& s5, - double& s6, double& s7, double& ss1, double& ss2, double& ss3, - double& ss4, double& ss5, double& ss6, double& ss7, double& sz1, - double& sz2, double& sz3, double& sz11, double& sz12, double& sz13, - double& sz21, double& sz22, double& sz23, double& sz31, double& sz32, - double& sz33, double& xgh2, double& xgh3, double& xgh4, double& xh2, - double& xh3, double& xi2, double& xi3, double& xl2, double& xl3, - double& xl4, double& nm, double& z1, double& z2, double& z3, - double& z11, double& z12, double& z13, double& z21, double& z22, - double& z23, double& z31, double& z32, double& z33, double& zmol, - double& zmos - ); - -static void dsinit - ( - gravconsttype whichconst, - double cosim, double emsq, double argpo, double s1, double s2, - double s3, double s4, double s5, double sinim, double ss1, - double ss2, double ss3, double ss4, double ss5, double sz1, - double sz3, double sz11, double sz13, double sz21, double sz23, - double sz31, double sz33, double t, double tc, double gsto, - double mo, double mdot, double no, double nodeo, double nodedot, - double xpidot, double z1, double z3, double z11, double z13, - double z21, double z23, double z31, double z33, double ecco, - double eccsq, double& em, double& argpm, double& inclm, double& mm, - double& nm, double& nodem, - int& irez, - double& atime, double& d2201, double& d2211, double& d3210, double& d3222, - double& d4410, double& d4422, double& d5220, double& d5232, double& d5421, - double& d5433, double& dedt, double& didt, double& dmdt, double& dndt, - double& dnodt, double& domdt, double& del1, double& del2, double& del3, - double& xfact, double& xlamo, double& xli, double& xni - ); - -static void dspace - ( - int irez, - double d2201, double d2211, double d3210, double d3222, double d4410, - double d4422, double d5220, double d5232, double d5421, double d5433, - double dedt, double del1, double del2, double del3, double didt, - double dmdt, double dnodt, double domdt, double argpo, double argpdot, - double t, double tc, double gsto, double xfact, double xlamo, - double no, - double& atime, double& em, double& argpm, double& inclm, double& xli, - double& mm, double& xni, double& nodem, double& dndt, double& nm - ); - -static void initl - ( - int satn, gravconsttype whichconst, - double ecco, double epoch, double inclo, double& no, - char& method, - double& ainv, double& ao, double& con41, double& con42, double& cosio, - double& cosio2,double& eccsq, double& omeosq, double& posq, - double& rp, double& rteosq,double& sinio , double& gsto, char opsmode - ); - -/* ----------------------------------------------------------------------------- -* -* procedure dpper -* -* this procedure provides deep space long period periodic contributions -* to the mean elements. by design, these periodics are zero at epoch. -* this used to be dscom which included initialization, but it's really a -* recurring function. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* e3 - -* ee2 - -* peo - -* pgho - -* pho - -* pinco - -* plo - -* se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 - -* t - -* xh2, xh3, xi2, xi3, xl2, xl3, xl4 - -* zmol - -* zmos - -* ep - eccentricity 0.0 - 1.0 -* inclo - inclination - needed for lyddane modification -* nodep - right ascension of ascending node -* argpp - argument of perigee -* mp - mean anomaly -* -* outputs : -* ep - eccentricity 0.0 - 1.0 -* inclp - inclination -* nodep - right ascension of ascending node -* argpp - argument of perigee -* mp - mean anomaly -* -* locals : -* alfdp - -* betdp - -* cosip , sinip , cosop , sinop , -* dalf - -* dbet - -* dls - -* f2, f3 - -* pe - -* pgh - -* ph - -* pinc - -* pl - -* sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis , -* sll , sls -* xls - -* xnoh - -* zf - -* zm - -* -* coupling : -* none. -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void dpper - ( - double e3, double ee2, double peo, double pgho, double pho, - double pinco, double plo, double se2, double se3, double sgh2, - double sgh3, double sgh4, double sh2, double sh3, double si2, - double si3, double sl2, double sl3, double sl4, double t, - double xgh2, double xgh3, double xgh4, double xh2, double xh3, - double xi2, double xi3, double xl2, double xl3, double xl4, - double zmol, double zmos, double inclo, - char init, - double& ep, double& inclp, double& nodep, double& argpp, double& mp, - char opsmode - ) -{ - /* --------------------- local variables ------------------------ */ - const double twopi = 2.0 * pi; - double alfdp, betdp, cosip, cosop, dalf, dbet, dls, - f2, f3, pe, pgh, ph, pinc, pl , - sel, ses, sghl, sghs, shll, shs, sil, - sinip, sinop, sinzf, sis, sll, sls, xls, - xnoh, zf, zm, zel, zes, znl, zns; - - /* kill warning */ - inclo = 0.; - - /* ---------------------- constants ----------------------------- */ - zns = 1.19459e-5; - zes = 0.01675; - znl = 1.5835218e-4; - zel = 0.05490; - - /* --------------- calculate time varying periodics ----------- */ - zm = zmos + zns * t; - // be sure that the initial call has time set to zero - if (init == 'y') - zm = zmos; - zf = zm + 2.0 * zes * sin(zm); - sinzf = sin(zf); - f2 = 0.5 * sinzf * sinzf - 0.25; - f3 = -0.5 * sinzf * cos(zf); - ses = se2* f2 + se3 * f3; - sis = si2 * f2 + si3 * f3; - sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf; - sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf; - shs = sh2 * f2 + sh3 * f3; - zm = zmol + znl * t; - if (init == 'y') - zm = zmol; - zf = zm + 2.0 * zel * sin(zm); - sinzf = sin(zf); - f2 = 0.5 * sinzf * sinzf - 0.25; - f3 = -0.5 * sinzf * cos(zf); - sel = ee2 * f2 + e3 * f3; - sil = xi2 * f2 + xi3 * f3; - sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf; - sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf; - shll = xh2 * f2 + xh3 * f3; - pe = ses + sel; - pinc = sis + sil; - pl = sls + sll; - pgh = sghs + sghl; - ph = shs + shll; - - if (init == 'n') - { - pe = pe - peo; - pinc = pinc - pinco; - pl = pl - plo; - pgh = pgh - pgho; - ph = ph - pho; - inclp = inclp + pinc; - ep = ep + pe; - sinip = sin(inclp); - cosip = cos(inclp); - - /* ----------------- apply periodics directly ------------ */ - // sgp4fix for lyddane choice - // strn3 used original inclination - this is technically feasible - // gsfc used perturbed inclination - also technically feasible - // probably best to readjust the 0.2 limit value and limit discontinuity - // 0.2 rad = 11.45916 deg - // use next line for original strn3 approach and original inclination - // if (inclo >= 0.2) - // use next line for gsfc version and perturbed inclination - if (inclp >= 0.2) - { - ph = ph / sinip; - pgh = pgh - cosip * ph; - argpp = argpp + pgh; - nodep = nodep + ph; - mp = mp + pl; - } - else - { - /* ---- apply periodics with lyddane modification ---- */ - sinop = sin(nodep); - cosop = cos(nodep); - alfdp = sinip * sinop; - betdp = sinip * cosop; - dalf = ph * cosop + pinc * cosip * sinop; - dbet = -ph * sinop + pinc * cosip * cosop; - alfdp = alfdp + dalf; - betdp = betdp + dbet; - nodep = fmod(nodep, twopi); - // sgp4fix for afspc written intrinsic functions - // nodep used without a trigonometric function ahead - if ((nodep < 0.0) && (opsmode == 'a')) - nodep = nodep + twopi; - xls = mp + argpp + cosip * nodep; - dls = pl + pgh - pinc * nodep * sinip; - xls = xls + dls; - xnoh = nodep; - nodep = atan2(alfdp, betdp); - // sgp4fix for afspc written intrinsic functions - // nodep used without a trigonometric function ahead - if ((nodep < 0.0) && (opsmode == 'a')) - nodep = nodep + twopi; - if (fabs(xnoh - nodep) > pi){ - if (nodep < xnoh) - nodep = nodep + twopi; - else - nodep = nodep - twopi; - } - mp = mp + pl; - argpp = xls - mp - cosip * nodep; - } - } // if init == 'n' - -//#include "debug1.cpp" -} // end dpper - -/*----------------------------------------------------------------------------- -* -* procedure dscom -* -* this procedure provides deep space common items used by both the secular -* and periodics subroutines. input is provided as shown. this routine -* used to be called dpper, but the functions inside weren't well organized. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* epoch - -* ep - eccentricity -* argpp - argument of perigee -* tc - -* inclp - inclination -* nodep - right ascension of ascending node -* np - mean motion -* -* outputs : -* sinim , cosim , sinomm , cosomm , snodm , cnodm -* day - -* e3 - -* ee2 - -* em - eccentricity -* emsq - eccentricity squared -* gam - -* peo - -* pgho - -* pho - -* pinco - -* plo - -* rtemsq - -* se2, se3 - -* sgh2, sgh3, sgh4 - -* sh2, sh3, si2, si3, sl2, sl3, sl4 - -* s1, s2, s3, s4, s5, s6, s7 - -* ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 - -* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 - -* xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 - -* nm - mean motion -* z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 - -* zmol - -* zmos - -* -* locals : -* a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 - -* betasq - -* cc - -* ctem, stem - -* x1, x2, x3, x4, x5, x6, x7, x8 - -* xnodce - -* xnoi - -* zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl , -* zcosi , zsini , zcosil , zsinil , -* zx - -* zy - -* -* coupling : -* none. -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void dscom - ( - double epoch, double ep, double argpp, double tc, double inclp, - double nodep, double np, - double& snodm, double& cnodm, double& sinim, double& cosim, double& sinomm, - double& cosomm,double& day, double& e3, double& ee2, double& em, - double& emsq, double& gam, double& peo, double& pgho, double& pho, - double& pinco, double& plo, double& rtemsq, double& se2, double& se3, - double& sgh2, double& sgh3, double& sgh4, double& sh2, double& sh3, - double& si2, double& si3, double& sl2, double& sl3, double& sl4, - double& s1, double& s2, double& s3, double& s4, double& s5, - double& s6, double& s7, double& ss1, double& ss2, double& ss3, - double& ss4, double& ss5, double& ss6, double& ss7, double& sz1, - double& sz2, double& sz3, double& sz11, double& sz12, double& sz13, - double& sz21, double& sz22, double& sz23, double& sz31, double& sz32, - double& sz33, double& xgh2, double& xgh3, double& xgh4, double& xh2, - double& xh3, double& xi2, double& xi3, double& xl2, double& xl3, - double& xl4, double& nm, double& z1, double& z2, double& z3, - double& z11, double& z12, double& z13, double& z21, double& z22, - double& z23, double& z31, double& z32, double& z33, double& zmol, - double& zmos - ) -{ - /* -------------------------- constants ------------------------- */ - const double zes = 0.01675; - const double zel = 0.05490; - const double c1ss = 2.9864797e-6; - const double c1l = 4.7968065e-7; - const double zsinis = 0.39785416; - const double zcosis = 0.91744867; - const double zcosgs = 0.1945905; - const double zsings = -0.98088458; - const double twopi = 2.0 * pi; - - /* --------------------- local variables ------------------------ */ - int lsflg; - double a1 , a2 , a3 , a4 , a5 , a6 , a7 , - a8 , a9 , a10 , betasq, cc , ctem , stem , - x1 , x2 , x3 , x4 , x5 , x6 , x7 , - x8 , xnodce, xnoi , zcosg , zcosgl, zcosh , zcoshl, - zcosi , zcosil, zsing , zsingl, zsinh , zsinhl, zsini , - zsinil, zx , zy; - - nm = np; - em = ep; - snodm = sin(nodep); - cnodm = cos(nodep); - sinomm = sin(argpp); - cosomm = cos(argpp); - sinim = sin(inclp); - cosim = cos(inclp); - emsq = em * em; - betasq = 1.0 - emsq; - rtemsq = sqrt(betasq); - - /* ----------------- initialize lunar solar terms --------------- */ - peo = 0.0; - pinco = 0.0; - plo = 0.0; - pgho = 0.0; - pho = 0.0; - day = epoch + 18261.5 + tc / 1440.0; - xnodce = fmod(4.5236020 - 9.2422029e-4 * day, twopi); - stem = sin(xnodce); - ctem = cos(xnodce); - zcosil = 0.91375164 - 0.03568096 * ctem; - zsinil = sqrt(1.0 - zcosil * zcosil); - zsinhl = 0.089683511 * stem / zsinil; - zcoshl = sqrt(1.0 - zsinhl * zsinhl); - gam = 5.8351514 + 0.0019443680 * day; - zx = 0.39785416 * stem / zsinil; - zy = zcoshl * ctem + 0.91744867 * zsinhl * stem; - zx = atan2(zx, zy); - zx = gam + zx - xnodce; - zcosgl = cos(zx); - zsingl = sin(zx); - - /* ------------------------- do solar terms --------------------- */ - zcosg = zcosgs; - zsing = zsings; - zcosi = zcosis; - zsini = zsinis; - zcosh = cnodm; - zsinh = snodm; - cc = c1ss; - xnoi = 1.0 / nm; - - for (lsflg = 1; lsflg <= 2; lsflg++) - { - a1 = zcosg * zcosh + zsing * zcosi * zsinh; - a3 = -zsing * zcosh + zcosg * zcosi * zsinh; - a7 = -zcosg * zsinh + zsing * zcosi * zcosh; - a8 = zsing * zsini; - a9 = zsing * zsinh + zcosg * zcosi * zcosh; - a10 = zcosg * zsini; - a2 = cosim * a7 + sinim * a8; - a4 = cosim * a9 + sinim * a10; - a5 = -sinim * a7 + cosim * a8; - a6 = -sinim * a9 + cosim * a10; - - x1 = a1 * cosomm + a2 * sinomm; - x2 = a3 * cosomm + a4 * sinomm; - x3 = -a1 * sinomm + a2 * cosomm; - x4 = -a3 * sinomm + a4 * cosomm; - x5 = a5 * sinomm; - x6 = a6 * sinomm; - x7 = a5 * cosomm; - x8 = a6 * cosomm; - - z31 = 12.0 * x1 * x1 - 3.0 * x3 * x3; - z32 = 24.0 * x1 * x2 - 6.0 * x3 * x4; - z33 = 12.0 * x2 * x2 - 3.0 * x4 * x4; - z1 = 3.0 * (a1 * a1 + a2 * a2) + z31 * emsq; - z2 = 6.0 * (a1 * a3 + a2 * a4) + z32 * emsq; - z3 = 3.0 * (a3 * a3 + a4 * a4) + z33 * emsq; - z11 = -6.0 * a1 * a5 + emsq * (-24.0 * x1 * x7-6.0 * x3 * x5); - z12 = -6.0 * (a1 * a6 + a3 * a5) + emsq * - (-24.0 * (x2 * x7 + x1 * x8) - 6.0 * (x3 * x6 + x4 * x5)); - z13 = -6.0 * a3 * a6 + emsq * (-24.0 * x2 * x8 - 6.0 * x4 * x6); - z21 = 6.0 * a2 * a5 + emsq * (24.0 * x1 * x5 - 6.0 * x3 * x7); - z22 = 6.0 * (a4 * a5 + a2 * a6) + emsq * - (24.0 * (x2 * x5 + x1 * x6) - 6.0 * (x4 * x7 + x3 * x8)); - z23 = 6.0 * a4 * a6 + emsq * (24.0 * x2 * x6 - 6.0 * x4 * x8); - z1 = z1 + z1 + betasq * z31; - z2 = z2 + z2 + betasq * z32; - z3 = z3 + z3 + betasq * z33; - s3 = cc * xnoi; - s2 = -0.5 * s3 / rtemsq; - s4 = s3 * rtemsq; - s1 = -15.0 * em * s4; - s5 = x1 * x3 + x2 * x4; - s6 = x2 * x3 + x1 * x4; - s7 = x2 * x4 - x1 * x3; - - /* ----------------------- do lunar terms ------------------- */ - if (lsflg == 1) - { - ss1 = s1; - ss2 = s2; - ss3 = s3; - ss4 = s4; - ss5 = s5; - ss6 = s6; - ss7 = s7; - sz1 = z1; - sz2 = z2; - sz3 = z3; - sz11 = z11; - sz12 = z12; - sz13 = z13; - sz21 = z21; - sz22 = z22; - sz23 = z23; - sz31 = z31; - sz32 = z32; - sz33 = z33; - zcosg = zcosgl; - zsing = zsingl; - zcosi = zcosil; - zsini = zsinil; - zcosh = zcoshl * cnodm + zsinhl * snodm; - zsinh = snodm * zcoshl - cnodm * zsinhl; - cc = c1l; - } - } - - zmol = fmod(4.7199672 + 0.22997150 * day - gam, twopi); - zmos = fmod(6.2565837 + 0.017201977 * day, twopi); - - /* ------------------------ do solar terms ---------------------- */ - se2 = 2.0 * ss1 * ss6; - se3 = 2.0 * ss1 * ss7; - si2 = 2.0 * ss2 * sz12; - si3 = 2.0 * ss2 * (sz13 - sz11); - sl2 = -2.0 * ss3 * sz2; - sl3 = -2.0 * ss3 * (sz3 - sz1); - sl4 = -2.0 * ss3 * (-21.0 - 9.0 * emsq) * zes; - sgh2 = 2.0 * ss4 * sz32; - sgh3 = 2.0 * ss4 * (sz33 - sz31); - sgh4 = -18.0 * ss4 * zes; - sh2 = -2.0 * ss2 * sz22; - sh3 = -2.0 * ss2 * (sz23 - sz21); - - /* ------------------------ do lunar terms ---------------------- */ - ee2 = 2.0 * s1 * s6; - e3 = 2.0 * s1 * s7; - xi2 = 2.0 * s2 * z12; - xi3 = 2.0 * s2 * (z13 - z11); - xl2 = -2.0 * s3 * z2; - xl3 = -2.0 * s3 * (z3 - z1); - xl4 = -2.0 * s3 * (-21.0 - 9.0 * emsq) * zel; - xgh2 = 2.0 * s4 * z32; - xgh3 = 2.0 * s4 * (z33 - z31); - xgh4 = -18.0 * s4 * zel; - xh2 = -2.0 * s2 * z22; - xh3 = -2.0 * s2 * (z23 - z21); - -//#include "debug2.cpp" -} // end dscom - -/*----------------------------------------------------------------------------- -* -* procedure dsinit -* -* this procedure provides deep space contributions to mean motion dot due -* to geopotential resonance with half day and one day orbits. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* cosim, sinim- -* emsq - eccentricity squared -* argpo - argument of perigee -* s1, s2, s3, s4, s5 - -* ss1, ss2, ss3, ss4, ss5 - -* sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 - -* t - time -* tc - -* gsto - greenwich sidereal time rad -* mo - mean anomaly -* mdot - mean anomaly dot (rate) -* no - mean motion -* nodeo - right ascension of ascending node -* nodedot - right ascension of ascending node dot (rate) -* xpidot - -* z1, z3, z11, z13, z21, z23, z31, z33 - -* eccm - eccentricity -* argpm - argument of perigee -* inclm - inclination -* mm - mean anomaly -* xn - mean motion -* nodem - right ascension of ascending node -* -* outputs : -* em - eccentricity -* argpm - argument of perigee -* inclm - inclination -* mm - mean anomaly -* nm - mean motion -* nodem - right ascension of ascending node -* irez - flag for resonance 0-none, 1-one day, 2-half day -* atime - -* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 - -* dedt - -* didt - -* dmdt - -* dndt - -* dnodt - -* domdt - -* del1, del2, del3 - -* ses , sghl , sghs , sgs , shl , shs , sis , sls -* theta - -* xfact - -* xlamo - -* xli - -* xni -* -* locals : -* ainv2 - -* aonv - -* cosisq - -* eoc - -* f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 - -* g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 - -* sini2 - -* temp - -* temp1 - -* theta - -* xno2 - -* -* coupling : -* getgravconst -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void dsinit - ( - gravconsttype whichconst, - double cosim, double emsq, double argpo, double s1, double s2, - double s3, double s4, double s5, double sinim, double ss1, - double ss2, double ss3, double ss4, double ss5, double sz1, - double sz3, double sz11, double sz13, double sz21, double sz23, - double sz31, double sz33, double t, double tc, double gsto, - double mo, double mdot, double no, double nodeo, double nodedot, - double xpidot, double z1, double z3, double z11, double z13, - double z21, double z23, double z31, double z33, double ecco, - double eccsq, double& em, double& argpm, double& inclm, double& mm, - double& nm, double& nodem, - int& irez, - double& atime, double& d2201, double& d2211, double& d3210, double& d3222, - double& d4410, double& d4422, double& d5220, double& d5232, double& d5421, - double& d5433, double& dedt, double& didt, double& dmdt, double& dndt, - double& dnodt, double& domdt, double& del1, double& del2, double& del3, - double& xfact, double& xlamo, double& xli, double& xni - ) -{ - /* --------------------- local variables ------------------------ */ - const double twopi = 2.0 * pi; - - double ainv2 , aonv=0.0, cosisq, eoc, f220 , f221 , f311 , - f321 , f322 , f330 , f441 , f442 , f522 , f523 , - f542 , f543 , g200 , g201 , g211 , g300 , g310 , - g322 , g410 , g422 , g520 , g521 , g532 , g533 , - ses , sgs , sghl , sghs , shs , shll , sis , - sini2 , sls , temp , temp1 , theta , xno2 , q22 , - q31 , q33 , root22, root44, root54, rptim , root32, - root52, x2o3 , xke , znl , emo , zns , emsqo, - tumin, mu, radiusearthkm, j2, j3, j4, j3oj2; - - q22 = 1.7891679e-6; - q31 = 2.1460748e-6; - q33 = 2.2123015e-7; - root22 = 1.7891679e-6; - root44 = 7.3636953e-9; - root54 = 2.1765803e-9; - rptim = 4.37526908801129966e-3; // this equates to 7.29211514668855e-5 rad/sec - root32 = 3.7393792e-7; - root52 = 1.1428639e-7; - x2o3 = 2.0 / 3.0; - znl = 1.5835218e-4; - zns = 1.19459e-5; - - // sgp4fix identify constants and allow alternate values - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - - /* -------------------- deep space initialization ------------ */ - irez = 0; - if ((nm < 0.0052359877) && (nm > 0.0034906585)) - irez = 1; - if ((nm >= 8.26e-3) && (nm <= 9.24e-3) && (em >= 0.5)) - irez = 2; - - /* ------------------------ do solar terms ------------------- */ - ses = ss1 * zns * ss5; - sis = ss2 * zns * (sz11 + sz13); - sls = -zns * ss3 * (sz1 + sz3 - 14.0 - 6.0 * emsq); - sghs = ss4 * zns * (sz31 + sz33 - 6.0); - shs = -zns * ss2 * (sz21 + sz23); - // sgp4fix for 180 deg incl - if ((inclm < 5.2359877e-2) || (inclm > pi - 5.2359877e-2)) - shs = 0.0; - if (sinim != 0.0) - shs = shs / sinim; - sgs = sghs - cosim * shs; - - /* ------------------------- do lunar terms ------------------ */ - dedt = ses + s1 * znl * s5; - didt = sis + s2 * znl * (z11 + z13); - dmdt = sls - znl * s3 * (z1 + z3 - 14.0 - 6.0 * emsq); - sghl = s4 * znl * (z31 + z33 - 6.0); - shll = -znl * s2 * (z21 + z23); - // sgp4fix for 180 deg incl - if ((inclm < 5.2359877e-2) || (inclm > pi - 5.2359877e-2)) - shll = 0.0; - domdt = sgs + sghl; - dnodt = shs; - if (sinim != 0.0) - { - domdt = domdt - cosim / sinim * shll; - dnodt = dnodt + shll / sinim; - } - - /* ----------- calculate deep space resonance effects -------- */ - dndt = 0.0; - theta = fmod(gsto + tc * rptim, twopi); - em = em + dedt * t; - inclm = inclm + didt * t; - argpm = argpm + domdt * t; - nodem = nodem + dnodt * t; - mm = mm + dmdt * t; - // sgp4fix for negative inclinations - // the following if statement should be commented out - //if (inclm < 0.0) - // { - // inclm = -inclm; - // argpm = argpm - pi; - // nodem = nodem + pi; - // } - - /* -------------- initialize the resonance terms ------------- */ - if (irez != 0) - { - aonv = pow(nm / xke, x2o3); - - /* ---------- geopotential resonance for 12 hour orbits ------ */ - if (irez == 2) - { - cosisq = cosim * cosim; - emo = em; - em = ecco; - emsqo = emsq; - emsq = eccsq; - eoc = em * emsq; - g201 = -0.306 - (em - 0.64) * 0.440; - - if (em <= 0.65) - { - g211 = 3.616 - 13.2470 * em + 16.2900 * emsq; - g310 = -19.302 + 117.3900 * em - 228.4190 * emsq + 156.5910 * eoc; - g322 = -18.9068 + 109.7927 * em - 214.6334 * emsq + 146.5816 * eoc; - g410 = -41.122 + 242.6940 * em - 471.0940 * emsq + 313.9530 * eoc; - g422 = -146.407 + 841.8800 * em - 1629.014 * emsq + 1083.4350 * eoc; - g520 = -532.114 + 3017.977 * em - 5740.032 * emsq + 3708.2760 * eoc; - } - else - { - g211 = -72.099 + 331.819 * em - 508.738 * emsq + 266.724 * eoc; - g310 = -346.844 + 1582.851 * em - 2415.925 * emsq + 1246.113 * eoc; - g322 = -342.585 + 1554.908 * em - 2366.899 * emsq + 1215.972 * eoc; - g410 = -1052.797 + 4758.686 * em - 7193.992 * emsq + 3651.957 * eoc; - g422 = -3581.690 + 16178.110 * em - 24462.770 * emsq + 12422.520 * eoc; - if (em > 0.715) - g520 =-5149.66 + 29936.92 * em - 54087.36 * emsq + 31324.56 * eoc; - else - g520 = 1464.74 - 4664.75 * em + 3763.64 * emsq; - } - if (em < 0.7) - { - g533 = -919.22770 + 4988.6100 * em - 9064.7700 * emsq + 5542.21 * eoc; - g521 = -822.71072 + 4568.6173 * em - 8491.4146 * emsq + 5337.524 * eoc; - g532 = -853.66600 + 4690.2500 * em - 8624.7700 * emsq + 5341.4 * eoc; - } - else - { - g533 =-37995.780 + 161616.52 * em - 229838.20 * emsq + 109377.94 * eoc; - g521 =-51752.104 + 218913.95 * em - 309468.16 * emsq + 146349.42 * eoc; - g532 =-40023.880 + 170470.89 * em - 242699.48 * emsq + 115605.82 * eoc; - } - - sini2= sinim * sinim; - f220 = 0.75 * (1.0 + 2.0 * cosim+cosisq); - f221 = 1.5 * sini2; - f321 = 1.875 * sinim * (1.0 - 2.0 * cosim - 3.0 * cosisq); - f322 = -1.875 * sinim * (1.0 + 2.0 * cosim - 3.0 * cosisq); - f441 = 35.0 * sini2 * f220; - f442 = 39.3750 * sini2 * sini2; - f522 = 9.84375 * sinim * (sini2 * (1.0 - 2.0 * cosim- 5.0 * cosisq) + - 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq) ); - f523 = sinim * (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + - 10.0 * cosisq) + 6.56250012 * (1.0+2.0 * cosim - 3.0 * cosisq)); - f542 = 29.53125 * sinim * (2.0 - 8.0 * cosim+cosisq * - (-12.0 + 8.0 * cosim + 10.0 * cosisq)); - f543 = 29.53125 * sinim * (-2.0 - 8.0 * cosim+cosisq * - (12.0 + 8.0 * cosim - 10.0 * cosisq)); - xno2 = nm * nm; - ainv2 = aonv * aonv; - temp1 = 3.0 * xno2 * ainv2; - temp = temp1 * root22; - d2201 = temp * f220 * g201; - d2211 = temp * f221 * g211; - temp1 = temp1 * aonv; - temp = temp1 * root32; - d3210 = temp * f321 * g310; - d3222 = temp * f322 * g322; - temp1 = temp1 * aonv; - temp = 2.0 * temp1 * root44; - d4410 = temp * f441 * g410; - d4422 = temp * f442 * g422; - temp1 = temp1 * aonv; - temp = temp1 * root52; - d5220 = temp * f522 * g520; - d5232 = temp * f523 * g532; - temp = 2.0 * temp1 * root54; - d5421 = temp * f542 * g521; - d5433 = temp * f543 * g533; - xlamo = fmod(mo + nodeo + nodeo-theta - theta, twopi); - xfact = mdot + dmdt + 2.0 * (nodedot + dnodt - rptim) - no; - em = emo; - emsq = emsqo; - } - - /* ---------------- synchronous resonance terms -------------- */ - if (irez == 1) - { - g200 = 1.0 + emsq * (-2.5 + 0.8125 * emsq); - g310 = 1.0 + 2.0 * emsq; - g300 = 1.0 + emsq * (-6.0 + 6.60937 * emsq); - f220 = 0.75 * (1.0 + cosim) * (1.0 + cosim); - f311 = 0.9375 * sinim * sinim * (1.0 + 3.0 * cosim) - 0.75 * (1.0 + cosim); - f330 = 1.0 + cosim; - f330 = 1.875 * f330 * f330 * f330; - del1 = 3.0 * nm * nm * aonv * aonv; - del2 = 2.0 * del1 * f220 * g200 * q22; - del3 = 3.0 * del1 * f330 * g300 * q33 * aonv; - del1 = del1 * f311 * g310 * q31 * aonv; - xlamo = fmod(mo + nodeo + argpo - theta, twopi); - xfact = mdot + xpidot - rptim + dmdt + domdt + dnodt - no; - } - - /* ------------ for sgp4, initialize the integrator ---------- */ - xli = xlamo; - xni = no; - atime = 0.0; - nm = no + dndt; - } - -//#include "debug3.cpp" -} // end dsinit - -/*----------------------------------------------------------------------------- -* -* procedure dspace -* -* this procedure provides deep space contributions to mean elements for -* perturbing third body. these effects have been averaged over one -* revolution of the sun and moon. for earth resonance effects, the -* effects have been averaged over no revolutions of the satellite. -* (mean motion) -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 - -* dedt - -* del1, del2, del3 - -* didt - -* dmdt - -* dnodt - -* domdt - -* irez - flag for resonance 0-none, 1-one day, 2-half day -* argpo - argument of perigee -* argpdot - argument of perigee dot (rate) -* t - time -* tc - -* gsto - gst -* xfact - -* xlamo - -* no - mean motion -* atime - -* em - eccentricity -* ft - -* argpm - argument of perigee -* inclm - inclination -* xli - -* mm - mean anomaly -* xni - mean motion -* nodem - right ascension of ascending node -* -* outputs : -* atime - -* em - eccentricity -* argpm - argument of perigee -* inclm - inclination -* xli - -* mm - mean anomaly -* xni - -* nodem - right ascension of ascending node -* dndt - -* nm - mean motion -* -* locals : -* delt - -* ft - -* theta - -* x2li - -* x2omi - -* xl - -* xldot - -* xnddt - -* xndt - -* xomi - -* -* coupling : -* none - -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void dspace - ( - int irez, - double d2201, double d2211, double d3210, double d3222, double d4410, - double d4422, double d5220, double d5232, double d5421, double d5433, - double dedt, double del1, double del2, double del3, double didt, - double dmdt, double dnodt, double domdt, double argpo, double argpdot, - double t, double tc, double gsto, double xfact, double xlamo, - double no, - double& atime, double& em, double& argpm, double& inclm, double& xli, - double& mm, double& xni, double& nodem, double& dndt, double& nm - ) -{ - const double twopi = 2.0 * pi; - int iretn , iret; - double delt, ft, theta, x2li, x2omi, xl, xldot , xnddt, xndt, xomi, g22, g32, - g44, g52, g54, fasx2, fasx4, fasx6, rptim , step2, stepn , stepp; - - fasx2 = 0.13130908; - fasx4 = 2.8843198; - fasx6 = 0.37448087; - g22 = 5.7686396; - g32 = 0.95240898; - g44 = 1.8014998; - g52 = 1.0508330; - g54 = 4.4108898; - rptim = 4.37526908801129966e-3; // this equates to 7.29211514668855e-5 rad/sec - stepp = 720.0; - stepn = -720.0; - step2 = 259200.0; - - /* ----------- calculate deep space resonance effects ----------- */ - dndt = 0.0; - theta = fmod(gsto + tc * rptim, twopi); - em = em + dedt * t; - - inclm = inclm + didt * t; - argpm = argpm + domdt * t; - nodem = nodem + dnodt * t; - mm = mm + dmdt * t; - - // sgp4fix for negative inclinations - // the following if statement should be commented out - // if (inclm < 0.0) - // { - // inclm = -inclm; - // argpm = argpm - pi; - // nodem = nodem + pi; - // } - - /* - update resonances : numerical (euler-maclaurin) integration - */ - /* ------------------------- epoch restart ---------------------- */ - // sgp4fix for propagator problems - // the following integration works for negative time steps and periods - // the specific changes are unknown because the original code was so convoluted - - // sgp4fix take out atime = 0.0 and fix for faster operation - ft = 0.0; - if (irez != 0) - { - // sgp4fix streamline check - if ((atime == 0.0) || (t * atime <= 0.0) || (fabs(t) < fabs(atime)) ) - { - atime = 0.0; - xni = no; - xli = xlamo; - } - // sgp4fix move check outside loop - if (t > 0.0) - delt = stepp; - else - delt = stepn; - - iretn = 381; // added for do loop - iret = 0; // added for loop - while (iretn == 381) - { - /* ------------------- dot terms calculated ------------- */ - /* ----------- near - synchronous resonance terms ------- */ - if (irez != 2) - { - xndt = del1 * sin(xli - fasx2) + del2 * sin(2.0 * (xli - fasx4)) + - del3 * sin(3.0 * (xli - fasx6)); - xldot = xni + xfact; - xnddt = del1 * cos(xli - fasx2) + - 2.0 * del2 * cos(2.0 * (xli - fasx4)) + - 3.0 * del3 * cos(3.0 * (xli - fasx6)); - xnddt = xnddt * xldot; - } - else - { - /* --------- near - half-day resonance terms -------- */ - xomi = argpo + argpdot * atime; - x2omi = xomi + xomi; - x2li = xli + xli; - xndt = d2201 * sin(x2omi + xli - g22) + d2211 * sin(xli - g22) + - d3210 * sin(xomi + xli - g32) + d3222 * sin(-xomi + xli - g32)+ - d4410 * sin(x2omi + x2li - g44)+ d4422 * sin(x2li - g44) + - d5220 * sin(xomi + xli - g52) + d5232 * sin(-xomi + xli - g52)+ - d5421 * sin(xomi + x2li - g54) + d5433 * sin(-xomi + x2li - g54); - xldot = xni + xfact; - xnddt = d2201 * cos(x2omi + xli - g22) + d2211 * cos(xli - g22) + - d3210 * cos(xomi + xli - g32) + d3222 * cos(-xomi + xli - g32) + - d5220 * cos(xomi + xli - g52) + d5232 * cos(-xomi + xli - g52) + - 2.0 * (d4410 * cos(x2omi + x2li - g44) + - d4422 * cos(x2li - g44) + d5421 * cos(xomi + x2li - g54) + - d5433 * cos(-xomi + x2li - g54)); - xnddt = xnddt * xldot; - } - - /* ----------------------- integrator ------------------- */ - // sgp4fix move end checks to end of routine - if (fabs(t - atime) >= stepp) - { - iret = 0; - iretn = 381; - } - else // exit here - { - ft = t - atime; - iretn = 0; - } - - if (iretn == 381) - { - xli = xli + xldot * delt + xndt * step2; - xni = xni + xndt * delt + xnddt * step2; - atime = atime + delt; - } - } // while iretn = 381 - - nm = xni + xndt * ft + xnddt * ft * ft * 0.5; - xl = xli + xldot * ft + xndt * ft * ft * 0.5; - if (irez != 1) - { - mm = xl - 2.0 * nodem + 2.0 * theta; - dndt = nm - no; - } - else - { - mm = xl - nodem - argpm + theta; - dndt = nm - no; - } - nm = no + dndt; - } - -//#include "debug4.cpp" -} // end dsspace - -/*----------------------------------------------------------------------------- -* -* procedure initl -* -* this procedure initializes the spg4 propagator. all the initialization is -* consolidated here instead of having multiple loops inside other routines. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* ecco - eccentricity 0.0 - 1.0 -* epoch - epoch time in days from jan 0, 1950. 0 hr -* inclo - inclination of satellite -* no - mean motion of satellite -* satn - satellite number -* -* outputs : -* ainv - 1.0 / a -* ao - semi major axis -* con41 - -* con42 - 1.0 - 5.0 cos(i) -* cosio - cosine of inclination -* cosio2 - cosio squared -* eccsq - eccentricity squared -* method - flag for deep space 'd', 'n' -* omeosq - 1.0 - ecco * ecco -* posq - semi-parameter squared -* rp - radius of perigee -* rteosq - square root of (1.0 - ecco*ecco) -* sinio - sine of inclination -* gsto - gst at time of observation rad -* no - mean motion of satellite -* -* locals : -* ak - -* d1 - -* del - -* adel - -* po - -* -* coupling : -* getgravconst -* gstime - find greenwich sidereal time from the julian date -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void initl - ( - int satn, gravconsttype whichconst, - double ecco, double epoch, double inclo, double& no, - char& method, - double& ainv, double& ao, double& con41, double& con42, double& cosio, - double& cosio2,double& eccsq, double& omeosq, double& posq, - double& rp, double& rteosq,double& sinio , double& gsto, - char opsmode - ) -{ - /* --------------------- local variables ------------------------ */ - double ak, d1, del, adel, po, x2o3, j2, xke, - tumin, mu, radiusearthkm, j3, j4, j3oj2; - - /* kill warning */ - satn = 0; - - // sgp4fix use old way of finding gst - double ds70; - double ts70, tfrac, c1, thgr70, fk5r, c1p2p; - const double twopi = 2.0 * pi; - - /* ----------------------- earth constants ---------------------- */ - // sgp4fix identify constants and allow alternate values - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - x2o3 = 2.0 / 3.0; - - /* ------------- calculate auxillary epoch quantities ---------- */ - eccsq = ecco * ecco; - omeosq = 1.0 - eccsq; - rteosq = sqrt(omeosq); - cosio = cos(inclo); - cosio2 = cosio * cosio; - - /* ------------------ un-kozai the mean motion ----------------- */ - ak = pow(xke / no, x2o3); - d1 = 0.75 * j2 * (3.0 * cosio2 - 1.0) / (rteosq * omeosq); - del = d1 / (ak * ak); - adel = ak * (1.0 - del * del - del * - (1.0 / 3.0 + 134.0 * del * del / 81.0)); - del = d1/(adel * adel); - no = no / (1.0 + del); - - ao = pow(xke / no, x2o3); - sinio = sin(inclo); - po = ao * omeosq; - con42 = 1.0 - 5.0 * cosio2; - con41 = -con42-cosio2-cosio2; - ainv = 1.0 / ao; - posq = po * po; - rp = ao * (1.0 - ecco); - method = 'n'; - - // sgp4fix modern approach to finding sidereal time - if (opsmode == 'a') - { - // sgp4fix use old way of finding gst - // count integer number of days from 0 jan 1970 - ts70 = epoch - 7305.0; - ds70 = floor(ts70 + 1.0e-8); - tfrac = ts70 - ds70; - // find greenwich location at epoch - c1 = 1.72027916940703639e-2; - thgr70= 1.7321343856509374; - fk5r = 5.07551419432269442e-15; - c1p2p = c1 + twopi; - gsto = fmod( thgr70 + c1*ds70 + c1p2p*tfrac + ts70*ts70*fk5r, twopi); - if ( gsto < 0.0 ) - gsto = gsto + twopi; - } - else - gsto = gstime(epoch + 2433281.5); - - -//#include "debug5.cpp" -} // end initl - -/*----------------------------------------------------------------------------- -* -* procedure sgp4init -* -* this procedure initializes variables for sgp4. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* opsmode - mode of operation afspc or improved 'a', 'i' -* whichconst - which set of constants to use 72, 84 -* satn - satellite number -* bstar - sgp4 type drag coefficient kg/m2er -* ecco - eccentricity -* epoch - epoch time in days from jan 0, 1950. 0 hr -* argpo - argument of perigee (output if ds) -* inclo - inclination -* mo - mean anomaly (output if ds) -* no - mean motion -* nodeo - right ascension of ascending node -* -* outputs : -* satrec - common values for subsequent calls -* return code - non-zero on error. -* 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er -* 2 - mean motion less than 0.0 -* 3 - pert elements, ecc < 0.0 or ecc > 1.0 -* 4 - semi-latus rectum < 0.0 -* 5 - epoch elements are sub-orbital -* 6 - satellite has decayed -* -* locals : -* cnodm , snodm , cosim , sinim , cosomm , sinomm -* cc1sq , cc2 , cc3 -* coef , coef1 -* cosio4 - -* day - -* dndt - -* em - eccentricity -* emsq - eccentricity squared -* eeta - -* etasq - -* gam - -* argpm - argument of perigee -* nodem - -* inclm - inclination -* mm - mean anomaly -* nm - mean motion -* perige - perigee -* pinvsq - -* psisq - -* qzms24 - -* rtemsq - -* s1, s2, s3, s4, s5, s6, s7 - -* sfour - -* ss1, ss2, ss3, ss4, ss5, ss6, ss7 - -* sz1, sz2, sz3 -* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 - -* tc - -* temp - -* temp1, temp2, temp3 - -* tsi - -* xpidot - -* xhdot1 - -* z1, z2, z3 - -* z11, z12, z13, z21, z22, z23, z31, z32, z33 - -* -* coupling : -* getgravconst- -* initl - -* dscom - -* dpper - -* dsinit - -* sgp4 - -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -bool sgp4init - ( - gravconsttype whichconst, char opsmode, const int satn, const double epoch, - const double xbstar, const double xecco, const double xargpo, - const double xinclo, const double xmo, const double xno, - const double xnodeo, elsetrec& satrec - ) -{ - /* --------------------- local variables ------------------------ */ - double ao, ainv, con42, cosio, sinio, cosio2, eccsq, - omeosq, posq, rp, rteosq, - cnodm , snodm , cosim , sinim , cosomm, sinomm, cc1sq , - cc2 , cc3 , coef , coef1 , cosio4, day , dndt , - em , emsq , eeta , etasq , gam , argpm , nodem , - inclm , mm , nm , perige, pinvsq, psisq , qzms24, - rtemsq, s1 , s2 , s3 , s4 , s5 , s6 , - s7 , sfour , ss1 , ss2 , ss3 , ss4 , ss5 , - ss6 , ss7 , sz1 , sz2 , sz3 , sz11 , sz12 , - sz13 , sz21 , sz22 , sz23 , sz31 , sz32 , sz33 , - tc , temp , temp1 , temp2 , temp3 , tsi , xpidot, - xhdot1, z1 , z2 , z3 , z11 , z12 , z13 , - z21 , z22 , z23 , z31 , z32 , z33, - qzms2t, ss, j2, j3oj2, j4, x2o3, r[3], v[3], - tumin, mu, radiusearthkm, xke, j3; - - /* ------------------------ initialization --------------------- */ - // sgp4fix divisor for divide by zero check on inclination - // the old check used 1.0 + cos(pi-1.0e-9), but then compared it to - // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency - const double temp4 = 1.5e-12; - - /* ----------- set all near earth variables to zero ------------ */ - satrec.isimp = 0; satrec.method = 'n'; satrec.aycof = 0.0; - satrec.con41 = 0.0; satrec.cc1 = 0.0; satrec.cc4 = 0.0; - satrec.cc5 = 0.0; satrec.d2 = 0.0; satrec.d3 = 0.0; - satrec.d4 = 0.0; satrec.delmo = 0.0; satrec.eta = 0.0; - satrec.argpdot = 0.0; satrec.omgcof = 0.0; satrec.sinmao = 0.0; - satrec.t = 0.0; satrec.t2cof = 0.0; satrec.t3cof = 0.0; - satrec.t4cof = 0.0; satrec.t5cof = 0.0; satrec.x1mth2 = 0.0; - satrec.x7thm1 = 0.0; satrec.mdot = 0.0; satrec.nodedot = 0.0; - satrec.xlcof = 0.0; satrec.xmcof = 0.0; satrec.nodecf = 0.0; - - /* ----------- set all deep space variables to zero ------------ */ - satrec.irez = 0; satrec.d2201 = 0.0; satrec.d2211 = 0.0; - satrec.d3210 = 0.0; satrec.d3222 = 0.0; satrec.d4410 = 0.0; - satrec.d4422 = 0.0; satrec.d5220 = 0.0; satrec.d5232 = 0.0; - satrec.d5421 = 0.0; satrec.d5433 = 0.0; satrec.dedt = 0.0; - satrec.del1 = 0.0; satrec.del2 = 0.0; satrec.del3 = 0.0; - satrec.didt = 0.0; satrec.dmdt = 0.0; satrec.dnodt = 0.0; - satrec.domdt = 0.0; satrec.e3 = 0.0; satrec.ee2 = 0.0; - satrec.peo = 0.0; satrec.pgho = 0.0; satrec.pho = 0.0; - satrec.pinco = 0.0; satrec.plo = 0.0; satrec.se2 = 0.0; - satrec.se3 = 0.0; satrec.sgh2 = 0.0; satrec.sgh3 = 0.0; - satrec.sgh4 = 0.0; satrec.sh2 = 0.0; satrec.sh3 = 0.0; - satrec.si2 = 0.0; satrec.si3 = 0.0; satrec.sl2 = 0.0; - satrec.sl3 = 0.0; satrec.sl4 = 0.0; satrec.gsto = 0.0; - satrec.xfact = 0.0; satrec.xgh2 = 0.0; satrec.xgh3 = 0.0; - satrec.xgh4 = 0.0; satrec.xh2 = 0.0; satrec.xh3 = 0.0; - satrec.xi2 = 0.0; satrec.xi3 = 0.0; satrec.xl2 = 0.0; - satrec.xl3 = 0.0; satrec.xl4 = 0.0; satrec.xlamo = 0.0; - satrec.zmol = 0.0; satrec.zmos = 0.0; satrec.atime = 0.0; - satrec.xli = 0.0; satrec.xni = 0.0; - - // sgp4fix - note the following variables are also passed directly via satrec. - // it is possible to streamline the sgp4init call by deleting the "x" - // variables, but the user would need to set the satrec.* values first. we - // include the additional assignments in case twoline2rv is not used. - satrec.bstar = xbstar; - satrec.ecco = xecco; - satrec.argpo = xargpo; - satrec.inclo = xinclo; - satrec.mo = xmo; - satrec.no = xno; - satrec.nodeo = xnodeo; - - // sgp4fix add opsmode - satrec.operationmode = opsmode; - - /* ------------------------ earth constants ----------------------- */ - // sgp4fix identify constants and allow alternate values - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - ss = 78.0 / radiusearthkm + 1.0; - qzms2t = pow(((120.0 - 78.0) / radiusearthkm), 4); - x2o3 = 2.0 / 3.0; - - satrec.init = 'y'; - satrec.t = 0.0; - - initl - ( - satn, whichconst, satrec.ecco, epoch, satrec.inclo, satrec.no, satrec.method, - ainv, ao, satrec.con41, con42, cosio, cosio2, eccsq, omeosq, - posq, rp, rteosq, sinio, satrec.gsto, satrec.operationmode - ); - satrec.error = 0; - - // sgp4fix remove this check as it is unnecessary - // the mrt check in sgp4 handles decaying satellite cases even if the starting - // condition is below the surface of te earth -// if (rp < 1.0) -// { -// printf("# *** satn%d epoch elts sub-orbital ***\n", satn); -// satrec.error = 5; -// } - - if ((omeosq >= 0.0 ) || ( satrec.no >= 0.0)) - { - satrec.isimp = 0; - if (rp < (220.0 / radiusearthkm + 1.0)) - satrec.isimp = 1; - sfour = ss; - qzms24 = qzms2t; - perige = (rp - 1.0) * radiusearthkm; - - /* - for perigees below 156 km, s and qoms2t are altered - */ - if (perige < 156.0) - { - sfour = perige - 78.0; - if (perige < 98.0) - sfour = 20.0; - qzms24 = pow(((120.0 - sfour) / radiusearthkm), 4.0); - sfour = sfour / radiusearthkm + 1.0; - } - pinvsq = 1.0 / posq; - - tsi = 1.0 / (ao - sfour); - satrec.eta = ao * satrec.ecco * tsi; - etasq = satrec.eta * satrec.eta; - eeta = satrec.ecco * satrec.eta; - psisq = fabs(1.0 - etasq); - coef = qzms24 * pow(tsi, 4.0); - coef1 = coef / pow(psisq, 3.5); - cc2 = coef1 * satrec.no * (ao * (1.0 + 1.5 * etasq + eeta * - (4.0 + etasq)) + 0.375 * j2 * tsi / psisq * satrec.con41 * - (8.0 + 3.0 * etasq * (8.0 + etasq))); - satrec.cc1 = satrec.bstar * cc2; - cc3 = 0.0; - if (satrec.ecco > 1.0e-4) - cc3 = -2.0 * coef * tsi * j3oj2 * satrec.no * sinio / satrec.ecco; - satrec.x1mth2 = 1.0 - cosio2; - satrec.cc4 = 2.0* satrec.no * coef1 * ao * omeosq * - (satrec.eta * (2.0 + 0.5 * etasq) + satrec.ecco * - (0.5 + 2.0 * etasq) - j2 * tsi / (ao * psisq) * - (-3.0 * satrec.con41 * (1.0 - 2.0 * eeta + etasq * - (1.5 - 0.5 * eeta)) + 0.75 * satrec.x1mth2 * - (2.0 * etasq - eeta * (1.0 + etasq)) * cos(2.0 * satrec.argpo))); - satrec.cc5 = 2.0 * coef1 * ao * omeosq * (1.0 + 2.75 * - (etasq + eeta) + eeta * etasq); - cosio4 = cosio2 * cosio2; - temp1 = 1.5 * j2 * pinvsq * satrec.no; - temp2 = 0.5 * temp1 * j2 * pinvsq; - temp3 = -0.46875 * j4 * pinvsq * pinvsq * satrec.no; - satrec.mdot = satrec.no + 0.5 * temp1 * rteosq * satrec.con41 + 0.0625 * - temp2 * rteosq * (13.0 - 78.0 * cosio2 + 137.0 * cosio4); - satrec.argpdot = -0.5 * temp1 * con42 + 0.0625 * temp2 * - (7.0 - 114.0 * cosio2 + 395.0 * cosio4) + - temp3 * (3.0 - 36.0 * cosio2 + 49.0 * cosio4); - xhdot1 = -temp1 * cosio; - satrec.nodedot = xhdot1 + (0.5 * temp2 * (4.0 - 19.0 * cosio2) + - 2.0 * temp3 * (3.0 - 7.0 * cosio2)) * cosio; - xpidot = satrec.argpdot+ satrec.nodedot; - satrec.omgcof = satrec.bstar * cc3 * cos(satrec.argpo); - satrec.xmcof = 0.0; - if (satrec.ecco > 1.0e-4) - satrec.xmcof = -x2o3 * coef * satrec.bstar / eeta; - satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1; - satrec.t2cof = 1.5 * satrec.cc1; - // sgp4fix for divide by zero with xinco = 180 deg - if (fabs(cosio+1.0) > 1.5e-12) - satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / (1.0 + cosio); - else - satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / temp4; - satrec.aycof = -0.5 * j3oj2 * sinio; - satrec.delmo = pow((1.0 + satrec.eta * cos(satrec.mo)), 3); - satrec.sinmao = sin(satrec.mo); - satrec.x7thm1 = 7.0 * cosio2 - 1.0; - - /* --------------- deep space initialization ------------- */ - if ((2*pi / satrec.no) >= 225.0) - { - satrec.method = 'd'; - satrec.isimp = 1; - tc = 0.0; - inclm = satrec.inclo; - - dscom - ( - epoch, satrec.ecco, satrec.argpo, tc, satrec.inclo, satrec.nodeo, - satrec.no, snodm, cnodm, sinim, cosim,sinomm, cosomm, - day, satrec.e3, satrec.ee2, em, emsq, gam, - satrec.peo, satrec.pgho, satrec.pho, satrec.pinco, - satrec.plo, rtemsq, satrec.se2, satrec.se3, - satrec.sgh2, satrec.sgh3, satrec.sgh4, - satrec.sh2, satrec.sh3, satrec.si2, satrec.si3, - satrec.sl2, satrec.sl3, satrec.sl4, s1, s2, s3, s4, s5, - s6, s7, ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3, - sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33, - satrec.xgh2, satrec.xgh3, satrec.xgh4, satrec.xh2, - satrec.xh3, satrec.xi2, satrec.xi3, satrec.xl2, - satrec.xl3, satrec.xl4, nm, z1, z2, z3, z11, - z12, z13, z21, z22, z23, z31, z32, z33, - satrec.zmol, satrec.zmos - ); - dpper - ( - satrec.e3, satrec.ee2, satrec.peo, satrec.pgho, - satrec.pho, satrec.pinco, satrec.plo, satrec.se2, - satrec.se3, satrec.sgh2, satrec.sgh3, satrec.sgh4, - satrec.sh2, satrec.sh3, satrec.si2, satrec.si3, - satrec.sl2, satrec.sl3, satrec.sl4, satrec.t, - satrec.xgh2,satrec.xgh3,satrec.xgh4, satrec.xh2, - satrec.xh3, satrec.xi2, satrec.xi3, satrec.xl2, - satrec.xl3, satrec.xl4, satrec.zmol, satrec.zmos, inclm, satrec.init, - satrec.ecco, satrec.inclo, satrec.nodeo, satrec.argpo, satrec.mo, - satrec.operationmode - ); - - argpm = 0.0; - nodem = 0.0; - mm = 0.0; - - dsinit - ( - whichconst, - cosim, emsq, satrec.argpo, s1, s2, s3, s4, s5, sinim, ss1, ss2, ss3, ss4, - ss5, sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33, satrec.t, tc, - satrec.gsto, satrec.mo, satrec.mdot, satrec.no, satrec.nodeo, - satrec.nodedot, xpidot, z1, z3, z11, z13, z21, z23, z31, z33, - satrec.ecco, eccsq, em, argpm, inclm, mm, nm, nodem, - satrec.irez, satrec.atime, - satrec.d2201, satrec.d2211, satrec.d3210, satrec.d3222 , - satrec.d4410, satrec.d4422, satrec.d5220, satrec.d5232, - satrec.d5421, satrec.d5433, satrec.dedt, satrec.didt, - satrec.dmdt, dndt, satrec.dnodt, satrec.domdt , - satrec.del1, satrec.del2, satrec.del3, satrec.xfact, - satrec.xlamo, satrec.xli, satrec.xni - ); - } - - /* ----------- set variables if not deep space ----------- */ - if (satrec.isimp != 1) - { - cc1sq = satrec.cc1 * satrec.cc1; - satrec.d2 = 4.0 * ao * tsi * cc1sq; - temp = satrec.d2 * tsi * satrec.cc1 / 3.0; - satrec.d3 = (17.0 * ao + sfour) * temp; - satrec.d4 = 0.5 * temp * ao * tsi * (221.0 * ao + 31.0 * sfour) * - satrec.cc1; - satrec.t3cof = satrec.d2 + 2.0 * cc1sq; - satrec.t4cof = 0.25 * (3.0 * satrec.d3 + satrec.cc1 * - (12.0 * satrec.d2 + 10.0 * cc1sq)); - satrec.t5cof = 0.2 * (3.0 * satrec.d4 + - 12.0 * satrec.cc1 * satrec.d3 + - 6.0 * satrec.d2 * satrec.d2 + - 15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq)); - } - } // if omeosq = 0 ... - - /* finally propogate to zero epoch to initialize all others. */ - // sgp4fix take out check to let satellites process until they are actually below earth surface -// if(satrec.error == 0) - sgp4(whichconst, satrec, 0.0, r, v); - - satrec.init = 'n'; - -//#include "debug6.cpp" - //sgp4fix return boolean. satrec.error contains any error codes - return true; -} // end sgp4init - -/*----------------------------------------------------------------------------- -* -* procedure sgp4 -* -* this procedure is the sgp4 prediction model from space command. this is an -* updated and combined version of sgp4 and sdp4, which were originally -* published separately in spacetrack report #3. this version follows the -* methodology from the aiaa paper (2006) describing the history and -* development of the code. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* satrec - initialised structure from sgp4init() call. -* tsince - time eince epoch (minutes) -* -* outputs : -* r - position vector km -* v - velocity km/sec -* return code - non-zero on error. -* 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er -* 2 - mean motion less than 0.0 -* 3 - pert elements, ecc < 0.0 or ecc > 1.0 -* 4 - semi-latus rectum < 0.0 -* 5 - epoch elements are sub-orbital -* 6 - satellite has decayed -* -* locals : -* am - -* axnl, aynl - -* betal - -* cosim , sinim , cosomm , sinomm , cnod , snod , cos2u , -* sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip , -* cosisq , cossu , sinsu , cosu , sinu -* delm - -* delomg - -* dndt - -* eccm - -* emsq - -* ecose - -* el2 - -* eo1 - -* eccp - -* esine - -* argpm - -* argpp - -* omgadf - -* pl - -* r - -* rtemsq - -* rdotl - -* rl - -* rvdot - -* rvdotl - -* su - -* t2 , t3 , t4 , tc -* tem5, temp , temp1 , temp2 , tempa , tempe , templ -* u , ux , uy , uz , vx , vy , vz -* inclm - inclination -* mm - mean anomaly -* nm - mean motion -* nodem - right asc of ascending node -* xinc - -* xincp - -* xl - -* xlm - -* mp - -* xmdf - -* xmx - -* xmy - -* nodedf - -* xnode - -* nodep - -* np - -* -* coupling : -* getgravconst- -* dpper -* dpspace -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -bool sgp4 - ( - gravconsttype whichconst, elsetrec& satrec, double tsince, - double r[3], double v[3] - ) -{ - double am , axnl , aynl , betal , cosim , cnod , - cos2u, coseo1, cosi , cosip , cosisq, cossu , cosu, - delm , delomg, em , emsq , ecose , el2 , eo1 , - ep , esine , argpm, argpp , argpdf, pl, mrt = 0.0, - mvt , rdotl , rl , rvdot , rvdotl, sinim , - sin2u, sineo1, sini , sinip , sinsu , sinu , - snod , su , t2 , t3 , t4 , tem5 , temp, - temp1, temp2 , tempa, tempe , templ , u , ux , - uy , uz , vx , vy , vz , inclm , mm , - nm , nodem, xinc , xincp , xl , xlm , mp , - xmdf , xmx , xmy , nodedf, xnode , nodep, tc , dndt, - twopi, x2o3 , j2 , j3 , tumin, j4 , xke , j3oj2, radiusearthkm, - mu, vkmpersec; - int ktr; - - /* ------------------ set mathematical constants --------------- */ - // sgp4fix divisor for divide by zero check on inclination - // the old check used 1.0 + cos(pi-1.0e-9), but then compared it to - // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency - const double temp4 = 1.5e-12; - twopi = 2.0 * pi; - x2o3 = 2.0 / 3.0; - // sgp4fix identify constants and allow alternate values - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - vkmpersec = radiusearthkm * xke/60.0; - - /* --------------------- clear sgp4 error flag ----------------- */ - satrec.t = tsince; - satrec.error = 0; - - /* ------- update for secular gravity and atmospheric drag ----- */ - xmdf = satrec.mo + satrec.mdot * satrec.t; - argpdf = satrec.argpo + satrec.argpdot * satrec.t; - nodedf = satrec.nodeo + satrec.nodedot * satrec.t; - argpm = argpdf; - mm = xmdf; - t2 = satrec.t * satrec.t; - nodem = nodedf + satrec.nodecf * t2; - tempa = 1.0 - satrec.cc1 * satrec.t; - tempe = satrec.bstar * satrec.cc4 * satrec.t; - templ = satrec.t2cof * t2; - - if (satrec.isimp != 1) - { - delomg = satrec.omgcof * satrec.t; - delm = satrec.xmcof * - (pow((1.0 + satrec.eta * cos(xmdf)), 3) - - satrec.delmo); - temp = delomg + delm; - mm = xmdf + temp; - argpm = argpdf - temp; - t3 = t2 * satrec.t; - t4 = t3 * satrec.t; - tempa = tempa - satrec.d2 * t2 - satrec.d3 * t3 - - satrec.d4 * t4; - tempe = tempe + satrec.bstar * satrec.cc5 * (sin(mm) - - satrec.sinmao); - templ = templ + satrec.t3cof * t3 + t4 * (satrec.t4cof + - satrec.t * satrec.t5cof); - } - - nm = satrec.no; - em = satrec.ecco; - inclm = satrec.inclo; - if (satrec.method == 'd') - { - tc = satrec.t; - dspace - ( - satrec.irez, - satrec.d2201, satrec.d2211, satrec.d3210, - satrec.d3222, satrec.d4410, satrec.d4422, - satrec.d5220, satrec.d5232, satrec.d5421, - satrec.d5433, satrec.dedt, satrec.del1, - satrec.del2, satrec.del3, satrec.didt, - satrec.dmdt, satrec.dnodt, satrec.domdt, - satrec.argpo, satrec.argpdot, satrec.t, tc, - satrec.gsto, satrec.xfact, satrec.xlamo, - satrec.no, satrec.atime, - em, argpm, inclm, satrec.xli, mm, satrec.xni, - nodem, dndt, nm - ); - } // if method = d - - if (nm <= 0.0) - { -// printf("# error nm %f\n", nm); - satrec.error = 2; - // sgp4fix add return - return false; - } - am = pow((xke / nm),x2o3) * tempa * tempa; - nm = xke / pow(am, 1.5); - em = em - tempe; - - // fix tolerance for error recognition - // sgp4fix am is fixed from the previous nm check - if ((em >= 1.0) || (em < -0.001)/* || (am < 0.95)*/ ) - { -// printf("# error em %f\n", em); - satrec.error = 1; - // sgp4fix to return if there is an error in eccentricity - return false; - } - // sgp4fix fix tolerance to avoid a divide by zero - if (em < 1.0e-6) - em = 1.0e-6; - mm = mm + satrec.no * templ; - xlm = mm + argpm + nodem; - emsq = em * em; - temp = 1.0 - emsq; - - nodem = fmod(nodem, twopi); - argpm = fmod(argpm, twopi); - xlm = fmod(xlm, twopi); - mm = fmod(xlm - argpm - nodem, twopi); - - /* ----------------- compute extra mean quantities ------------- */ - sinim = sin(inclm); - cosim = cos(inclm); - - /* -------------------- add lunar-solar periodics -------------- */ - ep = em; - xincp = inclm; - argpp = argpm; - nodep = nodem; - mp = mm; - sinip = sinim; - cosip = cosim; - if (satrec.method == 'd') - { - dpper - ( - satrec.e3, satrec.ee2, satrec.peo, - satrec.pgho, satrec.pho, satrec.pinco, - satrec.plo, satrec.se2, satrec.se3, - satrec.sgh2, satrec.sgh3, satrec.sgh4, - satrec.sh2, satrec.sh3, satrec.si2, - satrec.si3, satrec.sl2, satrec.sl3, - satrec.sl4, satrec.t, satrec.xgh2, - satrec.xgh3, satrec.xgh4, satrec.xh2, - satrec.xh3, satrec.xi2, satrec.xi3, - satrec.xl2, satrec.xl3, satrec.xl4, - satrec.zmol, satrec.zmos, satrec.inclo, - 'n', ep, xincp, nodep, argpp, mp, satrec.operationmode - ); - if (xincp < 0.0) - { - xincp = -xincp; - nodep = nodep + pi; - argpp = argpp - pi; - } - if ((ep < 0.0 ) || ( ep > 1.0)) - { -// printf("# error ep %f\n", ep); - satrec.error = 3; - // sgp4fix add return - return false; - } - } // if method = d - - /* -------------------- long period periodics ------------------ */ - if (satrec.method == 'd') - { - sinip = sin(xincp); - cosip = cos(xincp); - satrec.aycof = -0.5*j3oj2*sinip; - // sgp4fix for divide by zero for xincp = 180 deg - if (fabs(cosip+1.0) > 1.5e-12) - satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / (1.0 + cosip); - else - satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / temp4; - } - axnl = ep * cos(argpp); - temp = 1.0 / (am * (1.0 - ep * ep)); - aynl = ep* sin(argpp) + temp * satrec.aycof; - xl = mp + argpp + nodep + temp * satrec.xlcof * axnl; - - /* --------------------- solve kepler's equation --------------- */ - u = fmod(xl - nodep, twopi); - eo1 = u; - tem5 = 9999.9; - ktr = 1; - // sgp4fix for kepler iteration - // the following iteration needs better limits on corrections - while (( fabs(tem5) >= 1.0e-12) && (ktr <= 10) ) - { - sineo1 = sin(eo1); - coseo1 = cos(eo1); - tem5 = 1.0 - coseo1 * axnl - sineo1 * aynl; - tem5 = (u - aynl * coseo1 + axnl * sineo1 - eo1) / tem5; - if(fabs(tem5) >= 0.95) - tem5 = tem5 > 0.0 ? 0.95 : -0.95; - eo1 = eo1 + tem5; - ktr = ktr + 1; - } - - /* ------------- short period preliminary quantities ----------- */ - ecose = axnl*coseo1 + aynl*sineo1; - esine = axnl*sineo1 - aynl*coseo1; - el2 = axnl*axnl + aynl*aynl; - pl = am*(1.0-el2); - if (pl < 0.0) - { -// printf("# error pl %f\n", pl); - satrec.error = 4; - // sgp4fix add return - return false; - } - else - { - rl = am * (1.0 - ecose); - rdotl = sqrt(am) * esine/rl; - rvdotl = sqrt(pl) / rl; - betal = sqrt(1.0 - el2); - temp = esine / (1.0 + betal); - sinu = am / rl * (sineo1 - aynl - axnl * temp); - cosu = am / rl * (coseo1 - axnl + aynl * temp); - su = atan2(sinu, cosu); - sin2u = (cosu + cosu) * sinu; - cos2u = 1.0 - 2.0 * sinu * sinu; - temp = 1.0 / pl; - temp1 = 0.5 * j2 * temp; - temp2 = temp1 * temp; - - /* -------------- update for short period periodics ------------ */ - if (satrec.method == 'd') - { - cosisq = cosip * cosip; - satrec.con41 = 3.0*cosisq - 1.0; - satrec.x1mth2 = 1.0 - cosisq; - satrec.x7thm1 = 7.0*cosisq - 1.0; - } - mrt = rl * (1.0 - 1.5 * temp2 * betal * satrec.con41) + - 0.5 * temp1 * satrec.x1mth2 * cos2u; - su = su - 0.25 * temp2 * satrec.x7thm1 * sin2u; - xnode = nodep + 1.5 * temp2 * cosip * sin2u; - xinc = xincp + 1.5 * temp2 * cosip * sinip * cos2u; - mvt = rdotl - nm * temp1 * satrec.x1mth2 * sin2u / xke; - rvdot = rvdotl + nm * temp1 * (satrec.x1mth2 * cos2u + - 1.5 * satrec.con41) / xke; - - /* --------------------- orientation vectors ------------------- */ - sinsu = sin(su); - cossu = cos(su); - snod = sin(xnode); - cnod = cos(xnode); - sini = sin(xinc); - cosi = cos(xinc); - xmx = -snod * cosi; - xmy = cnod * cosi; - ux = xmx * sinsu + cnod * cossu; - uy = xmy * sinsu + snod * cossu; - uz = sini * sinsu; - vx = xmx * cossu - cnod * sinsu; - vy = xmy * cossu - snod * sinsu; - vz = sini * cossu; - - /* --------- position and velocity (in km and km/sec) ---------- */ - r[0] = (mrt * ux)* radiusearthkm; - r[1] = (mrt * uy)* radiusearthkm; - r[2] = (mrt * uz)* radiusearthkm; - v[0] = (mvt * ux + rvdot * vx) * vkmpersec; - v[1] = (mvt * uy + rvdot * vy) * vkmpersec; - v[2] = (mvt * uz + rvdot * vz) * vkmpersec; - } // if pl > 0 - - // sgp4fix for decaying satellites - if (mrt < 1.0) - { -// printf("# decay condition %11.6f \n",mrt); - satrec.error = 6; - return false; - } - -//#include "debug7.cpp" - return true; -} // end sgp4 - - -/* ----------------------------------------------------------------------------- -* -* function gstime -* -* this function finds the greenwich sidereal time. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* jdut1 - julian date in ut1 days from 4713 bc -* -* outputs : -* gstime - greenwich sidereal time 0 to 2pi rad -* -* locals : -* temp - temporary variable for doubles rad -* tut1 - julian centuries from the -* jan 1, 2000 12 h epoch (ut1) -* -* coupling : -* none -* -* references : -* vallado 2004, 191, eq 3-45 -* --------------------------------------------------------------------------- */ - -double gstime - ( - double jdut1 - ) - { - const double twopi = 2.0 * pi; - const double deg2rad = pi / 180.0; - double temp, tut1; - - tut1 = (jdut1 - 2451545.0) / 36525.0; - temp = -6.2e-6* tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + - (876600.0*3600 + 8640184.812866) * tut1 + 67310.54841; // sec - temp = fmod(temp * deg2rad / 240.0, twopi); //360/86400 = 1/240, to deg, to rad - - // ------------------------ check quadrants --------------------- - if (temp < 0.0) - temp += twopi; - - return temp; - } // end gstime - -/* ----------------------------------------------------------------------------- -* -* function getgravconst -* -* this function gets constants for the propagator. note that mu is identified to -* facilitiate comparisons with newer models. the common useage is wgs72. -* -* author : david vallado 719-573-2600 21 jul 2006 -* -* inputs : -* whichconst - which set of constants to use wgs72old, wgs72, wgs84 -* -* outputs : -* tumin - minutes in one time unit -* mu - earth gravitational parameter -* radiusearthkm - radius of the earth in km -* xke - reciprocal of tumin -* j2, j3, j4 - un-normalized zonal harmonic values -* j3oj2 - j3 divided by j2 -* -* locals : -* -* coupling : -* none -* -* references : -* norad spacetrack report #3 -* vallado, crawford, hujsak, kelso 2006 - --------------------------------------------------------------------------- */ - -void getgravconst - ( - gravconsttype whichconst, - double& tumin, - double& mu, - double& radiusearthkm, - double& xke, - double& j2, - double& j3, - double& j4, - double& j3oj2 - ) - { - - switch (whichconst) - { - // -- wgs-72 low precision str#3 constants -- - case wgs72old: - mu = 398600.79964; // in km3 / s2 - radiusearthkm = 6378.135; // km - xke = 0.0743669161; - tumin = 1.0 / xke; - j2 = 0.001082616; - j3 = -0.00000253881; - j4 = -0.00000165597; - j3oj2 = j3 / j2; - break; - // ------------ wgs-72 constants ------------ - case wgs72: - mu = 398600.8; // in km3 / s2 - radiusearthkm = 6378.135; // km - xke = 60.0 / sqrt(radiusearthkm*radiusearthkm*radiusearthkm/mu); - tumin = 1.0 / xke; - j2 = 0.001082616; - j3 = -0.00000253881; - j4 = -0.00000165597; - j3oj2 = j3 / j2; - break; - case wgs84: - // ------------ wgs-84 constants ------------ - mu = 398600.5; // in km3 / s2 - radiusearthkm = 6378.137; // km - xke = 60.0 / sqrt(radiusearthkm*radiusearthkm*radiusearthkm/mu); - tumin = 1.0 / xke; - j2 = 0.00108262998905; - j3 = -0.00000253215306; - j4 = -0.00000161098761; - j3oj2 = j3 / j2; - break; - default: - fprintf(stderr,"unknown gravity option (%d)\n",whichconst); - break; - } - - } // end getgravconst - - - - - +/* ---------------------------------------------------------------- +* +* sgp4unit.cpp +* +* this file contains the sgp4 procedures for analytical propagation +* of a satellite. the code was originally released in the 1980 and 1986 +* spacetrack papers. a detailed discussion of the theory and history +* may be found in the 2006 aiaa paper by vallado, crawford, hujsak, +* and kelso. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 3 Nov 08 david vallado +* put returns in for error codes +* changes : +* 29 sep 08 david vallado +* fix atime for faster operation in dspace +* add operationmode for afspc (a) or improved (i) +* performance mode +* 16 jun 08 david vallado +* update small eccentricity check +* 16 nov 07 david vallado +* misc fixes for better compliance +* 20 apr 07 david vallado +* misc fixes for constants +* 11 aug 06 david vallado +* chg lyddane choice back to strn3, constants, misc doc +* 15 dec 05 david vallado +* misc fixes +* 26 jul 05 david vallado +* fixes for paper +* note that each fix is preceded by a +* comment with "sgp4fix" and an explanation of +* what was changed +* 10 aug 04 david vallado +* 2nd printing baseline working +* 14 may 01 david vallado +* 2nd edition baseline +* 80 norad +* original baseline +* ---------------------------------------------------------------- */ + +#include "sgp4unit.h" + +const char help = 'n'; +FILE *dbgfile; + + +/* ----------- local functions - only ever used internally by sgp4 ---------- */ +static void dpper + ( + double e3, double ee2, double peo, double pgho, double pho, + double pinco, double plo, double se2, double se3, double sgh2, + double sgh3, double sgh4, double sh2, double sh3, double si2, + double si3, double sl2, double sl3, double sl4, double t, + double xgh2, double xgh3, double xgh4, double xh2, double xh3, + double xi2, double xi3, double xl2, double xl3, double xl4, + double zmol, double zmos, double inclo, + char init, + double& ep, double& inclp, double& nodep, double& argpp, double& mp, + char opsmode + ); + +static void dscom + ( + double epoch, double ep, double argpp, double tc, double inclp, + double nodep, double np, + double& snodm, double& cnodm, double& sinim, double& cosim, double& sinomm, + double& cosomm,double& day, double& e3, double& ee2, double& em, + double& emsq, double& gam, double& peo, double& pgho, double& pho, + double& pinco, double& plo, double& rtemsq, double& se2, double& se3, + double& sgh2, double& sgh3, double& sgh4, double& sh2, double& sh3, + double& si2, double& si3, double& sl2, double& sl3, double& sl4, + double& s1, double& s2, double& s3, double& s4, double& s5, + double& s6, double& s7, double& ss1, double& ss2, double& ss3, + double& ss4, double& ss5, double& ss6, double& ss7, double& sz1, + double& sz2, double& sz3, double& sz11, double& sz12, double& sz13, + double& sz21, double& sz22, double& sz23, double& sz31, double& sz32, + double& sz33, double& xgh2, double& xgh3, double& xgh4, double& xh2, + double& xh3, double& xi2, double& xi3, double& xl2, double& xl3, + double& xl4, double& nm, double& z1, double& z2, double& z3, + double& z11, double& z12, double& z13, double& z21, double& z22, + double& z23, double& z31, double& z32, double& z33, double& zmol, + double& zmos + ); + +static void dsinit + ( + gravconsttype whichconst, + double cosim, double emsq, double argpo, double s1, double s2, + double s3, double s4, double s5, double sinim, double ss1, + double ss2, double ss3, double ss4, double ss5, double sz1, + double sz3, double sz11, double sz13, double sz21, double sz23, + double sz31, double sz33, double t, double tc, double gsto, + double mo, double mdot, double no, double nodeo, double nodedot, + double xpidot, double z1, double z3, double z11, double z13, + double z21, double z23, double z31, double z33, double ecco, + double eccsq, double& em, double& argpm, double& inclm, double& mm, + double& nm, double& nodem, + int& irez, + double& atime, double& d2201, double& d2211, double& d3210, double& d3222, + double& d4410, double& d4422, double& d5220, double& d5232, double& d5421, + double& d5433, double& dedt, double& didt, double& dmdt, double& dndt, + double& dnodt, double& domdt, double& del1, double& del2, double& del3, + double& xfact, double& xlamo, double& xli, double& xni + ); + +static void dspace + ( + int irez, + double d2201, double d2211, double d3210, double d3222, double d4410, + double d4422, double d5220, double d5232, double d5421, double d5433, + double dedt, double del1, double del2, double del3, double didt, + double dmdt, double dnodt, double domdt, double argpo, double argpdot, + double t, double tc, double gsto, double xfact, double xlamo, + double no, + double& atime, double& em, double& argpm, double& inclm, double& xli, + double& mm, double& xni, double& nodem, double& dndt, double& nm + ); + +static void initl + ( + int satn, gravconsttype whichconst, + double ecco, double epoch, double inclo, double& no, + char& method, + double& ainv, double& ao, double& con41, double& con42, double& cosio, + double& cosio2,double& eccsq, double& omeosq, double& posq, + double& rp, double& rteosq,double& sinio , double& gsto, char opsmode + ); + +/* ----------------------------------------------------------------------------- +* +* procedure dpper +* +* this procedure provides deep space long period periodic contributions +* to the mean elements. by design, these periodics are zero at epoch. +* this used to be dscom which included initialization, but it's really a +* recurring function. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* e3 - +* ee2 - +* peo - +* pgho - +* pho - +* pinco - +* plo - +* se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 - +* t - +* xh2, xh3, xi2, xi3, xl2, xl3, xl4 - +* zmol - +* zmos - +* ep - eccentricity 0.0 - 1.0 +* inclo - inclination - needed for lyddane modification +* nodep - right ascension of ascending node +* argpp - argument of perigee +* mp - mean anomaly +* +* outputs : +* ep - eccentricity 0.0 - 1.0 +* inclp - inclination +* nodep - right ascension of ascending node +* argpp - argument of perigee +* mp - mean anomaly +* +* locals : +* alfdp - +* betdp - +* cosip , sinip , cosop , sinop , +* dalf - +* dbet - +* dls - +* f2, f3 - +* pe - +* pgh - +* ph - +* pinc - +* pl - +* sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis , +* sll , sls +* xls - +* xnoh - +* zf - +* zm - +* +* coupling : +* none. +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void dpper + ( + double e3, double ee2, double peo, double pgho, double pho, + double pinco, double plo, double se2, double se3, double sgh2, + double sgh3, double sgh4, double sh2, double sh3, double si2, + double si3, double sl2, double sl3, double sl4, double t, + double xgh2, double xgh3, double xgh4, double xh2, double xh3, + double xi2, double xi3, double xl2, double xl3, double xl4, + double zmol, double zmos, double inclo, + char init, + double& ep, double& inclp, double& nodep, double& argpp, double& mp, + char opsmode + ) +{ + /* --------------------- local variables ------------------------ */ + const double twopi = 2.0 * pi; + double alfdp, betdp, cosip, cosop, dalf, dbet, dls, + f2, f3, pe, pgh, ph, pinc, pl , + sel, ses, sghl, sghs, shll, shs, sil, + sinip, sinop, sinzf, sis, sll, sls, xls, + xnoh, zf, zm, zel, zes, znl, zns; + + /* kill warning */ + inclo = 0.; + + /* ---------------------- constants ----------------------------- */ + zns = 1.19459e-5; + zes = 0.01675; + znl = 1.5835218e-4; + zel = 0.05490; + + /* --------------- calculate time varying periodics ----------- */ + zm = zmos + zns * t; + // be sure that the initial call has time set to zero + if (init == 'y') + zm = zmos; + zf = zm + 2.0 * zes * sin(zm); + sinzf = sin(zf); + f2 = 0.5 * sinzf * sinzf - 0.25; + f3 = -0.5 * sinzf * cos(zf); + ses = se2* f2 + se3 * f3; + sis = si2 * f2 + si3 * f3; + sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf; + sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf; + shs = sh2 * f2 + sh3 * f3; + zm = zmol + znl * t; + if (init == 'y') + zm = zmol; + zf = zm + 2.0 * zel * sin(zm); + sinzf = sin(zf); + f2 = 0.5 * sinzf * sinzf - 0.25; + f3 = -0.5 * sinzf * cos(zf); + sel = ee2 * f2 + e3 * f3; + sil = xi2 * f2 + xi3 * f3; + sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf; + sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf; + shll = xh2 * f2 + xh3 * f3; + pe = ses + sel; + pinc = sis + sil; + pl = sls + sll; + pgh = sghs + sghl; + ph = shs + shll; + + if (init == 'n') + { + pe = pe - peo; + pinc = pinc - pinco; + pl = pl - plo; + pgh = pgh - pgho; + ph = ph - pho; + inclp = inclp + pinc; + ep = ep + pe; + sinip = sin(inclp); + cosip = cos(inclp); + + /* ----------------- apply periodics directly ------------ */ + // sgp4fix for lyddane choice + // strn3 used original inclination - this is technically feasible + // gsfc used perturbed inclination - also technically feasible + // probably best to readjust the 0.2 limit value and limit discontinuity + // 0.2 rad = 11.45916 deg + // use next line for original strn3 approach and original inclination + // if (inclo >= 0.2) + // use next line for gsfc version and perturbed inclination + if (inclp >= 0.2) + { + ph = ph / sinip; + pgh = pgh - cosip * ph; + argpp = argpp + pgh; + nodep = nodep + ph; + mp = mp + pl; + } + else + { + /* ---- apply periodics with lyddane modification ---- */ + sinop = sin(nodep); + cosop = cos(nodep); + alfdp = sinip * sinop; + betdp = sinip * cosop; + dalf = ph * cosop + pinc * cosip * sinop; + dbet = -ph * sinop + pinc * cosip * cosop; + alfdp = alfdp + dalf; + betdp = betdp + dbet; + nodep = fmod(nodep, twopi); + // sgp4fix for afspc written intrinsic functions + // nodep used without a trigonometric function ahead + if ((nodep < 0.0) && (opsmode == 'a')) + nodep = nodep + twopi; + xls = mp + argpp + cosip * nodep; + dls = pl + pgh - pinc * nodep * sinip; + xls = xls + dls; + xnoh = nodep; + nodep = atan2(alfdp, betdp); + // sgp4fix for afspc written intrinsic functions + // nodep used without a trigonometric function ahead + if ((nodep < 0.0) && (opsmode == 'a')) + nodep = nodep + twopi; + if (fabs(xnoh - nodep) > pi){ + if (nodep < xnoh) + nodep = nodep + twopi; + else + nodep = nodep - twopi; + } + mp = mp + pl; + argpp = xls - mp - cosip * nodep; + } + } // if init == 'n' + +//#include "debug1.cpp" +} // end dpper + +/*----------------------------------------------------------------------------- +* +* procedure dscom +* +* this procedure provides deep space common items used by both the secular +* and periodics subroutines. input is provided as shown. this routine +* used to be called dpper, but the functions inside weren't well organized. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* epoch - +* ep - eccentricity +* argpp - argument of perigee +* tc - +* inclp - inclination +* nodep - right ascension of ascending node +* np - mean motion +* +* outputs : +* sinim , cosim , sinomm , cosomm , snodm , cnodm +* day - +* e3 - +* ee2 - +* em - eccentricity +* emsq - eccentricity squared +* gam - +* peo - +* pgho - +* pho - +* pinco - +* plo - +* rtemsq - +* se2, se3 - +* sgh2, sgh3, sgh4 - +* sh2, sh3, si2, si3, sl2, sl3, sl4 - +* s1, s2, s3, s4, s5, s6, s7 - +* ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 - +* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 - +* xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 - +* nm - mean motion +* z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 - +* zmol - +* zmos - +* +* locals : +* a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 - +* betasq - +* cc - +* ctem, stem - +* x1, x2, x3, x4, x5, x6, x7, x8 - +* xnodce - +* xnoi - +* zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl , +* zcosi , zsini , zcosil , zsinil , +* zx - +* zy - +* +* coupling : +* none. +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void dscom + ( + double epoch, double ep, double argpp, double tc, double inclp, + double nodep, double np, + double& snodm, double& cnodm, double& sinim, double& cosim, double& sinomm, + double& cosomm,double& day, double& e3, double& ee2, double& em, + double& emsq, double& gam, double& peo, double& pgho, double& pho, + double& pinco, double& plo, double& rtemsq, double& se2, double& se3, + double& sgh2, double& sgh3, double& sgh4, double& sh2, double& sh3, + double& si2, double& si3, double& sl2, double& sl3, double& sl4, + double& s1, double& s2, double& s3, double& s4, double& s5, + double& s6, double& s7, double& ss1, double& ss2, double& ss3, + double& ss4, double& ss5, double& ss6, double& ss7, double& sz1, + double& sz2, double& sz3, double& sz11, double& sz12, double& sz13, + double& sz21, double& sz22, double& sz23, double& sz31, double& sz32, + double& sz33, double& xgh2, double& xgh3, double& xgh4, double& xh2, + double& xh3, double& xi2, double& xi3, double& xl2, double& xl3, + double& xl4, double& nm, double& z1, double& z2, double& z3, + double& z11, double& z12, double& z13, double& z21, double& z22, + double& z23, double& z31, double& z32, double& z33, double& zmol, + double& zmos + ) +{ + /* -------------------------- constants ------------------------- */ + const double zes = 0.01675; + const double zel = 0.05490; + const double c1ss = 2.9864797e-6; + const double c1l = 4.7968065e-7; + const double zsinis = 0.39785416; + const double zcosis = 0.91744867; + const double zcosgs = 0.1945905; + const double zsings = -0.98088458; + const double twopi = 2.0 * pi; + + /* --------------------- local variables ------------------------ */ + int lsflg; + double a1 , a2 , a3 , a4 , a5 , a6 , a7 , + a8 , a9 , a10 , betasq, cc , ctem , stem , + x1 , x2 , x3 , x4 , x5 , x6 , x7 , + x8 , xnodce, xnoi , zcosg , zcosgl, zcosh , zcoshl, + zcosi , zcosil, zsing , zsingl, zsinh , zsinhl, zsini , + zsinil, zx , zy; + + nm = np; + em = ep; + snodm = sin(nodep); + cnodm = cos(nodep); + sinomm = sin(argpp); + cosomm = cos(argpp); + sinim = sin(inclp); + cosim = cos(inclp); + emsq = em * em; + betasq = 1.0 - emsq; + rtemsq = sqrt(betasq); + + /* ----------------- initialize lunar solar terms --------------- */ + peo = 0.0; + pinco = 0.0; + plo = 0.0; + pgho = 0.0; + pho = 0.0; + day = epoch + 18261.5 + tc / 1440.0; + xnodce = fmod(4.5236020 - 9.2422029e-4 * day, twopi); + stem = sin(xnodce); + ctem = cos(xnodce); + zcosil = 0.91375164 - 0.03568096 * ctem; + zsinil = sqrt(1.0 - zcosil * zcosil); + zsinhl = 0.089683511 * stem / zsinil; + zcoshl = sqrt(1.0 - zsinhl * zsinhl); + gam = 5.8351514 + 0.0019443680 * day; + zx = 0.39785416 * stem / zsinil; + zy = zcoshl * ctem + 0.91744867 * zsinhl * stem; + zx = atan2(zx, zy); + zx = gam + zx - xnodce; + zcosgl = cos(zx); + zsingl = sin(zx); + + /* ------------------------- do solar terms --------------------- */ + zcosg = zcosgs; + zsing = zsings; + zcosi = zcosis; + zsini = zsinis; + zcosh = cnodm; + zsinh = snodm; + cc = c1ss; + xnoi = 1.0 / nm; + + for (lsflg = 1; lsflg <= 2; lsflg++) + { + a1 = zcosg * zcosh + zsing * zcosi * zsinh; + a3 = -zsing * zcosh + zcosg * zcosi * zsinh; + a7 = -zcosg * zsinh + zsing * zcosi * zcosh; + a8 = zsing * zsini; + a9 = zsing * zsinh + zcosg * zcosi * zcosh; + a10 = zcosg * zsini; + a2 = cosim * a7 + sinim * a8; + a4 = cosim * a9 + sinim * a10; + a5 = -sinim * a7 + cosim * a8; + a6 = -sinim * a9 + cosim * a10; + + x1 = a1 * cosomm + a2 * sinomm; + x2 = a3 * cosomm + a4 * sinomm; + x3 = -a1 * sinomm + a2 * cosomm; + x4 = -a3 * sinomm + a4 * cosomm; + x5 = a5 * sinomm; + x6 = a6 * sinomm; + x7 = a5 * cosomm; + x8 = a6 * cosomm; + + z31 = 12.0 * x1 * x1 - 3.0 * x3 * x3; + z32 = 24.0 * x1 * x2 - 6.0 * x3 * x4; + z33 = 12.0 * x2 * x2 - 3.0 * x4 * x4; + z1 = 3.0 * (a1 * a1 + a2 * a2) + z31 * emsq; + z2 = 6.0 * (a1 * a3 + a2 * a4) + z32 * emsq; + z3 = 3.0 * (a3 * a3 + a4 * a4) + z33 * emsq; + z11 = -6.0 * a1 * a5 + emsq * (-24.0 * x1 * x7-6.0 * x3 * x5); + z12 = -6.0 * (a1 * a6 + a3 * a5) + emsq * + (-24.0 * (x2 * x7 + x1 * x8) - 6.0 * (x3 * x6 + x4 * x5)); + z13 = -6.0 * a3 * a6 + emsq * (-24.0 * x2 * x8 - 6.0 * x4 * x6); + z21 = 6.0 * a2 * a5 + emsq * (24.0 * x1 * x5 - 6.0 * x3 * x7); + z22 = 6.0 * (a4 * a5 + a2 * a6) + emsq * + (24.0 * (x2 * x5 + x1 * x6) - 6.0 * (x4 * x7 + x3 * x8)); + z23 = 6.0 * a4 * a6 + emsq * (24.0 * x2 * x6 - 6.0 * x4 * x8); + z1 = z1 + z1 + betasq * z31; + z2 = z2 + z2 + betasq * z32; + z3 = z3 + z3 + betasq * z33; + s3 = cc * xnoi; + s2 = -0.5 * s3 / rtemsq; + s4 = s3 * rtemsq; + s1 = -15.0 * em * s4; + s5 = x1 * x3 + x2 * x4; + s6 = x2 * x3 + x1 * x4; + s7 = x2 * x4 - x1 * x3; + + /* ----------------------- do lunar terms ------------------- */ + if (lsflg == 1) + { + ss1 = s1; + ss2 = s2; + ss3 = s3; + ss4 = s4; + ss5 = s5; + ss6 = s6; + ss7 = s7; + sz1 = z1; + sz2 = z2; + sz3 = z3; + sz11 = z11; + sz12 = z12; + sz13 = z13; + sz21 = z21; + sz22 = z22; + sz23 = z23; + sz31 = z31; + sz32 = z32; + sz33 = z33; + zcosg = zcosgl; + zsing = zsingl; + zcosi = zcosil; + zsini = zsinil; + zcosh = zcoshl * cnodm + zsinhl * snodm; + zsinh = snodm * zcoshl - cnodm * zsinhl; + cc = c1l; + } + } + + zmol = fmod(4.7199672 + 0.22997150 * day - gam, twopi); + zmos = fmod(6.2565837 + 0.017201977 * day, twopi); + + /* ------------------------ do solar terms ---------------------- */ + se2 = 2.0 * ss1 * ss6; + se3 = 2.0 * ss1 * ss7; + si2 = 2.0 * ss2 * sz12; + si3 = 2.0 * ss2 * (sz13 - sz11); + sl2 = -2.0 * ss3 * sz2; + sl3 = -2.0 * ss3 * (sz3 - sz1); + sl4 = -2.0 * ss3 * (-21.0 - 9.0 * emsq) * zes; + sgh2 = 2.0 * ss4 * sz32; + sgh3 = 2.0 * ss4 * (sz33 - sz31); + sgh4 = -18.0 * ss4 * zes; + sh2 = -2.0 * ss2 * sz22; + sh3 = -2.0 * ss2 * (sz23 - sz21); + + /* ------------------------ do lunar terms ---------------------- */ + ee2 = 2.0 * s1 * s6; + e3 = 2.0 * s1 * s7; + xi2 = 2.0 * s2 * z12; + xi3 = 2.0 * s2 * (z13 - z11); + xl2 = -2.0 * s3 * z2; + xl3 = -2.0 * s3 * (z3 - z1); + xl4 = -2.0 * s3 * (-21.0 - 9.0 * emsq) * zel; + xgh2 = 2.0 * s4 * z32; + xgh3 = 2.0 * s4 * (z33 - z31); + xgh4 = -18.0 * s4 * zel; + xh2 = -2.0 * s2 * z22; + xh3 = -2.0 * s2 * (z23 - z21); + +//#include "debug2.cpp" +} // end dscom + +/*----------------------------------------------------------------------------- +* +* procedure dsinit +* +* this procedure provides deep space contributions to mean motion dot due +* to geopotential resonance with half day and one day orbits. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* cosim, sinim- +* emsq - eccentricity squared +* argpo - argument of perigee +* s1, s2, s3, s4, s5 - +* ss1, ss2, ss3, ss4, ss5 - +* sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 - +* t - time +* tc - +* gsto - greenwich sidereal time rad +* mo - mean anomaly +* mdot - mean anomaly dot (rate) +* no - mean motion +* nodeo - right ascension of ascending node +* nodedot - right ascension of ascending node dot (rate) +* xpidot - +* z1, z3, z11, z13, z21, z23, z31, z33 - +* eccm - eccentricity +* argpm - argument of perigee +* inclm - inclination +* mm - mean anomaly +* xn - mean motion +* nodem - right ascension of ascending node +* +* outputs : +* em - eccentricity +* argpm - argument of perigee +* inclm - inclination +* mm - mean anomaly +* nm - mean motion +* nodem - right ascension of ascending node +* irez - flag for resonance 0-none, 1-one day, 2-half day +* atime - +* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 - +* dedt - +* didt - +* dmdt - +* dndt - +* dnodt - +* domdt - +* del1, del2, del3 - +* ses , sghl , sghs , sgs , shl , shs , sis , sls +* theta - +* xfact - +* xlamo - +* xli - +* xni +* +* locals : +* ainv2 - +* aonv - +* cosisq - +* eoc - +* f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 - +* g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 - +* sini2 - +* temp - +* temp1 - +* theta - +* xno2 - +* +* coupling : +* getgravconst +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void dsinit + ( + gravconsttype whichconst, + double cosim, double emsq, double argpo, double s1, double s2, + double s3, double s4, double s5, double sinim, double ss1, + double ss2, double ss3, double ss4, double ss5, double sz1, + double sz3, double sz11, double sz13, double sz21, double sz23, + double sz31, double sz33, double t, double tc, double gsto, + double mo, double mdot, double no, double nodeo, double nodedot, + double xpidot, double z1, double z3, double z11, double z13, + double z21, double z23, double z31, double z33, double ecco, + double eccsq, double& em, double& argpm, double& inclm, double& mm, + double& nm, double& nodem, + int& irez, + double& atime, double& d2201, double& d2211, double& d3210, double& d3222, + double& d4410, double& d4422, double& d5220, double& d5232, double& d5421, + double& d5433, double& dedt, double& didt, double& dmdt, double& dndt, + double& dnodt, double& domdt, double& del1, double& del2, double& del3, + double& xfact, double& xlamo, double& xli, double& xni + ) +{ + /* --------------------- local variables ------------------------ */ + const double twopi = 2.0 * pi; + + double ainv2 , aonv=0.0, cosisq, eoc, f220 , f221 , f311 , + f321 , f322 , f330 , f441 , f442 , f522 , f523 , + f542 , f543 , g200 , g201 , g211 , g300 , g310 , + g322 , g410 , g422 , g520 , g521 , g532 , g533 , + ses , sgs , sghl , sghs , shs , shll , sis , + sini2 , sls , temp , temp1 , theta , xno2 , q22 , + q31 , q33 , root22, root44, root54, rptim , root32, + root52, x2o3 , xke , znl , emo , zns , emsqo, + tumin, mu, radiusearthkm, j2, j3, j4, j3oj2; + + q22 = 1.7891679e-6; + q31 = 2.1460748e-6; + q33 = 2.2123015e-7; + root22 = 1.7891679e-6; + root44 = 7.3636953e-9; + root54 = 2.1765803e-9; + rptim = 4.37526908801129966e-3; // this equates to 7.29211514668855e-5 rad/sec + root32 = 3.7393792e-7; + root52 = 1.1428639e-7; + x2o3 = 2.0 / 3.0; + znl = 1.5835218e-4; + zns = 1.19459e-5; + + // sgp4fix identify constants and allow alternate values + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + + /* -------------------- deep space initialization ------------ */ + irez = 0; + if ((nm < 0.0052359877) && (nm > 0.0034906585)) + irez = 1; + if ((nm >= 8.26e-3) && (nm <= 9.24e-3) && (em >= 0.5)) + irez = 2; + + /* ------------------------ do solar terms ------------------- */ + ses = ss1 * zns * ss5; + sis = ss2 * zns * (sz11 + sz13); + sls = -zns * ss3 * (sz1 + sz3 - 14.0 - 6.0 * emsq); + sghs = ss4 * zns * (sz31 + sz33 - 6.0); + shs = -zns * ss2 * (sz21 + sz23); + // sgp4fix for 180 deg incl + if ((inclm < 5.2359877e-2) || (inclm > pi - 5.2359877e-2)) + shs = 0.0; + if (sinim != 0.0) + shs = shs / sinim; + sgs = sghs - cosim * shs; + + /* ------------------------- do lunar terms ------------------ */ + dedt = ses + s1 * znl * s5; + didt = sis + s2 * znl * (z11 + z13); + dmdt = sls - znl * s3 * (z1 + z3 - 14.0 - 6.0 * emsq); + sghl = s4 * znl * (z31 + z33 - 6.0); + shll = -znl * s2 * (z21 + z23); + // sgp4fix for 180 deg incl + if ((inclm < 5.2359877e-2) || (inclm > pi - 5.2359877e-2)) + shll = 0.0; + domdt = sgs + sghl; + dnodt = shs; + if (sinim != 0.0) + { + domdt = domdt - cosim / sinim * shll; + dnodt = dnodt + shll / sinim; + } + + /* ----------- calculate deep space resonance effects -------- */ + dndt = 0.0; + theta = fmod(gsto + tc * rptim, twopi); + em = em + dedt * t; + inclm = inclm + didt * t; + argpm = argpm + domdt * t; + nodem = nodem + dnodt * t; + mm = mm + dmdt * t; + // sgp4fix for negative inclinations + // the following if statement should be commented out + //if (inclm < 0.0) + // { + // inclm = -inclm; + // argpm = argpm - pi; + // nodem = nodem + pi; + // } + + /* -------------- initialize the resonance terms ------------- */ + if (irez != 0) + { + aonv = pow(nm / xke, x2o3); + + /* ---------- geopotential resonance for 12 hour orbits ------ */ + if (irez == 2) + { + cosisq = cosim * cosim; + emo = em; + em = ecco; + emsqo = emsq; + emsq = eccsq; + eoc = em * emsq; + g201 = -0.306 - (em - 0.64) * 0.440; + + if (em <= 0.65) + { + g211 = 3.616 - 13.2470 * em + 16.2900 * emsq; + g310 = -19.302 + 117.3900 * em - 228.4190 * emsq + 156.5910 * eoc; + g322 = -18.9068 + 109.7927 * em - 214.6334 * emsq + 146.5816 * eoc; + g410 = -41.122 + 242.6940 * em - 471.0940 * emsq + 313.9530 * eoc; + g422 = -146.407 + 841.8800 * em - 1629.014 * emsq + 1083.4350 * eoc; + g520 = -532.114 + 3017.977 * em - 5740.032 * emsq + 3708.2760 * eoc; + } + else + { + g211 = -72.099 + 331.819 * em - 508.738 * emsq + 266.724 * eoc; + g310 = -346.844 + 1582.851 * em - 2415.925 * emsq + 1246.113 * eoc; + g322 = -342.585 + 1554.908 * em - 2366.899 * emsq + 1215.972 * eoc; + g410 = -1052.797 + 4758.686 * em - 7193.992 * emsq + 3651.957 * eoc; + g422 = -3581.690 + 16178.110 * em - 24462.770 * emsq + 12422.520 * eoc; + if (em > 0.715) + g520 =-5149.66 + 29936.92 * em - 54087.36 * emsq + 31324.56 * eoc; + else + g520 = 1464.74 - 4664.75 * em + 3763.64 * emsq; + } + if (em < 0.7) + { + g533 = -919.22770 + 4988.6100 * em - 9064.7700 * emsq + 5542.21 * eoc; + g521 = -822.71072 + 4568.6173 * em - 8491.4146 * emsq + 5337.524 * eoc; + g532 = -853.66600 + 4690.2500 * em - 8624.7700 * emsq + 5341.4 * eoc; + } + else + { + g533 =-37995.780 + 161616.52 * em - 229838.20 * emsq + 109377.94 * eoc; + g521 =-51752.104 + 218913.95 * em - 309468.16 * emsq + 146349.42 * eoc; + g532 =-40023.880 + 170470.89 * em - 242699.48 * emsq + 115605.82 * eoc; + } + + sini2= sinim * sinim; + f220 = 0.75 * (1.0 + 2.0 * cosim+cosisq); + f221 = 1.5 * sini2; + f321 = 1.875 * sinim * (1.0 - 2.0 * cosim - 3.0 * cosisq); + f322 = -1.875 * sinim * (1.0 + 2.0 * cosim - 3.0 * cosisq); + f441 = 35.0 * sini2 * f220; + f442 = 39.3750 * sini2 * sini2; + f522 = 9.84375 * sinim * (sini2 * (1.0 - 2.0 * cosim- 5.0 * cosisq) + + 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq) ); + f523 = sinim * (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + + 10.0 * cosisq) + 6.56250012 * (1.0+2.0 * cosim - 3.0 * cosisq)); + f542 = 29.53125 * sinim * (2.0 - 8.0 * cosim+cosisq * + (-12.0 + 8.0 * cosim + 10.0 * cosisq)); + f543 = 29.53125 * sinim * (-2.0 - 8.0 * cosim+cosisq * + (12.0 + 8.0 * cosim - 10.0 * cosisq)); + xno2 = nm * nm; + ainv2 = aonv * aonv; + temp1 = 3.0 * xno2 * ainv2; + temp = temp1 * root22; + d2201 = temp * f220 * g201; + d2211 = temp * f221 * g211; + temp1 = temp1 * aonv; + temp = temp1 * root32; + d3210 = temp * f321 * g310; + d3222 = temp * f322 * g322; + temp1 = temp1 * aonv; + temp = 2.0 * temp1 * root44; + d4410 = temp * f441 * g410; + d4422 = temp * f442 * g422; + temp1 = temp1 * aonv; + temp = temp1 * root52; + d5220 = temp * f522 * g520; + d5232 = temp * f523 * g532; + temp = 2.0 * temp1 * root54; + d5421 = temp * f542 * g521; + d5433 = temp * f543 * g533; + xlamo = fmod(mo + nodeo + nodeo-theta - theta, twopi); + xfact = mdot + dmdt + 2.0 * (nodedot + dnodt - rptim) - no; + em = emo; + emsq = emsqo; + } + + /* ---------------- synchronous resonance terms -------------- */ + if (irez == 1) + { + g200 = 1.0 + emsq * (-2.5 + 0.8125 * emsq); + g310 = 1.0 + 2.0 * emsq; + g300 = 1.0 + emsq * (-6.0 + 6.60937 * emsq); + f220 = 0.75 * (1.0 + cosim) * (1.0 + cosim); + f311 = 0.9375 * sinim * sinim * (1.0 + 3.0 * cosim) - 0.75 * (1.0 + cosim); + f330 = 1.0 + cosim; + f330 = 1.875 * f330 * f330 * f330; + del1 = 3.0 * nm * nm * aonv * aonv; + del2 = 2.0 * del1 * f220 * g200 * q22; + del3 = 3.0 * del1 * f330 * g300 * q33 * aonv; + del1 = del1 * f311 * g310 * q31 * aonv; + xlamo = fmod(mo + nodeo + argpo - theta, twopi); + xfact = mdot + xpidot - rptim + dmdt + domdt + dnodt - no; + } + + /* ------------ for sgp4, initialize the integrator ---------- */ + xli = xlamo; + xni = no; + atime = 0.0; + nm = no + dndt; + } + +//#include "debug3.cpp" +} // end dsinit + +/*----------------------------------------------------------------------------- +* +* procedure dspace +* +* this procedure provides deep space contributions to mean elements for +* perturbing third body. these effects have been averaged over one +* revolution of the sun and moon. for earth resonance effects, the +* effects have been averaged over no revolutions of the satellite. +* (mean motion) +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 - +* dedt - +* del1, del2, del3 - +* didt - +* dmdt - +* dnodt - +* domdt - +* irez - flag for resonance 0-none, 1-one day, 2-half day +* argpo - argument of perigee +* argpdot - argument of perigee dot (rate) +* t - time +* tc - +* gsto - gst +* xfact - +* xlamo - +* no - mean motion +* atime - +* em - eccentricity +* ft - +* argpm - argument of perigee +* inclm - inclination +* xli - +* mm - mean anomaly +* xni - mean motion +* nodem - right ascension of ascending node +* +* outputs : +* atime - +* em - eccentricity +* argpm - argument of perigee +* inclm - inclination +* xli - +* mm - mean anomaly +* xni - +* nodem - right ascension of ascending node +* dndt - +* nm - mean motion +* +* locals : +* delt - +* ft - +* theta - +* x2li - +* x2omi - +* xl - +* xldot - +* xnddt - +* xndt - +* xomi - +* +* coupling : +* none - +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void dspace + ( + int irez, + double d2201, double d2211, double d3210, double d3222, double d4410, + double d4422, double d5220, double d5232, double d5421, double d5433, + double dedt, double del1, double del2, double del3, double didt, + double dmdt, double dnodt, double domdt, double argpo, double argpdot, + double t, double tc, double gsto, double xfact, double xlamo, + double no, + double& atime, double& em, double& argpm, double& inclm, double& xli, + double& mm, double& xni, double& nodem, double& dndt, double& nm + ) +{ + const double twopi = 2.0 * pi; + int iretn , iret; + double delt, ft, theta, x2li, x2omi, xl, xldot , xnddt, xndt, xomi, g22, g32, + g44, g52, g54, fasx2, fasx4, fasx6, rptim , step2, stepn , stepp; + + fasx2 = 0.13130908; + fasx4 = 2.8843198; + fasx6 = 0.37448087; + g22 = 5.7686396; + g32 = 0.95240898; + g44 = 1.8014998; + g52 = 1.0508330; + g54 = 4.4108898; + rptim = 4.37526908801129966e-3; // this equates to 7.29211514668855e-5 rad/sec + stepp = 720.0; + stepn = -720.0; + step2 = 259200.0; + + /* ----------- calculate deep space resonance effects ----------- */ + dndt = 0.0; + theta = fmod(gsto + tc * rptim, twopi); + em = em + dedt * t; + + inclm = inclm + didt * t; + argpm = argpm + domdt * t; + nodem = nodem + dnodt * t; + mm = mm + dmdt * t; + + // sgp4fix for negative inclinations + // the following if statement should be commented out + // if (inclm < 0.0) + // { + // inclm = -inclm; + // argpm = argpm - pi; + // nodem = nodem + pi; + // } + + /* - update resonances : numerical (euler-maclaurin) integration - */ + /* ------------------------- epoch restart ---------------------- */ + // sgp4fix for propagator problems + // the following integration works for negative time steps and periods + // the specific changes are unknown because the original code was so convoluted + + // sgp4fix take out atime = 0.0 and fix for faster operation + ft = 0.0; + if (irez != 0) + { + // sgp4fix streamline check + if ((atime == 0.0) || (t * atime <= 0.0) || (fabs(t) < fabs(atime)) ) + { + atime = 0.0; + xni = no; + xli = xlamo; + } + // sgp4fix move check outside loop + if (t > 0.0) + delt = stepp; + else + delt = stepn; + + iretn = 381; // added for do loop + iret = 0; // added for loop + while (iretn == 381) + { + /* ------------------- dot terms calculated ------------- */ + /* ----------- near - synchronous resonance terms ------- */ + if (irez != 2) + { + xndt = del1 * sin(xli - fasx2) + del2 * sin(2.0 * (xli - fasx4)) + + del3 * sin(3.0 * (xli - fasx6)); + xldot = xni + xfact; + xnddt = del1 * cos(xli - fasx2) + + 2.0 * del2 * cos(2.0 * (xli - fasx4)) + + 3.0 * del3 * cos(3.0 * (xli - fasx6)); + xnddt = xnddt * xldot; + } + else + { + /* --------- near - half-day resonance terms -------- */ + xomi = argpo + argpdot * atime; + x2omi = xomi + xomi; + x2li = xli + xli; + xndt = d2201 * sin(x2omi + xli - g22) + d2211 * sin(xli - g22) + + d3210 * sin(xomi + xli - g32) + d3222 * sin(-xomi + xli - g32)+ + d4410 * sin(x2omi + x2li - g44)+ d4422 * sin(x2li - g44) + + d5220 * sin(xomi + xli - g52) + d5232 * sin(-xomi + xli - g52)+ + d5421 * sin(xomi + x2li - g54) + d5433 * sin(-xomi + x2li - g54); + xldot = xni + xfact; + xnddt = d2201 * cos(x2omi + xli - g22) + d2211 * cos(xli - g22) + + d3210 * cos(xomi + xli - g32) + d3222 * cos(-xomi + xli - g32) + + d5220 * cos(xomi + xli - g52) + d5232 * cos(-xomi + xli - g52) + + 2.0 * (d4410 * cos(x2omi + x2li - g44) + + d4422 * cos(x2li - g44) + d5421 * cos(xomi + x2li - g54) + + d5433 * cos(-xomi + x2li - g54)); + xnddt = xnddt * xldot; + } + + /* ----------------------- integrator ------------------- */ + // sgp4fix move end checks to end of routine + if (fabs(t - atime) >= stepp) + { + iret = 0; + iretn = 381; + } + else // exit here + { + ft = t - atime; + iretn = 0; + } + + if (iretn == 381) + { + xli = xli + xldot * delt + xndt * step2; + xni = xni + xndt * delt + xnddt * step2; + atime = atime + delt; + } + } // while iretn = 381 + + nm = xni + xndt * ft + xnddt * ft * ft * 0.5; + xl = xli + xldot * ft + xndt * ft * ft * 0.5; + if (irez != 1) + { + mm = xl - 2.0 * nodem + 2.0 * theta; + dndt = nm - no; + } + else + { + mm = xl - nodem - argpm + theta; + dndt = nm - no; + } + nm = no + dndt; + } + +//#include "debug4.cpp" +} // end dsspace + +/*----------------------------------------------------------------------------- +* +* procedure initl +* +* this procedure initializes the spg4 propagator. all the initialization is +* consolidated here instead of having multiple loops inside other routines. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* ecco - eccentricity 0.0 - 1.0 +* epoch - epoch time in days from jan 0, 1950. 0 hr +* inclo - inclination of satellite +* no - mean motion of satellite +* satn - satellite number +* +* outputs : +* ainv - 1.0 / a +* ao - semi major axis +* con41 - +* con42 - 1.0 - 5.0 cos(i) +* cosio - cosine of inclination +* cosio2 - cosio squared +* eccsq - eccentricity squared +* method - flag for deep space 'd', 'n' +* omeosq - 1.0 - ecco * ecco +* posq - semi-parameter squared +* rp - radius of perigee +* rteosq - square root of (1.0 - ecco*ecco) +* sinio - sine of inclination +* gsto - gst at time of observation rad +* no - mean motion of satellite +* +* locals : +* ak - +* d1 - +* del - +* adel - +* po - +* +* coupling : +* getgravconst +* gstime - find greenwich sidereal time from the julian date +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void initl + ( + int satn, gravconsttype whichconst, + double ecco, double epoch, double inclo, double& no, + char& method, + double& ainv, double& ao, double& con41, double& con42, double& cosio, + double& cosio2,double& eccsq, double& omeosq, double& posq, + double& rp, double& rteosq,double& sinio , double& gsto, + char opsmode + ) +{ + /* --------------------- local variables ------------------------ */ + double ak, d1, del, adel, po, x2o3, j2, xke, + tumin, mu, radiusearthkm, j3, j4, j3oj2; + + /* kill warning */ + satn = 0; + + // sgp4fix use old way of finding gst + double ds70; + double ts70, tfrac, c1, thgr70, fk5r, c1p2p; + const double twopi = 2.0 * pi; + + /* ----------------------- earth constants ---------------------- */ + // sgp4fix identify constants and allow alternate values + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + x2o3 = 2.0 / 3.0; + + /* ------------- calculate auxillary epoch quantities ---------- */ + eccsq = ecco * ecco; + omeosq = 1.0 - eccsq; + rteosq = sqrt(omeosq); + cosio = cos(inclo); + cosio2 = cosio * cosio; + + /* ------------------ un-kozai the mean motion ----------------- */ + ak = pow(xke / no, x2o3); + d1 = 0.75 * j2 * (3.0 * cosio2 - 1.0) / (rteosq * omeosq); + del = d1 / (ak * ak); + adel = ak * (1.0 - del * del - del * + (1.0 / 3.0 + 134.0 * del * del / 81.0)); + del = d1/(adel * adel); + no = no / (1.0 + del); + + ao = pow(xke / no, x2o3); + sinio = sin(inclo); + po = ao * omeosq; + con42 = 1.0 - 5.0 * cosio2; + con41 = -con42-cosio2-cosio2; + ainv = 1.0 / ao; + posq = po * po; + rp = ao * (1.0 - ecco); + method = 'n'; + + // sgp4fix modern approach to finding sidereal time + if (opsmode == 'a') + { + // sgp4fix use old way of finding gst + // count integer number of days from 0 jan 1970 + ts70 = epoch - 7305.0; + ds70 = floor(ts70 + 1.0e-8); + tfrac = ts70 - ds70; + // find greenwich location at epoch + c1 = 1.72027916940703639e-2; + thgr70= 1.7321343856509374; + fk5r = 5.07551419432269442e-15; + c1p2p = c1 + twopi; + gsto = fmod( thgr70 + c1*ds70 + c1p2p*tfrac + ts70*ts70*fk5r, twopi); + if ( gsto < 0.0 ) + gsto = gsto + twopi; + } + else + gsto = gstime(epoch + 2433281.5); + + +//#include "debug5.cpp" +} // end initl + +/*----------------------------------------------------------------------------- +* +* procedure sgp4init +* +* this procedure initializes variables for sgp4. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* opsmode - mode of operation afspc or improved 'a', 'i' +* whichconst - which set of constants to use 72, 84 +* satn - satellite number +* bstar - sgp4 type drag coefficient kg/m2er +* ecco - eccentricity +* epoch - epoch time in days from jan 0, 1950. 0 hr +* argpo - argument of perigee (output if ds) +* inclo - inclination +* mo - mean anomaly (output if ds) +* no - mean motion +* nodeo - right ascension of ascending node +* +* outputs : +* satrec - common values for subsequent calls +* return code - non-zero on error. +* 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er +* 2 - mean motion less than 0.0 +* 3 - pert elements, ecc < 0.0 or ecc > 1.0 +* 4 - semi-latus rectum < 0.0 +* 5 - epoch elements are sub-orbital +* 6 - satellite has decayed +* +* locals : +* cnodm , snodm , cosim , sinim , cosomm , sinomm +* cc1sq , cc2 , cc3 +* coef , coef1 +* cosio4 - +* day - +* dndt - +* em - eccentricity +* emsq - eccentricity squared +* eeta - +* etasq - +* gam - +* argpm - argument of perigee +* nodem - +* inclm - inclination +* mm - mean anomaly +* nm - mean motion +* perige - perigee +* pinvsq - +* psisq - +* qzms24 - +* rtemsq - +* s1, s2, s3, s4, s5, s6, s7 - +* sfour - +* ss1, ss2, ss3, ss4, ss5, ss6, ss7 - +* sz1, sz2, sz3 +* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 - +* tc - +* temp - +* temp1, temp2, temp3 - +* tsi - +* xpidot - +* xhdot1 - +* z1, z2, z3 - +* z11, z12, z13, z21, z22, z23, z31, z32, z33 - +* +* coupling : +* getgravconst- +* initl - +* dscom - +* dpper - +* dsinit - +* sgp4 - +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +bool sgp4init + ( + gravconsttype whichconst, char opsmode, const int satn, const double epoch, + const double xbstar, const double xecco, const double xargpo, + const double xinclo, const double xmo, const double xno, + const double xnodeo, elsetrec& satrec + ) +{ + /* --------------------- local variables ------------------------ */ + double ao, ainv, con42, cosio, sinio, cosio2, eccsq, + omeosq, posq, rp, rteosq, + cnodm , snodm , cosim , sinim , cosomm, sinomm, cc1sq , + cc2 , cc3 , coef , coef1 , cosio4, day , dndt , + em , emsq , eeta , etasq , gam , argpm , nodem , + inclm , mm , nm , perige, pinvsq, psisq , qzms24, + rtemsq, s1 , s2 , s3 , s4 , s5 , s6 , + s7 , sfour , ss1 , ss2 , ss3 , ss4 , ss5 , + ss6 , ss7 , sz1 , sz2 , sz3 , sz11 , sz12 , + sz13 , sz21 , sz22 , sz23 , sz31 , sz32 , sz33 , + tc , temp , temp1 , temp2 , temp3 , tsi , xpidot, + xhdot1, z1 , z2 , z3 , z11 , z12 , z13 , + z21 , z22 , z23 , z31 , z32 , z33, + qzms2t, ss, j2, j3oj2, j4, x2o3, r[3], v[3], + tumin, mu, radiusearthkm, xke, j3; + + /* ------------------------ initialization --------------------- */ + // sgp4fix divisor for divide by zero check on inclination + // the old check used 1.0 + cos(pi-1.0e-9), but then compared it to + // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency + const double temp4 = 1.5e-12; + + /* ----------- set all near earth variables to zero ------------ */ + satrec.isimp = 0; satrec.method = 'n'; satrec.aycof = 0.0; + satrec.con41 = 0.0; satrec.cc1 = 0.0; satrec.cc4 = 0.0; + satrec.cc5 = 0.0; satrec.d2 = 0.0; satrec.d3 = 0.0; + satrec.d4 = 0.0; satrec.delmo = 0.0; satrec.eta = 0.0; + satrec.argpdot = 0.0; satrec.omgcof = 0.0; satrec.sinmao = 0.0; + satrec.t = 0.0; satrec.t2cof = 0.0; satrec.t3cof = 0.0; + satrec.t4cof = 0.0; satrec.t5cof = 0.0; satrec.x1mth2 = 0.0; + satrec.x7thm1 = 0.0; satrec.mdot = 0.0; satrec.nodedot = 0.0; + satrec.xlcof = 0.0; satrec.xmcof = 0.0; satrec.nodecf = 0.0; + + /* ----------- set all deep space variables to zero ------------ */ + satrec.irez = 0; satrec.d2201 = 0.0; satrec.d2211 = 0.0; + satrec.d3210 = 0.0; satrec.d3222 = 0.0; satrec.d4410 = 0.0; + satrec.d4422 = 0.0; satrec.d5220 = 0.0; satrec.d5232 = 0.0; + satrec.d5421 = 0.0; satrec.d5433 = 0.0; satrec.dedt = 0.0; + satrec.del1 = 0.0; satrec.del2 = 0.0; satrec.del3 = 0.0; + satrec.didt = 0.0; satrec.dmdt = 0.0; satrec.dnodt = 0.0; + satrec.domdt = 0.0; satrec.e3 = 0.0; satrec.ee2 = 0.0; + satrec.peo = 0.0; satrec.pgho = 0.0; satrec.pho = 0.0; + satrec.pinco = 0.0; satrec.plo = 0.0; satrec.se2 = 0.0; + satrec.se3 = 0.0; satrec.sgh2 = 0.0; satrec.sgh3 = 0.0; + satrec.sgh4 = 0.0; satrec.sh2 = 0.0; satrec.sh3 = 0.0; + satrec.si2 = 0.0; satrec.si3 = 0.0; satrec.sl2 = 0.0; + satrec.sl3 = 0.0; satrec.sl4 = 0.0; satrec.gsto = 0.0; + satrec.xfact = 0.0; satrec.xgh2 = 0.0; satrec.xgh3 = 0.0; + satrec.xgh4 = 0.0; satrec.xh2 = 0.0; satrec.xh3 = 0.0; + satrec.xi2 = 0.0; satrec.xi3 = 0.0; satrec.xl2 = 0.0; + satrec.xl3 = 0.0; satrec.xl4 = 0.0; satrec.xlamo = 0.0; + satrec.zmol = 0.0; satrec.zmos = 0.0; satrec.atime = 0.0; + satrec.xli = 0.0; satrec.xni = 0.0; + + // sgp4fix - note the following variables are also passed directly via satrec. + // it is possible to streamline the sgp4init call by deleting the "x" + // variables, but the user would need to set the satrec.* values first. we + // include the additional assignments in case twoline2rv is not used. + satrec.bstar = xbstar; + satrec.ecco = xecco; + satrec.argpo = xargpo; + satrec.inclo = xinclo; + satrec.mo = xmo; + satrec.no = xno; + satrec.nodeo = xnodeo; + + // sgp4fix add opsmode + satrec.operationmode = opsmode; + + /* ------------------------ earth constants ----------------------- */ + // sgp4fix identify constants and allow alternate values + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + ss = 78.0 / radiusearthkm + 1.0; + qzms2t = pow(((120.0 - 78.0) / radiusearthkm), 4); + x2o3 = 2.0 / 3.0; + + satrec.init = 'y'; + satrec.t = 0.0; + + initl + ( + satn, whichconst, satrec.ecco, epoch, satrec.inclo, satrec.no, satrec.method, + ainv, ao, satrec.con41, con42, cosio, cosio2, eccsq, omeosq, + posq, rp, rteosq, sinio, satrec.gsto, satrec.operationmode + ); + satrec.error = 0; + + // sgp4fix remove this check as it is unnecessary + // the mrt check in sgp4 handles decaying satellite cases even if the starting + // condition is below the surface of te earth +// if (rp < 1.0) +// { +// printf("# *** satn%d epoch elts sub-orbital ***\n", satn); +// satrec.error = 5; +// } + + if ((omeosq >= 0.0 ) || ( satrec.no >= 0.0)) + { + satrec.isimp = 0; + if (rp < (220.0 / radiusearthkm + 1.0)) + satrec.isimp = 1; + sfour = ss; + qzms24 = qzms2t; + perige = (rp - 1.0) * radiusearthkm; + + /* - for perigees below 156 km, s and qoms2t are altered - */ + if (perige < 156.0) + { + sfour = perige - 78.0; + if (perige < 98.0) + sfour = 20.0; + qzms24 = pow(((120.0 - sfour) / radiusearthkm), 4.0); + sfour = sfour / radiusearthkm + 1.0; + } + pinvsq = 1.0 / posq; + + tsi = 1.0 / (ao - sfour); + satrec.eta = ao * satrec.ecco * tsi; + etasq = satrec.eta * satrec.eta; + eeta = satrec.ecco * satrec.eta; + psisq = fabs(1.0 - etasq); + coef = qzms24 * pow(tsi, 4.0); + coef1 = coef / pow(psisq, 3.5); + cc2 = coef1 * satrec.no * (ao * (1.0 + 1.5 * etasq + eeta * + (4.0 + etasq)) + 0.375 * j2 * tsi / psisq * satrec.con41 * + (8.0 + 3.0 * etasq * (8.0 + etasq))); + satrec.cc1 = satrec.bstar * cc2; + cc3 = 0.0; + if (satrec.ecco > 1.0e-4) + cc3 = -2.0 * coef * tsi * j3oj2 * satrec.no * sinio / satrec.ecco; + satrec.x1mth2 = 1.0 - cosio2; + satrec.cc4 = 2.0* satrec.no * coef1 * ao * omeosq * + (satrec.eta * (2.0 + 0.5 * etasq) + satrec.ecco * + (0.5 + 2.0 * etasq) - j2 * tsi / (ao * psisq) * + (-3.0 * satrec.con41 * (1.0 - 2.0 * eeta + etasq * + (1.5 - 0.5 * eeta)) + 0.75 * satrec.x1mth2 * + (2.0 * etasq - eeta * (1.0 + etasq)) * cos(2.0 * satrec.argpo))); + satrec.cc5 = 2.0 * coef1 * ao * omeosq * (1.0 + 2.75 * + (etasq + eeta) + eeta * etasq); + cosio4 = cosio2 * cosio2; + temp1 = 1.5 * j2 * pinvsq * satrec.no; + temp2 = 0.5 * temp1 * j2 * pinvsq; + temp3 = -0.46875 * j4 * pinvsq * pinvsq * satrec.no; + satrec.mdot = satrec.no + 0.5 * temp1 * rteosq * satrec.con41 + 0.0625 * + temp2 * rteosq * (13.0 - 78.0 * cosio2 + 137.0 * cosio4); + satrec.argpdot = -0.5 * temp1 * con42 + 0.0625 * temp2 * + (7.0 - 114.0 * cosio2 + 395.0 * cosio4) + + temp3 * (3.0 - 36.0 * cosio2 + 49.0 * cosio4); + xhdot1 = -temp1 * cosio; + satrec.nodedot = xhdot1 + (0.5 * temp2 * (4.0 - 19.0 * cosio2) + + 2.0 * temp3 * (3.0 - 7.0 * cosio2)) * cosio; + xpidot = satrec.argpdot+ satrec.nodedot; + satrec.omgcof = satrec.bstar * cc3 * cos(satrec.argpo); + satrec.xmcof = 0.0; + if (satrec.ecco > 1.0e-4) + satrec.xmcof = -x2o3 * coef * satrec.bstar / eeta; + satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1; + satrec.t2cof = 1.5 * satrec.cc1; + // sgp4fix for divide by zero with xinco = 180 deg + if (fabs(cosio+1.0) > 1.5e-12) + satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / (1.0 + cosio); + else + satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / temp4; + satrec.aycof = -0.5 * j3oj2 * sinio; + satrec.delmo = pow((1.0 + satrec.eta * cos(satrec.mo)), 3); + satrec.sinmao = sin(satrec.mo); + satrec.x7thm1 = 7.0 * cosio2 - 1.0; + + /* --------------- deep space initialization ------------- */ + if ((2*pi / satrec.no) >= 225.0) + { + satrec.method = 'd'; + satrec.isimp = 1; + tc = 0.0; + inclm = satrec.inclo; + + dscom + ( + epoch, satrec.ecco, satrec.argpo, tc, satrec.inclo, satrec.nodeo, + satrec.no, snodm, cnodm, sinim, cosim,sinomm, cosomm, + day, satrec.e3, satrec.ee2, em, emsq, gam, + satrec.peo, satrec.pgho, satrec.pho, satrec.pinco, + satrec.plo, rtemsq, satrec.se2, satrec.se3, + satrec.sgh2, satrec.sgh3, satrec.sgh4, + satrec.sh2, satrec.sh3, satrec.si2, satrec.si3, + satrec.sl2, satrec.sl3, satrec.sl4, s1, s2, s3, s4, s5, + s6, s7, ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3, + sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33, + satrec.xgh2, satrec.xgh3, satrec.xgh4, satrec.xh2, + satrec.xh3, satrec.xi2, satrec.xi3, satrec.xl2, + satrec.xl3, satrec.xl4, nm, z1, z2, z3, z11, + z12, z13, z21, z22, z23, z31, z32, z33, + satrec.zmol, satrec.zmos + ); + dpper + ( + satrec.e3, satrec.ee2, satrec.peo, satrec.pgho, + satrec.pho, satrec.pinco, satrec.plo, satrec.se2, + satrec.se3, satrec.sgh2, satrec.sgh3, satrec.sgh4, + satrec.sh2, satrec.sh3, satrec.si2, satrec.si3, + satrec.sl2, satrec.sl3, satrec.sl4, satrec.t, + satrec.xgh2,satrec.xgh3,satrec.xgh4, satrec.xh2, + satrec.xh3, satrec.xi2, satrec.xi3, satrec.xl2, + satrec.xl3, satrec.xl4, satrec.zmol, satrec.zmos, inclm, satrec.init, + satrec.ecco, satrec.inclo, satrec.nodeo, satrec.argpo, satrec.mo, + satrec.operationmode + ); + + argpm = 0.0; + nodem = 0.0; + mm = 0.0; + + dsinit + ( + whichconst, + cosim, emsq, satrec.argpo, s1, s2, s3, s4, s5, sinim, ss1, ss2, ss3, ss4, + ss5, sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33, satrec.t, tc, + satrec.gsto, satrec.mo, satrec.mdot, satrec.no, satrec.nodeo, + satrec.nodedot, xpidot, z1, z3, z11, z13, z21, z23, z31, z33, + satrec.ecco, eccsq, em, argpm, inclm, mm, nm, nodem, + satrec.irez, satrec.atime, + satrec.d2201, satrec.d2211, satrec.d3210, satrec.d3222 , + satrec.d4410, satrec.d4422, satrec.d5220, satrec.d5232, + satrec.d5421, satrec.d5433, satrec.dedt, satrec.didt, + satrec.dmdt, dndt, satrec.dnodt, satrec.domdt , + satrec.del1, satrec.del2, satrec.del3, satrec.xfact, + satrec.xlamo, satrec.xli, satrec.xni + ); + } + + /* ----------- set variables if not deep space ----------- */ + if (satrec.isimp != 1) + { + cc1sq = satrec.cc1 * satrec.cc1; + satrec.d2 = 4.0 * ao * tsi * cc1sq; + temp = satrec.d2 * tsi * satrec.cc1 / 3.0; + satrec.d3 = (17.0 * ao + sfour) * temp; + satrec.d4 = 0.5 * temp * ao * tsi * (221.0 * ao + 31.0 * sfour) * + satrec.cc1; + satrec.t3cof = satrec.d2 + 2.0 * cc1sq; + satrec.t4cof = 0.25 * (3.0 * satrec.d3 + satrec.cc1 * + (12.0 * satrec.d2 + 10.0 * cc1sq)); + satrec.t5cof = 0.2 * (3.0 * satrec.d4 + + 12.0 * satrec.cc1 * satrec.d3 + + 6.0 * satrec.d2 * satrec.d2 + + 15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq)); + } + } // if omeosq = 0 ... + + /* finally propogate to zero epoch to initialize all others. */ + // sgp4fix take out check to let satellites process until they are actually below earth surface +// if(satrec.error == 0) + sgp4(whichconst, satrec, 0.0, r, v); + + satrec.init = 'n'; + +//#include "debug6.cpp" + //sgp4fix return boolean. satrec.error contains any error codes + return true; +} // end sgp4init + +/*----------------------------------------------------------------------------- +* +* procedure sgp4 +* +* this procedure is the sgp4 prediction model from space command. this is an +* updated and combined version of sgp4 and sdp4, which were originally +* published separately in spacetrack report #3. this version follows the +* methodology from the aiaa paper (2006) describing the history and +* development of the code. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* satrec - initialised structure from sgp4init() call. +* tsince - time eince epoch (minutes) +* +* outputs : +* r - position vector km +* v - velocity km/sec +* return code - non-zero on error. +* 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er +* 2 - mean motion less than 0.0 +* 3 - pert elements, ecc < 0.0 or ecc > 1.0 +* 4 - semi-latus rectum < 0.0 +* 5 - epoch elements are sub-orbital +* 6 - satellite has decayed +* +* locals : +* am - +* axnl, aynl - +* betal - +* cosim , sinim , cosomm , sinomm , cnod , snod , cos2u , +* sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip , +* cosisq , cossu , sinsu , cosu , sinu +* delm - +* delomg - +* dndt - +* eccm - +* emsq - +* ecose - +* el2 - +* eo1 - +* eccp - +* esine - +* argpm - +* argpp - +* omgadf - +* pl - +* r - +* rtemsq - +* rdotl - +* rl - +* rvdot - +* rvdotl - +* su - +* t2 , t3 , t4 , tc +* tem5, temp , temp1 , temp2 , tempa , tempe , templ +* u , ux , uy , uz , vx , vy , vz +* inclm - inclination +* mm - mean anomaly +* nm - mean motion +* nodem - right asc of ascending node +* xinc - +* xincp - +* xl - +* xlm - +* mp - +* xmdf - +* xmx - +* xmy - +* nodedf - +* xnode - +* nodep - +* np - +* +* coupling : +* getgravconst- +* dpper +* dpspace +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +bool sgp4 + ( + gravconsttype whichconst, elsetrec& satrec, double tsince, + double r[3], double v[3] + ) +{ + double am , axnl , aynl , betal , cosim , cnod , + cos2u, coseo1, cosi , cosip , cosisq, cossu , cosu, + delm , delomg, em , emsq , ecose , el2 , eo1 , + ep , esine , argpm, argpp , argpdf, pl, mrt = 0.0, + mvt , rdotl , rl , rvdot , rvdotl, sinim , + sin2u, sineo1, sini , sinip , sinsu , sinu , + snod , su , t2 , t3 , t4 , tem5 , temp, + temp1, temp2 , tempa, tempe , templ , u , ux , + uy , uz , vx , vy , vz , inclm , mm , + nm , nodem, xinc , xincp , xl , xlm , mp , + xmdf , xmx , xmy , nodedf, xnode , nodep, tc , dndt, + twopi, x2o3 , j2 , j3 , tumin, j4 , xke , j3oj2, radiusearthkm, + mu, vkmpersec; + int ktr; + + /* ------------------ set mathematical constants --------------- */ + // sgp4fix divisor for divide by zero check on inclination + // the old check used 1.0 + cos(pi-1.0e-9), but then compared it to + // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency + const double temp4 = 1.5e-12; + twopi = 2.0 * pi; + x2o3 = 2.0 / 3.0; + // sgp4fix identify constants and allow alternate values + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + vkmpersec = radiusearthkm * xke/60.0; + + /* --------------------- clear sgp4 error flag ----------------- */ + satrec.t = tsince; + satrec.error = 0; + + /* ------- update for secular gravity and atmospheric drag ----- */ + xmdf = satrec.mo + satrec.mdot * satrec.t; + argpdf = satrec.argpo + satrec.argpdot * satrec.t; + nodedf = satrec.nodeo + satrec.nodedot * satrec.t; + argpm = argpdf; + mm = xmdf; + t2 = satrec.t * satrec.t; + nodem = nodedf + satrec.nodecf * t2; + tempa = 1.0 - satrec.cc1 * satrec.t; + tempe = satrec.bstar * satrec.cc4 * satrec.t; + templ = satrec.t2cof * t2; + + if (satrec.isimp != 1) + { + delomg = satrec.omgcof * satrec.t; + delm = satrec.xmcof * + (pow((1.0 + satrec.eta * cos(xmdf)), 3) - + satrec.delmo); + temp = delomg + delm; + mm = xmdf + temp; + argpm = argpdf - temp; + t3 = t2 * satrec.t; + t4 = t3 * satrec.t; + tempa = tempa - satrec.d2 * t2 - satrec.d3 * t3 - + satrec.d4 * t4; + tempe = tempe + satrec.bstar * satrec.cc5 * (sin(mm) - + satrec.sinmao); + templ = templ + satrec.t3cof * t3 + t4 * (satrec.t4cof + + satrec.t * satrec.t5cof); + } + + nm = satrec.no; + em = satrec.ecco; + inclm = satrec.inclo; + if (satrec.method == 'd') + { + tc = satrec.t; + dspace + ( + satrec.irez, + satrec.d2201, satrec.d2211, satrec.d3210, + satrec.d3222, satrec.d4410, satrec.d4422, + satrec.d5220, satrec.d5232, satrec.d5421, + satrec.d5433, satrec.dedt, satrec.del1, + satrec.del2, satrec.del3, satrec.didt, + satrec.dmdt, satrec.dnodt, satrec.domdt, + satrec.argpo, satrec.argpdot, satrec.t, tc, + satrec.gsto, satrec.xfact, satrec.xlamo, + satrec.no, satrec.atime, + em, argpm, inclm, satrec.xli, mm, satrec.xni, + nodem, dndt, nm + ); + } // if method = d + + if (nm <= 0.0) + { +// printf("# error nm %f\n", nm); + satrec.error = 2; + // sgp4fix add return + return false; + } + am = pow((xke / nm),x2o3) * tempa * tempa; + nm = xke / pow(am, 1.5); + em = em - tempe; + + // fix tolerance for error recognition + // sgp4fix am is fixed from the previous nm check + if ((em >= 1.0) || (em < -0.001)/* || (am < 0.95)*/ ) + { +// printf("# error em %f\n", em); + satrec.error = 1; + // sgp4fix to return if there is an error in eccentricity + return false; + } + // sgp4fix fix tolerance to avoid a divide by zero + if (em < 1.0e-6) + em = 1.0e-6; + mm = mm + satrec.no * templ; + xlm = mm + argpm + nodem; + emsq = em * em; + temp = 1.0 - emsq; + + nodem = fmod(nodem, twopi); + argpm = fmod(argpm, twopi); + xlm = fmod(xlm, twopi); + mm = fmod(xlm - argpm - nodem, twopi); + + /* ----------------- compute extra mean quantities ------------- */ + sinim = sin(inclm); + cosim = cos(inclm); + + /* -------------------- add lunar-solar periodics -------------- */ + ep = em; + xincp = inclm; + argpp = argpm; + nodep = nodem; + mp = mm; + sinip = sinim; + cosip = cosim; + if (satrec.method == 'd') + { + dpper + ( + satrec.e3, satrec.ee2, satrec.peo, + satrec.pgho, satrec.pho, satrec.pinco, + satrec.plo, satrec.se2, satrec.se3, + satrec.sgh2, satrec.sgh3, satrec.sgh4, + satrec.sh2, satrec.sh3, satrec.si2, + satrec.si3, satrec.sl2, satrec.sl3, + satrec.sl4, satrec.t, satrec.xgh2, + satrec.xgh3, satrec.xgh4, satrec.xh2, + satrec.xh3, satrec.xi2, satrec.xi3, + satrec.xl2, satrec.xl3, satrec.xl4, + satrec.zmol, satrec.zmos, satrec.inclo, + 'n', ep, xincp, nodep, argpp, mp, satrec.operationmode + ); + if (xincp < 0.0) + { + xincp = -xincp; + nodep = nodep + pi; + argpp = argpp - pi; + } + if ((ep < 0.0 ) || ( ep > 1.0)) + { +// printf("# error ep %f\n", ep); + satrec.error = 3; + // sgp4fix add return + return false; + } + } // if method = d + + /* -------------------- long period periodics ------------------ */ + if (satrec.method == 'd') + { + sinip = sin(xincp); + cosip = cos(xincp); + satrec.aycof = -0.5*j3oj2*sinip; + // sgp4fix for divide by zero for xincp = 180 deg + if (fabs(cosip+1.0) > 1.5e-12) + satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / (1.0 + cosip); + else + satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / temp4; + } + axnl = ep * cos(argpp); + temp = 1.0 / (am * (1.0 - ep * ep)); + aynl = ep* sin(argpp) + temp * satrec.aycof; + xl = mp + argpp + nodep + temp * satrec.xlcof * axnl; + + /* --------------------- solve kepler's equation --------------- */ + u = fmod(xl - nodep, twopi); + eo1 = u; + tem5 = 9999.9; + ktr = 1; + // sgp4fix for kepler iteration + // the following iteration needs better limits on corrections + while (( fabs(tem5) >= 1.0e-12) && (ktr <= 10) ) + { + sineo1 = sin(eo1); + coseo1 = cos(eo1); + tem5 = 1.0 - coseo1 * axnl - sineo1 * aynl; + tem5 = (u - aynl * coseo1 + axnl * sineo1 - eo1) / tem5; + if(fabs(tem5) >= 0.95) + tem5 = tem5 > 0.0 ? 0.95 : -0.95; + eo1 = eo1 + tem5; + ktr = ktr + 1; + } + + /* ------------- short period preliminary quantities ----------- */ + ecose = axnl*coseo1 + aynl*sineo1; + esine = axnl*sineo1 - aynl*coseo1; + el2 = axnl*axnl + aynl*aynl; + pl = am*(1.0-el2); + if (pl < 0.0) + { +// printf("# error pl %f\n", pl); + satrec.error = 4; + // sgp4fix add return + return false; + } + else + { + rl = am * (1.0 - ecose); + rdotl = sqrt(am) * esine/rl; + rvdotl = sqrt(pl) / rl; + betal = sqrt(1.0 - el2); + temp = esine / (1.0 + betal); + sinu = am / rl * (sineo1 - aynl - axnl * temp); + cosu = am / rl * (coseo1 - axnl + aynl * temp); + su = atan2(sinu, cosu); + sin2u = (cosu + cosu) * sinu; + cos2u = 1.0 - 2.0 * sinu * sinu; + temp = 1.0 / pl; + temp1 = 0.5 * j2 * temp; + temp2 = temp1 * temp; + + /* -------------- update for short period periodics ------------ */ + if (satrec.method == 'd') + { + cosisq = cosip * cosip; + satrec.con41 = 3.0*cosisq - 1.0; + satrec.x1mth2 = 1.0 - cosisq; + satrec.x7thm1 = 7.0*cosisq - 1.0; + } + mrt = rl * (1.0 - 1.5 * temp2 * betal * satrec.con41) + + 0.5 * temp1 * satrec.x1mth2 * cos2u; + su = su - 0.25 * temp2 * satrec.x7thm1 * sin2u; + xnode = nodep + 1.5 * temp2 * cosip * sin2u; + xinc = xincp + 1.5 * temp2 * cosip * sinip * cos2u; + mvt = rdotl - nm * temp1 * satrec.x1mth2 * sin2u / xke; + rvdot = rvdotl + nm * temp1 * (satrec.x1mth2 * cos2u + + 1.5 * satrec.con41) / xke; + + /* --------------------- orientation vectors ------------------- */ + sinsu = sin(su); + cossu = cos(su); + snod = sin(xnode); + cnod = cos(xnode); + sini = sin(xinc); + cosi = cos(xinc); + xmx = -snod * cosi; + xmy = cnod * cosi; + ux = xmx * sinsu + cnod * cossu; + uy = xmy * sinsu + snod * cossu; + uz = sini * sinsu; + vx = xmx * cossu - cnod * sinsu; + vy = xmy * cossu - snod * sinsu; + vz = sini * cossu; + + /* --------- position and velocity (in km and km/sec) ---------- */ + r[0] = (mrt * ux)* radiusearthkm; + r[1] = (mrt * uy)* radiusearthkm; + r[2] = (mrt * uz)* radiusearthkm; + v[0] = (mvt * ux + rvdot * vx) * vkmpersec; + v[1] = (mvt * uy + rvdot * vy) * vkmpersec; + v[2] = (mvt * uz + rvdot * vz) * vkmpersec; + } // if pl > 0 + + // sgp4fix for decaying satellites + if (mrt < 1.0) + { +// printf("# decay condition %11.6f \n",mrt); + satrec.error = 6; + return false; + } + +//#include "debug7.cpp" + return true; +} // end sgp4 + + +/* ----------------------------------------------------------------------------- +* +* function gstime +* +* this function finds the greenwich sidereal time. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* jdut1 - julian date in ut1 days from 4713 bc +* +* outputs : +* gstime - greenwich sidereal time 0 to 2pi rad +* +* locals : +* temp - temporary variable for doubles rad +* tut1 - julian centuries from the +* jan 1, 2000 12 h epoch (ut1) +* +* coupling : +* none +* +* references : +* vallado 2004, 191, eq 3-45 +* --------------------------------------------------------------------------- */ + +double gstime + ( + double jdut1 + ) + { + const double twopi = 2.0 * pi; + const double deg2rad = pi / 180.0; + double temp, tut1; + + tut1 = (jdut1 - 2451545.0) / 36525.0; + temp = -6.2e-6* tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + + (876600.0*3600 + 8640184.812866) * tut1 + 67310.54841; // sec + temp = fmod(temp * deg2rad / 240.0, twopi); //360/86400 = 1/240, to deg, to rad + + // ------------------------ check quadrants --------------------- + if (temp < 0.0) + temp += twopi; + + return temp; + } // end gstime + +/* ----------------------------------------------------------------------------- +* +* function getgravconst +* +* this function gets constants for the propagator. note that mu is identified to +* facilitiate comparisons with newer models. the common useage is wgs72. +* +* author : david vallado 719-573-2600 21 jul 2006 +* +* inputs : +* whichconst - which set of constants to use wgs72old, wgs72, wgs84 +* +* outputs : +* tumin - minutes in one time unit +* mu - earth gravitational parameter +* radiusearthkm - radius of the earth in km +* xke - reciprocal of tumin +* j2, j3, j4 - un-normalized zonal harmonic values +* j3oj2 - j3 divided by j2 +* +* locals : +* +* coupling : +* none +* +* references : +* norad spacetrack report #3 +* vallado, crawford, hujsak, kelso 2006 + --------------------------------------------------------------------------- */ + +void getgravconst + ( + gravconsttype whichconst, + double& tumin, + double& mu, + double& radiusearthkm, + double& xke, + double& j2, + double& j3, + double& j4, + double& j3oj2 + ) + { + + switch (whichconst) + { + // -- wgs-72 low precision str#3 constants -- + case wgs72old: + mu = 398600.79964; // in km3 / s2 + radiusearthkm = 6378.135; // km + xke = 0.0743669161; + tumin = 1.0 / xke; + j2 = 0.001082616; + j3 = -0.00000253881; + j4 = -0.00000165597; + j3oj2 = j3 / j2; + break; + // ------------ wgs-72 constants ------------ + case wgs72: + mu = 398600.8; // in km3 / s2 + radiusearthkm = 6378.135; // km + xke = 60.0 / sqrt(radiusearthkm*radiusearthkm*radiusearthkm/mu); + tumin = 1.0 / xke; + j2 = 0.001082616; + j3 = -0.00000253881; + j4 = -0.00000165597; + j3oj2 = j3 / j2; + break; + case wgs84: + // ------------ wgs-84 constants ------------ + mu = 398600.5; // in km3 / s2 + radiusearthkm = 6378.137; // km + xke = 60.0 / sqrt(radiusearthkm*radiusearthkm*radiusearthkm/mu); + tumin = 1.0 / xke; + j2 = 0.00108262998905; + j3 = -0.00000253215306; + j4 = -0.00000161098761; + j3oj2 = j3 / j2; + break; + default: + fprintf(stderr,"unknown gravity option (%d)\n",whichconst); + break; + } + + } // end getgravconst + + + + + diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.h similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.h index 9de25e4..5d71430 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.h +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.h @@ -1,126 +1,126 @@ -#ifndef _sgp4unit_ -#define _sgp4unit_ -/* ---------------------------------------------------------------- -* -* sgp4unit.h -* -* this file contains the sgp4 procedures for analytical propagation -* of a satellite. the code was originally released in the 1980 and 1986 -* spacetrack papers. a detailed discussion of the theory and history -* may be found in the 2006 aiaa paper by vallado, crawford, hujsak, -* and kelso. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 3 Nov 08 david vallado -* put returns in for error codes -* changes : -* 29 sep 08 david vallado -* fix atime for faster operation in dspace -* add operationmode for afspc (a) or improved (i) -* performance mode -* 20 apr 07 david vallado -* misc fixes for constants -* 11 aug 06 david vallado -* chg lyddane choice back to strn3, constants, misc doc -* 15 dec 05 david vallado -* misc fixes -* 26 jul 05 david vallado -* fixes for paper -* note that each fix is preceded by a -* comment with "sgp4fix" and an explanation of -* what was changed -* 10 aug 04 david vallado -* 2nd printing baseline working -* 14 may 01 david vallado -* 2nd edition baseline -* 80 norad -* original baseline -* ---------------------------------------------------------------- */ - -#include -#include -#define SGP4Version "SGP4 Version 2008-11-03" - -#define pi 3.14159265358979323846 - -// -------------------------- structure declarations ---------------------------- -typedef enum -{ - wgs72old, - wgs72, - wgs84 -} gravconsttype; - -typedef struct elsetrec -{ - long int satnum; - int epochyr, epochtynumrev; - int error; - char operationmode; - char init, method; - - /* Near Earth */ - int isimp; - double aycof , con41 , cc1 , cc4 , cc5 , d2 , d3 , d4 , - delmo , eta , argpdot, omgcof , sinmao , t , t2cof, t3cof , - t4cof , t5cof , x1mth2 , x7thm1 , mdot , nodedot, xlcof , xmcof , - nodecf; - - /* Deep Space */ - int irez; - double d2201 , d2211 , d3210 , d3222 , d4410 , d4422 , d5220 , d5232 , - d5421 , d5433 , dedt , del1 , del2 , del3 , didt , dmdt , - dnodt , domdt , e3 , ee2 , peo , pgho , pho , pinco , - plo , se2 , se3 , sgh2 , sgh3 , sgh4 , sh2 , sh3 , - si2 , si3 , sl2 , sl3 , sl4 , gsto , xfact , xgh2 , - xgh3 , xgh4 , xh2 , xh3 , xi2 , xi3 , xl2 , xl3 , - xl4 , xlamo , zmol , zmos , atime , xli , xni; - - double a , altp , alta , epochdays, jdsatepoch , nddot , ndot , - bstar , rcse , inclo , nodeo , ecco , argpo , mo , - no; -} elsetrec; - - -// --------------------------- function declarations ---------------------------- -bool sgp4init - ( - gravconsttype whichconst, char opsmode, const int satn, const double epoch, - const double xbstar, const double xecco, const double xargpo, - const double xinclo, const double xmo, const double xno, - const double xnodeo, elsetrec& satrec - ); - -bool sgp4 - ( - gravconsttype whichconst, elsetrec& satrec, double tsince, - double r[3], double v[3] - ); - -double gstime - ( - double jdut1 - ); - -void getgravconst - ( - gravconsttype whichconst, - double& tumin, - double& mu, - double& radiusearthkm, - double& xke, - double& j2, - double& j3, - double& j4, - double& j3oj2 - ); - -#endif - +#ifndef _sgp4unit_ +#define _sgp4unit_ +/* ---------------------------------------------------------------- +* +* sgp4unit.h +* +* this file contains the sgp4 procedures for analytical propagation +* of a satellite. the code was originally released in the 1980 and 1986 +* spacetrack papers. a detailed discussion of the theory and history +* may be found in the 2006 aiaa paper by vallado, crawford, hujsak, +* and kelso. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 3 Nov 08 david vallado +* put returns in for error codes +* changes : +* 29 sep 08 david vallado +* fix atime for faster operation in dspace +* add operationmode for afspc (a) or improved (i) +* performance mode +* 20 apr 07 david vallado +* misc fixes for constants +* 11 aug 06 david vallado +* chg lyddane choice back to strn3, constants, misc doc +* 15 dec 05 david vallado +* misc fixes +* 26 jul 05 david vallado +* fixes for paper +* note that each fix is preceded by a +* comment with "sgp4fix" and an explanation of +* what was changed +* 10 aug 04 david vallado +* 2nd printing baseline working +* 14 may 01 david vallado +* 2nd edition baseline +* 80 norad +* original baseline +* ---------------------------------------------------------------- */ + +#include +#include +#define SGP4Version "SGP4 Version 2008-11-03" + +#define pi 3.14159265358979323846 + +// -------------------------- structure declarations ---------------------------- +typedef enum +{ + wgs72old, + wgs72, + wgs84 +} gravconsttype; + +typedef struct elsetrec +{ + long int satnum; + int epochyr, epochtynumrev; + int error; + char operationmode; + char init, method; + + /* Near Earth */ + int isimp; + double aycof , con41 , cc1 , cc4 , cc5 , d2 , d3 , d4 , + delmo , eta , argpdot, omgcof , sinmao , t , t2cof, t3cof , + t4cof , t5cof , x1mth2 , x7thm1 , mdot , nodedot, xlcof , xmcof , + nodecf; + + /* Deep Space */ + int irez; + double d2201 , d2211 , d3210 , d3222 , d4410 , d4422 , d5220 , d5232 , + d5421 , d5433 , dedt , del1 , del2 , del3 , didt , dmdt , + dnodt , domdt , e3 , ee2 , peo , pgho , pho , pinco , + plo , se2 , se3 , sgh2 , sgh3 , sgh4 , sh2 , sh3 , + si2 , si3 , sl2 , sl3 , sl4 , gsto , xfact , xgh2 , + xgh3 , xgh4 , xh2 , xh3 , xi2 , xi3 , xl2 , xl3 , + xl4 , xlamo , zmol , zmos , atime , xli , xni; + + double a , altp , alta , epochdays, jdsatepoch , nddot , ndot , + bstar , rcse , inclo , nodeo , ecco , argpo , mo , + no; +} elsetrec; + + +// --------------------------- function declarations ---------------------------- +bool sgp4init + ( + gravconsttype whichconst, char opsmode, const int satn, const double epoch, + const double xbstar, const double xecco, const double xargpo, + const double xinclo, const double xmo, const double xno, + const double xnodeo, elsetrec& satrec + ); + +bool sgp4 + ( + gravconsttype whichconst, elsetrec& satrec, double tsince, + double r[3], double v[3] + ); + +double gstime + ( + double jdut1 + ); + +void getgravconst + ( + gravconsttype whichconst, + double& tumin, + double& mu, + double& radiusearthkm, + double& xke, + double& j2, + double& j3, + double& j4, + double& j3oj2 + ); + +#endif + diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/solarProcedures.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/solarProcedures.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/solarProcedures.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/solarProcedures.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/solarProcedures.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/solarProcedures.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/solarProcedures.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/solarProcedures.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/stdsat.h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/stdsat.h similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/stdsat.h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/stdsat.h diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.cproject b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.cproject similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.cproject rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.cproject diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.project b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.project similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.project rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.project diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.cdt.core.prefs b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.cdt.core.prefs similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.cdt.core.prefs rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.cdt.core.prefs diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.cdt.ui.prefs b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.cdt.ui.prefs similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.cdt.ui.prefs rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.cdt.ui.prefs diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.ltk.core.refactoring.prefs b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.ltk.core.refactoring.prefs similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.ltk.core.refactoring.prefs rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/.settings/org.eclipse.ltk.core.refactoring.prefs diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/AUTHORS b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/AUTHORS similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/AUTHORS rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/AUTHORS diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/COPYING b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/COPYING similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/COPYING rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/COPYING diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/INSTALL b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/INSTALL similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/INSTALL rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/INSTALL diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/NEWS b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/NEWS similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/NEWS rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/NEWS diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/README b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/README similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/README rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/README diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/TODO b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/TODO similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/TODO rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/TODO index 86b1d9a..fc268e5 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/TODO +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/TODO @@ -1,8 +1,8 @@ -Domentation: - Translate and publishing the Orbital Mechanics Estudy to english. - -TLE file parser: - Redesing to suport files and internet conection to get satellite data. - -Satellite tracking functionality: +Domentation: + Translate and publishing the Orbital Mechanics Estudy to english. + +TLE file parser: + Redesing to suport files and internet conection to get satellite data. + +Satellite tracking functionality: Design and codify classes to predict satellite positions in a time interval. \ No newline at end of file diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/acinclude.m4 b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/acinclude.m4 similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/acinclude.m4 rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/acinclude.m4 index 93b12f4..d9a951c 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/acinclude.m4 +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/acinclude.m4 @@ -1,321 +1,321 @@ -# This file is part of Autoconf. -*- Autoconf -*- - -# Copyright (C) 2004 Oren Ben-Kiki -# This file is distributed under the same terms as the Autoconf macro files. - -########## CHANGELOG ################## -# 2009-01-14 Martin Mann -# * DX_ARG_ABLE : new variable 'DX_FLAG_DX_CURRENT_FEATURE' -# * DX_CLEAR_DEPEND : use of explicit variable 'DX_FLAG_DX_CURRENT_FEATURE' -# in AC_SUBST instead of 'DX_FLAG[]DX_CURRENT_FEATURE' which is rejected by -# newer autotools - -# Generate automatic documentation using Doxygen. Works in concert with the -# aminclude.m4 file and a compatible doxygen configuration file. Defines the -# following public macros: -# -# DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature. -# Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics, -# 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI' -# for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF', -# 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment -# variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide' -# paper size. -# -# By default, HTML, PDF and PS documentation is generated as this seems to be -# the most popular and portable combination. MAN pages created by Doxygen are -# usually problematic, though by picking an appropriate subset and doing some -# massaging they might be better than nothing. CHM and RTF are specific for MS -# (note that you can't generate both HTML and CHM at the same time). The XML is -# rather useless unless you apply specialized post-processing to it. -# -# The macro mainly controls the default state of the feature. The use can -# override the default by specifying --enable or --disable. The macros ensure -# that contradictory flags are not given (e.g., --enable-doxygen-html and -# --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.) -# Finally, each feature will be automatically disabled (with a warning) if the -# required programs are missing. -# -# Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with -# the following parameters: a one-word name for the project for use as a -# filename base etc., an optional configuration file name (the default is -# 'Doxyfile', the same as Doxygen's default), and an optional output directory -# name (the default is 'doxygen-doc'). - -## ----------## -## Defaults. ## -## ----------## - -DX_ENV="" -AC_DEFUN([DX_FEATURE_doc], ON) -AC_DEFUN([DX_FEATURE_dot], ON) -AC_DEFUN([DX_FEATURE_man], OFF) -AC_DEFUN([DX_FEATURE_html], ON) -AC_DEFUN([DX_FEATURE_chm], OFF) -AC_DEFUN([DX_FEATURE_chi], OFF) -AC_DEFUN([DX_FEATURE_rtf], OFF) -AC_DEFUN([DX_FEATURE_xml], OFF) -AC_DEFUN([DX_FEATURE_pdf], ON) -AC_DEFUN([DX_FEATURE_ps], ON) - -## --------------- ## -## Private macros. ## -## --------------- ## - -# DX_ENV_APPEND(VARIABLE, VALUE) -# ------------------------------ -# Append VARIABLE="VALUE" to DX_ENV for invoking doxygen. -AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])]) - -# DX_DIRNAME_EXPR -# --------------- -# Expand into a shell expression prints the directory part of a path. -AC_DEFUN([DX_DIRNAME_EXPR], - [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']]) - -# DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF) -# ------------------------------------- -# Expands according to the M4 (static) status of the feature. -AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])]) - -# DX_REQUIRE_PROG(VARIABLE, PROGRAM) -# ---------------------------------- -# Require the specified program to be found for the DX_CURRENT_FEATURE to work. -AC_DEFUN([DX_REQUIRE_PROG], [ -AC_PATH_TOOL([$1], [$2]) -if test "$DX_FLAG_DX_CURRENT_FEATURE$$1" = 1; then - AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION]) - AC_SUBST([DX_FLAG_DX_CURRENT_FEATURE], 0) -fi -]) - -# DX_TEST_FEATURE(FEATURE) -# ------------------------ -# Expand to a shell expression testing whether the feature is active. -AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1]) - -# DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE) -# ------------------------------------------------- -# Verify that a required features has the right state before trying to turn on -# the DX_CURRENT_FEATURE. -AC_DEFUN([DX_CHECK_DEPEND], [ -test "$DX_FLAG_$1" = "$2" \ -|| AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1, - requires, contradicts) doxygen-DX_CURRENT_FEATURE]) -]) - -# DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE) -# ---------------------------------------------------------- -# Turn off the DX_CURRENT_FEATURE if the required feature is off. -AC_DEFUN([DX_CLEAR_DEPEND], [ -test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_DX_CURRENT_FEATURE], 0) -]) - - -# DX_FEATURE_ARG(FEATURE, DESCRIPTION, -# CHECK_DEPEND, CLEAR_DEPEND, -# REQUIRE, DO-IF-ON, DO-IF-OFF) -# -------------------------------------------- -# Parse the command-line option controlling a feature. CHECK_DEPEND is called -# if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND), -# otherwise CLEAR_DEPEND is called to turn off the default state if a required -# feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional -# requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and -# DO-IF-ON or DO-IF-OFF are called according to the final state of the feature. -AC_DEFUN([DX_ARG_ABLE], [ - AC_DEFUN([DX_CURRENT_FEATURE], [$1]) - AC_DEFUN([DX_FLAG_DX_CURRENT_FEATURE], [DX_FLAG_$1]) - AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2]) - AC_ARG_ENABLE(doxygen-$1, - [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1], - [--enable-doxygen-$1]), - DX_IF_FEATURE([$1], [don't $2], [$2]))], - [ -case "$enableval" in -#( -y|Y|yes|Yes|YES) - AC_SUBST([DX_FLAG_$1], 1) - $3 -;; #( -n|N|no|No|NO) - AC_SUBST([DX_FLAG_$1], 0) -;; #( -*) - AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1]) -;; -esac -], [ -AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)]) -$4 -]) -if DX_TEST_FEATURE([$1]); then - $5 - : -fi -if DX_TEST_FEATURE([$1]); then - AM_CONDITIONAL(DX_COND_$1, :) - $6 - : -else - AM_CONDITIONAL(DX_COND_$1, false) - $7 - : -fi -]) - -## -------------- ## -## Public macros. ## -## -------------- ## - -# DX_XXX_FEATURE(DEFAULT_STATE) -# ----------------------------- -AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])]) -AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])]) -AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])]) -AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])]) -AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])]) -AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])]) -AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) -AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) -AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])]) -AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])]) - -# DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR]) -# --------------------------------------------------------- -# PROJECT also serves as the base name for the documentation files. -# The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc". -AC_DEFUN([DX_INIT_DOXYGEN], [ - -# Files: -AC_SUBST([DX_PROJECT], [$1]) -AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])]) -AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])]) - -# Environment variables used inside doxygen.cfg: -DX_ENV_APPEND(SRCDIR, $srcdir) -DX_ENV_APPEND(PROJECT, $DX_PROJECT) -DX_ENV_APPEND(DOCDIR, $DX_DOCDIR) -DX_ENV_APPEND(VERSION, $PACKAGE_VERSION) - -# Doxygen itself: -DX_ARG_ABLE(doc, [generate any doxygen documentation], - [], - [], - [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen) - DX_REQUIRE_PROG([DX_PERL], perl)], - [DX_ENV_APPEND(PERL_PATH, $DX_PERL)]) - -# Dot for graphics: -DX_ARG_ABLE(dot, [generate graphics for doxygen documentation], - [DX_CHECK_DEPEND(doc, 1)], - [DX_CLEAR_DEPEND(doc, 1)], - [DX_REQUIRE_PROG([DX_DOT], dot)], - [DX_ENV_APPEND(HAVE_DOT, YES) - DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])], - [DX_ENV_APPEND(HAVE_DOT, NO)]) - -# Man pages generation: -DX_ARG_ABLE(man, [generate doxygen manual pages], - [DX_CHECK_DEPEND(doc, 1)], - [DX_CLEAR_DEPEND(doc, 1)], - [], - [DX_ENV_APPEND(GENERATE_MAN, YES)], - [DX_ENV_APPEND(GENERATE_MAN, NO)]) - -# RTF file generation: -DX_ARG_ABLE(rtf, [generate doxygen RTF documentation], - [DX_CHECK_DEPEND(doc, 1)], - [DX_CLEAR_DEPEND(doc, 1)], - [], - [DX_ENV_APPEND(GENERATE_RTF, YES)], - [DX_ENV_APPEND(GENERATE_RTF, NO)]) - -# XML file generation: -DX_ARG_ABLE(xml, [generate doxygen XML documentation], - [DX_CHECK_DEPEND(doc, 1)], - [DX_CLEAR_DEPEND(doc, 1)], - [], - [DX_ENV_APPEND(GENERATE_XML, YES)], - [DX_ENV_APPEND(GENERATE_XML, NO)]) - -# (Compressed) HTML help generation: -DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation], - [DX_CHECK_DEPEND(doc, 1)], - [DX_CLEAR_DEPEND(doc, 1)], - [DX_REQUIRE_PROG([DX_HHC], hhc)], - [DX_ENV_APPEND(HHC_PATH, $DX_HHC) - DX_ENV_APPEND(GENERATE_HTML, YES) - DX_ENV_APPEND(GENERATE_HTMLHELP, YES)], - [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)]) - -# Seperate CHI file generation. -DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file], - [DX_CHECK_DEPEND(chm, 1)], - [DX_CLEAR_DEPEND(chm, 1)], - [], - [DX_ENV_APPEND(GENERATE_CHI, YES)], - [DX_ENV_APPEND(GENERATE_CHI, NO)]) - -# Plain HTML pages generation: -DX_ARG_ABLE(html, [generate doxygen plain HTML documentation], - [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)], - [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)], - [], - [DX_ENV_APPEND(GENERATE_HTML, YES)], - [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)]) - -# PostScript file generation: -DX_ARG_ABLE(ps, [generate doxygen PostScript documentation], - [DX_CHECK_DEPEND(doc, 1)], - [DX_CLEAR_DEPEND(doc, 1)], - [DX_REQUIRE_PROG([DX_LATEX], latex) - DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) - DX_REQUIRE_PROG([DX_DVIPS], dvips) - DX_REQUIRE_PROG([DX_EGREP], egrep)]) - -# PDF file generation: -DX_ARG_ABLE(pdf, [generate doxygen PDF documentation], - [DX_CHECK_DEPEND(doc, 1)], - [DX_CLEAR_DEPEND(doc, 1)], - [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex) - DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) - DX_REQUIRE_PROG([DX_EGREP], egrep)]) - -# LaTeX generation for PS and/or PDF: -if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then - AM_CONDITIONAL(DX_COND_latex, :) - DX_ENV_APPEND(GENERATE_LATEX, YES) -else - AM_CONDITIONAL(DX_COND_latex, false) - DX_ENV_APPEND(GENERATE_LATEX, NO) -fi - -# Paper size for PS and/or PDF: -AC_ARG_VAR(DOXYGEN_PAPER_SIZE, - [a4wide (default), a4, letter, legal or executive]) -case "$DOXYGEN_PAPER_SIZE" in -#( -"") - AC_SUBST(DOXYGEN_PAPER_SIZE, "") -;; #( -a4wide|a4|letter|legal|executive) - DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE) -;; #( -*) - AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE']) -;; -esac - -#For debugging: -#echo DX_FLAG_doc=$DX_FLAG_doc -#echo DX_FLAG_dot=$DX_FLAG_dot -#echo DX_FLAG_man=$DX_FLAG_man -#echo DX_FLAG_html=$DX_FLAG_html -#echo DX_FLAG_chm=$DX_FLAG_chm -#echo DX_FLAG_chi=$DX_FLAG_chi -#echo DX_FLAG_rtf=$DX_FLAG_rtf -#echo DX_FLAG_xml=$DX_FLAG_xml -#echo DX_FLAG_pdf=$DX_FLAG_pdf -#echo DX_FLAG_ps=$DX_FLAG_ps -#echo DX_ENV=$DX_ENV -]) +# This file is part of Autoconf. -*- Autoconf -*- + +# Copyright (C) 2004 Oren Ben-Kiki +# This file is distributed under the same terms as the Autoconf macro files. + +########## CHANGELOG ################## +# 2009-01-14 Martin Mann +# * DX_ARG_ABLE : new variable 'DX_FLAG_DX_CURRENT_FEATURE' +# * DX_CLEAR_DEPEND : use of explicit variable 'DX_FLAG_DX_CURRENT_FEATURE' +# in AC_SUBST instead of 'DX_FLAG[]DX_CURRENT_FEATURE' which is rejected by +# newer autotools + +# Generate automatic documentation using Doxygen. Works in concert with the +# aminclude.m4 file and a compatible doxygen configuration file. Defines the +# following public macros: +# +# DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature. +# Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics, +# 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI' +# for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF', +# 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment +# variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide' +# paper size. +# +# By default, HTML, PDF and PS documentation is generated as this seems to be +# the most popular and portable combination. MAN pages created by Doxygen are +# usually problematic, though by picking an appropriate subset and doing some +# massaging they might be better than nothing. CHM and RTF are specific for MS +# (note that you can't generate both HTML and CHM at the same time). The XML is +# rather useless unless you apply specialized post-processing to it. +# +# The macro mainly controls the default state of the feature. The use can +# override the default by specifying --enable or --disable. The macros ensure +# that contradictory flags are not given (e.g., --enable-doxygen-html and +# --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.) +# Finally, each feature will be automatically disabled (with a warning) if the +# required programs are missing. +# +# Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with +# the following parameters: a one-word name for the project for use as a +# filename base etc., an optional configuration file name (the default is +# 'Doxyfile', the same as Doxygen's default), and an optional output directory +# name (the default is 'doxygen-doc'). + +## ----------## +## Defaults. ## +## ----------## + +DX_ENV="" +AC_DEFUN([DX_FEATURE_doc], ON) +AC_DEFUN([DX_FEATURE_dot], ON) +AC_DEFUN([DX_FEATURE_man], OFF) +AC_DEFUN([DX_FEATURE_html], ON) +AC_DEFUN([DX_FEATURE_chm], OFF) +AC_DEFUN([DX_FEATURE_chi], OFF) +AC_DEFUN([DX_FEATURE_rtf], OFF) +AC_DEFUN([DX_FEATURE_xml], OFF) +AC_DEFUN([DX_FEATURE_pdf], ON) +AC_DEFUN([DX_FEATURE_ps], ON) + +## --------------- ## +## Private macros. ## +## --------------- ## + +# DX_ENV_APPEND(VARIABLE, VALUE) +# ------------------------------ +# Append VARIABLE="VALUE" to DX_ENV for invoking doxygen. +AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])]) + +# DX_DIRNAME_EXPR +# --------------- +# Expand into a shell expression prints the directory part of a path. +AC_DEFUN([DX_DIRNAME_EXPR], + [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']]) + +# DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF) +# ------------------------------------- +# Expands according to the M4 (static) status of the feature. +AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])]) + +# DX_REQUIRE_PROG(VARIABLE, PROGRAM) +# ---------------------------------- +# Require the specified program to be found for the DX_CURRENT_FEATURE to work. +AC_DEFUN([DX_REQUIRE_PROG], [ +AC_PATH_TOOL([$1], [$2]) +if test "$DX_FLAG_DX_CURRENT_FEATURE$$1" = 1; then + AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION]) + AC_SUBST([DX_FLAG_DX_CURRENT_FEATURE], 0) +fi +]) + +# DX_TEST_FEATURE(FEATURE) +# ------------------------ +# Expand to a shell expression testing whether the feature is active. +AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1]) + +# DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE) +# ------------------------------------------------- +# Verify that a required features has the right state before trying to turn on +# the DX_CURRENT_FEATURE. +AC_DEFUN([DX_CHECK_DEPEND], [ +test "$DX_FLAG_$1" = "$2" \ +|| AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1, + requires, contradicts) doxygen-DX_CURRENT_FEATURE]) +]) + +# DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE) +# ---------------------------------------------------------- +# Turn off the DX_CURRENT_FEATURE if the required feature is off. +AC_DEFUN([DX_CLEAR_DEPEND], [ +test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_DX_CURRENT_FEATURE], 0) +]) + + +# DX_FEATURE_ARG(FEATURE, DESCRIPTION, +# CHECK_DEPEND, CLEAR_DEPEND, +# REQUIRE, DO-IF-ON, DO-IF-OFF) +# -------------------------------------------- +# Parse the command-line option controlling a feature. CHECK_DEPEND is called +# if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND), +# otherwise CLEAR_DEPEND is called to turn off the default state if a required +# feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional +# requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and +# DO-IF-ON or DO-IF-OFF are called according to the final state of the feature. +AC_DEFUN([DX_ARG_ABLE], [ + AC_DEFUN([DX_CURRENT_FEATURE], [$1]) + AC_DEFUN([DX_FLAG_DX_CURRENT_FEATURE], [DX_FLAG_$1]) + AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2]) + AC_ARG_ENABLE(doxygen-$1, + [AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1], + [--enable-doxygen-$1]), + DX_IF_FEATURE([$1], [don't $2], [$2]))], + [ +case "$enableval" in +#( +y|Y|yes|Yes|YES) + AC_SUBST([DX_FLAG_$1], 1) + $3 +;; #( +n|N|no|No|NO) + AC_SUBST([DX_FLAG_$1], 0) +;; #( +*) + AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1]) +;; +esac +], [ +AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)]) +$4 +]) +if DX_TEST_FEATURE([$1]); then + $5 + : +fi +if DX_TEST_FEATURE([$1]); then + AM_CONDITIONAL(DX_COND_$1, :) + $6 + : +else + AM_CONDITIONAL(DX_COND_$1, false) + $7 + : +fi +]) + +## -------------- ## +## Public macros. ## +## -------------- ## + +# DX_XXX_FEATURE(DEFAULT_STATE) +# ----------------------------- +AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])]) +AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])]) +AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])]) +AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])]) +AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])]) +AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])]) +AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) +AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) +AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])]) +AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])]) + +# DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR]) +# --------------------------------------------------------- +# PROJECT also serves as the base name for the documentation files. +# The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc". +AC_DEFUN([DX_INIT_DOXYGEN], [ + +# Files: +AC_SUBST([DX_PROJECT], [$1]) +AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])]) +AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])]) + +# Environment variables used inside doxygen.cfg: +DX_ENV_APPEND(SRCDIR, $srcdir) +DX_ENV_APPEND(PROJECT, $DX_PROJECT) +DX_ENV_APPEND(DOCDIR, $DX_DOCDIR) +DX_ENV_APPEND(VERSION, $PACKAGE_VERSION) + +# Doxygen itself: +DX_ARG_ABLE(doc, [generate any doxygen documentation], + [], + [], + [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen) + DX_REQUIRE_PROG([DX_PERL], perl)], + [DX_ENV_APPEND(PERL_PATH, $DX_PERL)]) + +# Dot for graphics: +DX_ARG_ABLE(dot, [generate graphics for doxygen documentation], + [DX_CHECK_DEPEND(doc, 1)], + [DX_CLEAR_DEPEND(doc, 1)], + [DX_REQUIRE_PROG([DX_DOT], dot)], + [DX_ENV_APPEND(HAVE_DOT, YES) + DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])], + [DX_ENV_APPEND(HAVE_DOT, NO)]) + +# Man pages generation: +DX_ARG_ABLE(man, [generate doxygen manual pages], + [DX_CHECK_DEPEND(doc, 1)], + [DX_CLEAR_DEPEND(doc, 1)], + [], + [DX_ENV_APPEND(GENERATE_MAN, YES)], + [DX_ENV_APPEND(GENERATE_MAN, NO)]) + +# RTF file generation: +DX_ARG_ABLE(rtf, [generate doxygen RTF documentation], + [DX_CHECK_DEPEND(doc, 1)], + [DX_CLEAR_DEPEND(doc, 1)], + [], + [DX_ENV_APPEND(GENERATE_RTF, YES)], + [DX_ENV_APPEND(GENERATE_RTF, NO)]) + +# XML file generation: +DX_ARG_ABLE(xml, [generate doxygen XML documentation], + [DX_CHECK_DEPEND(doc, 1)], + [DX_CLEAR_DEPEND(doc, 1)], + [], + [DX_ENV_APPEND(GENERATE_XML, YES)], + [DX_ENV_APPEND(GENERATE_XML, NO)]) + +# (Compressed) HTML help generation: +DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation], + [DX_CHECK_DEPEND(doc, 1)], + [DX_CLEAR_DEPEND(doc, 1)], + [DX_REQUIRE_PROG([DX_HHC], hhc)], + [DX_ENV_APPEND(HHC_PATH, $DX_HHC) + DX_ENV_APPEND(GENERATE_HTML, YES) + DX_ENV_APPEND(GENERATE_HTMLHELP, YES)], + [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)]) + +# Seperate CHI file generation. +DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file], + [DX_CHECK_DEPEND(chm, 1)], + [DX_CLEAR_DEPEND(chm, 1)], + [], + [DX_ENV_APPEND(GENERATE_CHI, YES)], + [DX_ENV_APPEND(GENERATE_CHI, NO)]) + +# Plain HTML pages generation: +DX_ARG_ABLE(html, [generate doxygen plain HTML documentation], + [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)], + [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)], + [], + [DX_ENV_APPEND(GENERATE_HTML, YES)], + [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)]) + +# PostScript file generation: +DX_ARG_ABLE(ps, [generate doxygen PostScript documentation], + [DX_CHECK_DEPEND(doc, 1)], + [DX_CLEAR_DEPEND(doc, 1)], + [DX_REQUIRE_PROG([DX_LATEX], latex) + DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) + DX_REQUIRE_PROG([DX_DVIPS], dvips) + DX_REQUIRE_PROG([DX_EGREP], egrep)]) + +# PDF file generation: +DX_ARG_ABLE(pdf, [generate doxygen PDF documentation], + [DX_CHECK_DEPEND(doc, 1)], + [DX_CLEAR_DEPEND(doc, 1)], + [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex) + DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) + DX_REQUIRE_PROG([DX_EGREP], egrep)]) + +# LaTeX generation for PS and/or PDF: +if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then + AM_CONDITIONAL(DX_COND_latex, :) + DX_ENV_APPEND(GENERATE_LATEX, YES) +else + AM_CONDITIONAL(DX_COND_latex, false) + DX_ENV_APPEND(GENERATE_LATEX, NO) +fi + +# Paper size for PS and/or PDF: +AC_ARG_VAR(DOXYGEN_PAPER_SIZE, + [a4wide (default), a4, letter, legal or executive]) +case "$DOXYGEN_PAPER_SIZE" in +#( +"") + AC_SUBST(DOXYGEN_PAPER_SIZE, "") +;; #( +a4wide|a4|letter|legal|executive) + DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE) +;; #( +*) + AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE']) +;; +esac + +#For debugging: +#echo DX_FLAG_doc=$DX_FLAG_doc +#echo DX_FLAG_dot=$DX_FLAG_dot +#echo DX_FLAG_man=$DX_FLAG_man +#echo DX_FLAG_html=$DX_FLAG_html +#echo DX_FLAG_chm=$DX_FLAG_chm +#echo DX_FLAG_chi=$DX_FLAG_chi +#echo DX_FLAG_rtf=$DX_FLAG_rtf +#echo DX_FLAG_xml=$DX_FLAG_xml +#echo DX_FLAG_pdf=$DX_FLAG_pdf +#echo DX_FLAG_ps=$DX_FLAG_ps +#echo DX_ENV=$DX_ENV +]) diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/aclocal.m4 b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/aclocal.m4 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/aclocal.m4 rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/aclocal.m4 diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/aminclude.am b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/aminclude.am similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/aminclude.am rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/aminclude.am diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.0 b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.0 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.0 rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.0 diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.1 b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.1 similarity index 99% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.1 rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.1 index b9af984..f6584f6 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.1 +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.1 @@ -14558,60 +14558,60 @@ fi - - -# Files: + + +# Files: DX_PROJECT=$PACKAGE_NAME - + DX_CONFIG=doxygen.cfg - + DX_DOCDIR=doxygen-doc - - -# Environment variables used inside doxygen.cfg: + + +# Environment variables used inside doxygen.cfg: DX_ENV="$DX_ENV SRCDIR='$srcdir'" - + DX_ENV="$DX_ENV PROJECT='$DX_PROJECT'" - + DX_ENV="$DX_ENV DOCDIR='$DX_DOCDIR'" - + DX_ENV="$DX_ENV VERSION='$PACKAGE_VERSION'" - - -# Doxygen itself: - - - - + + +# Doxygen itself: + + + + @%:@ Check whether --enable-doxygen-doc was given. if test "${enable_doxygen_doc+set}" = set; then : - enableval=$enable_doxygen_doc; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_doc; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_doc=1 - - -;; #( -n|N|no|No|NO) + + +;; #( +n|N|no|No|NO) DX_FLAG_doc=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-doc" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-doc" "$LINENO" 5 +;; +esac else - + DX_FLAG_doc=1 - - + + fi - -if test "$DX_FLAG_doc" = 1; then - + +if test "$DX_FLAG_doc" = 1; then + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}doxygen", so it can be a program name with args. set dummy ${ac_tool_prefix}doxygen; ac_word=$2 @@ -14709,15 +14709,15 @@ esac else DX_DOXYGEN="$ac_cv_path_DX_DOXYGEN" fi - -if test "$DX_FLAG_doc$DX_DOXYGEN" = 1; then + +if test "$DX_FLAG_doc$DX_DOXYGEN" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: doxygen not found - will not generate any doxygen documentation" >&5 -$as_echo "$as_me: WARNING: doxygen not found - will not generate any doxygen documentation" >&2;} +$as_echo "$as_me: WARNING: doxygen not found - will not generate any doxygen documentation" >&2;} DX_FLAG_doc=0 - -fi - - + +fi + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}perl", so it can be a program name with args. set dummy ${ac_tool_prefix}perl; ac_word=$2 @@ -14815,17 +14815,17 @@ esac else DX_PERL="$ac_cv_path_DX_PERL" fi - -if test "$DX_FLAG_doc$DX_PERL" = 1; then + +if test "$DX_FLAG_doc$DX_PERL" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: perl not found - will not generate any doxygen documentation" >&5 -$as_echo "$as_me: WARNING: perl not found - will not generate any doxygen documentation" >&2;} +$as_echo "$as_me: WARNING: perl not found - will not generate any doxygen documentation" >&2;} DX_FLAG_doc=0 - -fi - - : -fi -if test "$DX_FLAG_doc" = 1; then + +fi + + : +fi +if test "$DX_FLAG_doc" = 1; then if :; then DX_COND_doc_TRUE= DX_COND_doc_FALSE='#' @@ -14833,11 +14833,11 @@ else DX_COND_doc_TRUE='#' DX_COND_doc_FALSE= fi - + DX_ENV="$DX_ENV PERL_PATH='$DX_PERL'" - - : -else + + : +else if false; then DX_COND_doc_TRUE= DX_COND_doc_FALSE='#' @@ -14845,52 +14845,52 @@ else DX_COND_doc_TRUE='#' DX_COND_doc_FALSE= fi - - - : -fi - - -# Dot for graphics: - - - - + + + : +fi + + +# Dot for graphics: + + + + @%:@ Check whether --enable-doxygen-dot was given. if test "${enable_doxygen_dot+set}" = set; then : - enableval=$enable_doxygen_dot; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_dot; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_dot=1 - - -test "$DX_FLAG_doc" = "1" \ -|| as_fn_error "doxygen-dot requires doxygen-dot" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_doc" = "1" \ +|| as_fn_error "doxygen-dot requires doxygen-dot" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_dot=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-dot" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-dot" "$LINENO" 5 +;; +esac else - + DX_FLAG_dot=1 - - + + test "$DX_FLAG_doc" = "1" || DX_FLAG_dot=0 - - + + fi - -if test "$DX_FLAG_dot" = 1; then - + +if test "$DX_FLAG_dot" = 1; then + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dot", so it can be a program name with args. set dummy ${ac_tool_prefix}dot; ac_word=$2 @@ -14988,17 +14988,17 @@ esac else DX_DOT="$ac_cv_path_DX_DOT" fi - -if test "$DX_FLAG_dot$DX_DOT" = 1; then + +if test "$DX_FLAG_dot$DX_DOT" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: dot not found - will not generate graphics for doxygen documentation" >&5 -$as_echo "$as_me: WARNING: dot not found - will not generate graphics for doxygen documentation" >&2;} +$as_echo "$as_me: WARNING: dot not found - will not generate graphics for doxygen documentation" >&2;} DX_FLAG_dot=0 - -fi - - : -fi -if test "$DX_FLAG_dot" = 1; then + +fi + + : +fi +if test "$DX_FLAG_dot" = 1; then if :; then DX_COND_dot_TRUE= DX_COND_dot_FALSE='#' @@ -15006,13 +15006,13 @@ else DX_COND_dot_TRUE='#' DX_COND_dot_FALSE= fi - + DX_ENV="$DX_ENV HAVE_DOT='YES'" - + DX_ENV="$DX_ENV DOT_PATH='`expr ".$DX_DOT" : '\(\.\)[^/]*$' \| "x$DX_DOT" : 'x\(.*\)/[^/]*$'`'" - - : -else + + : +else if false; then DX_COND_dot_TRUE= DX_COND_dot_FALSE='#' @@ -15020,56 +15020,56 @@ else DX_COND_dot_TRUE='#' DX_COND_dot_FALSE= fi - + DX_ENV="$DX_ENV HAVE_DOT='NO'" - - : -fi - - -# Man pages generation: - - - - + + : +fi + + +# Man pages generation: + + + + @%:@ Check whether --enable-doxygen-man was given. if test "${enable_doxygen_man+set}" = set; then : - enableval=$enable_doxygen_man; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_man; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_man=1 - - -test "$DX_FLAG_doc" = "1" \ -|| as_fn_error "doxygen-man requires doxygen-man" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_doc" = "1" \ +|| as_fn_error "doxygen-man requires doxygen-man" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_man=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-man" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-man" "$LINENO" 5 +;; +esac else - + DX_FLAG_man=0 - - + + test "$DX_FLAG_doc" = "1" || DX_FLAG_man=0 - - + + +fi + +if test "$DX_FLAG_man" = 1; then + + : fi - -if test "$DX_FLAG_man" = 1; then - - : -fi -if test "$DX_FLAG_man" = 1; then +if test "$DX_FLAG_man" = 1; then if :; then DX_COND_man_TRUE= DX_COND_man_FALSE='#' @@ -15077,11 +15077,11 @@ else DX_COND_man_TRUE='#' DX_COND_man_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_MAN='YES'" - - : -else + + : +else if false; then DX_COND_man_TRUE= DX_COND_man_FALSE='#' @@ -15089,56 +15089,56 @@ else DX_COND_man_TRUE='#' DX_COND_man_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_MAN='NO'" - - : -fi - - -# RTF file generation: - - - - + + : +fi + + +# RTF file generation: + + + + @%:@ Check whether --enable-doxygen-rtf was given. if test "${enable_doxygen_rtf+set}" = set; then : - enableval=$enable_doxygen_rtf; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_rtf; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_rtf=1 - - -test "$DX_FLAG_doc" = "1" \ -|| as_fn_error "doxygen-rtf requires doxygen-rtf" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_doc" = "1" \ +|| as_fn_error "doxygen-rtf requires doxygen-rtf" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_rtf=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-rtf" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-rtf" "$LINENO" 5 +;; +esac else - + DX_FLAG_rtf=0 - - + + test "$DX_FLAG_doc" = "1" || DX_FLAG_rtf=0 - - + + +fi + +if test "$DX_FLAG_rtf" = 1; then + + : fi - -if test "$DX_FLAG_rtf" = 1; then - - : -fi -if test "$DX_FLAG_rtf" = 1; then +if test "$DX_FLAG_rtf" = 1; then if :; then DX_COND_rtf_TRUE= DX_COND_rtf_FALSE='#' @@ -15146,11 +15146,11 @@ else DX_COND_rtf_TRUE='#' DX_COND_rtf_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_RTF='YES'" - - : -else + + : +else if false; then DX_COND_rtf_TRUE= DX_COND_rtf_FALSE='#' @@ -15158,56 +15158,56 @@ else DX_COND_rtf_TRUE='#' DX_COND_rtf_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_RTF='NO'" - - : -fi - - -# XML file generation: - - - - + + : +fi + + +# XML file generation: + + + + @%:@ Check whether --enable-doxygen-xml was given. if test "${enable_doxygen_xml+set}" = set; then : - enableval=$enable_doxygen_xml; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_xml; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_xml=1 - - -test "$DX_FLAG_doc" = "1" \ -|| as_fn_error "doxygen-xml requires doxygen-xml" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_doc" = "1" \ +|| as_fn_error "doxygen-xml requires doxygen-xml" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_xml=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-xml" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-xml" "$LINENO" 5 +;; +esac else - + DX_FLAG_xml=0 - - + + test "$DX_FLAG_doc" = "1" || DX_FLAG_xml=0 - - + + fi - -if test "$DX_FLAG_xml" = 1; then - - : -fi -if test "$DX_FLAG_xml" = 1; then + +if test "$DX_FLAG_xml" = 1; then + + : +fi +if test "$DX_FLAG_xml" = 1; then if :; then DX_COND_xml_TRUE= DX_COND_xml_FALSE='#' @@ -15215,11 +15215,11 @@ else DX_COND_xml_TRUE='#' DX_COND_xml_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_XML='YES'" - - : -else + + : +else if false; then DX_COND_xml_TRUE= DX_COND_xml_FALSE='#' @@ -15227,53 +15227,53 @@ else DX_COND_xml_TRUE='#' DX_COND_xml_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_XML='NO'" - - : -fi - - -# (Compressed) HTML help generation: - - - - + + : +fi + + +# (Compressed) HTML help generation: + + + + @%:@ Check whether --enable-doxygen-chm was given. if test "${enable_doxygen_chm+set}" = set; then : - enableval=$enable_doxygen_chm; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_chm; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_chm=1 - - -test "$DX_FLAG_doc" = "1" \ -|| as_fn_error "doxygen-chm requires doxygen-chm" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_doc" = "1" \ +|| as_fn_error "doxygen-chm requires doxygen-chm" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_chm=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-chm" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-chm" "$LINENO" 5 +;; +esac else - + DX_FLAG_chm=0 - - + + test "$DX_FLAG_doc" = "1" || DX_FLAG_chm=0 - - + + fi - -if test "$DX_FLAG_chm" = 1; then - + +if test "$DX_FLAG_chm" = 1; then + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}hhc", so it can be a program name with args. set dummy ${ac_tool_prefix}hhc; ac_word=$2 @@ -15371,17 +15371,17 @@ esac else DX_HHC="$ac_cv_path_DX_HHC" fi - -if test "$DX_FLAG_chm$DX_HHC" = 1; then + +if test "$DX_FLAG_chm$DX_HHC" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: hhc not found - will not generate doxygen compressed HTML help documentation" >&5 -$as_echo "$as_me: WARNING: hhc not found - will not generate doxygen compressed HTML help documentation" >&2;} +$as_echo "$as_me: WARNING: hhc not found - will not generate doxygen compressed HTML help documentation" >&2;} DX_FLAG_chm=0 - -fi - - : -fi -if test "$DX_FLAG_chm" = 1; then + +fi + + : +fi +if test "$DX_FLAG_chm" = 1; then if :; then DX_COND_chm_TRUE= DX_COND_chm_FALSE='#' @@ -15389,15 +15389,15 @@ else DX_COND_chm_TRUE='#' DX_COND_chm_FALSE= fi - + DX_ENV="$DX_ENV HHC_PATH='$DX_HHC'" - + DX_ENV="$DX_ENV GENERATE_HTML='YES'" - + DX_ENV="$DX_ENV GENERATE_HTMLHELP='YES'" - - : -else + + : +else if false; then DX_COND_chm_TRUE= DX_COND_chm_FALSE='#' @@ -15405,56 +15405,56 @@ else DX_COND_chm_TRUE='#' DX_COND_chm_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_HTMLHELP='NO'" - - : -fi - - -# Seperate CHI file generation. - - - - + + : +fi + + +# Seperate CHI file generation. + + + + @%:@ Check whether --enable-doxygen-chi was given. if test "${enable_doxygen_chi+set}" = set; then : - enableval=$enable_doxygen_chi; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_chi; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_chi=1 - - -test "$DX_FLAG_chm" = "1" \ -|| as_fn_error "doxygen-chi requires doxygen-chi" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_chm" = "1" \ +|| as_fn_error "doxygen-chi requires doxygen-chi" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_chi=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-chi" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-chi" "$LINENO" 5 +;; +esac else - + DX_FLAG_chi=0 - - + + test "$DX_FLAG_chm" = "1" || DX_FLAG_chi=0 - - + + +fi + +if test "$DX_FLAG_chi" = 1; then + + : fi - -if test "$DX_FLAG_chi" = 1; then - - : -fi -if test "$DX_FLAG_chi" = 1; then +if test "$DX_FLAG_chi" = 1; then if :; then DX_COND_chi_TRUE= DX_COND_chi_FALSE='#' @@ -15462,11 +15462,11 @@ else DX_COND_chi_TRUE='#' DX_COND_chi_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_CHI='YES'" - - : -else + + : +else if false; then DX_COND_chi_TRUE= DX_COND_chi_FALSE='#' @@ -15474,62 +15474,62 @@ else DX_COND_chi_TRUE='#' DX_COND_chi_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_CHI='NO'" - - : -fi - - -# Plain HTML pages generation: - - - - + + : +fi + + +# Plain HTML pages generation: + + + + @%:@ Check whether --enable-doxygen-html was given. if test "${enable_doxygen_html+set}" = set; then : - enableval=$enable_doxygen_html; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_html; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_html=1 - - -test "$DX_FLAG_doc" = "1" \ -|| as_fn_error "doxygen-html requires doxygen-html" "$LINENO" 5 - -test "$DX_FLAG_chm" = "0" \ -|| as_fn_error "doxygen-html contradicts doxygen-html" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_doc" = "1" \ +|| as_fn_error "doxygen-html requires doxygen-html" "$LINENO" 5 + +test "$DX_FLAG_chm" = "0" \ +|| as_fn_error "doxygen-html contradicts doxygen-html" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_html=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-html" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-html" "$LINENO" 5 +;; +esac else - + DX_FLAG_html=1 - - + + test "$DX_FLAG_doc" = "1" || DX_FLAG_html=0 - - + + test "$DX_FLAG_chm" = "0" || DX_FLAG_html=0 - - + + fi - -if test "$DX_FLAG_html" = 1; then - - : -fi -if test "$DX_FLAG_html" = 1; then + +if test "$DX_FLAG_html" = 1; then + + : +fi +if test "$DX_FLAG_html" = 1; then if :; then DX_COND_html_TRUE= DX_COND_html_FALSE='#' @@ -15537,11 +15537,11 @@ else DX_COND_html_TRUE='#' DX_COND_html_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_HTML='YES'" - - : -else + + : +else if false; then DX_COND_html_TRUE= DX_COND_html_FALSE='#' @@ -15549,53 +15549,53 @@ else DX_COND_html_TRUE='#' DX_COND_html_FALSE= fi - + test "$DX_FLAG_chm" = 1 || DX_ENV="$DX_ENV GENERATE_HTML='NO'" - - : -fi - - -# PostScript file generation: - - - - + + : +fi + + +# PostScript file generation: + + + + @%:@ Check whether --enable-doxygen-ps was given. if test "${enable_doxygen_ps+set}" = set; then : - enableval=$enable_doxygen_ps; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_ps; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_ps=1 - - -test "$DX_FLAG_doc" = "1" \ -|| as_fn_error "doxygen-ps requires doxygen-ps" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_doc" = "1" \ +|| as_fn_error "doxygen-ps requires doxygen-ps" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_ps=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-ps" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-ps" "$LINENO" 5 +;; +esac else - + DX_FLAG_ps=0 - - + + test "$DX_FLAG_doc" = "1" || DX_FLAG_ps=0 - - + + fi - -if test "$DX_FLAG_ps" = 1; then - + +if test "$DX_FLAG_ps" = 1; then + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}latex", so it can be a program name with args. set dummy ${ac_tool_prefix}latex; ac_word=$2 @@ -15693,15 +15693,15 @@ esac else DX_LATEX="$ac_cv_path_DX_LATEX" fi - -if test "$DX_FLAG_ps$DX_LATEX" = 1; then + +if test "$DX_FLAG_ps$DX_LATEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: latex not found - will not generate doxygen PostScript documentation" >&5 -$as_echo "$as_me: WARNING: latex not found - will not generate doxygen PostScript documentation" >&2;} +$as_echo "$as_me: WARNING: latex not found - will not generate doxygen PostScript documentation" >&2;} DX_FLAG_ps=0 - -fi - - + +fi + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}makeindex", so it can be a program name with args. set dummy ${ac_tool_prefix}makeindex; ac_word=$2 @@ -15799,15 +15799,15 @@ esac else DX_MAKEINDEX="$ac_cv_path_DX_MAKEINDEX" fi - -if test "$DX_FLAG_ps$DX_MAKEINDEX" = 1; then + +if test "$DX_FLAG_ps$DX_MAKEINDEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: makeindex not found - will not generate doxygen PostScript documentation" >&5 -$as_echo "$as_me: WARNING: makeindex not found - will not generate doxygen PostScript documentation" >&2;} +$as_echo "$as_me: WARNING: makeindex not found - will not generate doxygen PostScript documentation" >&2;} DX_FLAG_ps=0 - -fi - - + +fi + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dvips", so it can be a program name with args. set dummy ${ac_tool_prefix}dvips; ac_word=$2 @@ -15905,15 +15905,15 @@ esac else DX_DVIPS="$ac_cv_path_DX_DVIPS" fi - -if test "$DX_FLAG_ps$DX_DVIPS" = 1; then + +if test "$DX_FLAG_ps$DX_DVIPS" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: dvips not found - will not generate doxygen PostScript documentation" >&5 -$as_echo "$as_me: WARNING: dvips not found - will not generate doxygen PostScript documentation" >&2;} +$as_echo "$as_me: WARNING: dvips not found - will not generate doxygen PostScript documentation" >&2;} DX_FLAG_ps=0 - -fi - - + +fi + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}egrep", so it can be a program name with args. set dummy ${ac_tool_prefix}egrep; ac_word=$2 @@ -16011,17 +16011,17 @@ esac else DX_EGREP="$ac_cv_path_DX_EGREP" fi - -if test "$DX_FLAG_ps$DX_EGREP" = 1; then + +if test "$DX_FLAG_ps$DX_EGREP" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: egrep not found - will not generate doxygen PostScript documentation" >&5 -$as_echo "$as_me: WARNING: egrep not found - will not generate doxygen PostScript documentation" >&2;} +$as_echo "$as_me: WARNING: egrep not found - will not generate doxygen PostScript documentation" >&2;} DX_FLAG_ps=0 - -fi - - : -fi -if test "$DX_FLAG_ps" = 1; then + +fi + + : +fi +if test "$DX_FLAG_ps" = 1; then if :; then DX_COND_ps_TRUE= DX_COND_ps_FALSE='#' @@ -16029,10 +16029,10 @@ else DX_COND_ps_TRUE='#' DX_COND_ps_FALSE= fi - - - : -else + + + : +else if false; then DX_COND_ps_TRUE= DX_COND_ps_FALSE='#' @@ -16040,52 +16040,52 @@ else DX_COND_ps_TRUE='#' DX_COND_ps_FALSE= fi - - - : -fi - - -# PDF file generation: - - - - + + + : +fi + + +# PDF file generation: + + + + @%:@ Check whether --enable-doxygen-pdf was given. if test "${enable_doxygen_pdf+set}" = set; then : - enableval=$enable_doxygen_pdf; -case "$enableval" in -#( -y|Y|yes|Yes|YES) + enableval=$enable_doxygen_pdf; +case "$enableval" in +#( +y|Y|yes|Yes|YES) DX_FLAG_pdf=1 - - -test "$DX_FLAG_doc" = "1" \ -|| as_fn_error "doxygen-pdf requires doxygen-pdf" "$LINENO" 5 - -;; #( -n|N|no|No|NO) + + +test "$DX_FLAG_doc" = "1" \ +|| as_fn_error "doxygen-pdf requires doxygen-pdf" "$LINENO" 5 + +;; #( +n|N|no|No|NO) DX_FLAG_pdf=0 - -;; #( -*) - as_fn_error "invalid value '$enableval' given to doxygen-pdf" "$LINENO" 5 -;; -esac + +;; #( +*) + as_fn_error "invalid value '$enableval' given to doxygen-pdf" "$LINENO" 5 +;; +esac else - + DX_FLAG_pdf=0 - - + + test "$DX_FLAG_doc" = "1" || DX_FLAG_pdf=0 - - + + fi - -if test "$DX_FLAG_pdf" = 1; then - + +if test "$DX_FLAG_pdf" = 1; then + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pdflatex", so it can be a program name with args. set dummy ${ac_tool_prefix}pdflatex; ac_word=$2 @@ -16183,15 +16183,15 @@ esac else DX_PDFLATEX="$ac_cv_path_DX_PDFLATEX" fi - -if test "$DX_FLAG_pdf$DX_PDFLATEX" = 1; then + +if test "$DX_FLAG_pdf$DX_PDFLATEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pdflatex not found - will not generate doxygen PDF documentation" >&5 -$as_echo "$as_me: WARNING: pdflatex not found - will not generate doxygen PDF documentation" >&2;} +$as_echo "$as_me: WARNING: pdflatex not found - will not generate doxygen PDF documentation" >&2;} DX_FLAG_pdf=0 - -fi - - + +fi + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}makeindex", so it can be a program name with args. set dummy ${ac_tool_prefix}makeindex; ac_word=$2 @@ -16289,15 +16289,15 @@ esac else DX_MAKEINDEX="$ac_cv_path_DX_MAKEINDEX" fi - -if test "$DX_FLAG_pdf$DX_MAKEINDEX" = 1; then + +if test "$DX_FLAG_pdf$DX_MAKEINDEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: makeindex not found - will not generate doxygen PDF documentation" >&5 -$as_echo "$as_me: WARNING: makeindex not found - will not generate doxygen PDF documentation" >&2;} +$as_echo "$as_me: WARNING: makeindex not found - will not generate doxygen PDF documentation" >&2;} DX_FLAG_pdf=0 - -fi - - + +fi + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}egrep", so it can be a program name with args. set dummy ${ac_tool_prefix}egrep; ac_word=$2 @@ -16395,17 +16395,17 @@ esac else DX_EGREP="$ac_cv_path_DX_EGREP" fi - -if test "$DX_FLAG_pdf$DX_EGREP" = 1; then + +if test "$DX_FLAG_pdf$DX_EGREP" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: egrep not found - will not generate doxygen PDF documentation" >&5 -$as_echo "$as_me: WARNING: egrep not found - will not generate doxygen PDF documentation" >&2;} +$as_echo "$as_me: WARNING: egrep not found - will not generate doxygen PDF documentation" >&2;} DX_FLAG_pdf=0 - -fi - - : -fi -if test "$DX_FLAG_pdf" = 1; then + +fi + + : +fi +if test "$DX_FLAG_pdf" = 1; then if :; then DX_COND_pdf_TRUE= DX_COND_pdf_FALSE='#' @@ -16413,10 +16413,10 @@ else DX_COND_pdf_TRUE='#' DX_COND_pdf_FALSE= fi - - - : -else + + + : +else if false; then DX_COND_pdf_TRUE= DX_COND_pdf_FALSE='#' @@ -16424,14 +16424,14 @@ else DX_COND_pdf_TRUE='#' DX_COND_pdf_FALSE= fi - - - : -fi - - -# LaTeX generation for PS and/or PDF: -if test "$DX_FLAG_ps" = 1 || test "$DX_FLAG_pdf" = 1; then + + + : +fi + + +# LaTeX generation for PS and/or PDF: +if test "$DX_FLAG_ps" = 1 || test "$DX_FLAG_pdf" = 1; then if :; then DX_COND_latex_TRUE= DX_COND_latex_FALSE='#' @@ -16439,10 +16439,10 @@ else DX_COND_latex_TRUE='#' DX_COND_latex_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_LATEX='YES'" - -else + +else if false; then DX_COND_latex_TRUE= DX_COND_latex_FALSE='#' @@ -16450,40 +16450,40 @@ else DX_COND_latex_TRUE='#' DX_COND_latex_FALSE= fi - + DX_ENV="$DX_ENV GENERATE_LATEX='NO'" - -fi - -# Paper size for PS and/or PDF: - -case "$DOXYGEN_PAPER_SIZE" in -#( -"") + +fi + +# Paper size for PS and/or PDF: + +case "$DOXYGEN_PAPER_SIZE" in +#( +"") DOXYGEN_PAPER_SIZE="" - -;; #( -a4wide|a4|letter|legal|executive) + +;; #( +a4wide|a4|letter|legal|executive) DX_ENV="$DX_ENV PAPER_SIZE='$DOXYGEN_PAPER_SIZE'" - -;; #( -*) - as_fn_error "unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'" "$LINENO" 5 -;; -esac - -#For debugging: -#echo DX_FLAG_doc=$DX_FLAG_doc -#echo DX_FLAG_dot=$DX_FLAG_dot -#echo DX_FLAG_man=$DX_FLAG_man -#echo DX_FLAG_html=$DX_FLAG_html -#echo DX_FLAG_chm=$DX_FLAG_chm -#echo DX_FLAG_chi=$DX_FLAG_chi -#echo DX_FLAG_rtf=$DX_FLAG_rtf -#echo DX_FLAG_xml=$DX_FLAG_xml -#echo DX_FLAG_pdf=$DX_FLAG_pdf -#echo DX_FLAG_ps=$DX_FLAG_ps -#echo DX_ENV=$DX_ENV + +;; #( +*) + as_fn_error "unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'" "$LINENO" 5 +;; +esac + +#For debugging: +#echo DX_FLAG_doc=$DX_FLAG_doc +#echo DX_FLAG_dot=$DX_FLAG_dot +#echo DX_FLAG_man=$DX_FLAG_man +#echo DX_FLAG_html=$DX_FLAG_html +#echo DX_FLAG_chm=$DX_FLAG_chm +#echo DX_FLAG_chi=$DX_FLAG_chi +#echo DX_FLAG_rtf=$DX_FLAG_rtf +#echo DX_FLAG_xml=$DX_FLAG_xml +#echo DX_FLAG_pdf=$DX_FLAG_pdf +#echo DX_FLAG_ps=$DX_FLAG_ps +#echo DX_ENV=$DX_ENV ###################################################################### diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.2 b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.2 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.2 rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/output.2 diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/requests b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/requests similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/requests rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/requests diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.0 b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.0 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.0 rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.0 diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.1 b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.1 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.1 rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.1 diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.2 b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.2 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.2 rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/autom4te.cache/traces.2 diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-VER.TLE b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-VER.TLE old mode 100755 new mode 100644 similarity index 98% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-VER.TLE rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-VER.TLE index cfa3133..381a7c3 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-VER.TLE +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-VER.TLE @@ -1,110 +1,110 @@ -# ------------------ Verification test cases ---------------------- -# # TEME example -1 00005U 58002B 00179.78495062 .00000023 00000-0 28098-4 0 4753 -2 00005 34.2682 348.7242 1859667 331.7664 19.3264 10.82419157413667 0.00 4320.0 360.00 -# ## fig show lyddane fix error with gsfc ver -1 04632U 70093B 04031.91070959 -.00000084 00000-0 10000-3 0 9955 -2 04632 11.4628 273.1101 1450506 207.6000 143.9350 1.20231981 44145 -5184.0 -4896.0 120.00 -# DELTA 1 DEB # near earth normal drag equation -# # perigee = 377.26km, so moderate drag case -1 06251U 62025E 06176.82412014 .00008885 00000-0 12808-3 0 3985 -2 06251 58.0579 54.0425 0030035 139.1568 221.1854 15.56387291 6774 0.0 2880.0 120.00 -# MOLNIYA 2-14 # 12h resonant ecc in 0.65 to 0.7 range -1 08195U 75081A 06176.33215444 .00000099 00000-0 11873-3 0 813 -2 08195 64.1586 279.0717 6877146 264.7651 20.2257 2.00491383225656 0.0 2880.0 120.00 -# MOLNIYA 1-36 ## fig 12h resonant ecc in 0.7 to 0.715 range -1 09880U 77021A 06176.56157475 .00000421 00000-0 10000-3 0 9814 -2 09880 64.5968 349.3786 7069051 270.0229 16.3320 2.00813614112380 0.0 2880.0 120.00 -# SMS 1 AKM # show the integrator problem with gsfc ver -1 09998U 74033F 05148.79417928 -.00000112 00000-0 00000+0 0 4480 -2 09998 9.4958 313.1750 0270971 327.5225 30.8097 1.16186785 45878 -1440.0 -720.00 60.0 -# # Original STR#3 SDP4 test -1 11801U 80230.29629788 .01431103 00000-0 14311-1 13 -2 11801 46.7916 230.4354 7318036 47.4722 10.4117 2.28537848 13 0.0 1440.0 360.00 -# EUTELSAT 1-F1 (ECS1)## fig lyddane choice in GSFC at 2080 min -1 14128U 83058A 06176.02844893 -.00000158 00000-0 10000-3 0 9627 -2 14128 11.4384 35.2134 0011562 26.4582 333.5652 0.98870114 46093 0.0 2880.0 120.00 -# SL-6 R/B(2) # Deep space, perigee = 82.48 (<98) for -# # s4 > 20 mod -1 16925U 86065D 06151.67415771 .02550794 -30915-6 18784-3 0 4486 -2 16925 62.0906 295.0239 5596327 245.1593 47.9690 4.88511875148616 0.0 1440.0 120.00 -# SL-12 R/B # Shows Lyddane choice at 1860 and 4700 min -1 20413U 83020D 05363.79166667 .00000000 00000-0 00000+0 0 7041 -2 20413 12.3514 187.4253 7864447 196.3027 356.5478 0.24690082 7978 1440.0 4320.0 120.00 -# MOLNIYA 1-83 # 12h resonant, ecc > 0.715 (negative BSTAR) -1 21897U 92011A 06176.02341244 -.00001273 00000-0 -13525-3 0 3044 -2 21897 62.1749 198.0096 7421690 253.0462 20.1561 2.01269994104880 0.0 2880.0 120.00 -# SL-6 R/B(2) # last tle given, decayed 2006-04-04, day 94 -1 22312U 93002D 06094.46235912 .99999999 81888-5 49949-3 0 3953 -2 22312 62.1486 77.4698 0308723 267.9229 88.7392 15.95744531 98783 54.2028672 1440.0 20.00 -# SL-6 R/B(2) # 12h resonant ecc in the > 0.715 range -1 22674U 93035D 06176.55909107 .00002121 00000-0 29868-3 0 6569 -2 22674 63.5035 354.4452 7541712 253.3264 18.7754 1.96679808 93877 0.0 2880.0 120.00 -# ARIANE 44L+ R/B # Lyddane bug at <= 70 min for atan2(), -# # no quadrant fix -1 23177U 94040C 06175.45752052 .00000386 00000-0 76590-3 0 95 -2 23177 7.0496 179.8238 7258491 296.0482 8.3061 2.25906668 97438 0.0 1440.0 120.00 -# WIND # STR#3 Kepler failes past about 200 min -1 23333U 94071A 94305.49999999 -.00172956 26967-3 10000-3 0 15 -2 23333 28.7490 2.3720 9728298 30.4360 1.3500 0.07309491 70 0.0 1600.0 120.00 -# ARIANE 42P+3 R/B ## fig Lyddane bug at > 280.5 min for AcTan() -1 23599U 95029B 06171.76535463 .00085586 12891-6 12956-2 0 2905 -2 23599 6.9327 0.2849 5782022 274.4436 25.2425 4.47796565123555 0.0 720.0 20.00 -# ITALSAT 2 # 24h resonant GEO, inclination > 3 deg -1 24208U 96044A 06177.04061740 -.00000094 00000-0 10000-3 0 1600 -2 24208 3.8536 80.0121 0026640 311.0977 48.3000 1.00778054 36119 0.0 1440.0 120.00 -# AMC-4 ## fig low incl, show incl shift with -# ## gsfc version from 240 to 1440 min -1 25954U 99060A 04039.68057285 -.00000108 00000-0 00000-0 0 6847 -2 25954 0.0004 243.8136 0001765 15.5294 22.7134 1.00271289 15615 -1440.0 1440.0 120.00 -# INTELSAT 902 # negative incl at 9313 min then -# # 270 deg Lyddane bug at 37606 min -1 26900U 01039A 06106.74503247 .00000045 00000-0 10000-3 0 8290 -2 26900 0.0164 266.5378 0003319 86.1794 182.2590 1.00273847 16981 9300.00 9400.00 60.00 -# COSMOS 1024 DEB # 12h resonant ecc in 0.5 to 0.65 range -1 26975U 78066F 06174.85818871 .00000620 00000-0 10000-3 0 6809 -2 26975 68.4714 236.1303 5602877 123.7484 302.5767 2.05657553 67521 0.0 2880.0 120.00 -# CBERS 2 # Near Earth, ecc = 8.84E-5 (< 1.0e-4) -# # drop certain normal drag terms -1 28057U 03049A 06177.78615833 .00000060 00000-0 35940-4 0 1836 -2 28057 98.4283 247.6961 0000884 88.1964 271.9322 14.35478080140550 0.0 2880.0 120.00 -# NAVSTAR 53 (USA 175)# 12h non-resonant GPS (ecc < 0.5 ecc) -1 28129U 03058A 06175.57071136 -.00000104 00000-0 10000-3 0 459 -2 28129 54.7298 324.8098 0048506 266.2640 93.1663 2.00562768 18443 0.0 1440.0 120.00 -# COSMOS 2405 # Near Earth, perigee = 127.20 (< 156) s4 mod -1 28350U 04020A 06167.21788666 .16154492 76267-5 18678-3 0 8894 -2 28350 64.9977 345.6130 0024870 260.7578 99.9590 16.47856722116490 0.0 2880.0 120.00 -# H-2 R/B # Deep space, perigee = 135.75 (<156) s4 mod -1 28623U 05006B 06177.81079184 .00637644 69054-6 96390-3 0 6000 -2 28623 28.5200 114.9834 6249053 170.2550 212.8965 3.79477162 12753 0.0 1440.0 120.00 -# XM-3 # 24h resonant geo, incl < 3 deg goes -# # negative around 1130 min -1 28626U 05008A 06176.46683397 -.00000205 00000-0 10000-3 0 2190 -2 28626 0.0019 286.9433 0000335 13.7918 55.6504 1.00270176 4891 0.0 1440.0 120.00 -# MINOTAUR R/B # Sub-orbital case - Decayed 2005-11-29 -# #(perigee = -51km), lost in 50 minutes -1 28872U 05037B 05333.02012661 .25992681 00000-0 24476-3 0 1534 -2 28872 96.4736 157.9986 0303955 244.0492 110.6523 16.46015938 10708 0.0 60.0 5.00 -# SL-14 DEB # Last stage of decay - lost in under 420 min -1 29141U 85108AA 06170.26783845 .99999999 00000-0 13519-0 0 718 -2 29141 82.4288 273.4882 0015848 277.2124 83.9133 15.93343074 6828 0.0 440.0 20.00 -# SL-12 DEB # Near Earth, perigee = 212.24 < 220 -# # simplified drag eq -1 29238U 06022G 06177.28732010 .00766286 10823-4 13334-2 0 101 -2 29238 51.5595 213.7903 0202579 95.2503 267.9010 15.73823839 1061 0.0 1440.0 120.00 -# # Original STR#3 SGP4 test -1 88888U 80275.98708465 .00073094 13844-3 66816-4 0 87 -2 88888 72.8435 115.9689 0086731 52.6988 110.5714 16.05824518 1058 0.0 1440.0 120.00 -# -# # check error code 4 -1 33333U 05037B 05333.02012661 .25992681 00000-0 24476-3 0 1534 -2 33333 96.4736 157.9986 9950000 244.0492 110.6523 4.00004038 10708 0.0 150.0 5.00 -# # try and check error code 2 but this -1 33334U 78066F 06174.85818871 .00000620 00000-0 10000-3 0 6809 -2 33334 68.4714 236.1303 5602877 123.7484 302.5767 0.00001000 67521 0.0 1440.0 1.00 -# # try to check error code 3 looks like ep never goes below zero, tied close to ecc -1 33335U 05008A 06176.46683397 -.00000205 00000-0 10000-3 0 2190 -2 33335 0.0019 286.9433 0000004 13.7918 55.6504 1.00270176 4891 0.0 1440.0 20.00 -# SL-12 R/B # Shows Lyddane choice at 1860 and 4700 min -1 20413U 83020D 05363.79166667 .00000000 00000-0 00000+0 0 7041 -2 20413 12.3514 187.4253 7864447 196.3027 356.5478 0.24690082 7978 1844000 1845100 5.00 +# ------------------ Verification test cases ---------------------- +# # TEME example +1 00005U 58002B 00179.78495062 .00000023 00000-0 28098-4 0 4753 +2 00005 34.2682 348.7242 1859667 331.7664 19.3264 10.82419157413667 0.00 4320.0 360.00 +# ## fig show lyddane fix error with gsfc ver +1 04632U 70093B 04031.91070959 -.00000084 00000-0 10000-3 0 9955 +2 04632 11.4628 273.1101 1450506 207.6000 143.9350 1.20231981 44145 -5184.0 -4896.0 120.00 +# DELTA 1 DEB # near earth normal drag equation +# # perigee = 377.26km, so moderate drag case +1 06251U 62025E 06176.82412014 .00008885 00000-0 12808-3 0 3985 +2 06251 58.0579 54.0425 0030035 139.1568 221.1854 15.56387291 6774 0.0 2880.0 120.00 +# MOLNIYA 2-14 # 12h resonant ecc in 0.65 to 0.7 range +1 08195U 75081A 06176.33215444 .00000099 00000-0 11873-3 0 813 +2 08195 64.1586 279.0717 6877146 264.7651 20.2257 2.00491383225656 0.0 2880.0 120.00 +# MOLNIYA 1-36 ## fig 12h resonant ecc in 0.7 to 0.715 range +1 09880U 77021A 06176.56157475 .00000421 00000-0 10000-3 0 9814 +2 09880 64.5968 349.3786 7069051 270.0229 16.3320 2.00813614112380 0.0 2880.0 120.00 +# SMS 1 AKM # show the integrator problem with gsfc ver +1 09998U 74033F 05148.79417928 -.00000112 00000-0 00000+0 0 4480 +2 09998 9.4958 313.1750 0270971 327.5225 30.8097 1.16186785 45878 -1440.0 -720.00 60.0 +# # Original STR#3 SDP4 test +1 11801U 80230.29629788 .01431103 00000-0 14311-1 13 +2 11801 46.7916 230.4354 7318036 47.4722 10.4117 2.28537848 13 0.0 1440.0 360.00 +# EUTELSAT 1-F1 (ECS1)## fig lyddane choice in GSFC at 2080 min +1 14128U 83058A 06176.02844893 -.00000158 00000-0 10000-3 0 9627 +2 14128 11.4384 35.2134 0011562 26.4582 333.5652 0.98870114 46093 0.0 2880.0 120.00 +# SL-6 R/B(2) # Deep space, perigee = 82.48 (<98) for +# # s4 > 20 mod +1 16925U 86065D 06151.67415771 .02550794 -30915-6 18784-3 0 4486 +2 16925 62.0906 295.0239 5596327 245.1593 47.9690 4.88511875148616 0.0 1440.0 120.00 +# SL-12 R/B # Shows Lyddane choice at 1860 and 4700 min +1 20413U 83020D 05363.79166667 .00000000 00000-0 00000+0 0 7041 +2 20413 12.3514 187.4253 7864447 196.3027 356.5478 0.24690082 7978 1440.0 4320.0 120.00 +# MOLNIYA 1-83 # 12h resonant, ecc > 0.715 (negative BSTAR) +1 21897U 92011A 06176.02341244 -.00001273 00000-0 -13525-3 0 3044 +2 21897 62.1749 198.0096 7421690 253.0462 20.1561 2.01269994104880 0.0 2880.0 120.00 +# SL-6 R/B(2) # last tle given, decayed 2006-04-04, day 94 +1 22312U 93002D 06094.46235912 .99999999 81888-5 49949-3 0 3953 +2 22312 62.1486 77.4698 0308723 267.9229 88.7392 15.95744531 98783 54.2028672 1440.0 20.00 +# SL-6 R/B(2) # 12h resonant ecc in the > 0.715 range +1 22674U 93035D 06176.55909107 .00002121 00000-0 29868-3 0 6569 +2 22674 63.5035 354.4452 7541712 253.3264 18.7754 1.96679808 93877 0.0 2880.0 120.00 +# ARIANE 44L+ R/B # Lyddane bug at <= 70 min for atan2(), +# # no quadrant fix +1 23177U 94040C 06175.45752052 .00000386 00000-0 76590-3 0 95 +2 23177 7.0496 179.8238 7258491 296.0482 8.3061 2.25906668 97438 0.0 1440.0 120.00 +# WIND # STR#3 Kepler failes past about 200 min +1 23333U 94071A 94305.49999999 -.00172956 26967-3 10000-3 0 15 +2 23333 28.7490 2.3720 9728298 30.4360 1.3500 0.07309491 70 0.0 1600.0 120.00 +# ARIANE 42P+3 R/B ## fig Lyddane bug at > 280.5 min for AcTan() +1 23599U 95029B 06171.76535463 .00085586 12891-6 12956-2 0 2905 +2 23599 6.9327 0.2849 5782022 274.4436 25.2425 4.47796565123555 0.0 720.0 20.00 +# ITALSAT 2 # 24h resonant GEO, inclination > 3 deg +1 24208U 96044A 06177.04061740 -.00000094 00000-0 10000-3 0 1600 +2 24208 3.8536 80.0121 0026640 311.0977 48.3000 1.00778054 36119 0.0 1440.0 120.00 +# AMC-4 ## fig low incl, show incl shift with +# ## gsfc version from 240 to 1440 min +1 25954U 99060A 04039.68057285 -.00000108 00000-0 00000-0 0 6847 +2 25954 0.0004 243.8136 0001765 15.5294 22.7134 1.00271289 15615 -1440.0 1440.0 120.00 +# INTELSAT 902 # negative incl at 9313 min then +# # 270 deg Lyddane bug at 37606 min +1 26900U 01039A 06106.74503247 .00000045 00000-0 10000-3 0 8290 +2 26900 0.0164 266.5378 0003319 86.1794 182.2590 1.00273847 16981 9300.00 9400.00 60.00 +# COSMOS 1024 DEB # 12h resonant ecc in 0.5 to 0.65 range +1 26975U 78066F 06174.85818871 .00000620 00000-0 10000-3 0 6809 +2 26975 68.4714 236.1303 5602877 123.7484 302.5767 2.05657553 67521 0.0 2880.0 120.00 +# CBERS 2 # Near Earth, ecc = 8.84E-5 (< 1.0e-4) +# # drop certain normal drag terms +1 28057U 03049A 06177.78615833 .00000060 00000-0 35940-4 0 1836 +2 28057 98.4283 247.6961 0000884 88.1964 271.9322 14.35478080140550 0.0 2880.0 120.00 +# NAVSTAR 53 (USA 175)# 12h non-resonant GPS (ecc < 0.5 ecc) +1 28129U 03058A 06175.57071136 -.00000104 00000-0 10000-3 0 459 +2 28129 54.7298 324.8098 0048506 266.2640 93.1663 2.00562768 18443 0.0 1440.0 120.00 +# COSMOS 2405 # Near Earth, perigee = 127.20 (< 156) s4 mod +1 28350U 04020A 06167.21788666 .16154492 76267-5 18678-3 0 8894 +2 28350 64.9977 345.6130 0024870 260.7578 99.9590 16.47856722116490 0.0 2880.0 120.00 +# H-2 R/B # Deep space, perigee = 135.75 (<156) s4 mod +1 28623U 05006B 06177.81079184 .00637644 69054-6 96390-3 0 6000 +2 28623 28.5200 114.9834 6249053 170.2550 212.8965 3.79477162 12753 0.0 1440.0 120.00 +# XM-3 # 24h resonant geo, incl < 3 deg goes +# # negative around 1130 min +1 28626U 05008A 06176.46683397 -.00000205 00000-0 10000-3 0 2190 +2 28626 0.0019 286.9433 0000335 13.7918 55.6504 1.00270176 4891 0.0 1440.0 120.00 +# MINOTAUR R/B # Sub-orbital case - Decayed 2005-11-29 +# #(perigee = -51km), lost in 50 minutes +1 28872U 05037B 05333.02012661 .25992681 00000-0 24476-3 0 1534 +2 28872 96.4736 157.9986 0303955 244.0492 110.6523 16.46015938 10708 0.0 60.0 5.00 +# SL-14 DEB # Last stage of decay - lost in under 420 min +1 29141U 85108AA 06170.26783845 .99999999 00000-0 13519-0 0 718 +2 29141 82.4288 273.4882 0015848 277.2124 83.9133 15.93343074 6828 0.0 440.0 20.00 +# SL-12 DEB # Near Earth, perigee = 212.24 < 220 +# # simplified drag eq +1 29238U 06022G 06177.28732010 .00766286 10823-4 13334-2 0 101 +2 29238 51.5595 213.7903 0202579 95.2503 267.9010 15.73823839 1061 0.0 1440.0 120.00 +# # Original STR#3 SGP4 test +1 88888U 80275.98708465 .00073094 13844-3 66816-4 0 87 +2 88888 72.8435 115.9689 0086731 52.6988 110.5714 16.05824518 1058 0.0 1440.0 120.00 +# +# # check error code 4 +1 33333U 05037B 05333.02012661 .25992681 00000-0 24476-3 0 1534 +2 33333 96.4736 157.9986 9950000 244.0492 110.6523 4.00004038 10708 0.0 150.0 5.00 +# # try and check error code 2 but this +1 33334U 78066F 06174.85818871 .00000620 00000-0 10000-3 0 6809 +2 33334 68.4714 236.1303 5602877 123.7484 302.5767 0.00001000 67521 0.0 1440.0 1.00 +# # try to check error code 3 looks like ep never goes below zero, tied close to ecc +1 33335U 05008A 06176.46683397 -.00000205 00000-0 10000-3 0 2190 +2 33335 0.0019 286.9433 0000004 13.7918 55.6504 1.00270176 4891 0.0 1440.0 20.00 +# SL-12 R/B # Shows Lyddane choice at 1860 and 4700 min +1 20413U 83020D 05363.79166667 .00000000 00000-0 00000+0 0 7041 +2 20413 12.3514 187.4253 7864447 196.3027 356.5478 0.24690082 7978 1844000 1845100 5.00 diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-test.TLE b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-test.TLE old mode 100755 new mode 100644 similarity index 98% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-test.TLE rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-test.TLE index 6bf2965..1946dc0 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-test.TLE +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/SGP4-test.TLE @@ -1,24 +1,24 @@ -TEST1 -1 00005U 58002B 00179.78495062 .00000023 00000-0 28098-4 0 4753 -2 00005 34.2682 348.7242 1859667 331.7664 19.3264 10.82419157413667 0.00 4320.0 360.00 -TEST2 -1 04632U 70093B 04031.91070959 -.00000084 00000-0 10000-3 0 9955 -2 04632 11.4628 273.1101 1450506 207.6000 143.9350 1.20231981 44145 -5184.0 -4896.0 120.00 -TEST3 -1 06251U 62025E 06176.82412014 .00008885 00000-0 12808-3 0 3985 -2 06251 58.0579 54.0425 0030035 139.1568 221.1854 15.56387291 6774 0.0 2880.0 120.00 -TEST4 -1 08195U 75081A 06176.33215444 .00000099 00000-0 11873-3 0 813 -2 08195 64.1586 279.0717 6877146 264.7651 20.2257 2.00491383225656 0.0 2880.0 120.00 -TEST5 -1 09880U 77021A 06176.56157475 .00000421 00000-0 10000-3 0 9814 -2 09880 64.5968 349.3786 7069051 270.0229 16.3320 2.00813614112380 0.0 2880.0 120.00 -TEST6 -1 09998U 74033F 05148.79417928 -.00000112 00000-0 00000+0 0 4480 -2 09998 9.4958 313.1750 0270971 327.5225 30.8097 1.16186785 45878 -1440.0 -720.00 60.0 -TEST7 -1 11801U 80230.29629788 .01431103 00000-0 14311-1 13 -2 11801 46.7916 230.4354 7318036 47.4722 10.4117 2.28537848 13 0.0 1440.0 360.00 -TEST8 -1 14128U 83058A 06176.02844893 -.00000158 10000-3 10000-3 0 9627 -2 14128 11.4384 35.2134 0011562 26.4582 333.5652 0.98870114 46093 0.0 2880.0 120.00 +TEST1 +1 00005U 58002B 00179.78495062 .00000023 00000-0 28098-4 0 4753 +2 00005 34.2682 348.7242 1859667 331.7664 19.3264 10.82419157413667 0.00 4320.0 360.00 +TEST2 +1 04632U 70093B 04031.91070959 -.00000084 00000-0 10000-3 0 9955 +2 04632 11.4628 273.1101 1450506 207.6000 143.9350 1.20231981 44145 -5184.0 -4896.0 120.00 +TEST3 +1 06251U 62025E 06176.82412014 .00008885 00000-0 12808-3 0 3985 +2 06251 58.0579 54.0425 0030035 139.1568 221.1854 15.56387291 6774 0.0 2880.0 120.00 +TEST4 +1 08195U 75081A 06176.33215444 .00000099 00000-0 11873-3 0 813 +2 08195 64.1586 279.0717 6877146 264.7651 20.2257 2.00491383225656 0.0 2880.0 120.00 +TEST5 +1 09880U 77021A 06176.56157475 .00000421 00000-0 10000-3 0 9814 +2 09880 64.5968 349.3786 7069051 270.0229 16.3320 2.00813614112380 0.0 2880.0 120.00 +TEST6 +1 09998U 74033F 05148.79417928 -.00000112 00000-0 00000+0 0 4480 +2 09998 9.4958 313.1750 0270971 327.5225 30.8097 1.16186785 45878 -1440.0 -720.00 60.0 +TEST7 +1 11801U 80230.29629788 .01431103 00000-0 14311-1 13 +2 11801 46.7916 230.4354 7318036 47.4722 10.4117 2.28537848 13 0.0 1440.0 360.00 +TEST8 +1 14128U 83058A 06176.02844893 -.00000158 10000-3 10000-3 0 9627 +2 14128 11.4384 35.2134 0011562 26.4582 333.5652 0.98870114 46093 0.0 2880.0 120.00 diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTEME2_expl.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTEME2_expl.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTEME2_expl.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTEME2_expl.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTEME_expl.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTEME_expl.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTEME_expl.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTEME_expl.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTracking_expl.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTracking_expl.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTracking_expl.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gSatTracking_expl.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gTime_expl.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gTime_expl.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gTime_expl.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gTime_expl.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gTleFileAccessor_expl.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gTleFileAccessor_expl.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gTleFileAccessor_expl.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/gTleFileAccessor_expl.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/sunPosition_expl.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/sunPosition_expl.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/sunPosition_expl.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/code_examples/sunPosition_expl.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.guess b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.guess old mode 100755 new mode 100644 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.guess rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.guess diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.h.in b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.h.in similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.h.in rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.h.in diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.sub b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.sub old mode 100755 new mode 100644 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.sub rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/config.sub diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/configure b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/configure old mode 100755 new mode 100644 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/configure rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/configure diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/configure.in b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/configure.in similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/configure.in rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/configure.in diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/depcomp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/depcomp old mode 100755 new mode 100644 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/depcomp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/depcomp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/install-sh b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/install-sh old mode 100755 new mode 100644 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/install-sh rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/install-sh diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/ltmain.sh b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/ltmain.sh old mode 100755 new mode 100644 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/ltmain.sh rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/ltmain.sh diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/missing b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/missing old mode 100755 new mode 100644 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/missing rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/missing diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/mkinstalldirs b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/mkinstalldirs old mode 100755 new mode 100644 similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/mkinstalldirs rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/mkinstalldirs diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gException.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gException.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gException.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gException.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrix.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrix.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrix.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrix.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrix.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrix.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrix.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrix.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrixTempl.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrixTempl.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrixTempl.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gMatrixTempl.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gObserver.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gObserver.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gObserver.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gObserver.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gObserver.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gObserver.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gObserver.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gObserver.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gSatTEME.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gSatTEME.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gSatTEME.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gSatTEME.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gSatTEME.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gSatTEME.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gSatTEME.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gSatTEME.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTime.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTime.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTime.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTime.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTime.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTime.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTime.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTime.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTimeSpan.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTimeSpan.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTimeSpan.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTimeSpan.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleFileAccessor.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleFileAccessor.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleFileAccessor.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleFileAccessor.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleFileAccessor.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleFileAccessor.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleFileAccessor.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleFileAccessor.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleParser.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleParser.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleParser.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleParser.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleParser.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleParser.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleParser.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gTleParser.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVector.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVector.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVector.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVector.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVector.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVector.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVector.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVector.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVectorTempl.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVectorTempl.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVectorTempl.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/gVectorTempl.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/mathUtils.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/mathUtils.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/mathUtils.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/mathUtils.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/mathUtils.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/mathUtils.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/mathUtils.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/mathUtils.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.cpp similarity index 96% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.cpp index afc479a..edd1757 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.cpp +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.cpp @@ -1,724 +1,724 @@ -/* ---------------------------------------------------------------- -* -* sgp4ext.cpp -* -* this file contains extra routines needed for the main test program for sgp4. -* these routines are derived from the astro libraries. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 7 may 08 david vallado -* fix sgn -* changes : -* 2 apr 07 david vallado -* fix jday floor and str lengths -* updates for constants -* 14 aug 06 david vallado -* original baseline -* ---------------------------------------------------------------- */ - -#include "sgp4ext.h" - - -double sgn - ( - double x - ) - { - if (x < 0.0) - { - return -1.0; - } - else - { - return 1.0; - } - - } // end sgn - -/* ----------------------------------------------------------------------------- -* -* function mag -* -* this procedure finds the magnitude of a vector. the tolerance is set to -* 0.000001, thus the 1.0e-12 for the squared test of underflows. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* vec - vector -* -* outputs : -* vec - answer stored in fourth component -* -* locals : -* none. -* -* coupling : -* none. -* --------------------------------------------------------------------------- */ - -double mag - ( - double x[3] - ) - { - return sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]); - } // end mag - -/* ----------------------------------------------------------------------------- -* -* procedure cross -* -* this procedure crosses two vectors. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* vec1 - vector number 1 -* vec2 - vector number 2 -* -* outputs : -* outvec - vector result of a x b -* -* locals : -* none. -* -* coupling : -* mag magnitude of a vector - ---------------------------------------------------------------------------- */ - -void cross - ( - double vec1[3], double vec2[3], double outvec[3] - ) - { - outvec[0]= vec1[1]*vec2[2] - vec1[2]*vec2[1]; - outvec[1]= vec1[2]*vec2[0] - vec1[0]*vec2[2]; - outvec[2]= vec1[0]*vec2[1] - vec1[1]*vec2[0]; - } // end cross - - -/* ----------------------------------------------------------------------------- -* -* function dot -* -* this function finds the dot product of two vectors. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* vec1 - vector number 1 -* vec2 - vector number 2 -* -* outputs : -* dot - result -* -* locals : -* none. -* -* coupling : -* none. -* -* --------------------------------------------------------------------------- */ - -double dot - ( - double x[3], double y[3] - ) - { - return (x[0]*y[0] + x[1]*y[1] + x[2]*y[2]); - } // end dot - -/* ----------------------------------------------------------------------------- -* -* procedure angle -* -* this procedure calculates the angle between two vectors. the output is -* set to 999999.1 to indicate an undefined value. be sure to check for -* this at the output phase. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* vec1 - vector number 1 -* vec2 - vector number 2 -* -* outputs : -* theta - angle between the two vectors -pi to pi -* -* locals : -* temp - temporary real variable -* -* coupling : -* dot dot product of two vectors -* --------------------------------------------------------------------------- */ - -double angle - ( - double vec1[3], - double vec2[3] - ) - { - double small, undefined, magv1, magv2, temp; - small = 0.00000001; - undefined = 999999.1; - - magv1 = mag(vec1); - magv2 = mag(vec2); - - if (magv1*magv2 > small*small) - { - temp= dot(vec1,vec2) / (magv1*magv2); - if (fabs( temp ) > 1.0) - temp= sgn(temp) * 1.0; - return acos( temp ); - } - else - return undefined; - } // end angle - - -/* ----------------------------------------------------------------------------- -* -* function asinh -* -* this function evaluates the inverse hyperbolic sine function. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* xval - angle value any real -* -* outputs : -* arcsinh - result any real -* -* locals : -* none. -* -* coupling : -* none. -* -* --------------------------------------------------------------------------- */ - -double asinh - ( - double xval - ) - { - return log( xval + sqrt( xval*xval + 1.0 ) ); - } // end asinh - - -/* ----------------------------------------------------------------------------- -* -* function newtonnu -* -* this function solves keplers equation when the true anomaly is known. -* the mean and eccentric, parabolic, or hyperbolic anomaly is also found. -* the parabolic limit at 168ø is arbitrary. the hyperbolic anomaly is also -* limited. the hyperbolic sine is used because it's not double valued. -* -* author : david vallado 719-573-2600 27 may 2002 -* -* revisions -* vallado - fix small 24 sep 2002 -* -* inputs description range / units -* ecc - eccentricity 0.0 to -* nu - true anomaly -2pi to 2pi rad -* -* outputs : -* e0 - eccentric anomaly 0.0 to 2pi rad 153.02 ø -* m - mean anomaly 0.0 to 2pi rad 151.7425 ø -* -* locals : -* e1 - eccentric anomaly, next value rad -* sine - sine of e -* cose - cosine of e -* ktr - index -* -* coupling : -* asinh - arc hyperbolic sine -* -* references : -* vallado 2007, 85, alg 5 -* --------------------------------------------------------------------------- */ - -void newtonnu - ( - double ecc, double nu, - double& e0, double& m - ) - { - double small, sine, cose; - - // --------------------- implementation --------------------- - e0= 999999.9; - m = 999999.9; - small = 0.00000001; - - // --------------------------- circular ------------------------ - if ( fabs( ecc ) < small ) - { - m = nu; - e0= nu; - } - else - // ---------------------- elliptical ----------------------- - if ( ecc < 1.0-small ) - { - sine= ( sqrt( 1.0 -ecc*ecc ) * sin(nu) ) / ( 1.0 +ecc*cos(nu) ); - cose= ( ecc + cos(nu) ) / ( 1.0 + ecc*cos(nu) ); - e0 = atan2( sine,cose ); - m = e0 - ecc*sin(e0); - } - else - // -------------------- hyperbolic -------------------- - if ( ecc > 1.0 + small ) - { - if ((ecc > 1.0 ) && (fabs(nu)+0.00001 < pi-acos(1.0 /ecc))) - { - sine= ( sqrt( ecc*ecc-1.0 ) * sin(nu) ) / ( 1.0 + ecc*cos(nu) ); - e0 = asinh( sine ); - m = ecc*sinh(e0) - e0; - } - } - else - // ----------------- parabolic --------------------- - if ( fabs(nu) < 168.0*pi/180.0 ) - { - e0= tan( nu*0.5 ); - m = e0 + (e0*e0*e0)/3.0; - } - - if ( ecc < 1.0 ) - { - m = fmod( m,2.0 *pi ); - if ( m < 0.0 ) - m = m + 2.0 *pi; - e0 = fmod( e0,2.0 *pi ); - } - } // end newtonnu - - -/* ----------------------------------------------------------------------------- -* -* function rv2coe -* -* this function finds the classical orbital elements given the geocentric -* equatorial position and velocity vectors. -* -* author : david vallado 719-573-2600 21 jun 2002 -* -* revisions -* vallado - fix special cases 5 sep 2002 -* vallado - delete extra check in inclination code 16 oct 2002 -* vallado - add constant file use 29 jun 2003 -* vallado - add mu 2 apr 2007 -* -* inputs description range / units -* r - ijk position vector km -* v - ijk velocity vector km / s -* mu - gravitational parameter km3 / s2 -* -* outputs : -* p - semilatus rectum km -* a - semimajor axis km -* ecc - eccentricity -* incl - inclination 0.0 to pi rad -* omega - longitude of ascending node 0.0 to 2pi rad -* argp - argument of perigee 0.0 to 2pi rad -* nu - true anomaly 0.0 to 2pi rad -* m - mean anomaly 0.0 to 2pi rad -* arglat - argument of latitude (ci) 0.0 to 2pi rad -* truelon - true longitude (ce) 0.0 to 2pi rad -* lonper - longitude of periapsis (ee) 0.0 to 2pi rad -* -* locals : -* hbar - angular momentum h vector km2 / s -* ebar - eccentricity e vector -* nbar - line of nodes n vector -* c1 - v**2 - u/r -* rdotv - r dot v -* hk - hk unit vector -* sme - specfic mechanical energy km2 / s2 -* i - index -* e - eccentric, parabolic, -* hyperbolic anomaly rad -* temp - temporary variable -* typeorbit - type of orbit ee, ei, ce, ci -* -* coupling : -* mag - magnitude of a vector -* cross - cross product of two vectors -* angle - find the angle between two vectors -* newtonnu - find the mean anomaly -* -* references : -* vallado 2007, 126, alg 9, ex 2-5 -* --------------------------------------------------------------------------- */ - -void rv2coe - ( - double r[3], double v[3], double mu, - double& p, double& a, double& ecc, double& incl, double& omega, double& argp, - double& nu, double& m, double& arglat, double& truelon, double& lonper - ) - { - double undefined, small, hbar[3], nbar[3], magr, magv, magn, ebar[3], sme, - rdotv, infinite, temp, c1, hk, twopi, magh, halfpi, e; - - int i; - char typeorbit[3]; - - twopi = 2.0 * pi; - halfpi = 0.5 * pi; - small = 0.00000001; - undefined = 999999.1; - infinite = 999999.9; - - // ------------------------- implementation ----------------- - magr = mag( r ); - magv = mag( v ); - - // ------------------ find h n and e vectors ---------------- - cross( r,v, hbar ); - magh = mag( hbar ); - if ( magh > small ) - { - nbar[0]= -hbar[1]; - nbar[1]= hbar[0]; - nbar[2]= 0.0; - magn = mag( nbar ); - c1 = magv*magv - mu /magr; - rdotv = dot( r,v ); - for (i= 0; i <= 2; i++) - ebar[i]= (c1*r[i] - rdotv*v[i])/mu; - ecc = mag( ebar ); - - // ------------ find a e and semi-latus rectum ---------- - sme= ( magv*magv*0.5 ) - ( mu /magr ); - if ( fabs( sme ) > small ) - a= -mu / (2.0 *sme); - else - a= infinite; - p = magh*magh/mu; - - // ----------------- find inclination ------------------- - hk= hbar[2]/magh; - incl= acos( hk ); - - // -------- determine type of orbit for later use -------- - // ------ elliptical, parabolic, hyperbolic inclined ------- - strcpy(typeorbit,"ei"); - if ( ecc < small ) - { - // ---------------- circular equatorial --------------- - if ((incl small ) - { - temp= nbar[0] / magn; - if ( fabs(temp) > 1.0 ) - temp= sgn(temp); - omega= acos( temp ); - if ( nbar[1] < 0.0 ) - omega= twopi - omega; - } - else - omega= undefined; - - // ---------------- find argument of perigee --------------- - if ( strcmp(typeorbit,"ei") == 0 ) - { - argp = angle( nbar,ebar); - if ( ebar[2] < 0.0 ) - argp= twopi - argp; - } - else - argp= undefined; - - // ------------ find true anomaly at epoch ------------- - if ( typeorbit[0] == 'e' ) - { - nu = angle( ebar,r); - if ( rdotv < 0.0 ) - nu= twopi - nu; - } - else - nu= undefined; - - // ---- find argument of latitude - circular inclined ----- - if ( strcmp(typeorbit,"ci") == 0 ) - { - arglat = angle( nbar,r ); - if ( r[2] < 0.0 ) - arglat= twopi - arglat; - m = arglat; - } - else - arglat= undefined; - - // -- find longitude of perigee - elliptical equatorial ---- - if (( ecc>small ) && (strcmp(typeorbit,"ee") == 0)) - { - temp= ebar[0]/ecc; - if ( fabs(temp) > 1.0 ) - temp= sgn(temp); - lonper= acos( temp ); - if ( ebar[1] < 0.0 ) - lonper= twopi - lonper; - if ( incl > halfpi ) - lonper= twopi - lonper; - } - else - lonper= undefined; - - // -------- find true longitude - circular equatorial ------ - if (( magr>small ) && ( strcmp(typeorbit,"ce") == 0 )) - { - temp= r[0]/magr; - if ( fabs(temp) > 1.0 ) - temp= sgn(temp); - truelon= acos( temp ); - if ( r[1] < 0.0 ) - truelon= twopi - truelon; - if ( incl > halfpi ) - truelon= twopi - truelon; - m = truelon; - } - else - truelon= undefined; - - // ------------ find mean anomaly for all orbits ----------- - if ( typeorbit[0] == 'e' ) - newtonnu(ecc,nu, e, m); - } - else - { - p = undefined; - a = undefined; - ecc = undefined; - incl = undefined; - omega= undefined; - argp = undefined; - nu = undefined; - m = undefined; - arglat = undefined; - truelon= undefined; - lonper = undefined; - } - } // end rv2coe - -/* ----------------------------------------------------------------------------- -* -* procedure jday -* -* this procedure finds the julian date given the year, month, day, and time. -* the julian date is defined by each elapsed day since noon, jan 1, 4713 bc. -* -* algorithm : calculate the answer in one step for efficiency -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* year - year 1900 .. 2100 -* mon - month 1 .. 12 -* day - day 1 .. 28,29,30,31 -* hr - universal time hour 0 .. 23 -* min - universal time min 0 .. 59 -* sec - universal time sec 0.0 .. 59.999 -* -* outputs : -* jd - julian date days from 4713 bc -* -* locals : -* none. -* -* coupling : -* none. -* -* references : -* vallado 2007, 189, alg 14, ex 3-14 -* -* --------------------------------------------------------------------------- */ - -void jday - ( - int year, int mon, int day, int hr, int minute, double sec, - double& jd - ) - { - jd = 367.0 * year - - floor((7 * (year + floor((mon + 9) / 12.0))) * 0.25) + - floor( 275 * mon / 9.0 ) + - day + 1721013.5 + - ((sec / 60.0 + minute) / 60.0 + hr) / 24.0; // ut in days - // - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5; - } // end jday - -/* ----------------------------------------------------------------------------- -* -* procedure days2mdhms -* -* this procedure converts the day of the year, days, to the equivalent month -* day, hour, minute and second. -* -* algorithm : set up array for the number of days per month -* find leap year - use 1900 because 2000 is a leap year -* loop through a temp value while the value is < the days -* perform int conversions to the correct day and month -* convert remainder into h m s using type conversions -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* year - year 1900 .. 2100 -* days - julian day of the year 0.0 .. 366.0 -* -* outputs : -* mon - month 1 .. 12 -* day - day 1 .. 28,29,30,31 -* hr - hour 0 .. 23 -* min - minute 0 .. 59 -* sec - second 0.0 .. 59.999 -* -* locals : -* dayofyr - day of year -* temp - temporary extended values -* inttemp - temporary int value -* i - index -* lmonth[12] - int array containing the number of days per month -* -* coupling : -* none. -* --------------------------------------------------------------------------- */ - -void days2mdhms - ( - int year, double days, - int& mon, int& day, int& hr, int& minute, double& sec - ) - { - int i, inttemp, dayofyr; - double temp; - int lmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - - dayofyr = (int)floor(days); - /* ----------------- find month and day of month ---------------- */ - if ( (year % 4) == 0 ) - lmonth[1] = 29; - - i = 1; - inttemp = 0; - while ((dayofyr > inttemp + lmonth[i-1]) && (i < 12)) - { - inttemp = inttemp + lmonth[i-1]; - i++; - } - mon = i; - day = dayofyr - inttemp; - - /* ----------------- find hours minutes and seconds ------------- */ - temp = (days - dayofyr) * 24.0; - hr = (int)floor(temp); - temp = (temp - hr) * 60.0; - minute = (int)floor(temp); - sec = (temp - minute) * 60.0; - } // end days2mdhms - -/* ----------------------------------------------------------------------------- -* -* procedure invjday -* -* this procedure finds the year, month, day, hour, minute and second -* given the julian date. tu can be ut1, tdt, tdb, etc. -* -* algorithm : set up starting values -* find leap year - use 1900 because 2000 is a leap year -* find the elapsed days through the year in a loop -* call routine to find each individual value -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* jd - julian date days from 4713 bc -* -* outputs : -* year - year 1900 .. 2100 -* mon - month 1 .. 12 -* day - day 1 .. 28,29,30,31 -* hr - hour 0 .. 23 -* min - minute 0 .. 59 -* sec - second 0.0 .. 59.999 -* -* locals : -* days - day of year plus fractional -* portion of a day days -* tu - julian centuries from 0 h -* jan 0, 1900 -* temp - temporary double values -* leapyrs - number of leap years from 1900 -* -* coupling : -* days2mdhms - finds month, day, hour, minute and second given days and year -* -* references : -* vallado 2007, 208, alg 22, ex 3-13 -* --------------------------------------------------------------------------- */ - -void invjday - ( - double jd, - int& year, int& mon, int& day, - int& hr, int& minute, double& sec - ) - { - int leapyrs; - double days, tu, temp; - - /* --------------- find year and days of the year --------------- */ - temp = jd - 2415019.5; - tu = temp / 365.25; - year = 1900 + (int)floor(tu); - leapyrs = (int)floor((year - 1901) * 0.25); - - // optional nudge by 8.64x10-7 sec to get even outputs - days = temp - ((year - 1900) * 365.0 + leapyrs) + 0.00000000001; - - /* ------------ check for case of beginning of a year ----------- */ - if (days < 1.0) - { - year = year - 1; - leapyrs = (int)floor((year - 1901) * 0.25); - days = temp - ((year - 1900) * 365.0 + leapyrs); - } - - /* ----------------- find remaing data ------------------------- */ - days2mdhms(year, days, mon, day, hr, minute, sec); - sec = sec - 0.00000086400; - } // end invjday - - - - - +/* ---------------------------------------------------------------- +* +* sgp4ext.cpp +* +* this file contains extra routines needed for the main test program for sgp4. +* these routines are derived from the astro libraries. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 7 may 08 david vallado +* fix sgn +* changes : +* 2 apr 07 david vallado +* fix jday floor and str lengths +* updates for constants +* 14 aug 06 david vallado +* original baseline +* ---------------------------------------------------------------- */ + +#include "sgp4ext.h" + + +double sgn + ( + double x + ) + { + if (x < 0.0) + { + return -1.0; + } + else + { + return 1.0; + } + + } // end sgn + +/* ----------------------------------------------------------------------------- +* +* function mag +* +* this procedure finds the magnitude of a vector. the tolerance is set to +* 0.000001, thus the 1.0e-12 for the squared test of underflows. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* vec - vector +* +* outputs : +* vec - answer stored in fourth component +* +* locals : +* none. +* +* coupling : +* none. +* --------------------------------------------------------------------------- */ + +double mag + ( + double x[3] + ) + { + return sqrt(x[0]*x[0] + x[1]*x[1] + x[2]*x[2]); + } // end mag + +/* ----------------------------------------------------------------------------- +* +* procedure cross +* +* this procedure crosses two vectors. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* vec1 - vector number 1 +* vec2 - vector number 2 +* +* outputs : +* outvec - vector result of a x b +* +* locals : +* none. +* +* coupling : +* mag magnitude of a vector + ---------------------------------------------------------------------------- */ + +void cross + ( + double vec1[3], double vec2[3], double outvec[3] + ) + { + outvec[0]= vec1[1]*vec2[2] - vec1[2]*vec2[1]; + outvec[1]= vec1[2]*vec2[0] - vec1[0]*vec2[2]; + outvec[2]= vec1[0]*vec2[1] - vec1[1]*vec2[0]; + } // end cross + + +/* ----------------------------------------------------------------------------- +* +* function dot +* +* this function finds the dot product of two vectors. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* vec1 - vector number 1 +* vec2 - vector number 2 +* +* outputs : +* dot - result +* +* locals : +* none. +* +* coupling : +* none. +* +* --------------------------------------------------------------------------- */ + +double dot + ( + double x[3], double y[3] + ) + { + return (x[0]*y[0] + x[1]*y[1] + x[2]*y[2]); + } // end dot + +/* ----------------------------------------------------------------------------- +* +* procedure angle +* +* this procedure calculates the angle between two vectors. the output is +* set to 999999.1 to indicate an undefined value. be sure to check for +* this at the output phase. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* vec1 - vector number 1 +* vec2 - vector number 2 +* +* outputs : +* theta - angle between the two vectors -pi to pi +* +* locals : +* temp - temporary real variable +* +* coupling : +* dot dot product of two vectors +* --------------------------------------------------------------------------- */ + +double angle + ( + double vec1[3], + double vec2[3] + ) + { + double small, undefined, magv1, magv2, temp; + small = 0.00000001; + undefined = 999999.1; + + magv1 = mag(vec1); + magv2 = mag(vec2); + + if (magv1*magv2 > small*small) + { + temp= dot(vec1,vec2) / (magv1*magv2); + if (fabs( temp ) > 1.0) + temp= sgn(temp) * 1.0; + return acos( temp ); + } + else + return undefined; + } // end angle + + +/* ----------------------------------------------------------------------------- +* +* function asinh +* +* this function evaluates the inverse hyperbolic sine function. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* xval - angle value any real +* +* outputs : +* arcsinh - result any real +* +* locals : +* none. +* +* coupling : +* none. +* +* --------------------------------------------------------------------------- */ + +double asinh + ( + double xval + ) + { + return log( xval + sqrt( xval*xval + 1.0 ) ); + } // end asinh + + +/* ----------------------------------------------------------------------------- +* +* function newtonnu +* +* this function solves keplers equation when the true anomaly is known. +* the mean and eccentric, parabolic, or hyperbolic anomaly is also found. +* the parabolic limit at 168ø is arbitrary. the hyperbolic anomaly is also +* limited. the hyperbolic sine is used because it's not double valued. +* +* author : david vallado 719-573-2600 27 may 2002 +* +* revisions +* vallado - fix small 24 sep 2002 +* +* inputs description range / units +* ecc - eccentricity 0.0 to +* nu - true anomaly -2pi to 2pi rad +* +* outputs : +* e0 - eccentric anomaly 0.0 to 2pi rad 153.02 ø +* m - mean anomaly 0.0 to 2pi rad 151.7425 ø +* +* locals : +* e1 - eccentric anomaly, next value rad +* sine - sine of e +* cose - cosine of e +* ktr - index +* +* coupling : +* asinh - arc hyperbolic sine +* +* references : +* vallado 2007, 85, alg 5 +* --------------------------------------------------------------------------- */ + +void newtonnu + ( + double ecc, double nu, + double& e0, double& m + ) + { + double small, sine, cose; + + // --------------------- implementation --------------------- + e0= 999999.9; + m = 999999.9; + small = 0.00000001; + + // --------------------------- circular ------------------------ + if ( fabs( ecc ) < small ) + { + m = nu; + e0= nu; + } + else + // ---------------------- elliptical ----------------------- + if ( ecc < 1.0-small ) + { + sine= ( sqrt( 1.0 -ecc*ecc ) * sin(nu) ) / ( 1.0 +ecc*cos(nu) ); + cose= ( ecc + cos(nu) ) / ( 1.0 + ecc*cos(nu) ); + e0 = atan2( sine,cose ); + m = e0 - ecc*sin(e0); + } + else + // -------------------- hyperbolic -------------------- + if ( ecc > 1.0 + small ) + { + if ((ecc > 1.0 ) && (fabs(nu)+0.00001 < pi-acos(1.0 /ecc))) + { + sine= ( sqrt( ecc*ecc-1.0 ) * sin(nu) ) / ( 1.0 + ecc*cos(nu) ); + e0 = asinh( sine ); + m = ecc*sinh(e0) - e0; + } + } + else + // ----------------- parabolic --------------------- + if ( fabs(nu) < 168.0*pi/180.0 ) + { + e0= tan( nu*0.5 ); + m = e0 + (e0*e0*e0)/3.0; + } + + if ( ecc < 1.0 ) + { + m = fmod( m,2.0 *pi ); + if ( m < 0.0 ) + m = m + 2.0 *pi; + e0 = fmod( e0,2.0 *pi ); + } + } // end newtonnu + + +/* ----------------------------------------------------------------------------- +* +* function rv2coe +* +* this function finds the classical orbital elements given the geocentric +* equatorial position and velocity vectors. +* +* author : david vallado 719-573-2600 21 jun 2002 +* +* revisions +* vallado - fix special cases 5 sep 2002 +* vallado - delete extra check in inclination code 16 oct 2002 +* vallado - add constant file use 29 jun 2003 +* vallado - add mu 2 apr 2007 +* +* inputs description range / units +* r - ijk position vector km +* v - ijk velocity vector km / s +* mu - gravitational parameter km3 / s2 +* +* outputs : +* p - semilatus rectum km +* a - semimajor axis km +* ecc - eccentricity +* incl - inclination 0.0 to pi rad +* omega - longitude of ascending node 0.0 to 2pi rad +* argp - argument of perigee 0.0 to 2pi rad +* nu - true anomaly 0.0 to 2pi rad +* m - mean anomaly 0.0 to 2pi rad +* arglat - argument of latitude (ci) 0.0 to 2pi rad +* truelon - true longitude (ce) 0.0 to 2pi rad +* lonper - longitude of periapsis (ee) 0.0 to 2pi rad +* +* locals : +* hbar - angular momentum h vector km2 / s +* ebar - eccentricity e vector +* nbar - line of nodes n vector +* c1 - v**2 - u/r +* rdotv - r dot v +* hk - hk unit vector +* sme - specfic mechanical energy km2 / s2 +* i - index +* e - eccentric, parabolic, +* hyperbolic anomaly rad +* temp - temporary variable +* typeorbit - type of orbit ee, ei, ce, ci +* +* coupling : +* mag - magnitude of a vector +* cross - cross product of two vectors +* angle - find the angle between two vectors +* newtonnu - find the mean anomaly +* +* references : +* vallado 2007, 126, alg 9, ex 2-5 +* --------------------------------------------------------------------------- */ + +void rv2coe + ( + double r[3], double v[3], double mu, + double& p, double& a, double& ecc, double& incl, double& omega, double& argp, + double& nu, double& m, double& arglat, double& truelon, double& lonper + ) + { + double undefined, small, hbar[3], nbar[3], magr, magv, magn, ebar[3], sme, + rdotv, infinite, temp, c1, hk, twopi, magh, halfpi, e; + + int i; + char typeorbit[3]; + + twopi = 2.0 * pi; + halfpi = 0.5 * pi; + small = 0.00000001; + undefined = 999999.1; + infinite = 999999.9; + + // ------------------------- implementation ----------------- + magr = mag( r ); + magv = mag( v ); + + // ------------------ find h n and e vectors ---------------- + cross( r,v, hbar ); + magh = mag( hbar ); + if ( magh > small ) + { + nbar[0]= -hbar[1]; + nbar[1]= hbar[0]; + nbar[2]= 0.0; + magn = mag( nbar ); + c1 = magv*magv - mu /magr; + rdotv = dot( r,v ); + for (i= 0; i <= 2; i++) + ebar[i]= (c1*r[i] - rdotv*v[i])/mu; + ecc = mag( ebar ); + + // ------------ find a e and semi-latus rectum ---------- + sme= ( magv*magv*0.5 ) - ( mu /magr ); + if ( fabs( sme ) > small ) + a= -mu / (2.0 *sme); + else + a= infinite; + p = magh*magh/mu; + + // ----------------- find inclination ------------------- + hk= hbar[2]/magh; + incl= acos( hk ); + + // -------- determine type of orbit for later use -------- + // ------ elliptical, parabolic, hyperbolic inclined ------- + strcpy(typeorbit,"ei"); + if ( ecc < small ) + { + // ---------------- circular equatorial --------------- + if ((incl small ) + { + temp= nbar[0] / magn; + if ( fabs(temp) > 1.0 ) + temp= sgn(temp); + omega= acos( temp ); + if ( nbar[1] < 0.0 ) + omega= twopi - omega; + } + else + omega= undefined; + + // ---------------- find argument of perigee --------------- + if ( strcmp(typeorbit,"ei") == 0 ) + { + argp = angle( nbar,ebar); + if ( ebar[2] < 0.0 ) + argp= twopi - argp; + } + else + argp= undefined; + + // ------------ find true anomaly at epoch ------------- + if ( typeorbit[0] == 'e' ) + { + nu = angle( ebar,r); + if ( rdotv < 0.0 ) + nu= twopi - nu; + } + else + nu= undefined; + + // ---- find argument of latitude - circular inclined ----- + if ( strcmp(typeorbit,"ci") == 0 ) + { + arglat = angle( nbar,r ); + if ( r[2] < 0.0 ) + arglat= twopi - arglat; + m = arglat; + } + else + arglat= undefined; + + // -- find longitude of perigee - elliptical equatorial ---- + if (( ecc>small ) && (strcmp(typeorbit,"ee") == 0)) + { + temp= ebar[0]/ecc; + if ( fabs(temp) > 1.0 ) + temp= sgn(temp); + lonper= acos( temp ); + if ( ebar[1] < 0.0 ) + lonper= twopi - lonper; + if ( incl > halfpi ) + lonper= twopi - lonper; + } + else + lonper= undefined; + + // -------- find true longitude - circular equatorial ------ + if (( magr>small ) && ( strcmp(typeorbit,"ce") == 0 )) + { + temp= r[0]/magr; + if ( fabs(temp) > 1.0 ) + temp= sgn(temp); + truelon= acos( temp ); + if ( r[1] < 0.0 ) + truelon= twopi - truelon; + if ( incl > halfpi ) + truelon= twopi - truelon; + m = truelon; + } + else + truelon= undefined; + + // ------------ find mean anomaly for all orbits ----------- + if ( typeorbit[0] == 'e' ) + newtonnu(ecc,nu, e, m); + } + else + { + p = undefined; + a = undefined; + ecc = undefined; + incl = undefined; + omega= undefined; + argp = undefined; + nu = undefined; + m = undefined; + arglat = undefined; + truelon= undefined; + lonper = undefined; + } + } // end rv2coe + +/* ----------------------------------------------------------------------------- +* +* procedure jday +* +* this procedure finds the julian date given the year, month, day, and time. +* the julian date is defined by each elapsed day since noon, jan 1, 4713 bc. +* +* algorithm : calculate the answer in one step for efficiency +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* year - year 1900 .. 2100 +* mon - month 1 .. 12 +* day - day 1 .. 28,29,30,31 +* hr - universal time hour 0 .. 23 +* min - universal time min 0 .. 59 +* sec - universal time sec 0.0 .. 59.999 +* +* outputs : +* jd - julian date days from 4713 bc +* +* locals : +* none. +* +* coupling : +* none. +* +* references : +* vallado 2007, 189, alg 14, ex 3-14 +* +* --------------------------------------------------------------------------- */ + +void jday + ( + int year, int mon, int day, int hr, int minute, double sec, + double& jd + ) + { + jd = 367.0 * year - + floor((7 * (year + floor((mon + 9) / 12.0))) * 0.25) + + floor( 275 * mon / 9.0 ) + + day + 1721013.5 + + ((sec / 60.0 + minute) / 60.0 + hr) / 24.0; // ut in days + // - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5; + } // end jday + +/* ----------------------------------------------------------------------------- +* +* procedure days2mdhms +* +* this procedure converts the day of the year, days, to the equivalent month +* day, hour, minute and second. +* +* algorithm : set up array for the number of days per month +* find leap year - use 1900 because 2000 is a leap year +* loop through a temp value while the value is < the days +* perform int conversions to the correct day and month +* convert remainder into h m s using type conversions +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* year - year 1900 .. 2100 +* days - julian day of the year 0.0 .. 366.0 +* +* outputs : +* mon - month 1 .. 12 +* day - day 1 .. 28,29,30,31 +* hr - hour 0 .. 23 +* min - minute 0 .. 59 +* sec - second 0.0 .. 59.999 +* +* locals : +* dayofyr - day of year +* temp - temporary extended values +* inttemp - temporary int value +* i - index +* lmonth[12] - int array containing the number of days per month +* +* coupling : +* none. +* --------------------------------------------------------------------------- */ + +void days2mdhms + ( + int year, double days, + int& mon, int& day, int& hr, int& minute, double& sec + ) + { + int i, inttemp, dayofyr; + double temp; + int lmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + dayofyr = (int)floor(days); + /* ----------------- find month and day of month ---------------- */ + if ( (year % 4) == 0 ) + lmonth[1] = 29; + + i = 1; + inttemp = 0; + while ((dayofyr > inttemp + lmonth[i-1]) && (i < 12)) + { + inttemp = inttemp + lmonth[i-1]; + i++; + } + mon = i; + day = dayofyr - inttemp; + + /* ----------------- find hours minutes and seconds ------------- */ + temp = (days - dayofyr) * 24.0; + hr = (int)floor(temp); + temp = (temp - hr) * 60.0; + minute = (int)floor(temp); + sec = (temp - minute) * 60.0; + } // end days2mdhms + +/* ----------------------------------------------------------------------------- +* +* procedure invjday +* +* this procedure finds the year, month, day, hour, minute and second +* given the julian date. tu can be ut1, tdt, tdb, etc. +* +* algorithm : set up starting values +* find leap year - use 1900 because 2000 is a leap year +* find the elapsed days through the year in a loop +* call routine to find each individual value +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* jd - julian date days from 4713 bc +* +* outputs : +* year - year 1900 .. 2100 +* mon - month 1 .. 12 +* day - day 1 .. 28,29,30,31 +* hr - hour 0 .. 23 +* min - minute 0 .. 59 +* sec - second 0.0 .. 59.999 +* +* locals : +* days - day of year plus fractional +* portion of a day days +* tu - julian centuries from 0 h +* jan 0, 1900 +* temp - temporary double values +* leapyrs - number of leap years from 1900 +* +* coupling : +* days2mdhms - finds month, day, hour, minute and second given days and year +* +* references : +* vallado 2007, 208, alg 22, ex 3-13 +* --------------------------------------------------------------------------- */ + +void invjday + ( + double jd, + int& year, int& mon, int& day, + int& hr, int& minute, double& sec + ) + { + int leapyrs; + double days, tu, temp; + + /* --------------- find year and days of the year --------------- */ + temp = jd - 2415019.5; + tu = temp / 365.25; + year = 1900 + (int)floor(tu); + leapyrs = (int)floor((year - 1901) * 0.25); + + // optional nudge by 8.64x10-7 sec to get even outputs + days = temp - ((year - 1900) * 365.0 + leapyrs) + 0.00000000001; + + /* ------------ check for case of beginning of a year ----------- */ + if (days < 1.0) + { + year = year - 1; + leapyrs = (int)floor((year - 1901) * 0.25); + days = temp - ((year - 1900) * 365.0 + leapyrs); + } + + /* ----------------- find remaing data ------------------------- */ + days2mdhms(year, days, mon, day, hr, minute, sec); + sec = sec - 0.00000086400; + } // end invjday + + + + + diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.h similarity index 95% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.h index 593f498..7967bcc 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.h +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4ext.h @@ -1,97 +1,97 @@ -#ifndef _sgp4ext_ -#define _sgp4ext_ -/* ---------------------------------------------------------------- -* -* sgp4ext.h -* -* this file contains extra routines needed for the main test program for sgp4. -* these routines are derived from the astro libraries. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 20 apr 07 david vallado -* misc documentation updates -* changes : -* 14 aug 06 david vallado -* original baseline -* ---------------------------------------------------------------- */ - -#include -#include - -#include "sgp4unit.h" - - -// ------------------------- function declarations ------------------------- - -double sgn - ( - double x - ); - -double mag - ( - double x[3] - ); - -void cross - ( - double vec1[3], double vec2[3], double outvec[3] - ); - -double dot - ( - double x[3], double y[3] - ); - -double angle - ( - double vec1[3], - double vec2[3] - ); - -void newtonnu - ( - double ecc, double nu, - double& e0, double& m - ); - -double asinh - ( - double xval - ); - -void rv2coe - ( - double r[3], double v[3], double mu, - double& p, double& a, double& ecc, double& incl, double& omega, double& argp, - double& nu, double& m, double& arglat, double& truelon, double& lonper - ); - -void jday - ( - int year, int mon, int day, int hr, int minute, double sec, - double& jd - ); - -void days2mdhms - ( - int year, double days, - int& mon, int& day, int& hr, int& minute, double& sec - ); - -void invjday - ( - double jd, - int& year, int& mon, int& day, - int& hr, int& minute, double& sec - ); - -#endif - +#ifndef _sgp4ext_ +#define _sgp4ext_ +/* ---------------------------------------------------------------- +* +* sgp4ext.h +* +* this file contains extra routines needed for the main test program for sgp4. +* these routines are derived from the astro libraries. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 20 apr 07 david vallado +* misc documentation updates +* changes : +* 14 aug 06 david vallado +* original baseline +* ---------------------------------------------------------------- */ + +#include +#include + +#include "sgp4unit.h" + + +// ------------------------- function declarations ------------------------- + +double sgn + ( + double x + ); + +double mag + ( + double x[3] + ); + +void cross + ( + double vec1[3], double vec2[3], double outvec[3] + ); + +double dot + ( + double x[3], double y[3] + ); + +double angle + ( + double vec1[3], + double vec2[3] + ); + +void newtonnu + ( + double ecc, double nu, + double& e0, double& m + ); + +double asinh + ( + double xval + ); + +void rv2coe + ( + double r[3], double v[3], double mu, + double& p, double& a, double& ecc, double& incl, double& omega, double& argp, + double& nu, double& m, double& arglat, double& truelon, double& lonper + ); + +void jday + ( + int year, int mon, int day, int hr, int minute, double sec, + double& jd + ); + +void days2mdhms + ( + int year, double days, + int& mon, int& day, int& hr, int& minute, double& sec + ); + +void invjday + ( + double jd, + int& year, int& mon, int& day, + int& hr, int& minute, double& sec + ); + +#endif + diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.cpp similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.cpp index 0316087..0b3418f 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.cpp +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.cpp @@ -1,208 +1,208 @@ -/* ---------------------------------------------------------------- -* -* sgp4io.cpp -* -* this file contains a function to read two line element sets. while -* not formerly part of the sgp4 mathematical theory, it is -* required for practical implemenation. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* Note: Deleted code related with command line inputs. That implementation -* is not a god way to build a library. It's better to aisle logic and interface. -* J.L. Canales 20/11/2010 -* -* current : -* 3 sep 08 david vallado -* add operationmode for afspc (a) or improved (i) -* changes : -* 9 may 07 david vallado -* fix year correction to 57 -* 27 mar 07 david vallado -* misc fixes to manual inputs -* 14 aug 06 david vallado -* original baseline -* ---------------------------------------------------------------- */ - -#include "sgp4io.h" - -/* ----------------------------------------------------------------------------- -* -* function twoline2rv -* -* this function converts the two line element set character string data to -* variables and initializes the sgp4 variables. several intermediate varaibles -* and quantities are determined. note that the result is a structure so multiple -* satellites can be processed simultaneously without having to reinitialize. the -* verification mode is an important option that permits quick checks of any -* changes to the underlying technical theory. this option works using a -* modified tle file in which the start, stop, and delta time values are -* included at the end of the second line of data. this only works with the -* verification mode. the catalog mode simply propagates from -1440 to 1440 min -* from epoch and is useful when performing entire catalog runs. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs : -* longstr1 - first line of the tle -* longstr2 - second line of the tle -* typerun - type of run verification 'v', catalog 'c', -* manual 'm' -* typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd' -* opsmode - mode of operation afspc or improved 'a', 'i' -* whichconst - which set of constants to use 72, 84 -* -* outputs : -* satrec - structure containing all the sgp4 satellite information -* -* coupling : -* getgravconst- -* days2mdhms - conversion of days to month, day, hour, minute, second -* jday - convert day month year hour minute second into julian date -* sgp4init - initialize the sgp4 variables -* -* references : -* norad spacetrack report #3 -* vallado, crawford, hujsak, kelso 2006 - --------------------------------------------------------------------------- */ - -void twoline2rv - ( - char longstr1[130], char longstr2[130], - char typerun, char typeinput, char opsmode, - gravconsttype whichconst, - double& startmfe, double& stopmfe, double& deltamin, - elsetrec& satrec - ) - { - const double deg2rad = pi / 180.0; // 0.0174532925199433 - const double xpdotp = 1440.0 / (2.0 *pi); // 229.1831180523293 - - double sec, mu, radiusearthkm, tumin, xke, j2, j3, j4, j3oj2; - int cardnumb, numb, j; - long revnum = 0, elnum = 0; - char classification, intldesg[11]; - int year = 0; - int mon, day, hr, minute, nexp, ibexp; - - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - - satrec.error = 0; - - // set the implied decimal points since doing a formated read - // fixes for bad input data values (missing, ...) - for (j = 10; j <= 15; j++) - if (longstr1[j] == ' ') - longstr1[j] = '_'; - - if (longstr1[44] != ' ') - longstr1[43] = longstr1[44]; - longstr1[44] = '.'; - if (longstr1[7] == ' ') - longstr1[7] = 'U'; - if (longstr1[9] == ' ') - longstr1[9] = '.'; - for (j = 45; j <= 49; j++) - if (longstr1[j] == ' ') - longstr1[j] = '0'; - if (longstr1[51] == ' ') - longstr1[51] = '0'; - if (longstr1[53] != ' ') - longstr1[52] = longstr1[53]; - longstr1[53] = '.'; - longstr2[25] = '.'; - for (j = 26; j <= 32; j++) - if (longstr2[j] == ' ') - longstr2[j] = '0'; - if (longstr1[62] == ' ') - longstr1[62] = '0'; - if (longstr1[68] == ' ') - longstr1[68] = '0'; - - sscanf(longstr1,"%2d %5ld %1c %10s %2d %12lf %11lf %7lf %2d %7lf %2d %2d %6ld ", - &cardnumb,&satrec.satnum,&classification, intldesg, &satrec.epochyr, - &satrec.epochdays,&satrec.ndot, &satrec.nddot, &nexp, &satrec.bstar, - &ibexp, &numb, &elnum ); - - if (typerun == 'v') // run for specified times from the file - { - if (longstr2[52] == ' ') - sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld %lf %lf %lf \n", - &cardnumb,&satrec.satnum, &satrec.inclo, - &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, - &revnum, &startmfe, &stopmfe, &deltamin ); - else - sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld %lf %lf %lf \n", - &cardnumb,&satrec.satnum, &satrec.inclo, - &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, - &revnum, &startmfe, &stopmfe, &deltamin ); - } - else // simply run -1 day to +1 day or user input times - { - if (longstr2[52] == ' ') - sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld \n", - &cardnumb,&satrec.satnum, &satrec.inclo, - &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, - &revnum ); - else - sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld \n", - &cardnumb,&satrec.satnum, &satrec.inclo, - &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, - &revnum ); - } - - // ---- find no, ndot, nddot ---- - satrec.no = satrec.no / xpdotp; //* rad/min - satrec.nddot= satrec.nddot * pow(10.0, nexp); - satrec.bstar= satrec.bstar * pow(10.0, ibexp); - - // ---- convert to sgp4 units ---- - satrec.a = pow( satrec.no*tumin , (-2.0/3.0) ); - satrec.ndot = satrec.ndot / (xpdotp*1440.0); //* ? * minperday - satrec.nddot= satrec.nddot / (xpdotp*1440.0*1440); - - // ---- find standard orbital elements ---- - satrec.inclo = satrec.inclo * deg2rad; - satrec.nodeo = satrec.nodeo * deg2rad; - satrec.argpo = satrec.argpo * deg2rad; - satrec.mo = satrec.mo * deg2rad; - - satrec.alta = satrec.a*(1.0 + satrec.ecco) - 1.0; - satrec.altp = satrec.a*(1.0 - satrec.ecco) - 1.0; - - // ---------------------------------------------------------------- - // find sgp4epoch time of element set - // remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch) - // and minutes from the epoch (time) - // ---------------------------------------------------------------- - - // ---------------- temp fix for years from 1957-2056 ------------------- - // --------- correct fix will occur when year is 4-digit in tle --------- - if (satrec.epochyr < 57) - year= satrec.epochyr + 2000; - else - year= satrec.epochyr + 1900; - - days2mdhms ( year,satrec.epochdays, mon,day,hr,minute,sec ); - jday( year,mon,day,hr,minute,sec, satrec.jdsatepoch ); - - // ------------ perform complete catalog evaluation, -+ 1 day ----------- - if (typerun == 'c') - { - startmfe = -1440.0; - stopmfe = 1440.0; - deltamin = 10.0; - } - - // ---------------- initialize the orbit at sgp4epoch ------------------- - sgp4init( whichconst, opsmode, satrec.satnum, satrec.jdsatepoch-2433281.5, satrec.bstar, - satrec.ecco, satrec.argpo, satrec.inclo, satrec.mo, satrec.no, - satrec.nodeo, satrec); - } // end twoline2rv - - +/* ---------------------------------------------------------------- +* +* sgp4io.cpp +* +* this file contains a function to read two line element sets. while +* not formerly part of the sgp4 mathematical theory, it is +* required for practical implemenation. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* Note: Deleted code related with command line inputs. That implementation +* is not a god way to build a library. It's better to aisle logic and interface. +* J.L. Canales 20/11/2010 +* +* current : +* 3 sep 08 david vallado +* add operationmode for afspc (a) or improved (i) +* changes : +* 9 may 07 david vallado +* fix year correction to 57 +* 27 mar 07 david vallado +* misc fixes to manual inputs +* 14 aug 06 david vallado +* original baseline +* ---------------------------------------------------------------- */ + +#include "sgp4io.h" + +/* ----------------------------------------------------------------------------- +* +* function twoline2rv +* +* this function converts the two line element set character string data to +* variables and initializes the sgp4 variables. several intermediate varaibles +* and quantities are determined. note that the result is a structure so multiple +* satellites can be processed simultaneously without having to reinitialize. the +* verification mode is an important option that permits quick checks of any +* changes to the underlying technical theory. this option works using a +* modified tle file in which the start, stop, and delta time values are +* included at the end of the second line of data. this only works with the +* verification mode. the catalog mode simply propagates from -1440 to 1440 min +* from epoch and is useful when performing entire catalog runs. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs : +* longstr1 - first line of the tle +* longstr2 - second line of the tle +* typerun - type of run verification 'v', catalog 'c', +* manual 'm' +* typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd' +* opsmode - mode of operation afspc or improved 'a', 'i' +* whichconst - which set of constants to use 72, 84 +* +* outputs : +* satrec - structure containing all the sgp4 satellite information +* +* coupling : +* getgravconst- +* days2mdhms - conversion of days to month, day, hour, minute, second +* jday - convert day month year hour minute second into julian date +* sgp4init - initialize the sgp4 variables +* +* references : +* norad spacetrack report #3 +* vallado, crawford, hujsak, kelso 2006 + --------------------------------------------------------------------------- */ + +void twoline2rv + ( + char longstr1[130], char longstr2[130], + char typerun, char typeinput, char opsmode, + gravconsttype whichconst, + double& startmfe, double& stopmfe, double& deltamin, + elsetrec& satrec + ) + { + const double deg2rad = pi / 180.0; // 0.0174532925199433 + const double xpdotp = 1440.0 / (2.0 *pi); // 229.1831180523293 + + double sec, mu, radiusearthkm, tumin, xke, j2, j3, j4, j3oj2; + int cardnumb, numb, j; + long revnum = 0, elnum = 0; + char classification, intldesg[11]; + int year = 0; + int mon, day, hr, minute, nexp, ibexp; + + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + + satrec.error = 0; + + // set the implied decimal points since doing a formated read + // fixes for bad input data values (missing, ...) + for (j = 10; j <= 15; j++) + if (longstr1[j] == ' ') + longstr1[j] = '_'; + + if (longstr1[44] != ' ') + longstr1[43] = longstr1[44]; + longstr1[44] = '.'; + if (longstr1[7] == ' ') + longstr1[7] = 'U'; + if (longstr1[9] == ' ') + longstr1[9] = '.'; + for (j = 45; j <= 49; j++) + if (longstr1[j] == ' ') + longstr1[j] = '0'; + if (longstr1[51] == ' ') + longstr1[51] = '0'; + if (longstr1[53] != ' ') + longstr1[52] = longstr1[53]; + longstr1[53] = '.'; + longstr2[25] = '.'; + for (j = 26; j <= 32; j++) + if (longstr2[j] == ' ') + longstr2[j] = '0'; + if (longstr1[62] == ' ') + longstr1[62] = '0'; + if (longstr1[68] == ' ') + longstr1[68] = '0'; + + sscanf(longstr1,"%2d %5ld %1c %10s %2d %12lf %11lf %7lf %2d %7lf %2d %2d %6ld ", + &cardnumb,&satrec.satnum,&classification, intldesg, &satrec.epochyr, + &satrec.epochdays,&satrec.ndot, &satrec.nddot, &nexp, &satrec.bstar, + &ibexp, &numb, &elnum ); + + if (typerun == 'v') // run for specified times from the file + { + if (longstr2[52] == ' ') + sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld %lf %lf %lf \n", + &cardnumb,&satrec.satnum, &satrec.inclo, + &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, + &revnum, &startmfe, &stopmfe, &deltamin ); + else + sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld %lf %lf %lf \n", + &cardnumb,&satrec.satnum, &satrec.inclo, + &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, + &revnum, &startmfe, &stopmfe, &deltamin ); + } + else // simply run -1 day to +1 day or user input times + { + if (longstr2[52] == ' ') + sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %10lf %6ld \n", + &cardnumb,&satrec.satnum, &satrec.inclo, + &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, + &revnum ); + else + sscanf(longstr2,"%2d %5ld %9lf %9lf %8lf %9lf %9lf %11lf %6ld \n", + &cardnumb,&satrec.satnum, &satrec.inclo, + &satrec.nodeo,&satrec.ecco, &satrec.argpo, &satrec.mo, &satrec.no, + &revnum ); + } + + // ---- find no, ndot, nddot ---- + satrec.no = satrec.no / xpdotp; //* rad/min + satrec.nddot= satrec.nddot * pow(10.0, nexp); + satrec.bstar= satrec.bstar * pow(10.0, ibexp); + + // ---- convert to sgp4 units ---- + satrec.a = pow( satrec.no*tumin , (-2.0/3.0) ); + satrec.ndot = satrec.ndot / (xpdotp*1440.0); //* ? * minperday + satrec.nddot= satrec.nddot / (xpdotp*1440.0*1440); + + // ---- find standard orbital elements ---- + satrec.inclo = satrec.inclo * deg2rad; + satrec.nodeo = satrec.nodeo * deg2rad; + satrec.argpo = satrec.argpo * deg2rad; + satrec.mo = satrec.mo * deg2rad; + + satrec.alta = satrec.a*(1.0 + satrec.ecco) - 1.0; + satrec.altp = satrec.a*(1.0 - satrec.ecco) - 1.0; + + // ---------------------------------------------------------------- + // find sgp4epoch time of element set + // remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch) + // and minutes from the epoch (time) + // ---------------------------------------------------------------- + + // ---------------- temp fix for years from 1957-2056 ------------------- + // --------- correct fix will occur when year is 4-digit in tle --------- + if (satrec.epochyr < 57) + year= satrec.epochyr + 2000; + else + year= satrec.epochyr + 1900; + + days2mdhms ( year,satrec.epochdays, mon,day,hr,minute,sec ); + jday( year,mon,day,hr,minute,sec, satrec.jdsatepoch ); + + // ------------ perform complete catalog evaluation, -+ 1 day ----------- + if (typerun == 'c') + { + startmfe = -1440.0; + stopmfe = 1440.0; + deltamin = 10.0; + } + + // ---------------- initialize the orbit at sgp4epoch ------------------- + sgp4init( whichconst, opsmode, satrec.satnum, satrec.jdsatepoch-2433281.5, satrec.bstar, + satrec.ecco, satrec.argpo, satrec.inclo, satrec.mo, satrec.no, + satrec.nodeo, satrec); + } // end twoline2rv + + diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.h similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.h index 20fb599..613cce8 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.h +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4io.h @@ -1,46 +1,46 @@ -#ifndef _sgp4io_ -#define _sgp4io_ -/* ---------------------------------------------------------------- -* -* sgp4io.h; -* -* this file contains a function to read two line element sets. while -* not formerly part of the sgp4 mathematical theory, it is -* required for practical implemenation. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 3 sep 07 david vallado -* add operationmode for afspc (a) or improved (i) -* changes : -* 20 apr 07 david vallado -* misc updates for manual operation -* 14 aug 06 david vallado -* original baseline -* ---------------------------------------------------------------- */ - -#include -#include - -#include "sgp4ext.h" // for several misc routines -#include "sgp4unit.h" // for sgp4init and getgravconst - -// ------------------------- function declarations ------------------------- - -void twoline2rv - ( - char longstr1[130], char longstr2[130], - char typerun, char typeinput, char opsmode, - gravconsttype whichconst, - double& startmfe, double& stopmfe, double& deltamin, - elsetrec& satrec - ); - -#endif - +#ifndef _sgp4io_ +#define _sgp4io_ +/* ---------------------------------------------------------------- +* +* sgp4io.h; +* +* this file contains a function to read two line element sets. while +* not formerly part of the sgp4 mathematical theory, it is +* required for practical implemenation. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 3 sep 07 david vallado +* add operationmode for afspc (a) or improved (i) +* changes : +* 20 apr 07 david vallado +* misc updates for manual operation +* 14 aug 06 david vallado +* original baseline +* ---------------------------------------------------------------- */ + +#include +#include + +#include "sgp4ext.h" // for several misc routines +#include "sgp4unit.h" // for sgp4init and getgravconst + +// ------------------------- function declarations ------------------------- + +void twoline2rv + ( + char longstr1[130], char longstr2[130], + char typerun, char typeinput, char opsmode, + gravconsttype whichconst, + double& startmfe, double& stopmfe, double& deltamin, + elsetrec& satrec + ); + +#endif + diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.cpp similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.cpp index 86072d2..3ddec87 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.cpp +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.cpp @@ -1,2119 +1,2119 @@ -/* ---------------------------------------------------------------- -* -* sgp4unit.cpp -* -* this file contains the sgp4 procedures for analytical propagation -* of a satellite. the code was originally released in the 1980 and 1986 -* spacetrack papers. a detailed discussion of the theory and history -* may be found in the 2006 aiaa paper by vallado, crawford, hujsak, -* and kelso. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 3 Nov 08 david vallado -* put returns in for error codes -* changes : -* 29 sep 08 david vallado -* fix atime for faster operation in dspace -* add operationmode for afspc (a) or improved (i) -* performance mode -* 16 jun 08 david vallado -* update small eccentricity check -* 16 nov 07 david vallado -* misc fixes for better compliance -* 20 apr 07 david vallado -* misc fixes for constants -* 11 aug 06 david vallado -* chg lyddane choice back to strn3, constants, misc doc -* 15 dec 05 david vallado -* misc fixes -* 26 jul 05 david vallado -* fixes for paper -* note that each fix is preceded by a -* comment with "sgp4fix" and an explanation of -* what was changed -* 10 aug 04 david vallado -* 2nd printing baseline working -* 14 may 01 david vallado -* 2nd edition baseline -* 80 norad -* original baseline -* ---------------------------------------------------------------- */ - -#include "sgp4unit.h" - -const char help = 'n'; -FILE *dbgfile; - - -/* ----------- local functions - only ever used internally by sgp4 ---------- */ -static void dpper - ( - double e3, double ee2, double peo, double pgho, double pho, - double pinco, double plo, double se2, double se3, double sgh2, - double sgh3, double sgh4, double sh2, double sh3, double si2, - double si3, double sl2, double sl3, double sl4, double t, - double xgh2, double xgh3, double xgh4, double xh2, double xh3, - double xi2, double xi3, double xl2, double xl3, double xl4, - double zmol, double zmos, double inclo, - char init, - double& ep, double& inclp, double& nodep, double& argpp, double& mp, - char opsmode - ); - -static void dscom - ( - double epoch, double ep, double argpp, double tc, double inclp, - double nodep, double np, - double& snodm, double& cnodm, double& sinim, double& cosim, double& sinomm, - double& cosomm,double& day, double& e3, double& ee2, double& em, - double& emsq, double& gam, double& peo, double& pgho, double& pho, - double& pinco, double& plo, double& rtemsq, double& se2, double& se3, - double& sgh2, double& sgh3, double& sgh4, double& sh2, double& sh3, - double& si2, double& si3, double& sl2, double& sl3, double& sl4, - double& s1, double& s2, double& s3, double& s4, double& s5, - double& s6, double& s7, double& ss1, double& ss2, double& ss3, - double& ss4, double& ss5, double& ss6, double& ss7, double& sz1, - double& sz2, double& sz3, double& sz11, double& sz12, double& sz13, - double& sz21, double& sz22, double& sz23, double& sz31, double& sz32, - double& sz33, double& xgh2, double& xgh3, double& xgh4, double& xh2, - double& xh3, double& xi2, double& xi3, double& xl2, double& xl3, - double& xl4, double& nm, double& z1, double& z2, double& z3, - double& z11, double& z12, double& z13, double& z21, double& z22, - double& z23, double& z31, double& z32, double& z33, double& zmol, - double& zmos - ); - -static void dsinit - ( - gravconsttype whichconst, - double cosim, double emsq, double argpo, double s1, double s2, - double s3, double s4, double s5, double sinim, double ss1, - double ss2, double ss3, double ss4, double ss5, double sz1, - double sz3, double sz11, double sz13, double sz21, double sz23, - double sz31, double sz33, double t, double tc, double gsto, - double mo, double mdot, double no, double nodeo, double nodedot, - double xpidot, double z1, double z3, double z11, double z13, - double z21, double z23, double z31, double z33, double ecco, - double eccsq, double& em, double& argpm, double& inclm, double& mm, - double& nm, double& nodem, - int& irez, - double& atime, double& d2201, double& d2211, double& d3210, double& d3222, - double& d4410, double& d4422, double& d5220, double& d5232, double& d5421, - double& d5433, double& dedt, double& didt, double& dmdt, double& dndt, - double& dnodt, double& domdt, double& del1, double& del2, double& del3, - double& xfact, double& xlamo, double& xli, double& xni - ); - -static void dspace - ( - int irez, - double d2201, double d2211, double d3210, double d3222, double d4410, - double d4422, double d5220, double d5232, double d5421, double d5433, - double dedt, double del1, double del2, double del3, double didt, - double dmdt, double dnodt, double domdt, double argpo, double argpdot, - double t, double tc, double gsto, double xfact, double xlamo, - double no, - double& atime, double& em, double& argpm, double& inclm, double& xli, - double& mm, double& xni, double& nodem, double& dndt, double& nm - ); - -static void initl - ( - int satn, gravconsttype whichconst, - double ecco, double epoch, double inclo, double& no, - char& method, - double& ainv, double& ao, double& con41, double& con42, double& cosio, - double& cosio2,double& eccsq, double& omeosq, double& posq, - double& rp, double& rteosq,double& sinio , double& gsto, char opsmode - ); - -/* ----------------------------------------------------------------------------- -* -* procedure dpper -* -* this procedure provides deep space long period periodic contributions -* to the mean elements. by design, these periodics are zero at epoch. -* this used to be dscom which included initialization, but it's really a -* recurring function. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* e3 - -* ee2 - -* peo - -* pgho - -* pho - -* pinco - -* plo - -* se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 - -* t - -* xh2, xh3, xi2, xi3, xl2, xl3, xl4 - -* zmol - -* zmos - -* ep - eccentricity 0.0 - 1.0 -* inclo - inclination - needed for lyddane modification -* nodep - right ascension of ascending node -* argpp - argument of perigee -* mp - mean anomaly -* -* outputs : -* ep - eccentricity 0.0 - 1.0 -* inclp - inclination -* nodep - right ascension of ascending node -* argpp - argument of perigee -* mp - mean anomaly -* -* locals : -* alfdp - -* betdp - -* cosip , sinip , cosop , sinop , -* dalf - -* dbet - -* dls - -* f2, f3 - -* pe - -* pgh - -* ph - -* pinc - -* pl - -* sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis , -* sll , sls -* xls - -* xnoh - -* zf - -* zm - -* -* coupling : -* none. -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void dpper - ( - double e3, double ee2, double peo, double pgho, double pho, - double pinco, double plo, double se2, double se3, double sgh2, - double sgh3, double sgh4, double sh2, double sh3, double si2, - double si3, double sl2, double sl3, double sl4, double t, - double xgh2, double xgh3, double xgh4, double xh2, double xh3, - double xi2, double xi3, double xl2, double xl3, double xl4, - double zmol, double zmos, double inclo, - char init, - double& ep, double& inclp, double& nodep, double& argpp, double& mp, - char opsmode - ) -{ - /* --------------------- local variables ------------------------ */ - const double twopi = 2.0 * pi; - double alfdp, betdp, cosip, cosop, dalf, dbet, dls, - f2, f3, pe, pgh, ph, pinc, pl , - sel, ses, sghl, sghs, shll, shs, sil, - sinip, sinop, sinzf, sis, sll, sls, xls, - xnoh, zf, zm, zel, zes, znl, zns; - - /* kill warning */ - inclo = 0.; - - /* ---------------------- constants ----------------------------- */ - zns = 1.19459e-5; - zes = 0.01675; - znl = 1.5835218e-4; - zel = 0.05490; - - /* --------------- calculate time varying periodics ----------- */ - zm = zmos + zns * t; - // be sure that the initial call has time set to zero - if (init == 'y') - zm = zmos; - zf = zm + 2.0 * zes * sin(zm); - sinzf = sin(zf); - f2 = 0.5 * sinzf * sinzf - 0.25; - f3 = -0.5 * sinzf * cos(zf); - ses = se2* f2 + se3 * f3; - sis = si2 * f2 + si3 * f3; - sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf; - sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf; - shs = sh2 * f2 + sh3 * f3; - zm = zmol + znl * t; - if (init == 'y') - zm = zmol; - zf = zm + 2.0 * zel * sin(zm); - sinzf = sin(zf); - f2 = 0.5 * sinzf * sinzf - 0.25; - f3 = -0.5 * sinzf * cos(zf); - sel = ee2 * f2 + e3 * f3; - sil = xi2 * f2 + xi3 * f3; - sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf; - sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf; - shll = xh2 * f2 + xh3 * f3; - pe = ses + sel; - pinc = sis + sil; - pl = sls + sll; - pgh = sghs + sghl; - ph = shs + shll; - - if (init == 'n') - { - pe = pe - peo; - pinc = pinc - pinco; - pl = pl - plo; - pgh = pgh - pgho; - ph = ph - pho; - inclp = inclp + pinc; - ep = ep + pe; - sinip = sin(inclp); - cosip = cos(inclp); - - /* ----------------- apply periodics directly ------------ */ - // sgp4fix for lyddane choice - // strn3 used original inclination - this is technically feasible - // gsfc used perturbed inclination - also technically feasible - // probably best to readjust the 0.2 limit value and limit discontinuity - // 0.2 rad = 11.45916 deg - // use next line for original strn3 approach and original inclination - // if (inclo >= 0.2) - // use next line for gsfc version and perturbed inclination - if (inclp >= 0.2) - { - ph = ph / sinip; - pgh = pgh - cosip * ph; - argpp = argpp + pgh; - nodep = nodep + ph; - mp = mp + pl; - } - else - { - /* ---- apply periodics with lyddane modification ---- */ - sinop = sin(nodep); - cosop = cos(nodep); - alfdp = sinip * sinop; - betdp = sinip * cosop; - dalf = ph * cosop + pinc * cosip * sinop; - dbet = -ph * sinop + pinc * cosip * cosop; - alfdp = alfdp + dalf; - betdp = betdp + dbet; - nodep = fmod(nodep, twopi); - // sgp4fix for afspc written intrinsic functions - // nodep used without a trigonometric function ahead - if ((nodep < 0.0) && (opsmode == 'a')) - nodep = nodep + twopi; - xls = mp + argpp + cosip * nodep; - dls = pl + pgh - pinc * nodep * sinip; - xls = xls + dls; - xnoh = nodep; - nodep = atan2(alfdp, betdp); - // sgp4fix for afspc written intrinsic functions - // nodep used without a trigonometric function ahead - if ((nodep < 0.0) && (opsmode == 'a')) - nodep = nodep + twopi; - if (fabs(xnoh - nodep) > pi){ - if (nodep < xnoh) - nodep = nodep + twopi; - else - nodep = nodep - twopi; - } - mp = mp + pl; - argpp = xls - mp - cosip * nodep; - } - } // if init == 'n' - -//#include "debug1.cpp" -} // end dpper - -/*----------------------------------------------------------------------------- -* -* procedure dscom -* -* this procedure provides deep space common items used by both the secular -* and periodics subroutines. input is provided as shown. this routine -* used to be called dpper, but the functions inside weren't well organized. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* epoch - -* ep - eccentricity -* argpp - argument of perigee -* tc - -* inclp - inclination -* nodep - right ascension of ascending node -* np - mean motion -* -* outputs : -* sinim , cosim , sinomm , cosomm , snodm , cnodm -* day - -* e3 - -* ee2 - -* em - eccentricity -* emsq - eccentricity squared -* gam - -* peo - -* pgho - -* pho - -* pinco - -* plo - -* rtemsq - -* se2, se3 - -* sgh2, sgh3, sgh4 - -* sh2, sh3, si2, si3, sl2, sl3, sl4 - -* s1, s2, s3, s4, s5, s6, s7 - -* ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 - -* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 - -* xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 - -* nm - mean motion -* z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 - -* zmol - -* zmos - -* -* locals : -* a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 - -* betasq - -* cc - -* ctem, stem - -* x1, x2, x3, x4, x5, x6, x7, x8 - -* xnodce - -* xnoi - -* zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl , -* zcosi , zsini , zcosil , zsinil , -* zx - -* zy - -* -* coupling : -* none. -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void dscom - ( - double epoch, double ep, double argpp, double tc, double inclp, - double nodep, double np, - double& snodm, double& cnodm, double& sinim, double& cosim, double& sinomm, - double& cosomm,double& day, double& e3, double& ee2, double& em, - double& emsq, double& gam, double& peo, double& pgho, double& pho, - double& pinco, double& plo, double& rtemsq, double& se2, double& se3, - double& sgh2, double& sgh3, double& sgh4, double& sh2, double& sh3, - double& si2, double& si3, double& sl2, double& sl3, double& sl4, - double& s1, double& s2, double& s3, double& s4, double& s5, - double& s6, double& s7, double& ss1, double& ss2, double& ss3, - double& ss4, double& ss5, double& ss6, double& ss7, double& sz1, - double& sz2, double& sz3, double& sz11, double& sz12, double& sz13, - double& sz21, double& sz22, double& sz23, double& sz31, double& sz32, - double& sz33, double& xgh2, double& xgh3, double& xgh4, double& xh2, - double& xh3, double& xi2, double& xi3, double& xl2, double& xl3, - double& xl4, double& nm, double& z1, double& z2, double& z3, - double& z11, double& z12, double& z13, double& z21, double& z22, - double& z23, double& z31, double& z32, double& z33, double& zmol, - double& zmos - ) -{ - /* -------------------------- constants ------------------------- */ - const double zes = 0.01675; - const double zel = 0.05490; - const double c1ss = 2.9864797e-6; - const double c1l = 4.7968065e-7; - const double zsinis = 0.39785416; - const double zcosis = 0.91744867; - const double zcosgs = 0.1945905; - const double zsings = -0.98088458; - const double twopi = 2.0 * pi; - - /* --------------------- local variables ------------------------ */ - int lsflg; - double a1 , a2 , a3 , a4 , a5 , a6 , a7 , - a8 , a9 , a10 , betasq, cc , ctem , stem , - x1 , x2 , x3 , x4 , x5 , x6 , x7 , - x8 , xnodce, xnoi , zcosg , zcosgl, zcosh , zcoshl, - zcosi , zcosil, zsing , zsingl, zsinh , zsinhl, zsini , - zsinil, zx , zy; - - nm = np; - em = ep; - snodm = sin(nodep); - cnodm = cos(nodep); - sinomm = sin(argpp); - cosomm = cos(argpp); - sinim = sin(inclp); - cosim = cos(inclp); - emsq = em * em; - betasq = 1.0 - emsq; - rtemsq = sqrt(betasq); - - /* ----------------- initialize lunar solar terms --------------- */ - peo = 0.0; - pinco = 0.0; - plo = 0.0; - pgho = 0.0; - pho = 0.0; - day = epoch + 18261.5 + tc / 1440.0; - xnodce = fmod(4.5236020 - 9.2422029e-4 * day, twopi); - stem = sin(xnodce); - ctem = cos(xnodce); - zcosil = 0.91375164 - 0.03568096 * ctem; - zsinil = sqrt(1.0 - zcosil * zcosil); - zsinhl = 0.089683511 * stem / zsinil; - zcoshl = sqrt(1.0 - zsinhl * zsinhl); - gam = 5.8351514 + 0.0019443680 * day; - zx = 0.39785416 * stem / zsinil; - zy = zcoshl * ctem + 0.91744867 * zsinhl * stem; - zx = atan2(zx, zy); - zx = gam + zx - xnodce; - zcosgl = cos(zx); - zsingl = sin(zx); - - /* ------------------------- do solar terms --------------------- */ - zcosg = zcosgs; - zsing = zsings; - zcosi = zcosis; - zsini = zsinis; - zcosh = cnodm; - zsinh = snodm; - cc = c1ss; - xnoi = 1.0 / nm; - - for (lsflg = 1; lsflg <= 2; lsflg++) - { - a1 = zcosg * zcosh + zsing * zcosi * zsinh; - a3 = -zsing * zcosh + zcosg * zcosi * zsinh; - a7 = -zcosg * zsinh + zsing * zcosi * zcosh; - a8 = zsing * zsini; - a9 = zsing * zsinh + zcosg * zcosi * zcosh; - a10 = zcosg * zsini; - a2 = cosim * a7 + sinim * a8; - a4 = cosim * a9 + sinim * a10; - a5 = -sinim * a7 + cosim * a8; - a6 = -sinim * a9 + cosim * a10; - - x1 = a1 * cosomm + a2 * sinomm; - x2 = a3 * cosomm + a4 * sinomm; - x3 = -a1 * sinomm + a2 * cosomm; - x4 = -a3 * sinomm + a4 * cosomm; - x5 = a5 * sinomm; - x6 = a6 * sinomm; - x7 = a5 * cosomm; - x8 = a6 * cosomm; - - z31 = 12.0 * x1 * x1 - 3.0 * x3 * x3; - z32 = 24.0 * x1 * x2 - 6.0 * x3 * x4; - z33 = 12.0 * x2 * x2 - 3.0 * x4 * x4; - z1 = 3.0 * (a1 * a1 + a2 * a2) + z31 * emsq; - z2 = 6.0 * (a1 * a3 + a2 * a4) + z32 * emsq; - z3 = 3.0 * (a3 * a3 + a4 * a4) + z33 * emsq; - z11 = -6.0 * a1 * a5 + emsq * (-24.0 * x1 * x7-6.0 * x3 * x5); - z12 = -6.0 * (a1 * a6 + a3 * a5) + emsq * - (-24.0 * (x2 * x7 + x1 * x8) - 6.0 * (x3 * x6 + x4 * x5)); - z13 = -6.0 * a3 * a6 + emsq * (-24.0 * x2 * x8 - 6.0 * x4 * x6); - z21 = 6.0 * a2 * a5 + emsq * (24.0 * x1 * x5 - 6.0 * x3 * x7); - z22 = 6.0 * (a4 * a5 + a2 * a6) + emsq * - (24.0 * (x2 * x5 + x1 * x6) - 6.0 * (x4 * x7 + x3 * x8)); - z23 = 6.0 * a4 * a6 + emsq * (24.0 * x2 * x6 - 6.0 * x4 * x8); - z1 = z1 + z1 + betasq * z31; - z2 = z2 + z2 + betasq * z32; - z3 = z3 + z3 + betasq * z33; - s3 = cc * xnoi; - s2 = -0.5 * s3 / rtemsq; - s4 = s3 * rtemsq; - s1 = -15.0 * em * s4; - s5 = x1 * x3 + x2 * x4; - s6 = x2 * x3 + x1 * x4; - s7 = x2 * x4 - x1 * x3; - - /* ----------------------- do lunar terms ------------------- */ - if (lsflg == 1) - { - ss1 = s1; - ss2 = s2; - ss3 = s3; - ss4 = s4; - ss5 = s5; - ss6 = s6; - ss7 = s7; - sz1 = z1; - sz2 = z2; - sz3 = z3; - sz11 = z11; - sz12 = z12; - sz13 = z13; - sz21 = z21; - sz22 = z22; - sz23 = z23; - sz31 = z31; - sz32 = z32; - sz33 = z33; - zcosg = zcosgl; - zsing = zsingl; - zcosi = zcosil; - zsini = zsinil; - zcosh = zcoshl * cnodm + zsinhl * snodm; - zsinh = snodm * zcoshl - cnodm * zsinhl; - cc = c1l; - } - } - - zmol = fmod(4.7199672 + 0.22997150 * day - gam, twopi); - zmos = fmod(6.2565837 + 0.017201977 * day, twopi); - - /* ------------------------ do solar terms ---------------------- */ - se2 = 2.0 * ss1 * ss6; - se3 = 2.0 * ss1 * ss7; - si2 = 2.0 * ss2 * sz12; - si3 = 2.0 * ss2 * (sz13 - sz11); - sl2 = -2.0 * ss3 * sz2; - sl3 = -2.0 * ss3 * (sz3 - sz1); - sl4 = -2.0 * ss3 * (-21.0 - 9.0 * emsq) * zes; - sgh2 = 2.0 * ss4 * sz32; - sgh3 = 2.0 * ss4 * (sz33 - sz31); - sgh4 = -18.0 * ss4 * zes; - sh2 = -2.0 * ss2 * sz22; - sh3 = -2.0 * ss2 * (sz23 - sz21); - - /* ------------------------ do lunar terms ---------------------- */ - ee2 = 2.0 * s1 * s6; - e3 = 2.0 * s1 * s7; - xi2 = 2.0 * s2 * z12; - xi3 = 2.0 * s2 * (z13 - z11); - xl2 = -2.0 * s3 * z2; - xl3 = -2.0 * s3 * (z3 - z1); - xl4 = -2.0 * s3 * (-21.0 - 9.0 * emsq) * zel; - xgh2 = 2.0 * s4 * z32; - xgh3 = 2.0 * s4 * (z33 - z31); - xgh4 = -18.0 * s4 * zel; - xh2 = -2.0 * s2 * z22; - xh3 = -2.0 * s2 * (z23 - z21); - -//#include "debug2.cpp" -} // end dscom - -/*----------------------------------------------------------------------------- -* -* procedure dsinit -* -* this procedure provides deep space contributions to mean motion dot due -* to geopotential resonance with half day and one day orbits. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* cosim, sinim- -* emsq - eccentricity squared -* argpo - argument of perigee -* s1, s2, s3, s4, s5 - -* ss1, ss2, ss3, ss4, ss5 - -* sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 - -* t - time -* tc - -* gsto - greenwich sidereal time rad -* mo - mean anomaly -* mdot - mean anomaly dot (rate) -* no - mean motion -* nodeo - right ascension of ascending node -* nodedot - right ascension of ascending node dot (rate) -* xpidot - -* z1, z3, z11, z13, z21, z23, z31, z33 - -* eccm - eccentricity -* argpm - argument of perigee -* inclm - inclination -* mm - mean anomaly -* xn - mean motion -* nodem - right ascension of ascending node -* -* outputs : -* em - eccentricity -* argpm - argument of perigee -* inclm - inclination -* mm - mean anomaly -* nm - mean motion -* nodem - right ascension of ascending node -* irez - flag for resonance 0-none, 1-one day, 2-half day -* atime - -* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 - -* dedt - -* didt - -* dmdt - -* dndt - -* dnodt - -* domdt - -* del1, del2, del3 - -* ses , sghl , sghs , sgs , shl , shs , sis , sls -* theta - -* xfact - -* xlamo - -* xli - -* xni -* -* locals : -* ainv2 - -* aonv - -* cosisq - -* eoc - -* f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 - -* g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 - -* sini2 - -* temp - -* temp1 - -* theta - -* xno2 - -* -* coupling : -* getgravconst -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void dsinit - ( - gravconsttype whichconst, - double cosim, double emsq, double argpo, double s1, double s2, - double s3, double s4, double s5, double sinim, double ss1, - double ss2, double ss3, double ss4, double ss5, double sz1, - double sz3, double sz11, double sz13, double sz21, double sz23, - double sz31, double sz33, double t, double tc, double gsto, - double mo, double mdot, double no, double nodeo, double nodedot, - double xpidot, double z1, double z3, double z11, double z13, - double z21, double z23, double z31, double z33, double ecco, - double eccsq, double& em, double& argpm, double& inclm, double& mm, - double& nm, double& nodem, - int& irez, - double& atime, double& d2201, double& d2211, double& d3210, double& d3222, - double& d4410, double& d4422, double& d5220, double& d5232, double& d5421, - double& d5433, double& dedt, double& didt, double& dmdt, double& dndt, - double& dnodt, double& domdt, double& del1, double& del2, double& del3, - double& xfact, double& xlamo, double& xli, double& xni - ) -{ - /* --------------------- local variables ------------------------ */ - const double twopi = 2.0 * pi; - - double ainv2 , aonv=0.0, cosisq, eoc, f220 , f221 , f311 , - f321 , f322 , f330 , f441 , f442 , f522 , f523 , - f542 , f543 , g200 , g201 , g211 , g300 , g310 , - g322 , g410 , g422 , g520 , g521 , g532 , g533 , - ses , sgs , sghl , sghs , shs , shll , sis , - sini2 , sls , temp , temp1 , theta , xno2 , q22 , - q31 , q33 , root22, root44, root54, rptim , root32, - root52, x2o3 , xke , znl , emo , zns , emsqo, - tumin, mu, radiusearthkm, j2, j3, j4, j3oj2; - - q22 = 1.7891679e-6; - q31 = 2.1460748e-6; - q33 = 2.2123015e-7; - root22 = 1.7891679e-6; - root44 = 7.3636953e-9; - root54 = 2.1765803e-9; - rptim = 4.37526908801129966e-3; // this equates to 7.29211514668855e-5 rad/sec - root32 = 3.7393792e-7; - root52 = 1.1428639e-7; - x2o3 = 2.0 / 3.0; - znl = 1.5835218e-4; - zns = 1.19459e-5; - - // sgp4fix identify constants and allow alternate values - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - - /* -------------------- deep space initialization ------------ */ - irez = 0; - if ((nm < 0.0052359877) && (nm > 0.0034906585)) - irez = 1; - if ((nm >= 8.26e-3) && (nm <= 9.24e-3) && (em >= 0.5)) - irez = 2; - - /* ------------------------ do solar terms ------------------- */ - ses = ss1 * zns * ss5; - sis = ss2 * zns * (sz11 + sz13); - sls = -zns * ss3 * (sz1 + sz3 - 14.0 - 6.0 * emsq); - sghs = ss4 * zns * (sz31 + sz33 - 6.0); - shs = -zns * ss2 * (sz21 + sz23); - // sgp4fix for 180 deg incl - if ((inclm < 5.2359877e-2) || (inclm > pi - 5.2359877e-2)) - shs = 0.0; - if (sinim != 0.0) - shs = shs / sinim; - sgs = sghs - cosim * shs; - - /* ------------------------- do lunar terms ------------------ */ - dedt = ses + s1 * znl * s5; - didt = sis + s2 * znl * (z11 + z13); - dmdt = sls - znl * s3 * (z1 + z3 - 14.0 - 6.0 * emsq); - sghl = s4 * znl * (z31 + z33 - 6.0); - shll = -znl * s2 * (z21 + z23); - // sgp4fix for 180 deg incl - if ((inclm < 5.2359877e-2) || (inclm > pi - 5.2359877e-2)) - shll = 0.0; - domdt = sgs + sghl; - dnodt = shs; - if (sinim != 0.0) - { - domdt = domdt - cosim / sinim * shll; - dnodt = dnodt + shll / sinim; - } - - /* ----------- calculate deep space resonance effects -------- */ - dndt = 0.0; - theta = fmod(gsto + tc * rptim, twopi); - em = em + dedt * t; - inclm = inclm + didt * t; - argpm = argpm + domdt * t; - nodem = nodem + dnodt * t; - mm = mm + dmdt * t; - // sgp4fix for negative inclinations - // the following if statement should be commented out - //if (inclm < 0.0) - // { - // inclm = -inclm; - // argpm = argpm - pi; - // nodem = nodem + pi; - // } - - /* -------------- initialize the resonance terms ------------- */ - if (irez != 0) - { - aonv = pow(nm / xke, x2o3); - - /* ---------- geopotential resonance for 12 hour orbits ------ */ - if (irez == 2) - { - cosisq = cosim * cosim; - emo = em; - em = ecco; - emsqo = emsq; - emsq = eccsq; - eoc = em * emsq; - g201 = -0.306 - (em - 0.64) * 0.440; - - if (em <= 0.65) - { - g211 = 3.616 - 13.2470 * em + 16.2900 * emsq; - g310 = -19.302 + 117.3900 * em - 228.4190 * emsq + 156.5910 * eoc; - g322 = -18.9068 + 109.7927 * em - 214.6334 * emsq + 146.5816 * eoc; - g410 = -41.122 + 242.6940 * em - 471.0940 * emsq + 313.9530 * eoc; - g422 = -146.407 + 841.8800 * em - 1629.014 * emsq + 1083.4350 * eoc; - g520 = -532.114 + 3017.977 * em - 5740.032 * emsq + 3708.2760 * eoc; - } - else - { - g211 = -72.099 + 331.819 * em - 508.738 * emsq + 266.724 * eoc; - g310 = -346.844 + 1582.851 * em - 2415.925 * emsq + 1246.113 * eoc; - g322 = -342.585 + 1554.908 * em - 2366.899 * emsq + 1215.972 * eoc; - g410 = -1052.797 + 4758.686 * em - 7193.992 * emsq + 3651.957 * eoc; - g422 = -3581.690 + 16178.110 * em - 24462.770 * emsq + 12422.520 * eoc; - if (em > 0.715) - g520 =-5149.66 + 29936.92 * em - 54087.36 * emsq + 31324.56 * eoc; - else - g520 = 1464.74 - 4664.75 * em + 3763.64 * emsq; - } - if (em < 0.7) - { - g533 = -919.22770 + 4988.6100 * em - 9064.7700 * emsq + 5542.21 * eoc; - g521 = -822.71072 + 4568.6173 * em - 8491.4146 * emsq + 5337.524 * eoc; - g532 = -853.66600 + 4690.2500 * em - 8624.7700 * emsq + 5341.4 * eoc; - } - else - { - g533 =-37995.780 + 161616.52 * em - 229838.20 * emsq + 109377.94 * eoc; - g521 =-51752.104 + 218913.95 * em - 309468.16 * emsq + 146349.42 * eoc; - g532 =-40023.880 + 170470.89 * em - 242699.48 * emsq + 115605.82 * eoc; - } - - sini2= sinim * sinim; - f220 = 0.75 * (1.0 + 2.0 * cosim+cosisq); - f221 = 1.5 * sini2; - f321 = 1.875 * sinim * (1.0 - 2.0 * cosim - 3.0 * cosisq); - f322 = -1.875 * sinim * (1.0 + 2.0 * cosim - 3.0 * cosisq); - f441 = 35.0 * sini2 * f220; - f442 = 39.3750 * sini2 * sini2; - f522 = 9.84375 * sinim * (sini2 * (1.0 - 2.0 * cosim- 5.0 * cosisq) + - 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq) ); - f523 = sinim * (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + - 10.0 * cosisq) + 6.56250012 * (1.0+2.0 * cosim - 3.0 * cosisq)); - f542 = 29.53125 * sinim * (2.0 - 8.0 * cosim+cosisq * - (-12.0 + 8.0 * cosim + 10.0 * cosisq)); - f543 = 29.53125 * sinim * (-2.0 - 8.0 * cosim+cosisq * - (12.0 + 8.0 * cosim - 10.0 * cosisq)); - xno2 = nm * nm; - ainv2 = aonv * aonv; - temp1 = 3.0 * xno2 * ainv2; - temp = temp1 * root22; - d2201 = temp * f220 * g201; - d2211 = temp * f221 * g211; - temp1 = temp1 * aonv; - temp = temp1 * root32; - d3210 = temp * f321 * g310; - d3222 = temp * f322 * g322; - temp1 = temp1 * aonv; - temp = 2.0 * temp1 * root44; - d4410 = temp * f441 * g410; - d4422 = temp * f442 * g422; - temp1 = temp1 * aonv; - temp = temp1 * root52; - d5220 = temp * f522 * g520; - d5232 = temp * f523 * g532; - temp = 2.0 * temp1 * root54; - d5421 = temp * f542 * g521; - d5433 = temp * f543 * g533; - xlamo = fmod(mo + nodeo + nodeo-theta - theta, twopi); - xfact = mdot + dmdt + 2.0 * (nodedot + dnodt - rptim) - no; - em = emo; - emsq = emsqo; - } - - /* ---------------- synchronous resonance terms -------------- */ - if (irez == 1) - { - g200 = 1.0 + emsq * (-2.5 + 0.8125 * emsq); - g310 = 1.0 + 2.0 * emsq; - g300 = 1.0 + emsq * (-6.0 + 6.60937 * emsq); - f220 = 0.75 * (1.0 + cosim) * (1.0 + cosim); - f311 = 0.9375 * sinim * sinim * (1.0 + 3.0 * cosim) - 0.75 * (1.0 + cosim); - f330 = 1.0 + cosim; - f330 = 1.875 * f330 * f330 * f330; - del1 = 3.0 * nm * nm * aonv * aonv; - del2 = 2.0 * del1 * f220 * g200 * q22; - del3 = 3.0 * del1 * f330 * g300 * q33 * aonv; - del1 = del1 * f311 * g310 * q31 * aonv; - xlamo = fmod(mo + nodeo + argpo - theta, twopi); - xfact = mdot + xpidot - rptim + dmdt + domdt + dnodt - no; - } - - /* ------------ for sgp4, initialize the integrator ---------- */ - xli = xlamo; - xni = no; - atime = 0.0; - nm = no + dndt; - } - -//#include "debug3.cpp" -} // end dsinit - -/*----------------------------------------------------------------------------- -* -* procedure dspace -* -* this procedure provides deep space contributions to mean elements for -* perturbing third body. these effects have been averaged over one -* revolution of the sun and moon. for earth resonance effects, the -* effects have been averaged over no revolutions of the satellite. -* (mean motion) -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 - -* dedt - -* del1, del2, del3 - -* didt - -* dmdt - -* dnodt - -* domdt - -* irez - flag for resonance 0-none, 1-one day, 2-half day -* argpo - argument of perigee -* argpdot - argument of perigee dot (rate) -* t - time -* tc - -* gsto - gst -* xfact - -* xlamo - -* no - mean motion -* atime - -* em - eccentricity -* ft - -* argpm - argument of perigee -* inclm - inclination -* xli - -* mm - mean anomaly -* xni - mean motion -* nodem - right ascension of ascending node -* -* outputs : -* atime - -* em - eccentricity -* argpm - argument of perigee -* inclm - inclination -* xli - -* mm - mean anomaly -* xni - -* nodem - right ascension of ascending node -* dndt - -* nm - mean motion -* -* locals : -* delt - -* ft - -* theta - -* x2li - -* x2omi - -* xl - -* xldot - -* xnddt - -* xndt - -* xomi - -* -* coupling : -* none - -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void dspace - ( - int irez, - double d2201, double d2211, double d3210, double d3222, double d4410, - double d4422, double d5220, double d5232, double d5421, double d5433, - double dedt, double del1, double del2, double del3, double didt, - double dmdt, double dnodt, double domdt, double argpo, double argpdot, - double t, double tc, double gsto, double xfact, double xlamo, - double no, - double& atime, double& em, double& argpm, double& inclm, double& xli, - double& mm, double& xni, double& nodem, double& dndt, double& nm - ) -{ - const double twopi = 2.0 * pi; - int iretn , iret; - double delt, ft, theta, x2li, x2omi, xl, xldot , xnddt, xndt, xomi, g22, g32, - g44, g52, g54, fasx2, fasx4, fasx6, rptim , step2, stepn , stepp; - - fasx2 = 0.13130908; - fasx4 = 2.8843198; - fasx6 = 0.37448087; - g22 = 5.7686396; - g32 = 0.95240898; - g44 = 1.8014998; - g52 = 1.0508330; - g54 = 4.4108898; - rptim = 4.37526908801129966e-3; // this equates to 7.29211514668855e-5 rad/sec - stepp = 720.0; - stepn = -720.0; - step2 = 259200.0; - - /* ----------- calculate deep space resonance effects ----------- */ - dndt = 0.0; - theta = fmod(gsto + tc * rptim, twopi); - em = em + dedt * t; - - inclm = inclm + didt * t; - argpm = argpm + domdt * t; - nodem = nodem + dnodt * t; - mm = mm + dmdt * t; - - // sgp4fix for negative inclinations - // the following if statement should be commented out - // if (inclm < 0.0) - // { - // inclm = -inclm; - // argpm = argpm - pi; - // nodem = nodem + pi; - // } - - /* - update resonances : numerical (euler-maclaurin) integration - */ - /* ------------------------- epoch restart ---------------------- */ - // sgp4fix for propagator problems - // the following integration works for negative time steps and periods - // the specific changes are unknown because the original code was so convoluted - - // sgp4fix take out atime = 0.0 and fix for faster operation - ft = 0.0; - if (irez != 0) - { - // sgp4fix streamline check - if ((atime == 0.0) || (t * atime <= 0.0) || (fabs(t) < fabs(atime)) ) - { - atime = 0.0; - xni = no; - xli = xlamo; - } - // sgp4fix move check outside loop - if (t > 0.0) - delt = stepp; - else - delt = stepn; - - iretn = 381; // added for do loop - iret = 0; // added for loop - while (iretn == 381) - { - /* ------------------- dot terms calculated ------------- */ - /* ----------- near - synchronous resonance terms ------- */ - if (irez != 2) - { - xndt = del1 * sin(xli - fasx2) + del2 * sin(2.0 * (xli - fasx4)) + - del3 * sin(3.0 * (xli - fasx6)); - xldot = xni + xfact; - xnddt = del1 * cos(xli - fasx2) + - 2.0 * del2 * cos(2.0 * (xli - fasx4)) + - 3.0 * del3 * cos(3.0 * (xli - fasx6)); - xnddt = xnddt * xldot; - } - else - { - /* --------- near - half-day resonance terms -------- */ - xomi = argpo + argpdot * atime; - x2omi = xomi + xomi; - x2li = xli + xli; - xndt = d2201 * sin(x2omi + xli - g22) + d2211 * sin(xli - g22) + - d3210 * sin(xomi + xli - g32) + d3222 * sin(-xomi + xli - g32)+ - d4410 * sin(x2omi + x2li - g44)+ d4422 * sin(x2li - g44) + - d5220 * sin(xomi + xli - g52) + d5232 * sin(-xomi + xli - g52)+ - d5421 * sin(xomi + x2li - g54) + d5433 * sin(-xomi + x2li - g54); - xldot = xni + xfact; - xnddt = d2201 * cos(x2omi + xli - g22) + d2211 * cos(xli - g22) + - d3210 * cos(xomi + xli - g32) + d3222 * cos(-xomi + xli - g32) + - d5220 * cos(xomi + xli - g52) + d5232 * cos(-xomi + xli - g52) + - 2.0 * (d4410 * cos(x2omi + x2li - g44) + - d4422 * cos(x2li - g44) + d5421 * cos(xomi + x2li - g54) + - d5433 * cos(-xomi + x2li - g54)); - xnddt = xnddt * xldot; - } - - /* ----------------------- integrator ------------------- */ - // sgp4fix move end checks to end of routine - if (fabs(t - atime) >= stepp) - { - iret = 0; - iretn = 381; - } - else // exit here - { - ft = t - atime; - iretn = 0; - } - - if (iretn == 381) - { - xli = xli + xldot * delt + xndt * step2; - xni = xni + xndt * delt + xnddt * step2; - atime = atime + delt; - } - } // while iretn = 381 - - nm = xni + xndt * ft + xnddt * ft * ft * 0.5; - xl = xli + xldot * ft + xndt * ft * ft * 0.5; - if (irez != 1) - { - mm = xl - 2.0 * nodem + 2.0 * theta; - dndt = nm - no; - } - else - { - mm = xl - nodem - argpm + theta; - dndt = nm - no; - } - nm = no + dndt; - } - -//#include "debug4.cpp" -} // end dsspace - -/*----------------------------------------------------------------------------- -* -* procedure initl -* -* this procedure initializes the spg4 propagator. all the initialization is -* consolidated here instead of having multiple loops inside other routines. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* ecco - eccentricity 0.0 - 1.0 -* epoch - epoch time in days from jan 0, 1950. 0 hr -* inclo - inclination of satellite -* no - mean motion of satellite -* satn - satellite number -* -* outputs : -* ainv - 1.0 / a -* ao - semi major axis -* con41 - -* con42 - 1.0 - 5.0 cos(i) -* cosio - cosine of inclination -* cosio2 - cosio squared -* eccsq - eccentricity squared -* method - flag for deep space 'd', 'n' -* omeosq - 1.0 - ecco * ecco -* posq - semi-parameter squared -* rp - radius of perigee -* rteosq - square root of (1.0 - ecco*ecco) -* sinio - sine of inclination -* gsto - gst at time of observation rad -* no - mean motion of satellite -* -* locals : -* ak - -* d1 - -* del - -* adel - -* po - -* -* coupling : -* getgravconst -* gstime - find greenwich sidereal time from the julian date -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -static void initl - ( - int satn, gravconsttype whichconst, - double ecco, double epoch, double inclo, double& no, - char& method, - double& ainv, double& ao, double& con41, double& con42, double& cosio, - double& cosio2,double& eccsq, double& omeosq, double& posq, - double& rp, double& rteosq,double& sinio , double& gsto, - char opsmode - ) -{ - /* --------------------- local variables ------------------------ */ - double ak, d1, del, adel, po, x2o3, j2, xke, - tumin, mu, radiusearthkm, j3, j4, j3oj2; - - /* kill warning */ - satn = 0; - - // sgp4fix use old way of finding gst - double ds70; - double ts70, tfrac, c1, thgr70, fk5r, c1p2p; - const double twopi = 2.0 * pi; - - /* ----------------------- earth constants ---------------------- */ - // sgp4fix identify constants and allow alternate values - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - x2o3 = 2.0 / 3.0; - - /* ------------- calculate auxillary epoch quantities ---------- */ - eccsq = ecco * ecco; - omeosq = 1.0 - eccsq; - rteosq = sqrt(omeosq); - cosio = cos(inclo); - cosio2 = cosio * cosio; - - /* ------------------ un-kozai the mean motion ----------------- */ - ak = pow(xke / no, x2o3); - d1 = 0.75 * j2 * (3.0 * cosio2 - 1.0) / (rteosq * omeosq); - del = d1 / (ak * ak); - adel = ak * (1.0 - del * del - del * - (1.0 / 3.0 + 134.0 * del * del / 81.0)); - del = d1/(adel * adel); - no = no / (1.0 + del); - - ao = pow(xke / no, x2o3); - sinio = sin(inclo); - po = ao * omeosq; - con42 = 1.0 - 5.0 * cosio2; - con41 = -con42-cosio2-cosio2; - ainv = 1.0 / ao; - posq = po * po; - rp = ao * (1.0 - ecco); - method = 'n'; - - // sgp4fix modern approach to finding sidereal time - if (opsmode == 'a') - { - // sgp4fix use old way of finding gst - // count integer number of days from 0 jan 1970 - ts70 = epoch - 7305.0; - ds70 = floor(ts70 + 1.0e-8); - tfrac = ts70 - ds70; - // find greenwich location at epoch - c1 = 1.72027916940703639e-2; - thgr70= 1.7321343856509374; - fk5r = 5.07551419432269442e-15; - c1p2p = c1 + twopi; - gsto = fmod( thgr70 + c1*ds70 + c1p2p*tfrac + ts70*ts70*fk5r, twopi); - if ( gsto < 0.0 ) - gsto = gsto + twopi; - } - else - gsto = gstime(epoch + 2433281.5); - - -//#include "debug5.cpp" -} // end initl - -/*----------------------------------------------------------------------------- -* -* procedure sgp4init -* -* this procedure initializes variables for sgp4. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* opsmode - mode of operation afspc or improved 'a', 'i' -* whichconst - which set of constants to use 72, 84 -* satn - satellite number -* bstar - sgp4 type drag coefficient kg/m2er -* ecco - eccentricity -* epoch - epoch time in days from jan 0, 1950. 0 hr -* argpo - argument of perigee (output if ds) -* inclo - inclination -* mo - mean anomaly (output if ds) -* no - mean motion -* nodeo - right ascension of ascending node -* -* outputs : -* satrec - common values for subsequent calls -* return code - non-zero on error. -* 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er -* 2 - mean motion less than 0.0 -* 3 - pert elements, ecc < 0.0 or ecc > 1.0 -* 4 - semi-latus rectum < 0.0 -* 5 - epoch elements are sub-orbital -* 6 - satellite has decayed -* -* locals : -* cnodm , snodm , cosim , sinim , cosomm , sinomm -* cc1sq , cc2 , cc3 -* coef , coef1 -* cosio4 - -* day - -* dndt - -* em - eccentricity -* emsq - eccentricity squared -* eeta - -* etasq - -* gam - -* argpm - argument of perigee -* nodem - -* inclm - inclination -* mm - mean anomaly -* nm - mean motion -* perige - perigee -* pinvsq - -* psisq - -* qzms24 - -* rtemsq - -* s1, s2, s3, s4, s5, s6, s7 - -* sfour - -* ss1, ss2, ss3, ss4, ss5, ss6, ss7 - -* sz1, sz2, sz3 -* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 - -* tc - -* temp - -* temp1, temp2, temp3 - -* tsi - -* xpidot - -* xhdot1 - -* z1, z2, z3 - -* z11, z12, z13, z21, z22, z23, z31, z32, z33 - -* -* coupling : -* getgravconst- -* initl - -* dscom - -* dpper - -* dsinit - -* sgp4 - -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -bool sgp4init - ( - gravconsttype whichconst, char opsmode, const int satn, const double epoch, - const double xbstar, const double xecco, const double xargpo, - const double xinclo, const double xmo, const double xno, - const double xnodeo, elsetrec& satrec - ) -{ - /* --------------------- local variables ------------------------ */ - double ao, ainv, con42, cosio, sinio, cosio2, eccsq, - omeosq, posq, rp, rteosq, - cnodm , snodm , cosim , sinim , cosomm, sinomm, cc1sq , - cc2 , cc3 , coef , coef1 , cosio4, day , dndt , - em , emsq , eeta , etasq , gam , argpm , nodem , - inclm , mm , nm , perige, pinvsq, psisq , qzms24, - rtemsq, s1 , s2 , s3 , s4 , s5 , s6 , - s7 , sfour , ss1 , ss2 , ss3 , ss4 , ss5 , - ss6 , ss7 , sz1 , sz2 , sz3 , sz11 , sz12 , - sz13 , sz21 , sz22 , sz23 , sz31 , sz32 , sz33 , - tc , temp , temp1 , temp2 , temp3 , tsi , xpidot, - xhdot1, z1 , z2 , z3 , z11 , z12 , z13 , - z21 , z22 , z23 , z31 , z32 , z33, - qzms2t, ss, j2, j3oj2, j4, x2o3, r[3], v[3], - tumin, mu, radiusearthkm, xke, j3; - - /* ------------------------ initialization --------------------- */ - // sgp4fix divisor for divide by zero check on inclination - // the old check used 1.0 + cos(pi-1.0e-9), but then compared it to - // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency - const double temp4 = 1.5e-12; - - /* ----------- set all near earth variables to zero ------------ */ - satrec.isimp = 0; satrec.method = 'n'; satrec.aycof = 0.0; - satrec.con41 = 0.0; satrec.cc1 = 0.0; satrec.cc4 = 0.0; - satrec.cc5 = 0.0; satrec.d2 = 0.0; satrec.d3 = 0.0; - satrec.d4 = 0.0; satrec.delmo = 0.0; satrec.eta = 0.0; - satrec.argpdot = 0.0; satrec.omgcof = 0.0; satrec.sinmao = 0.0; - satrec.t = 0.0; satrec.t2cof = 0.0; satrec.t3cof = 0.0; - satrec.t4cof = 0.0; satrec.t5cof = 0.0; satrec.x1mth2 = 0.0; - satrec.x7thm1 = 0.0; satrec.mdot = 0.0; satrec.nodedot = 0.0; - satrec.xlcof = 0.0; satrec.xmcof = 0.0; satrec.nodecf = 0.0; - - /* ----------- set all deep space variables to zero ------------ */ - satrec.irez = 0; satrec.d2201 = 0.0; satrec.d2211 = 0.0; - satrec.d3210 = 0.0; satrec.d3222 = 0.0; satrec.d4410 = 0.0; - satrec.d4422 = 0.0; satrec.d5220 = 0.0; satrec.d5232 = 0.0; - satrec.d5421 = 0.0; satrec.d5433 = 0.0; satrec.dedt = 0.0; - satrec.del1 = 0.0; satrec.del2 = 0.0; satrec.del3 = 0.0; - satrec.didt = 0.0; satrec.dmdt = 0.0; satrec.dnodt = 0.0; - satrec.domdt = 0.0; satrec.e3 = 0.0; satrec.ee2 = 0.0; - satrec.peo = 0.0; satrec.pgho = 0.0; satrec.pho = 0.0; - satrec.pinco = 0.0; satrec.plo = 0.0; satrec.se2 = 0.0; - satrec.se3 = 0.0; satrec.sgh2 = 0.0; satrec.sgh3 = 0.0; - satrec.sgh4 = 0.0; satrec.sh2 = 0.0; satrec.sh3 = 0.0; - satrec.si2 = 0.0; satrec.si3 = 0.0; satrec.sl2 = 0.0; - satrec.sl3 = 0.0; satrec.sl4 = 0.0; satrec.gsto = 0.0; - satrec.xfact = 0.0; satrec.xgh2 = 0.0; satrec.xgh3 = 0.0; - satrec.xgh4 = 0.0; satrec.xh2 = 0.0; satrec.xh3 = 0.0; - satrec.xi2 = 0.0; satrec.xi3 = 0.0; satrec.xl2 = 0.0; - satrec.xl3 = 0.0; satrec.xl4 = 0.0; satrec.xlamo = 0.0; - satrec.zmol = 0.0; satrec.zmos = 0.0; satrec.atime = 0.0; - satrec.xli = 0.0; satrec.xni = 0.0; - - // sgp4fix - note the following variables are also passed directly via satrec. - // it is possible to streamline the sgp4init call by deleting the "x" - // variables, but the user would need to set the satrec.* values first. we - // include the additional assignments in case twoline2rv is not used. - satrec.bstar = xbstar; - satrec.ecco = xecco; - satrec.argpo = xargpo; - satrec.inclo = xinclo; - satrec.mo = xmo; - satrec.no = xno; - satrec.nodeo = xnodeo; - - // sgp4fix add opsmode - satrec.operationmode = opsmode; - - /* ------------------------ earth constants ----------------------- */ - // sgp4fix identify constants and allow alternate values - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - ss = 78.0 / radiusearthkm + 1.0; - qzms2t = pow(((120.0 - 78.0) / radiusearthkm), 4); - x2o3 = 2.0 / 3.0; - - satrec.init = 'y'; - satrec.t = 0.0; - - initl - ( - satn, whichconst, satrec.ecco, epoch, satrec.inclo, satrec.no, satrec.method, - ainv, ao, satrec.con41, con42, cosio, cosio2, eccsq, omeosq, - posq, rp, rteosq, sinio, satrec.gsto, satrec.operationmode - ); - satrec.error = 0; - - // sgp4fix remove this check as it is unnecessary - // the mrt check in sgp4 handles decaying satellite cases even if the starting - // condition is below the surface of te earth -// if (rp < 1.0) -// { -// printf("# *** satn%d epoch elts sub-orbital ***\n", satn); -// satrec.error = 5; -// } - - if ((omeosq >= 0.0 ) || ( satrec.no >= 0.0)) - { - satrec.isimp = 0; - if (rp < (220.0 / radiusearthkm + 1.0)) - satrec.isimp = 1; - sfour = ss; - qzms24 = qzms2t; - perige = (rp - 1.0) * radiusearthkm; - - /* - for perigees below 156 km, s and qoms2t are altered - */ - if (perige < 156.0) - { - sfour = perige - 78.0; - if (perige < 98.0) - sfour = 20.0; - qzms24 = pow(((120.0 - sfour) / radiusearthkm), 4.0); - sfour = sfour / radiusearthkm + 1.0; - } - pinvsq = 1.0 / posq; - - tsi = 1.0 / (ao - sfour); - satrec.eta = ao * satrec.ecco * tsi; - etasq = satrec.eta * satrec.eta; - eeta = satrec.ecco * satrec.eta; - psisq = fabs(1.0 - etasq); - coef = qzms24 * pow(tsi, 4.0); - coef1 = coef / pow(psisq, 3.5); - cc2 = coef1 * satrec.no * (ao * (1.0 + 1.5 * etasq + eeta * - (4.0 + etasq)) + 0.375 * j2 * tsi / psisq * satrec.con41 * - (8.0 + 3.0 * etasq * (8.0 + etasq))); - satrec.cc1 = satrec.bstar * cc2; - cc3 = 0.0; - if (satrec.ecco > 1.0e-4) - cc3 = -2.0 * coef * tsi * j3oj2 * satrec.no * sinio / satrec.ecco; - satrec.x1mth2 = 1.0 - cosio2; - satrec.cc4 = 2.0* satrec.no * coef1 * ao * omeosq * - (satrec.eta * (2.0 + 0.5 * etasq) + satrec.ecco * - (0.5 + 2.0 * etasq) - j2 * tsi / (ao * psisq) * - (-3.0 * satrec.con41 * (1.0 - 2.0 * eeta + etasq * - (1.5 - 0.5 * eeta)) + 0.75 * satrec.x1mth2 * - (2.0 * etasq - eeta * (1.0 + etasq)) * cos(2.0 * satrec.argpo))); - satrec.cc5 = 2.0 * coef1 * ao * omeosq * (1.0 + 2.75 * - (etasq + eeta) + eeta * etasq); - cosio4 = cosio2 * cosio2; - temp1 = 1.5 * j2 * pinvsq * satrec.no; - temp2 = 0.5 * temp1 * j2 * pinvsq; - temp3 = -0.46875 * j4 * pinvsq * pinvsq * satrec.no; - satrec.mdot = satrec.no + 0.5 * temp1 * rteosq * satrec.con41 + 0.0625 * - temp2 * rteosq * (13.0 - 78.0 * cosio2 + 137.0 * cosio4); - satrec.argpdot = -0.5 * temp1 * con42 + 0.0625 * temp2 * - (7.0 - 114.0 * cosio2 + 395.0 * cosio4) + - temp3 * (3.0 - 36.0 * cosio2 + 49.0 * cosio4); - xhdot1 = -temp1 * cosio; - satrec.nodedot = xhdot1 + (0.5 * temp2 * (4.0 - 19.0 * cosio2) + - 2.0 * temp3 * (3.0 - 7.0 * cosio2)) * cosio; - xpidot = satrec.argpdot+ satrec.nodedot; - satrec.omgcof = satrec.bstar * cc3 * cos(satrec.argpo); - satrec.xmcof = 0.0; - if (satrec.ecco > 1.0e-4) - satrec.xmcof = -x2o3 * coef * satrec.bstar / eeta; - satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1; - satrec.t2cof = 1.5 * satrec.cc1; - // sgp4fix for divide by zero with xinco = 180 deg - if (fabs(cosio+1.0) > 1.5e-12) - satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / (1.0 + cosio); - else - satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / temp4; - satrec.aycof = -0.5 * j3oj2 * sinio; - satrec.delmo = pow((1.0 + satrec.eta * cos(satrec.mo)), 3); - satrec.sinmao = sin(satrec.mo); - satrec.x7thm1 = 7.0 * cosio2 - 1.0; - - /* --------------- deep space initialization ------------- */ - if ((2*pi / satrec.no) >= 225.0) - { - satrec.method = 'd'; - satrec.isimp = 1; - tc = 0.0; - inclm = satrec.inclo; - - dscom - ( - epoch, satrec.ecco, satrec.argpo, tc, satrec.inclo, satrec.nodeo, - satrec.no, snodm, cnodm, sinim, cosim,sinomm, cosomm, - day, satrec.e3, satrec.ee2, em, emsq, gam, - satrec.peo, satrec.pgho, satrec.pho, satrec.pinco, - satrec.plo, rtemsq, satrec.se2, satrec.se3, - satrec.sgh2, satrec.sgh3, satrec.sgh4, - satrec.sh2, satrec.sh3, satrec.si2, satrec.si3, - satrec.sl2, satrec.sl3, satrec.sl4, s1, s2, s3, s4, s5, - s6, s7, ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3, - sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33, - satrec.xgh2, satrec.xgh3, satrec.xgh4, satrec.xh2, - satrec.xh3, satrec.xi2, satrec.xi3, satrec.xl2, - satrec.xl3, satrec.xl4, nm, z1, z2, z3, z11, - z12, z13, z21, z22, z23, z31, z32, z33, - satrec.zmol, satrec.zmos - ); - dpper - ( - satrec.e3, satrec.ee2, satrec.peo, satrec.pgho, - satrec.pho, satrec.pinco, satrec.plo, satrec.se2, - satrec.se3, satrec.sgh2, satrec.sgh3, satrec.sgh4, - satrec.sh2, satrec.sh3, satrec.si2, satrec.si3, - satrec.sl2, satrec.sl3, satrec.sl4, satrec.t, - satrec.xgh2,satrec.xgh3,satrec.xgh4, satrec.xh2, - satrec.xh3, satrec.xi2, satrec.xi3, satrec.xl2, - satrec.xl3, satrec.xl4, satrec.zmol, satrec.zmos, inclm, satrec.init, - satrec.ecco, satrec.inclo, satrec.nodeo, satrec.argpo, satrec.mo, - satrec.operationmode - ); - - argpm = 0.0; - nodem = 0.0; - mm = 0.0; - - dsinit - ( - whichconst, - cosim, emsq, satrec.argpo, s1, s2, s3, s4, s5, sinim, ss1, ss2, ss3, ss4, - ss5, sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33, satrec.t, tc, - satrec.gsto, satrec.mo, satrec.mdot, satrec.no, satrec.nodeo, - satrec.nodedot, xpidot, z1, z3, z11, z13, z21, z23, z31, z33, - satrec.ecco, eccsq, em, argpm, inclm, mm, nm, nodem, - satrec.irez, satrec.atime, - satrec.d2201, satrec.d2211, satrec.d3210, satrec.d3222 , - satrec.d4410, satrec.d4422, satrec.d5220, satrec.d5232, - satrec.d5421, satrec.d5433, satrec.dedt, satrec.didt, - satrec.dmdt, dndt, satrec.dnodt, satrec.domdt , - satrec.del1, satrec.del2, satrec.del3, satrec.xfact, - satrec.xlamo, satrec.xli, satrec.xni - ); - } - - /* ----------- set variables if not deep space ----------- */ - if (satrec.isimp != 1) - { - cc1sq = satrec.cc1 * satrec.cc1; - satrec.d2 = 4.0 * ao * tsi * cc1sq; - temp = satrec.d2 * tsi * satrec.cc1 / 3.0; - satrec.d3 = (17.0 * ao + sfour) * temp; - satrec.d4 = 0.5 * temp * ao * tsi * (221.0 * ao + 31.0 * sfour) * - satrec.cc1; - satrec.t3cof = satrec.d2 + 2.0 * cc1sq; - satrec.t4cof = 0.25 * (3.0 * satrec.d3 + satrec.cc1 * - (12.0 * satrec.d2 + 10.0 * cc1sq)); - satrec.t5cof = 0.2 * (3.0 * satrec.d4 + - 12.0 * satrec.cc1 * satrec.d3 + - 6.0 * satrec.d2 * satrec.d2 + - 15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq)); - } - } // if omeosq = 0 ... - - /* finally propogate to zero epoch to initialize all others. */ - // sgp4fix take out check to let satellites process until they are actually below earth surface -// if(satrec.error == 0) - sgp4(whichconst, satrec, 0.0, r, v); - - satrec.init = 'n'; - -//#include "debug6.cpp" - //sgp4fix return boolean. satrec.error contains any error codes - return true; -} // end sgp4init - -/*----------------------------------------------------------------------------- -* -* procedure sgp4 -* -* this procedure is the sgp4 prediction model from space command. this is an -* updated and combined version of sgp4 and sdp4, which were originally -* published separately in spacetrack report #3. this version follows the -* methodology from the aiaa paper (2006) describing the history and -* development of the code. -* -* author : david vallado 719-573-2600 28 jun 2005 -* -* inputs : -* satrec - initialised structure from sgp4init() call. -* tsince - time eince epoch (minutes) -* -* outputs : -* r - position vector km -* v - velocity km/sec -* return code - non-zero on error. -* 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er -* 2 - mean motion less than 0.0 -* 3 - pert elements, ecc < 0.0 or ecc > 1.0 -* 4 - semi-latus rectum < 0.0 -* 5 - epoch elements are sub-orbital -* 6 - satellite has decayed -* -* locals : -* am - -* axnl, aynl - -* betal - -* cosim , sinim , cosomm , sinomm , cnod , snod , cos2u , -* sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip , -* cosisq , cossu , sinsu , cosu , sinu -* delm - -* delomg - -* dndt - -* eccm - -* emsq - -* ecose - -* el2 - -* eo1 - -* eccp - -* esine - -* argpm - -* argpp - -* omgadf - -* pl - -* r - -* rtemsq - -* rdotl - -* rl - -* rvdot - -* rvdotl - -* su - -* t2 , t3 , t4 , tc -* tem5, temp , temp1 , temp2 , tempa , tempe , templ -* u , ux , uy , uz , vx , vy , vz -* inclm - inclination -* mm - mean anomaly -* nm - mean motion -* nodem - right asc of ascending node -* xinc - -* xincp - -* xl - -* xlm - -* mp - -* xmdf - -* xmx - -* xmy - -* nodedf - -* xnode - -* nodep - -* np - -* -* coupling : -* getgravconst- -* dpper -* dpspace -* -* references : -* hoots, roehrich, norad spacetrack report #3 1980 -* hoots, norad spacetrack report #6 1986 -* hoots, schumacher and glover 2004 -* vallado, crawford, hujsak, kelso 2006 - ----------------------------------------------------------------------------*/ - -bool sgp4 - ( - gravconsttype whichconst, elsetrec& satrec, double tsince, - double r[3], double v[3] - ) -{ - double am , axnl , aynl , betal , cosim , cnod , - cos2u, coseo1, cosi , cosip , cosisq, cossu , cosu, - delm , delomg, em , emsq , ecose , el2 , eo1 , - ep , esine , argpm, argpp , argpdf, pl, mrt = 0.0, - mvt , rdotl , rl , rvdot , rvdotl, sinim , - sin2u, sineo1, sini , sinip , sinsu , sinu , - snod , su , t2 , t3 , t4 , tem5 , temp, - temp1, temp2 , tempa, tempe , templ , u , ux , - uy , uz , vx , vy , vz , inclm , mm , - nm , nodem, xinc , xincp , xl , xlm , mp , - xmdf , xmx , xmy , nodedf, xnode , nodep, tc , dndt, - twopi, x2o3 , j2 , j3 , tumin, j4 , xke , j3oj2, radiusearthkm, - mu, vkmpersec; - int ktr; - - /* ------------------ set mathematical constants --------------- */ - // sgp4fix divisor for divide by zero check on inclination - // the old check used 1.0 + cos(pi-1.0e-9), but then compared it to - // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency - const double temp4 = 1.5e-12; - twopi = 2.0 * pi; - x2o3 = 2.0 / 3.0; - // sgp4fix identify constants and allow alternate values - getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); - vkmpersec = radiusearthkm * xke/60.0; - - /* --------------------- clear sgp4 error flag ----------------- */ - satrec.t = tsince; - satrec.error = 0; - - /* ------- update for secular gravity and atmospheric drag ----- */ - xmdf = satrec.mo + satrec.mdot * satrec.t; - argpdf = satrec.argpo + satrec.argpdot * satrec.t; - nodedf = satrec.nodeo + satrec.nodedot * satrec.t; - argpm = argpdf; - mm = xmdf; - t2 = satrec.t * satrec.t; - nodem = nodedf + satrec.nodecf * t2; - tempa = 1.0 - satrec.cc1 * satrec.t; - tempe = satrec.bstar * satrec.cc4 * satrec.t; - templ = satrec.t2cof * t2; - - if (satrec.isimp != 1) - { - delomg = satrec.omgcof * satrec.t; - delm = satrec.xmcof * - (pow((1.0 + satrec.eta * cos(xmdf)), 3) - - satrec.delmo); - temp = delomg + delm; - mm = xmdf + temp; - argpm = argpdf - temp; - t3 = t2 * satrec.t; - t4 = t3 * satrec.t; - tempa = tempa - satrec.d2 * t2 - satrec.d3 * t3 - - satrec.d4 * t4; - tempe = tempe + satrec.bstar * satrec.cc5 * (sin(mm) - - satrec.sinmao); - templ = templ + satrec.t3cof * t3 + t4 * (satrec.t4cof + - satrec.t * satrec.t5cof); - } - - nm = satrec.no; - em = satrec.ecco; - inclm = satrec.inclo; - if (satrec.method == 'd') - { - tc = satrec.t; - dspace - ( - satrec.irez, - satrec.d2201, satrec.d2211, satrec.d3210, - satrec.d3222, satrec.d4410, satrec.d4422, - satrec.d5220, satrec.d5232, satrec.d5421, - satrec.d5433, satrec.dedt, satrec.del1, - satrec.del2, satrec.del3, satrec.didt, - satrec.dmdt, satrec.dnodt, satrec.domdt, - satrec.argpo, satrec.argpdot, satrec.t, tc, - satrec.gsto, satrec.xfact, satrec.xlamo, - satrec.no, satrec.atime, - em, argpm, inclm, satrec.xli, mm, satrec.xni, - nodem, dndt, nm - ); - } // if method = d - - if (nm <= 0.0) - { -// printf("# error nm %f\n", nm); - satrec.error = 2; - // sgp4fix add return - return false; - } - am = pow((xke / nm),x2o3) * tempa * tempa; - nm = xke / pow(am, 1.5); - em = em - tempe; - - // fix tolerance for error recognition - // sgp4fix am is fixed from the previous nm check - if ((em >= 1.0) || (em < -0.001)/* || (am < 0.95)*/ ) - { -// printf("# error em %f\n", em); - satrec.error = 1; - // sgp4fix to return if there is an error in eccentricity - return false; - } - // sgp4fix fix tolerance to avoid a divide by zero - if (em < 1.0e-6) - em = 1.0e-6; - mm = mm + satrec.no * templ; - xlm = mm + argpm + nodem; - emsq = em * em; - temp = 1.0 - emsq; - - nodem = fmod(nodem, twopi); - argpm = fmod(argpm, twopi); - xlm = fmod(xlm, twopi); - mm = fmod(xlm - argpm - nodem, twopi); - - /* ----------------- compute extra mean quantities ------------- */ - sinim = sin(inclm); - cosim = cos(inclm); - - /* -------------------- add lunar-solar periodics -------------- */ - ep = em; - xincp = inclm; - argpp = argpm; - nodep = nodem; - mp = mm; - sinip = sinim; - cosip = cosim; - if (satrec.method == 'd') - { - dpper - ( - satrec.e3, satrec.ee2, satrec.peo, - satrec.pgho, satrec.pho, satrec.pinco, - satrec.plo, satrec.se2, satrec.se3, - satrec.sgh2, satrec.sgh3, satrec.sgh4, - satrec.sh2, satrec.sh3, satrec.si2, - satrec.si3, satrec.sl2, satrec.sl3, - satrec.sl4, satrec.t, satrec.xgh2, - satrec.xgh3, satrec.xgh4, satrec.xh2, - satrec.xh3, satrec.xi2, satrec.xi3, - satrec.xl2, satrec.xl3, satrec.xl4, - satrec.zmol, satrec.zmos, satrec.inclo, - 'n', ep, xincp, nodep, argpp, mp, satrec.operationmode - ); - if (xincp < 0.0) - { - xincp = -xincp; - nodep = nodep + pi; - argpp = argpp - pi; - } - if ((ep < 0.0 ) || ( ep > 1.0)) - { -// printf("# error ep %f\n", ep); - satrec.error = 3; - // sgp4fix add return - return false; - } - } // if method = d - - /* -------------------- long period periodics ------------------ */ - if (satrec.method == 'd') - { - sinip = sin(xincp); - cosip = cos(xincp); - satrec.aycof = -0.5*j3oj2*sinip; - // sgp4fix for divide by zero for xincp = 180 deg - if (fabs(cosip+1.0) > 1.5e-12) - satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / (1.0 + cosip); - else - satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / temp4; - } - axnl = ep * cos(argpp); - temp = 1.0 / (am * (1.0 - ep * ep)); - aynl = ep* sin(argpp) + temp * satrec.aycof; - xl = mp + argpp + nodep + temp * satrec.xlcof * axnl; - - /* --------------------- solve kepler's equation --------------- */ - u = fmod(xl - nodep, twopi); - eo1 = u; - tem5 = 9999.9; - ktr = 1; - // sgp4fix for kepler iteration - // the following iteration needs better limits on corrections - while (( fabs(tem5) >= 1.0e-12) && (ktr <= 10) ) - { - sineo1 = sin(eo1); - coseo1 = cos(eo1); - tem5 = 1.0 - coseo1 * axnl - sineo1 * aynl; - tem5 = (u - aynl * coseo1 + axnl * sineo1 - eo1) / tem5; - if(fabs(tem5) >= 0.95) - tem5 = tem5 > 0.0 ? 0.95 : -0.95; - eo1 = eo1 + tem5; - ktr = ktr + 1; - } - - /* ------------- short period preliminary quantities ----------- */ - ecose = axnl*coseo1 + aynl*sineo1; - esine = axnl*sineo1 - aynl*coseo1; - el2 = axnl*axnl + aynl*aynl; - pl = am*(1.0-el2); - if (pl < 0.0) - { -// printf("# error pl %f\n", pl); - satrec.error = 4; - // sgp4fix add return - return false; - } - else - { - rl = am * (1.0 - ecose); - rdotl = sqrt(am) * esine/rl; - rvdotl = sqrt(pl) / rl; - betal = sqrt(1.0 - el2); - temp = esine / (1.0 + betal); - sinu = am / rl * (sineo1 - aynl - axnl * temp); - cosu = am / rl * (coseo1 - axnl + aynl * temp); - su = atan2(sinu, cosu); - sin2u = (cosu + cosu) * sinu; - cos2u = 1.0 - 2.0 * sinu * sinu; - temp = 1.0 / pl; - temp1 = 0.5 * j2 * temp; - temp2 = temp1 * temp; - - /* -------------- update for short period periodics ------------ */ - if (satrec.method == 'd') - { - cosisq = cosip * cosip; - satrec.con41 = 3.0*cosisq - 1.0; - satrec.x1mth2 = 1.0 - cosisq; - satrec.x7thm1 = 7.0*cosisq - 1.0; - } - mrt = rl * (1.0 - 1.5 * temp2 * betal * satrec.con41) + - 0.5 * temp1 * satrec.x1mth2 * cos2u; - su = su - 0.25 * temp2 * satrec.x7thm1 * sin2u; - xnode = nodep + 1.5 * temp2 * cosip * sin2u; - xinc = xincp + 1.5 * temp2 * cosip * sinip * cos2u; - mvt = rdotl - nm * temp1 * satrec.x1mth2 * sin2u / xke; - rvdot = rvdotl + nm * temp1 * (satrec.x1mth2 * cos2u + - 1.5 * satrec.con41) / xke; - - /* --------------------- orientation vectors ------------------- */ - sinsu = sin(su); - cossu = cos(su); - snod = sin(xnode); - cnod = cos(xnode); - sini = sin(xinc); - cosi = cos(xinc); - xmx = -snod * cosi; - xmy = cnod * cosi; - ux = xmx * sinsu + cnod * cossu; - uy = xmy * sinsu + snod * cossu; - uz = sini * sinsu; - vx = xmx * cossu - cnod * sinsu; - vy = xmy * cossu - snod * sinsu; - vz = sini * cossu; - - /* --------- position and velocity (in km and km/sec) ---------- */ - r[0] = (mrt * ux)* radiusearthkm; - r[1] = (mrt * uy)* radiusearthkm; - r[2] = (mrt * uz)* radiusearthkm; - v[0] = (mvt * ux + rvdot * vx) * vkmpersec; - v[1] = (mvt * uy + rvdot * vy) * vkmpersec; - v[2] = (mvt * uz + rvdot * vz) * vkmpersec; - } // if pl > 0 - - // sgp4fix for decaying satellites - if (mrt < 1.0) - { -// printf("# decay condition %11.6f \n",mrt); - satrec.error = 6; - return false; - } - -//#include "debug7.cpp" - return true; -} // end sgp4 - - -/* ----------------------------------------------------------------------------- -* -* function gstime -* -* this function finds the greenwich sidereal time. -* -* author : david vallado 719-573-2600 1 mar 2001 -* -* inputs description range / units -* jdut1 - julian date in ut1 days from 4713 bc -* -* outputs : -* gstime - greenwich sidereal time 0 to 2pi rad -* -* locals : -* temp - temporary variable for doubles rad -* tut1 - julian centuries from the -* jan 1, 2000 12 h epoch (ut1) -* -* coupling : -* none -* -* references : -* vallado 2004, 191, eq 3-45 -* --------------------------------------------------------------------------- */ - -double gstime - ( - double jdut1 - ) - { - const double twopi = 2.0 * pi; - const double deg2rad = pi / 180.0; - double temp, tut1; - - tut1 = (jdut1 - 2451545.0) / 36525.0; - temp = -6.2e-6* tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + - (876600.0*3600 + 8640184.812866) * tut1 + 67310.54841; // sec - temp = fmod(temp * deg2rad / 240.0, twopi); //360/86400 = 1/240, to deg, to rad - - // ------------------------ check quadrants --------------------- - if (temp < 0.0) - temp += twopi; - - return temp; - } // end gstime - -/* ----------------------------------------------------------------------------- -* -* function getgravconst -* -* this function gets constants for the propagator. note that mu is identified to -* facilitiate comparisons with newer models. the common useage is wgs72. -* -* author : david vallado 719-573-2600 21 jul 2006 -* -* inputs : -* whichconst - which set of constants to use wgs72old, wgs72, wgs84 -* -* outputs : -* tumin - minutes in one time unit -* mu - earth gravitational parameter -* radiusearthkm - radius of the earth in km -* xke - reciprocal of tumin -* j2, j3, j4 - un-normalized zonal harmonic values -* j3oj2 - j3 divided by j2 -* -* locals : -* -* coupling : -* none -* -* references : -* norad spacetrack report #3 -* vallado, crawford, hujsak, kelso 2006 - --------------------------------------------------------------------------- */ - -void getgravconst - ( - gravconsttype whichconst, - double& tumin, - double& mu, - double& radiusearthkm, - double& xke, - double& j2, - double& j3, - double& j4, - double& j3oj2 - ) - { - - switch (whichconst) - { - // -- wgs-72 low precision str#3 constants -- - case wgs72old: - mu = 398600.79964; // in km3 / s2 - radiusearthkm = 6378.135; // km - xke = 0.0743669161; - tumin = 1.0 / xke; - j2 = 0.001082616; - j3 = -0.00000253881; - j4 = -0.00000165597; - j3oj2 = j3 / j2; - break; - // ------------ wgs-72 constants ------------ - case wgs72: - mu = 398600.8; // in km3 / s2 - radiusearthkm = 6378.135; // km - xke = 60.0 / sqrt(radiusearthkm*radiusearthkm*radiusearthkm/mu); - tumin = 1.0 / xke; - j2 = 0.001082616; - j3 = -0.00000253881; - j4 = -0.00000165597; - j3oj2 = j3 / j2; - break; - case wgs84: - // ------------ wgs-84 constants ------------ - mu = 398600.5; // in km3 / s2 - radiusearthkm = 6378.137; // km - xke = 60.0 / sqrt(radiusearthkm*radiusearthkm*radiusearthkm/mu); - tumin = 1.0 / xke; - j2 = 0.00108262998905; - j3 = -0.00000253215306; - j4 = -0.00000161098761; - j3oj2 = j3 / j2; - break; - default: - fprintf(stderr,"unknown gravity option (%d)\n",whichconst); - break; - } - - } // end getgravconst - - - - - +/* ---------------------------------------------------------------- +* +* sgp4unit.cpp +* +* this file contains the sgp4 procedures for analytical propagation +* of a satellite. the code was originally released in the 1980 and 1986 +* spacetrack papers. a detailed discussion of the theory and history +* may be found in the 2006 aiaa paper by vallado, crawford, hujsak, +* and kelso. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 3 Nov 08 david vallado +* put returns in for error codes +* changes : +* 29 sep 08 david vallado +* fix atime for faster operation in dspace +* add operationmode for afspc (a) or improved (i) +* performance mode +* 16 jun 08 david vallado +* update small eccentricity check +* 16 nov 07 david vallado +* misc fixes for better compliance +* 20 apr 07 david vallado +* misc fixes for constants +* 11 aug 06 david vallado +* chg lyddane choice back to strn3, constants, misc doc +* 15 dec 05 david vallado +* misc fixes +* 26 jul 05 david vallado +* fixes for paper +* note that each fix is preceded by a +* comment with "sgp4fix" and an explanation of +* what was changed +* 10 aug 04 david vallado +* 2nd printing baseline working +* 14 may 01 david vallado +* 2nd edition baseline +* 80 norad +* original baseline +* ---------------------------------------------------------------- */ + +#include "sgp4unit.h" + +const char help = 'n'; +FILE *dbgfile; + + +/* ----------- local functions - only ever used internally by sgp4 ---------- */ +static void dpper + ( + double e3, double ee2, double peo, double pgho, double pho, + double pinco, double plo, double se2, double se3, double sgh2, + double sgh3, double sgh4, double sh2, double sh3, double si2, + double si3, double sl2, double sl3, double sl4, double t, + double xgh2, double xgh3, double xgh4, double xh2, double xh3, + double xi2, double xi3, double xl2, double xl3, double xl4, + double zmol, double zmos, double inclo, + char init, + double& ep, double& inclp, double& nodep, double& argpp, double& mp, + char opsmode + ); + +static void dscom + ( + double epoch, double ep, double argpp, double tc, double inclp, + double nodep, double np, + double& snodm, double& cnodm, double& sinim, double& cosim, double& sinomm, + double& cosomm,double& day, double& e3, double& ee2, double& em, + double& emsq, double& gam, double& peo, double& pgho, double& pho, + double& pinco, double& plo, double& rtemsq, double& se2, double& se3, + double& sgh2, double& sgh3, double& sgh4, double& sh2, double& sh3, + double& si2, double& si3, double& sl2, double& sl3, double& sl4, + double& s1, double& s2, double& s3, double& s4, double& s5, + double& s6, double& s7, double& ss1, double& ss2, double& ss3, + double& ss4, double& ss5, double& ss6, double& ss7, double& sz1, + double& sz2, double& sz3, double& sz11, double& sz12, double& sz13, + double& sz21, double& sz22, double& sz23, double& sz31, double& sz32, + double& sz33, double& xgh2, double& xgh3, double& xgh4, double& xh2, + double& xh3, double& xi2, double& xi3, double& xl2, double& xl3, + double& xl4, double& nm, double& z1, double& z2, double& z3, + double& z11, double& z12, double& z13, double& z21, double& z22, + double& z23, double& z31, double& z32, double& z33, double& zmol, + double& zmos + ); + +static void dsinit + ( + gravconsttype whichconst, + double cosim, double emsq, double argpo, double s1, double s2, + double s3, double s4, double s5, double sinim, double ss1, + double ss2, double ss3, double ss4, double ss5, double sz1, + double sz3, double sz11, double sz13, double sz21, double sz23, + double sz31, double sz33, double t, double tc, double gsto, + double mo, double mdot, double no, double nodeo, double nodedot, + double xpidot, double z1, double z3, double z11, double z13, + double z21, double z23, double z31, double z33, double ecco, + double eccsq, double& em, double& argpm, double& inclm, double& mm, + double& nm, double& nodem, + int& irez, + double& atime, double& d2201, double& d2211, double& d3210, double& d3222, + double& d4410, double& d4422, double& d5220, double& d5232, double& d5421, + double& d5433, double& dedt, double& didt, double& dmdt, double& dndt, + double& dnodt, double& domdt, double& del1, double& del2, double& del3, + double& xfact, double& xlamo, double& xli, double& xni + ); + +static void dspace + ( + int irez, + double d2201, double d2211, double d3210, double d3222, double d4410, + double d4422, double d5220, double d5232, double d5421, double d5433, + double dedt, double del1, double del2, double del3, double didt, + double dmdt, double dnodt, double domdt, double argpo, double argpdot, + double t, double tc, double gsto, double xfact, double xlamo, + double no, + double& atime, double& em, double& argpm, double& inclm, double& xli, + double& mm, double& xni, double& nodem, double& dndt, double& nm + ); + +static void initl + ( + int satn, gravconsttype whichconst, + double ecco, double epoch, double inclo, double& no, + char& method, + double& ainv, double& ao, double& con41, double& con42, double& cosio, + double& cosio2,double& eccsq, double& omeosq, double& posq, + double& rp, double& rteosq,double& sinio , double& gsto, char opsmode + ); + +/* ----------------------------------------------------------------------------- +* +* procedure dpper +* +* this procedure provides deep space long period periodic contributions +* to the mean elements. by design, these periodics are zero at epoch. +* this used to be dscom which included initialization, but it's really a +* recurring function. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* e3 - +* ee2 - +* peo - +* pgho - +* pho - +* pinco - +* plo - +* se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 - +* t - +* xh2, xh3, xi2, xi3, xl2, xl3, xl4 - +* zmol - +* zmos - +* ep - eccentricity 0.0 - 1.0 +* inclo - inclination - needed for lyddane modification +* nodep - right ascension of ascending node +* argpp - argument of perigee +* mp - mean anomaly +* +* outputs : +* ep - eccentricity 0.0 - 1.0 +* inclp - inclination +* nodep - right ascension of ascending node +* argpp - argument of perigee +* mp - mean anomaly +* +* locals : +* alfdp - +* betdp - +* cosip , sinip , cosop , sinop , +* dalf - +* dbet - +* dls - +* f2, f3 - +* pe - +* pgh - +* ph - +* pinc - +* pl - +* sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis , +* sll , sls +* xls - +* xnoh - +* zf - +* zm - +* +* coupling : +* none. +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void dpper + ( + double e3, double ee2, double peo, double pgho, double pho, + double pinco, double plo, double se2, double se3, double sgh2, + double sgh3, double sgh4, double sh2, double sh3, double si2, + double si3, double sl2, double sl3, double sl4, double t, + double xgh2, double xgh3, double xgh4, double xh2, double xh3, + double xi2, double xi3, double xl2, double xl3, double xl4, + double zmol, double zmos, double inclo, + char init, + double& ep, double& inclp, double& nodep, double& argpp, double& mp, + char opsmode + ) +{ + /* --------------------- local variables ------------------------ */ + const double twopi = 2.0 * pi; + double alfdp, betdp, cosip, cosop, dalf, dbet, dls, + f2, f3, pe, pgh, ph, pinc, pl , + sel, ses, sghl, sghs, shll, shs, sil, + sinip, sinop, sinzf, sis, sll, sls, xls, + xnoh, zf, zm, zel, zes, znl, zns; + + /* kill warning */ + inclo = 0.; + + /* ---------------------- constants ----------------------------- */ + zns = 1.19459e-5; + zes = 0.01675; + znl = 1.5835218e-4; + zel = 0.05490; + + /* --------------- calculate time varying periodics ----------- */ + zm = zmos + zns * t; + // be sure that the initial call has time set to zero + if (init == 'y') + zm = zmos; + zf = zm + 2.0 * zes * sin(zm); + sinzf = sin(zf); + f2 = 0.5 * sinzf * sinzf - 0.25; + f3 = -0.5 * sinzf * cos(zf); + ses = se2* f2 + se3 * f3; + sis = si2 * f2 + si3 * f3; + sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf; + sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf; + shs = sh2 * f2 + sh3 * f3; + zm = zmol + znl * t; + if (init == 'y') + zm = zmol; + zf = zm + 2.0 * zel * sin(zm); + sinzf = sin(zf); + f2 = 0.5 * sinzf * sinzf - 0.25; + f3 = -0.5 * sinzf * cos(zf); + sel = ee2 * f2 + e3 * f3; + sil = xi2 * f2 + xi3 * f3; + sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf; + sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf; + shll = xh2 * f2 + xh3 * f3; + pe = ses + sel; + pinc = sis + sil; + pl = sls + sll; + pgh = sghs + sghl; + ph = shs + shll; + + if (init == 'n') + { + pe = pe - peo; + pinc = pinc - pinco; + pl = pl - plo; + pgh = pgh - pgho; + ph = ph - pho; + inclp = inclp + pinc; + ep = ep + pe; + sinip = sin(inclp); + cosip = cos(inclp); + + /* ----------------- apply periodics directly ------------ */ + // sgp4fix for lyddane choice + // strn3 used original inclination - this is technically feasible + // gsfc used perturbed inclination - also technically feasible + // probably best to readjust the 0.2 limit value and limit discontinuity + // 0.2 rad = 11.45916 deg + // use next line for original strn3 approach and original inclination + // if (inclo >= 0.2) + // use next line for gsfc version and perturbed inclination + if (inclp >= 0.2) + { + ph = ph / sinip; + pgh = pgh - cosip * ph; + argpp = argpp + pgh; + nodep = nodep + ph; + mp = mp + pl; + } + else + { + /* ---- apply periodics with lyddane modification ---- */ + sinop = sin(nodep); + cosop = cos(nodep); + alfdp = sinip * sinop; + betdp = sinip * cosop; + dalf = ph * cosop + pinc * cosip * sinop; + dbet = -ph * sinop + pinc * cosip * cosop; + alfdp = alfdp + dalf; + betdp = betdp + dbet; + nodep = fmod(nodep, twopi); + // sgp4fix for afspc written intrinsic functions + // nodep used without a trigonometric function ahead + if ((nodep < 0.0) && (opsmode == 'a')) + nodep = nodep + twopi; + xls = mp + argpp + cosip * nodep; + dls = pl + pgh - pinc * nodep * sinip; + xls = xls + dls; + xnoh = nodep; + nodep = atan2(alfdp, betdp); + // sgp4fix for afspc written intrinsic functions + // nodep used without a trigonometric function ahead + if ((nodep < 0.0) && (opsmode == 'a')) + nodep = nodep + twopi; + if (fabs(xnoh - nodep) > pi){ + if (nodep < xnoh) + nodep = nodep + twopi; + else + nodep = nodep - twopi; + } + mp = mp + pl; + argpp = xls - mp - cosip * nodep; + } + } // if init == 'n' + +//#include "debug1.cpp" +} // end dpper + +/*----------------------------------------------------------------------------- +* +* procedure dscom +* +* this procedure provides deep space common items used by both the secular +* and periodics subroutines. input is provided as shown. this routine +* used to be called dpper, but the functions inside weren't well organized. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* epoch - +* ep - eccentricity +* argpp - argument of perigee +* tc - +* inclp - inclination +* nodep - right ascension of ascending node +* np - mean motion +* +* outputs : +* sinim , cosim , sinomm , cosomm , snodm , cnodm +* day - +* e3 - +* ee2 - +* em - eccentricity +* emsq - eccentricity squared +* gam - +* peo - +* pgho - +* pho - +* pinco - +* plo - +* rtemsq - +* se2, se3 - +* sgh2, sgh3, sgh4 - +* sh2, sh3, si2, si3, sl2, sl3, sl4 - +* s1, s2, s3, s4, s5, s6, s7 - +* ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 - +* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 - +* xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 - +* nm - mean motion +* z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 - +* zmol - +* zmos - +* +* locals : +* a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 - +* betasq - +* cc - +* ctem, stem - +* x1, x2, x3, x4, x5, x6, x7, x8 - +* xnodce - +* xnoi - +* zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl , +* zcosi , zsini , zcosil , zsinil , +* zx - +* zy - +* +* coupling : +* none. +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void dscom + ( + double epoch, double ep, double argpp, double tc, double inclp, + double nodep, double np, + double& snodm, double& cnodm, double& sinim, double& cosim, double& sinomm, + double& cosomm,double& day, double& e3, double& ee2, double& em, + double& emsq, double& gam, double& peo, double& pgho, double& pho, + double& pinco, double& plo, double& rtemsq, double& se2, double& se3, + double& sgh2, double& sgh3, double& sgh4, double& sh2, double& sh3, + double& si2, double& si3, double& sl2, double& sl3, double& sl4, + double& s1, double& s2, double& s3, double& s4, double& s5, + double& s6, double& s7, double& ss1, double& ss2, double& ss3, + double& ss4, double& ss5, double& ss6, double& ss7, double& sz1, + double& sz2, double& sz3, double& sz11, double& sz12, double& sz13, + double& sz21, double& sz22, double& sz23, double& sz31, double& sz32, + double& sz33, double& xgh2, double& xgh3, double& xgh4, double& xh2, + double& xh3, double& xi2, double& xi3, double& xl2, double& xl3, + double& xl4, double& nm, double& z1, double& z2, double& z3, + double& z11, double& z12, double& z13, double& z21, double& z22, + double& z23, double& z31, double& z32, double& z33, double& zmol, + double& zmos + ) +{ + /* -------------------------- constants ------------------------- */ + const double zes = 0.01675; + const double zel = 0.05490; + const double c1ss = 2.9864797e-6; + const double c1l = 4.7968065e-7; + const double zsinis = 0.39785416; + const double zcosis = 0.91744867; + const double zcosgs = 0.1945905; + const double zsings = -0.98088458; + const double twopi = 2.0 * pi; + + /* --------------------- local variables ------------------------ */ + int lsflg; + double a1 , a2 , a3 , a4 , a5 , a6 , a7 , + a8 , a9 , a10 , betasq, cc , ctem , stem , + x1 , x2 , x3 , x4 , x5 , x6 , x7 , + x8 , xnodce, xnoi , zcosg , zcosgl, zcosh , zcoshl, + zcosi , zcosil, zsing , zsingl, zsinh , zsinhl, zsini , + zsinil, zx , zy; + + nm = np; + em = ep; + snodm = sin(nodep); + cnodm = cos(nodep); + sinomm = sin(argpp); + cosomm = cos(argpp); + sinim = sin(inclp); + cosim = cos(inclp); + emsq = em * em; + betasq = 1.0 - emsq; + rtemsq = sqrt(betasq); + + /* ----------------- initialize lunar solar terms --------------- */ + peo = 0.0; + pinco = 0.0; + plo = 0.0; + pgho = 0.0; + pho = 0.0; + day = epoch + 18261.5 + tc / 1440.0; + xnodce = fmod(4.5236020 - 9.2422029e-4 * day, twopi); + stem = sin(xnodce); + ctem = cos(xnodce); + zcosil = 0.91375164 - 0.03568096 * ctem; + zsinil = sqrt(1.0 - zcosil * zcosil); + zsinhl = 0.089683511 * stem / zsinil; + zcoshl = sqrt(1.0 - zsinhl * zsinhl); + gam = 5.8351514 + 0.0019443680 * day; + zx = 0.39785416 * stem / zsinil; + zy = zcoshl * ctem + 0.91744867 * zsinhl * stem; + zx = atan2(zx, zy); + zx = gam + zx - xnodce; + zcosgl = cos(zx); + zsingl = sin(zx); + + /* ------------------------- do solar terms --------------------- */ + zcosg = zcosgs; + zsing = zsings; + zcosi = zcosis; + zsini = zsinis; + zcosh = cnodm; + zsinh = snodm; + cc = c1ss; + xnoi = 1.0 / nm; + + for (lsflg = 1; lsflg <= 2; lsflg++) + { + a1 = zcosg * zcosh + zsing * zcosi * zsinh; + a3 = -zsing * zcosh + zcosg * zcosi * zsinh; + a7 = -zcosg * zsinh + zsing * zcosi * zcosh; + a8 = zsing * zsini; + a9 = zsing * zsinh + zcosg * zcosi * zcosh; + a10 = zcosg * zsini; + a2 = cosim * a7 + sinim * a8; + a4 = cosim * a9 + sinim * a10; + a5 = -sinim * a7 + cosim * a8; + a6 = -sinim * a9 + cosim * a10; + + x1 = a1 * cosomm + a2 * sinomm; + x2 = a3 * cosomm + a4 * sinomm; + x3 = -a1 * sinomm + a2 * cosomm; + x4 = -a3 * sinomm + a4 * cosomm; + x5 = a5 * sinomm; + x6 = a6 * sinomm; + x7 = a5 * cosomm; + x8 = a6 * cosomm; + + z31 = 12.0 * x1 * x1 - 3.0 * x3 * x3; + z32 = 24.0 * x1 * x2 - 6.0 * x3 * x4; + z33 = 12.0 * x2 * x2 - 3.0 * x4 * x4; + z1 = 3.0 * (a1 * a1 + a2 * a2) + z31 * emsq; + z2 = 6.0 * (a1 * a3 + a2 * a4) + z32 * emsq; + z3 = 3.0 * (a3 * a3 + a4 * a4) + z33 * emsq; + z11 = -6.0 * a1 * a5 + emsq * (-24.0 * x1 * x7-6.0 * x3 * x5); + z12 = -6.0 * (a1 * a6 + a3 * a5) + emsq * + (-24.0 * (x2 * x7 + x1 * x8) - 6.0 * (x3 * x6 + x4 * x5)); + z13 = -6.0 * a3 * a6 + emsq * (-24.0 * x2 * x8 - 6.0 * x4 * x6); + z21 = 6.0 * a2 * a5 + emsq * (24.0 * x1 * x5 - 6.0 * x3 * x7); + z22 = 6.0 * (a4 * a5 + a2 * a6) + emsq * + (24.0 * (x2 * x5 + x1 * x6) - 6.0 * (x4 * x7 + x3 * x8)); + z23 = 6.0 * a4 * a6 + emsq * (24.0 * x2 * x6 - 6.0 * x4 * x8); + z1 = z1 + z1 + betasq * z31; + z2 = z2 + z2 + betasq * z32; + z3 = z3 + z3 + betasq * z33; + s3 = cc * xnoi; + s2 = -0.5 * s3 / rtemsq; + s4 = s3 * rtemsq; + s1 = -15.0 * em * s4; + s5 = x1 * x3 + x2 * x4; + s6 = x2 * x3 + x1 * x4; + s7 = x2 * x4 - x1 * x3; + + /* ----------------------- do lunar terms ------------------- */ + if (lsflg == 1) + { + ss1 = s1; + ss2 = s2; + ss3 = s3; + ss4 = s4; + ss5 = s5; + ss6 = s6; + ss7 = s7; + sz1 = z1; + sz2 = z2; + sz3 = z3; + sz11 = z11; + sz12 = z12; + sz13 = z13; + sz21 = z21; + sz22 = z22; + sz23 = z23; + sz31 = z31; + sz32 = z32; + sz33 = z33; + zcosg = zcosgl; + zsing = zsingl; + zcosi = zcosil; + zsini = zsinil; + zcosh = zcoshl * cnodm + zsinhl * snodm; + zsinh = snodm * zcoshl - cnodm * zsinhl; + cc = c1l; + } + } + + zmol = fmod(4.7199672 + 0.22997150 * day - gam, twopi); + zmos = fmod(6.2565837 + 0.017201977 * day, twopi); + + /* ------------------------ do solar terms ---------------------- */ + se2 = 2.0 * ss1 * ss6; + se3 = 2.0 * ss1 * ss7; + si2 = 2.0 * ss2 * sz12; + si3 = 2.0 * ss2 * (sz13 - sz11); + sl2 = -2.0 * ss3 * sz2; + sl3 = -2.0 * ss3 * (sz3 - sz1); + sl4 = -2.0 * ss3 * (-21.0 - 9.0 * emsq) * zes; + sgh2 = 2.0 * ss4 * sz32; + sgh3 = 2.0 * ss4 * (sz33 - sz31); + sgh4 = -18.0 * ss4 * zes; + sh2 = -2.0 * ss2 * sz22; + sh3 = -2.0 * ss2 * (sz23 - sz21); + + /* ------------------------ do lunar terms ---------------------- */ + ee2 = 2.0 * s1 * s6; + e3 = 2.0 * s1 * s7; + xi2 = 2.0 * s2 * z12; + xi3 = 2.0 * s2 * (z13 - z11); + xl2 = -2.0 * s3 * z2; + xl3 = -2.0 * s3 * (z3 - z1); + xl4 = -2.0 * s3 * (-21.0 - 9.0 * emsq) * zel; + xgh2 = 2.0 * s4 * z32; + xgh3 = 2.0 * s4 * (z33 - z31); + xgh4 = -18.0 * s4 * zel; + xh2 = -2.0 * s2 * z22; + xh3 = -2.0 * s2 * (z23 - z21); + +//#include "debug2.cpp" +} // end dscom + +/*----------------------------------------------------------------------------- +* +* procedure dsinit +* +* this procedure provides deep space contributions to mean motion dot due +* to geopotential resonance with half day and one day orbits. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* cosim, sinim- +* emsq - eccentricity squared +* argpo - argument of perigee +* s1, s2, s3, s4, s5 - +* ss1, ss2, ss3, ss4, ss5 - +* sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 - +* t - time +* tc - +* gsto - greenwich sidereal time rad +* mo - mean anomaly +* mdot - mean anomaly dot (rate) +* no - mean motion +* nodeo - right ascension of ascending node +* nodedot - right ascension of ascending node dot (rate) +* xpidot - +* z1, z3, z11, z13, z21, z23, z31, z33 - +* eccm - eccentricity +* argpm - argument of perigee +* inclm - inclination +* mm - mean anomaly +* xn - mean motion +* nodem - right ascension of ascending node +* +* outputs : +* em - eccentricity +* argpm - argument of perigee +* inclm - inclination +* mm - mean anomaly +* nm - mean motion +* nodem - right ascension of ascending node +* irez - flag for resonance 0-none, 1-one day, 2-half day +* atime - +* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 - +* dedt - +* didt - +* dmdt - +* dndt - +* dnodt - +* domdt - +* del1, del2, del3 - +* ses , sghl , sghs , sgs , shl , shs , sis , sls +* theta - +* xfact - +* xlamo - +* xli - +* xni +* +* locals : +* ainv2 - +* aonv - +* cosisq - +* eoc - +* f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 - +* g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 - +* sini2 - +* temp - +* temp1 - +* theta - +* xno2 - +* +* coupling : +* getgravconst +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void dsinit + ( + gravconsttype whichconst, + double cosim, double emsq, double argpo, double s1, double s2, + double s3, double s4, double s5, double sinim, double ss1, + double ss2, double ss3, double ss4, double ss5, double sz1, + double sz3, double sz11, double sz13, double sz21, double sz23, + double sz31, double sz33, double t, double tc, double gsto, + double mo, double mdot, double no, double nodeo, double nodedot, + double xpidot, double z1, double z3, double z11, double z13, + double z21, double z23, double z31, double z33, double ecco, + double eccsq, double& em, double& argpm, double& inclm, double& mm, + double& nm, double& nodem, + int& irez, + double& atime, double& d2201, double& d2211, double& d3210, double& d3222, + double& d4410, double& d4422, double& d5220, double& d5232, double& d5421, + double& d5433, double& dedt, double& didt, double& dmdt, double& dndt, + double& dnodt, double& domdt, double& del1, double& del2, double& del3, + double& xfact, double& xlamo, double& xli, double& xni + ) +{ + /* --------------------- local variables ------------------------ */ + const double twopi = 2.0 * pi; + + double ainv2 , aonv=0.0, cosisq, eoc, f220 , f221 , f311 , + f321 , f322 , f330 , f441 , f442 , f522 , f523 , + f542 , f543 , g200 , g201 , g211 , g300 , g310 , + g322 , g410 , g422 , g520 , g521 , g532 , g533 , + ses , sgs , sghl , sghs , shs , shll , sis , + sini2 , sls , temp , temp1 , theta , xno2 , q22 , + q31 , q33 , root22, root44, root54, rptim , root32, + root52, x2o3 , xke , znl , emo , zns , emsqo, + tumin, mu, radiusearthkm, j2, j3, j4, j3oj2; + + q22 = 1.7891679e-6; + q31 = 2.1460748e-6; + q33 = 2.2123015e-7; + root22 = 1.7891679e-6; + root44 = 7.3636953e-9; + root54 = 2.1765803e-9; + rptim = 4.37526908801129966e-3; // this equates to 7.29211514668855e-5 rad/sec + root32 = 3.7393792e-7; + root52 = 1.1428639e-7; + x2o3 = 2.0 / 3.0; + znl = 1.5835218e-4; + zns = 1.19459e-5; + + // sgp4fix identify constants and allow alternate values + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + + /* -------------------- deep space initialization ------------ */ + irez = 0; + if ((nm < 0.0052359877) && (nm > 0.0034906585)) + irez = 1; + if ((nm >= 8.26e-3) && (nm <= 9.24e-3) && (em >= 0.5)) + irez = 2; + + /* ------------------------ do solar terms ------------------- */ + ses = ss1 * zns * ss5; + sis = ss2 * zns * (sz11 + sz13); + sls = -zns * ss3 * (sz1 + sz3 - 14.0 - 6.0 * emsq); + sghs = ss4 * zns * (sz31 + sz33 - 6.0); + shs = -zns * ss2 * (sz21 + sz23); + // sgp4fix for 180 deg incl + if ((inclm < 5.2359877e-2) || (inclm > pi - 5.2359877e-2)) + shs = 0.0; + if (sinim != 0.0) + shs = shs / sinim; + sgs = sghs - cosim * shs; + + /* ------------------------- do lunar terms ------------------ */ + dedt = ses + s1 * znl * s5; + didt = sis + s2 * znl * (z11 + z13); + dmdt = sls - znl * s3 * (z1 + z3 - 14.0 - 6.0 * emsq); + sghl = s4 * znl * (z31 + z33 - 6.0); + shll = -znl * s2 * (z21 + z23); + // sgp4fix for 180 deg incl + if ((inclm < 5.2359877e-2) || (inclm > pi - 5.2359877e-2)) + shll = 0.0; + domdt = sgs + sghl; + dnodt = shs; + if (sinim != 0.0) + { + domdt = domdt - cosim / sinim * shll; + dnodt = dnodt + shll / sinim; + } + + /* ----------- calculate deep space resonance effects -------- */ + dndt = 0.0; + theta = fmod(gsto + tc * rptim, twopi); + em = em + dedt * t; + inclm = inclm + didt * t; + argpm = argpm + domdt * t; + nodem = nodem + dnodt * t; + mm = mm + dmdt * t; + // sgp4fix for negative inclinations + // the following if statement should be commented out + //if (inclm < 0.0) + // { + // inclm = -inclm; + // argpm = argpm - pi; + // nodem = nodem + pi; + // } + + /* -------------- initialize the resonance terms ------------- */ + if (irez != 0) + { + aonv = pow(nm / xke, x2o3); + + /* ---------- geopotential resonance for 12 hour orbits ------ */ + if (irez == 2) + { + cosisq = cosim * cosim; + emo = em; + em = ecco; + emsqo = emsq; + emsq = eccsq; + eoc = em * emsq; + g201 = -0.306 - (em - 0.64) * 0.440; + + if (em <= 0.65) + { + g211 = 3.616 - 13.2470 * em + 16.2900 * emsq; + g310 = -19.302 + 117.3900 * em - 228.4190 * emsq + 156.5910 * eoc; + g322 = -18.9068 + 109.7927 * em - 214.6334 * emsq + 146.5816 * eoc; + g410 = -41.122 + 242.6940 * em - 471.0940 * emsq + 313.9530 * eoc; + g422 = -146.407 + 841.8800 * em - 1629.014 * emsq + 1083.4350 * eoc; + g520 = -532.114 + 3017.977 * em - 5740.032 * emsq + 3708.2760 * eoc; + } + else + { + g211 = -72.099 + 331.819 * em - 508.738 * emsq + 266.724 * eoc; + g310 = -346.844 + 1582.851 * em - 2415.925 * emsq + 1246.113 * eoc; + g322 = -342.585 + 1554.908 * em - 2366.899 * emsq + 1215.972 * eoc; + g410 = -1052.797 + 4758.686 * em - 7193.992 * emsq + 3651.957 * eoc; + g422 = -3581.690 + 16178.110 * em - 24462.770 * emsq + 12422.520 * eoc; + if (em > 0.715) + g520 =-5149.66 + 29936.92 * em - 54087.36 * emsq + 31324.56 * eoc; + else + g520 = 1464.74 - 4664.75 * em + 3763.64 * emsq; + } + if (em < 0.7) + { + g533 = -919.22770 + 4988.6100 * em - 9064.7700 * emsq + 5542.21 * eoc; + g521 = -822.71072 + 4568.6173 * em - 8491.4146 * emsq + 5337.524 * eoc; + g532 = -853.66600 + 4690.2500 * em - 8624.7700 * emsq + 5341.4 * eoc; + } + else + { + g533 =-37995.780 + 161616.52 * em - 229838.20 * emsq + 109377.94 * eoc; + g521 =-51752.104 + 218913.95 * em - 309468.16 * emsq + 146349.42 * eoc; + g532 =-40023.880 + 170470.89 * em - 242699.48 * emsq + 115605.82 * eoc; + } + + sini2= sinim * sinim; + f220 = 0.75 * (1.0 + 2.0 * cosim+cosisq); + f221 = 1.5 * sini2; + f321 = 1.875 * sinim * (1.0 - 2.0 * cosim - 3.0 * cosisq); + f322 = -1.875 * sinim * (1.0 + 2.0 * cosim - 3.0 * cosisq); + f441 = 35.0 * sini2 * f220; + f442 = 39.3750 * sini2 * sini2; + f522 = 9.84375 * sinim * (sini2 * (1.0 - 2.0 * cosim- 5.0 * cosisq) + + 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq) ); + f523 = sinim * (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + + 10.0 * cosisq) + 6.56250012 * (1.0+2.0 * cosim - 3.0 * cosisq)); + f542 = 29.53125 * sinim * (2.0 - 8.0 * cosim+cosisq * + (-12.0 + 8.0 * cosim + 10.0 * cosisq)); + f543 = 29.53125 * sinim * (-2.0 - 8.0 * cosim+cosisq * + (12.0 + 8.0 * cosim - 10.0 * cosisq)); + xno2 = nm * nm; + ainv2 = aonv * aonv; + temp1 = 3.0 * xno2 * ainv2; + temp = temp1 * root22; + d2201 = temp * f220 * g201; + d2211 = temp * f221 * g211; + temp1 = temp1 * aonv; + temp = temp1 * root32; + d3210 = temp * f321 * g310; + d3222 = temp * f322 * g322; + temp1 = temp1 * aonv; + temp = 2.0 * temp1 * root44; + d4410 = temp * f441 * g410; + d4422 = temp * f442 * g422; + temp1 = temp1 * aonv; + temp = temp1 * root52; + d5220 = temp * f522 * g520; + d5232 = temp * f523 * g532; + temp = 2.0 * temp1 * root54; + d5421 = temp * f542 * g521; + d5433 = temp * f543 * g533; + xlamo = fmod(mo + nodeo + nodeo-theta - theta, twopi); + xfact = mdot + dmdt + 2.0 * (nodedot + dnodt - rptim) - no; + em = emo; + emsq = emsqo; + } + + /* ---------------- synchronous resonance terms -------------- */ + if (irez == 1) + { + g200 = 1.0 + emsq * (-2.5 + 0.8125 * emsq); + g310 = 1.0 + 2.0 * emsq; + g300 = 1.0 + emsq * (-6.0 + 6.60937 * emsq); + f220 = 0.75 * (1.0 + cosim) * (1.0 + cosim); + f311 = 0.9375 * sinim * sinim * (1.0 + 3.0 * cosim) - 0.75 * (1.0 + cosim); + f330 = 1.0 + cosim; + f330 = 1.875 * f330 * f330 * f330; + del1 = 3.0 * nm * nm * aonv * aonv; + del2 = 2.0 * del1 * f220 * g200 * q22; + del3 = 3.0 * del1 * f330 * g300 * q33 * aonv; + del1 = del1 * f311 * g310 * q31 * aonv; + xlamo = fmod(mo + nodeo + argpo - theta, twopi); + xfact = mdot + xpidot - rptim + dmdt + domdt + dnodt - no; + } + + /* ------------ for sgp4, initialize the integrator ---------- */ + xli = xlamo; + xni = no; + atime = 0.0; + nm = no + dndt; + } + +//#include "debug3.cpp" +} // end dsinit + +/*----------------------------------------------------------------------------- +* +* procedure dspace +* +* this procedure provides deep space contributions to mean elements for +* perturbing third body. these effects have been averaged over one +* revolution of the sun and moon. for earth resonance effects, the +* effects have been averaged over no revolutions of the satellite. +* (mean motion) +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 - +* dedt - +* del1, del2, del3 - +* didt - +* dmdt - +* dnodt - +* domdt - +* irez - flag for resonance 0-none, 1-one day, 2-half day +* argpo - argument of perigee +* argpdot - argument of perigee dot (rate) +* t - time +* tc - +* gsto - gst +* xfact - +* xlamo - +* no - mean motion +* atime - +* em - eccentricity +* ft - +* argpm - argument of perigee +* inclm - inclination +* xli - +* mm - mean anomaly +* xni - mean motion +* nodem - right ascension of ascending node +* +* outputs : +* atime - +* em - eccentricity +* argpm - argument of perigee +* inclm - inclination +* xli - +* mm - mean anomaly +* xni - +* nodem - right ascension of ascending node +* dndt - +* nm - mean motion +* +* locals : +* delt - +* ft - +* theta - +* x2li - +* x2omi - +* xl - +* xldot - +* xnddt - +* xndt - +* xomi - +* +* coupling : +* none - +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void dspace + ( + int irez, + double d2201, double d2211, double d3210, double d3222, double d4410, + double d4422, double d5220, double d5232, double d5421, double d5433, + double dedt, double del1, double del2, double del3, double didt, + double dmdt, double dnodt, double domdt, double argpo, double argpdot, + double t, double tc, double gsto, double xfact, double xlamo, + double no, + double& atime, double& em, double& argpm, double& inclm, double& xli, + double& mm, double& xni, double& nodem, double& dndt, double& nm + ) +{ + const double twopi = 2.0 * pi; + int iretn , iret; + double delt, ft, theta, x2li, x2omi, xl, xldot , xnddt, xndt, xomi, g22, g32, + g44, g52, g54, fasx2, fasx4, fasx6, rptim , step2, stepn , stepp; + + fasx2 = 0.13130908; + fasx4 = 2.8843198; + fasx6 = 0.37448087; + g22 = 5.7686396; + g32 = 0.95240898; + g44 = 1.8014998; + g52 = 1.0508330; + g54 = 4.4108898; + rptim = 4.37526908801129966e-3; // this equates to 7.29211514668855e-5 rad/sec + stepp = 720.0; + stepn = -720.0; + step2 = 259200.0; + + /* ----------- calculate deep space resonance effects ----------- */ + dndt = 0.0; + theta = fmod(gsto + tc * rptim, twopi); + em = em + dedt * t; + + inclm = inclm + didt * t; + argpm = argpm + domdt * t; + nodem = nodem + dnodt * t; + mm = mm + dmdt * t; + + // sgp4fix for negative inclinations + // the following if statement should be commented out + // if (inclm < 0.0) + // { + // inclm = -inclm; + // argpm = argpm - pi; + // nodem = nodem + pi; + // } + + /* - update resonances : numerical (euler-maclaurin) integration - */ + /* ------------------------- epoch restart ---------------------- */ + // sgp4fix for propagator problems + // the following integration works for negative time steps and periods + // the specific changes are unknown because the original code was so convoluted + + // sgp4fix take out atime = 0.0 and fix for faster operation + ft = 0.0; + if (irez != 0) + { + // sgp4fix streamline check + if ((atime == 0.0) || (t * atime <= 0.0) || (fabs(t) < fabs(atime)) ) + { + atime = 0.0; + xni = no; + xli = xlamo; + } + // sgp4fix move check outside loop + if (t > 0.0) + delt = stepp; + else + delt = stepn; + + iretn = 381; // added for do loop + iret = 0; // added for loop + while (iretn == 381) + { + /* ------------------- dot terms calculated ------------- */ + /* ----------- near - synchronous resonance terms ------- */ + if (irez != 2) + { + xndt = del1 * sin(xli - fasx2) + del2 * sin(2.0 * (xli - fasx4)) + + del3 * sin(3.0 * (xli - fasx6)); + xldot = xni + xfact; + xnddt = del1 * cos(xli - fasx2) + + 2.0 * del2 * cos(2.0 * (xli - fasx4)) + + 3.0 * del3 * cos(3.0 * (xli - fasx6)); + xnddt = xnddt * xldot; + } + else + { + /* --------- near - half-day resonance terms -------- */ + xomi = argpo + argpdot * atime; + x2omi = xomi + xomi; + x2li = xli + xli; + xndt = d2201 * sin(x2omi + xli - g22) + d2211 * sin(xli - g22) + + d3210 * sin(xomi + xli - g32) + d3222 * sin(-xomi + xli - g32)+ + d4410 * sin(x2omi + x2li - g44)+ d4422 * sin(x2li - g44) + + d5220 * sin(xomi + xli - g52) + d5232 * sin(-xomi + xli - g52)+ + d5421 * sin(xomi + x2li - g54) + d5433 * sin(-xomi + x2li - g54); + xldot = xni + xfact; + xnddt = d2201 * cos(x2omi + xli - g22) + d2211 * cos(xli - g22) + + d3210 * cos(xomi + xli - g32) + d3222 * cos(-xomi + xli - g32) + + d5220 * cos(xomi + xli - g52) + d5232 * cos(-xomi + xli - g52) + + 2.0 * (d4410 * cos(x2omi + x2li - g44) + + d4422 * cos(x2li - g44) + d5421 * cos(xomi + x2li - g54) + + d5433 * cos(-xomi + x2li - g54)); + xnddt = xnddt * xldot; + } + + /* ----------------------- integrator ------------------- */ + // sgp4fix move end checks to end of routine + if (fabs(t - atime) >= stepp) + { + iret = 0; + iretn = 381; + } + else // exit here + { + ft = t - atime; + iretn = 0; + } + + if (iretn == 381) + { + xli = xli + xldot * delt + xndt * step2; + xni = xni + xndt * delt + xnddt * step2; + atime = atime + delt; + } + } // while iretn = 381 + + nm = xni + xndt * ft + xnddt * ft * ft * 0.5; + xl = xli + xldot * ft + xndt * ft * ft * 0.5; + if (irez != 1) + { + mm = xl - 2.0 * nodem + 2.0 * theta; + dndt = nm - no; + } + else + { + mm = xl - nodem - argpm + theta; + dndt = nm - no; + } + nm = no + dndt; + } + +//#include "debug4.cpp" +} // end dsspace + +/*----------------------------------------------------------------------------- +* +* procedure initl +* +* this procedure initializes the spg4 propagator. all the initialization is +* consolidated here instead of having multiple loops inside other routines. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* ecco - eccentricity 0.0 - 1.0 +* epoch - epoch time in days from jan 0, 1950. 0 hr +* inclo - inclination of satellite +* no - mean motion of satellite +* satn - satellite number +* +* outputs : +* ainv - 1.0 / a +* ao - semi major axis +* con41 - +* con42 - 1.0 - 5.0 cos(i) +* cosio - cosine of inclination +* cosio2 - cosio squared +* eccsq - eccentricity squared +* method - flag for deep space 'd', 'n' +* omeosq - 1.0 - ecco * ecco +* posq - semi-parameter squared +* rp - radius of perigee +* rteosq - square root of (1.0 - ecco*ecco) +* sinio - sine of inclination +* gsto - gst at time of observation rad +* no - mean motion of satellite +* +* locals : +* ak - +* d1 - +* del - +* adel - +* po - +* +* coupling : +* getgravconst +* gstime - find greenwich sidereal time from the julian date +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +static void initl + ( + int satn, gravconsttype whichconst, + double ecco, double epoch, double inclo, double& no, + char& method, + double& ainv, double& ao, double& con41, double& con42, double& cosio, + double& cosio2,double& eccsq, double& omeosq, double& posq, + double& rp, double& rteosq,double& sinio , double& gsto, + char opsmode + ) +{ + /* --------------------- local variables ------------------------ */ + double ak, d1, del, adel, po, x2o3, j2, xke, + tumin, mu, radiusearthkm, j3, j4, j3oj2; + + /* kill warning */ + satn = 0; + + // sgp4fix use old way of finding gst + double ds70; + double ts70, tfrac, c1, thgr70, fk5r, c1p2p; + const double twopi = 2.0 * pi; + + /* ----------------------- earth constants ---------------------- */ + // sgp4fix identify constants and allow alternate values + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + x2o3 = 2.0 / 3.0; + + /* ------------- calculate auxillary epoch quantities ---------- */ + eccsq = ecco * ecco; + omeosq = 1.0 - eccsq; + rteosq = sqrt(omeosq); + cosio = cos(inclo); + cosio2 = cosio * cosio; + + /* ------------------ un-kozai the mean motion ----------------- */ + ak = pow(xke / no, x2o3); + d1 = 0.75 * j2 * (3.0 * cosio2 - 1.0) / (rteosq * omeosq); + del = d1 / (ak * ak); + adel = ak * (1.0 - del * del - del * + (1.0 / 3.0 + 134.0 * del * del / 81.0)); + del = d1/(adel * adel); + no = no / (1.0 + del); + + ao = pow(xke / no, x2o3); + sinio = sin(inclo); + po = ao * omeosq; + con42 = 1.0 - 5.0 * cosio2; + con41 = -con42-cosio2-cosio2; + ainv = 1.0 / ao; + posq = po * po; + rp = ao * (1.0 - ecco); + method = 'n'; + + // sgp4fix modern approach to finding sidereal time + if (opsmode == 'a') + { + // sgp4fix use old way of finding gst + // count integer number of days from 0 jan 1970 + ts70 = epoch - 7305.0; + ds70 = floor(ts70 + 1.0e-8); + tfrac = ts70 - ds70; + // find greenwich location at epoch + c1 = 1.72027916940703639e-2; + thgr70= 1.7321343856509374; + fk5r = 5.07551419432269442e-15; + c1p2p = c1 + twopi; + gsto = fmod( thgr70 + c1*ds70 + c1p2p*tfrac + ts70*ts70*fk5r, twopi); + if ( gsto < 0.0 ) + gsto = gsto + twopi; + } + else + gsto = gstime(epoch + 2433281.5); + + +//#include "debug5.cpp" +} // end initl + +/*----------------------------------------------------------------------------- +* +* procedure sgp4init +* +* this procedure initializes variables for sgp4. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* opsmode - mode of operation afspc or improved 'a', 'i' +* whichconst - which set of constants to use 72, 84 +* satn - satellite number +* bstar - sgp4 type drag coefficient kg/m2er +* ecco - eccentricity +* epoch - epoch time in days from jan 0, 1950. 0 hr +* argpo - argument of perigee (output if ds) +* inclo - inclination +* mo - mean anomaly (output if ds) +* no - mean motion +* nodeo - right ascension of ascending node +* +* outputs : +* satrec - common values for subsequent calls +* return code - non-zero on error. +* 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er +* 2 - mean motion less than 0.0 +* 3 - pert elements, ecc < 0.0 or ecc > 1.0 +* 4 - semi-latus rectum < 0.0 +* 5 - epoch elements are sub-orbital +* 6 - satellite has decayed +* +* locals : +* cnodm , snodm , cosim , sinim , cosomm , sinomm +* cc1sq , cc2 , cc3 +* coef , coef1 +* cosio4 - +* day - +* dndt - +* em - eccentricity +* emsq - eccentricity squared +* eeta - +* etasq - +* gam - +* argpm - argument of perigee +* nodem - +* inclm - inclination +* mm - mean anomaly +* nm - mean motion +* perige - perigee +* pinvsq - +* psisq - +* qzms24 - +* rtemsq - +* s1, s2, s3, s4, s5, s6, s7 - +* sfour - +* ss1, ss2, ss3, ss4, ss5, ss6, ss7 - +* sz1, sz2, sz3 +* sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 - +* tc - +* temp - +* temp1, temp2, temp3 - +* tsi - +* xpidot - +* xhdot1 - +* z1, z2, z3 - +* z11, z12, z13, z21, z22, z23, z31, z32, z33 - +* +* coupling : +* getgravconst- +* initl - +* dscom - +* dpper - +* dsinit - +* sgp4 - +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +bool sgp4init + ( + gravconsttype whichconst, char opsmode, const int satn, const double epoch, + const double xbstar, const double xecco, const double xargpo, + const double xinclo, const double xmo, const double xno, + const double xnodeo, elsetrec& satrec + ) +{ + /* --------------------- local variables ------------------------ */ + double ao, ainv, con42, cosio, sinio, cosio2, eccsq, + omeosq, posq, rp, rteosq, + cnodm , snodm , cosim , sinim , cosomm, sinomm, cc1sq , + cc2 , cc3 , coef , coef1 , cosio4, day , dndt , + em , emsq , eeta , etasq , gam , argpm , nodem , + inclm , mm , nm , perige, pinvsq, psisq , qzms24, + rtemsq, s1 , s2 , s3 , s4 , s5 , s6 , + s7 , sfour , ss1 , ss2 , ss3 , ss4 , ss5 , + ss6 , ss7 , sz1 , sz2 , sz3 , sz11 , sz12 , + sz13 , sz21 , sz22 , sz23 , sz31 , sz32 , sz33 , + tc , temp , temp1 , temp2 , temp3 , tsi , xpidot, + xhdot1, z1 , z2 , z3 , z11 , z12 , z13 , + z21 , z22 , z23 , z31 , z32 , z33, + qzms2t, ss, j2, j3oj2, j4, x2o3, r[3], v[3], + tumin, mu, radiusearthkm, xke, j3; + + /* ------------------------ initialization --------------------- */ + // sgp4fix divisor for divide by zero check on inclination + // the old check used 1.0 + cos(pi-1.0e-9), but then compared it to + // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency + const double temp4 = 1.5e-12; + + /* ----------- set all near earth variables to zero ------------ */ + satrec.isimp = 0; satrec.method = 'n'; satrec.aycof = 0.0; + satrec.con41 = 0.0; satrec.cc1 = 0.0; satrec.cc4 = 0.0; + satrec.cc5 = 0.0; satrec.d2 = 0.0; satrec.d3 = 0.0; + satrec.d4 = 0.0; satrec.delmo = 0.0; satrec.eta = 0.0; + satrec.argpdot = 0.0; satrec.omgcof = 0.0; satrec.sinmao = 0.0; + satrec.t = 0.0; satrec.t2cof = 0.0; satrec.t3cof = 0.0; + satrec.t4cof = 0.0; satrec.t5cof = 0.0; satrec.x1mth2 = 0.0; + satrec.x7thm1 = 0.0; satrec.mdot = 0.0; satrec.nodedot = 0.0; + satrec.xlcof = 0.0; satrec.xmcof = 0.0; satrec.nodecf = 0.0; + + /* ----------- set all deep space variables to zero ------------ */ + satrec.irez = 0; satrec.d2201 = 0.0; satrec.d2211 = 0.0; + satrec.d3210 = 0.0; satrec.d3222 = 0.0; satrec.d4410 = 0.0; + satrec.d4422 = 0.0; satrec.d5220 = 0.0; satrec.d5232 = 0.0; + satrec.d5421 = 0.0; satrec.d5433 = 0.0; satrec.dedt = 0.0; + satrec.del1 = 0.0; satrec.del2 = 0.0; satrec.del3 = 0.0; + satrec.didt = 0.0; satrec.dmdt = 0.0; satrec.dnodt = 0.0; + satrec.domdt = 0.0; satrec.e3 = 0.0; satrec.ee2 = 0.0; + satrec.peo = 0.0; satrec.pgho = 0.0; satrec.pho = 0.0; + satrec.pinco = 0.0; satrec.plo = 0.0; satrec.se2 = 0.0; + satrec.se3 = 0.0; satrec.sgh2 = 0.0; satrec.sgh3 = 0.0; + satrec.sgh4 = 0.0; satrec.sh2 = 0.0; satrec.sh3 = 0.0; + satrec.si2 = 0.0; satrec.si3 = 0.0; satrec.sl2 = 0.0; + satrec.sl3 = 0.0; satrec.sl4 = 0.0; satrec.gsto = 0.0; + satrec.xfact = 0.0; satrec.xgh2 = 0.0; satrec.xgh3 = 0.0; + satrec.xgh4 = 0.0; satrec.xh2 = 0.0; satrec.xh3 = 0.0; + satrec.xi2 = 0.0; satrec.xi3 = 0.0; satrec.xl2 = 0.0; + satrec.xl3 = 0.0; satrec.xl4 = 0.0; satrec.xlamo = 0.0; + satrec.zmol = 0.0; satrec.zmos = 0.0; satrec.atime = 0.0; + satrec.xli = 0.0; satrec.xni = 0.0; + + // sgp4fix - note the following variables are also passed directly via satrec. + // it is possible to streamline the sgp4init call by deleting the "x" + // variables, but the user would need to set the satrec.* values first. we + // include the additional assignments in case twoline2rv is not used. + satrec.bstar = xbstar; + satrec.ecco = xecco; + satrec.argpo = xargpo; + satrec.inclo = xinclo; + satrec.mo = xmo; + satrec.no = xno; + satrec.nodeo = xnodeo; + + // sgp4fix add opsmode + satrec.operationmode = opsmode; + + /* ------------------------ earth constants ----------------------- */ + // sgp4fix identify constants and allow alternate values + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + ss = 78.0 / radiusearthkm + 1.0; + qzms2t = pow(((120.0 - 78.0) / radiusearthkm), 4); + x2o3 = 2.0 / 3.0; + + satrec.init = 'y'; + satrec.t = 0.0; + + initl + ( + satn, whichconst, satrec.ecco, epoch, satrec.inclo, satrec.no, satrec.method, + ainv, ao, satrec.con41, con42, cosio, cosio2, eccsq, omeosq, + posq, rp, rteosq, sinio, satrec.gsto, satrec.operationmode + ); + satrec.error = 0; + + // sgp4fix remove this check as it is unnecessary + // the mrt check in sgp4 handles decaying satellite cases even if the starting + // condition is below the surface of te earth +// if (rp < 1.0) +// { +// printf("# *** satn%d epoch elts sub-orbital ***\n", satn); +// satrec.error = 5; +// } + + if ((omeosq >= 0.0 ) || ( satrec.no >= 0.0)) + { + satrec.isimp = 0; + if (rp < (220.0 / radiusearthkm + 1.0)) + satrec.isimp = 1; + sfour = ss; + qzms24 = qzms2t; + perige = (rp - 1.0) * radiusearthkm; + + /* - for perigees below 156 km, s and qoms2t are altered - */ + if (perige < 156.0) + { + sfour = perige - 78.0; + if (perige < 98.0) + sfour = 20.0; + qzms24 = pow(((120.0 - sfour) / radiusearthkm), 4.0); + sfour = sfour / radiusearthkm + 1.0; + } + pinvsq = 1.0 / posq; + + tsi = 1.0 / (ao - sfour); + satrec.eta = ao * satrec.ecco * tsi; + etasq = satrec.eta * satrec.eta; + eeta = satrec.ecco * satrec.eta; + psisq = fabs(1.0 - etasq); + coef = qzms24 * pow(tsi, 4.0); + coef1 = coef / pow(psisq, 3.5); + cc2 = coef1 * satrec.no * (ao * (1.0 + 1.5 * etasq + eeta * + (4.0 + etasq)) + 0.375 * j2 * tsi / psisq * satrec.con41 * + (8.0 + 3.0 * etasq * (8.0 + etasq))); + satrec.cc1 = satrec.bstar * cc2; + cc3 = 0.0; + if (satrec.ecco > 1.0e-4) + cc3 = -2.0 * coef * tsi * j3oj2 * satrec.no * sinio / satrec.ecco; + satrec.x1mth2 = 1.0 - cosio2; + satrec.cc4 = 2.0* satrec.no * coef1 * ao * omeosq * + (satrec.eta * (2.0 + 0.5 * etasq) + satrec.ecco * + (0.5 + 2.0 * etasq) - j2 * tsi / (ao * psisq) * + (-3.0 * satrec.con41 * (1.0 - 2.0 * eeta + etasq * + (1.5 - 0.5 * eeta)) + 0.75 * satrec.x1mth2 * + (2.0 * etasq - eeta * (1.0 + etasq)) * cos(2.0 * satrec.argpo))); + satrec.cc5 = 2.0 * coef1 * ao * omeosq * (1.0 + 2.75 * + (etasq + eeta) + eeta * etasq); + cosio4 = cosio2 * cosio2; + temp1 = 1.5 * j2 * pinvsq * satrec.no; + temp2 = 0.5 * temp1 * j2 * pinvsq; + temp3 = -0.46875 * j4 * pinvsq * pinvsq * satrec.no; + satrec.mdot = satrec.no + 0.5 * temp1 * rteosq * satrec.con41 + 0.0625 * + temp2 * rteosq * (13.0 - 78.0 * cosio2 + 137.0 * cosio4); + satrec.argpdot = -0.5 * temp1 * con42 + 0.0625 * temp2 * + (7.0 - 114.0 * cosio2 + 395.0 * cosio4) + + temp3 * (3.0 - 36.0 * cosio2 + 49.0 * cosio4); + xhdot1 = -temp1 * cosio; + satrec.nodedot = xhdot1 + (0.5 * temp2 * (4.0 - 19.0 * cosio2) + + 2.0 * temp3 * (3.0 - 7.0 * cosio2)) * cosio; + xpidot = satrec.argpdot+ satrec.nodedot; + satrec.omgcof = satrec.bstar * cc3 * cos(satrec.argpo); + satrec.xmcof = 0.0; + if (satrec.ecco > 1.0e-4) + satrec.xmcof = -x2o3 * coef * satrec.bstar / eeta; + satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1; + satrec.t2cof = 1.5 * satrec.cc1; + // sgp4fix for divide by zero with xinco = 180 deg + if (fabs(cosio+1.0) > 1.5e-12) + satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / (1.0 + cosio); + else + satrec.xlcof = -0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio) / temp4; + satrec.aycof = -0.5 * j3oj2 * sinio; + satrec.delmo = pow((1.0 + satrec.eta * cos(satrec.mo)), 3); + satrec.sinmao = sin(satrec.mo); + satrec.x7thm1 = 7.0 * cosio2 - 1.0; + + /* --------------- deep space initialization ------------- */ + if ((2*pi / satrec.no) >= 225.0) + { + satrec.method = 'd'; + satrec.isimp = 1; + tc = 0.0; + inclm = satrec.inclo; + + dscom + ( + epoch, satrec.ecco, satrec.argpo, tc, satrec.inclo, satrec.nodeo, + satrec.no, snodm, cnodm, sinim, cosim,sinomm, cosomm, + day, satrec.e3, satrec.ee2, em, emsq, gam, + satrec.peo, satrec.pgho, satrec.pho, satrec.pinco, + satrec.plo, rtemsq, satrec.se2, satrec.se3, + satrec.sgh2, satrec.sgh3, satrec.sgh4, + satrec.sh2, satrec.sh3, satrec.si2, satrec.si3, + satrec.sl2, satrec.sl3, satrec.sl4, s1, s2, s3, s4, s5, + s6, s7, ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3, + sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33, + satrec.xgh2, satrec.xgh3, satrec.xgh4, satrec.xh2, + satrec.xh3, satrec.xi2, satrec.xi3, satrec.xl2, + satrec.xl3, satrec.xl4, nm, z1, z2, z3, z11, + z12, z13, z21, z22, z23, z31, z32, z33, + satrec.zmol, satrec.zmos + ); + dpper + ( + satrec.e3, satrec.ee2, satrec.peo, satrec.pgho, + satrec.pho, satrec.pinco, satrec.plo, satrec.se2, + satrec.se3, satrec.sgh2, satrec.sgh3, satrec.sgh4, + satrec.sh2, satrec.sh3, satrec.si2, satrec.si3, + satrec.sl2, satrec.sl3, satrec.sl4, satrec.t, + satrec.xgh2,satrec.xgh3,satrec.xgh4, satrec.xh2, + satrec.xh3, satrec.xi2, satrec.xi3, satrec.xl2, + satrec.xl3, satrec.xl4, satrec.zmol, satrec.zmos, inclm, satrec.init, + satrec.ecco, satrec.inclo, satrec.nodeo, satrec.argpo, satrec.mo, + satrec.operationmode + ); + + argpm = 0.0; + nodem = 0.0; + mm = 0.0; + + dsinit + ( + whichconst, + cosim, emsq, satrec.argpo, s1, s2, s3, s4, s5, sinim, ss1, ss2, ss3, ss4, + ss5, sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33, satrec.t, tc, + satrec.gsto, satrec.mo, satrec.mdot, satrec.no, satrec.nodeo, + satrec.nodedot, xpidot, z1, z3, z11, z13, z21, z23, z31, z33, + satrec.ecco, eccsq, em, argpm, inclm, mm, nm, nodem, + satrec.irez, satrec.atime, + satrec.d2201, satrec.d2211, satrec.d3210, satrec.d3222 , + satrec.d4410, satrec.d4422, satrec.d5220, satrec.d5232, + satrec.d5421, satrec.d5433, satrec.dedt, satrec.didt, + satrec.dmdt, dndt, satrec.dnodt, satrec.domdt , + satrec.del1, satrec.del2, satrec.del3, satrec.xfact, + satrec.xlamo, satrec.xli, satrec.xni + ); + } + + /* ----------- set variables if not deep space ----------- */ + if (satrec.isimp != 1) + { + cc1sq = satrec.cc1 * satrec.cc1; + satrec.d2 = 4.0 * ao * tsi * cc1sq; + temp = satrec.d2 * tsi * satrec.cc1 / 3.0; + satrec.d3 = (17.0 * ao + sfour) * temp; + satrec.d4 = 0.5 * temp * ao * tsi * (221.0 * ao + 31.0 * sfour) * + satrec.cc1; + satrec.t3cof = satrec.d2 + 2.0 * cc1sq; + satrec.t4cof = 0.25 * (3.0 * satrec.d3 + satrec.cc1 * + (12.0 * satrec.d2 + 10.0 * cc1sq)); + satrec.t5cof = 0.2 * (3.0 * satrec.d4 + + 12.0 * satrec.cc1 * satrec.d3 + + 6.0 * satrec.d2 * satrec.d2 + + 15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq)); + } + } // if omeosq = 0 ... + + /* finally propogate to zero epoch to initialize all others. */ + // sgp4fix take out check to let satellites process until they are actually below earth surface +// if(satrec.error == 0) + sgp4(whichconst, satrec, 0.0, r, v); + + satrec.init = 'n'; + +//#include "debug6.cpp" + //sgp4fix return boolean. satrec.error contains any error codes + return true; +} // end sgp4init + +/*----------------------------------------------------------------------------- +* +* procedure sgp4 +* +* this procedure is the sgp4 prediction model from space command. this is an +* updated and combined version of sgp4 and sdp4, which were originally +* published separately in spacetrack report #3. this version follows the +* methodology from the aiaa paper (2006) describing the history and +* development of the code. +* +* author : david vallado 719-573-2600 28 jun 2005 +* +* inputs : +* satrec - initialised structure from sgp4init() call. +* tsince - time eince epoch (minutes) +* +* outputs : +* r - position vector km +* v - velocity km/sec +* return code - non-zero on error. +* 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er +* 2 - mean motion less than 0.0 +* 3 - pert elements, ecc < 0.0 or ecc > 1.0 +* 4 - semi-latus rectum < 0.0 +* 5 - epoch elements are sub-orbital +* 6 - satellite has decayed +* +* locals : +* am - +* axnl, aynl - +* betal - +* cosim , sinim , cosomm , sinomm , cnod , snod , cos2u , +* sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip , +* cosisq , cossu , sinsu , cosu , sinu +* delm - +* delomg - +* dndt - +* eccm - +* emsq - +* ecose - +* el2 - +* eo1 - +* eccp - +* esine - +* argpm - +* argpp - +* omgadf - +* pl - +* r - +* rtemsq - +* rdotl - +* rl - +* rvdot - +* rvdotl - +* su - +* t2 , t3 , t4 , tc +* tem5, temp , temp1 , temp2 , tempa , tempe , templ +* u , ux , uy , uz , vx , vy , vz +* inclm - inclination +* mm - mean anomaly +* nm - mean motion +* nodem - right asc of ascending node +* xinc - +* xincp - +* xl - +* xlm - +* mp - +* xmdf - +* xmx - +* xmy - +* nodedf - +* xnode - +* nodep - +* np - +* +* coupling : +* getgravconst- +* dpper +* dpspace +* +* references : +* hoots, roehrich, norad spacetrack report #3 1980 +* hoots, norad spacetrack report #6 1986 +* hoots, schumacher and glover 2004 +* vallado, crawford, hujsak, kelso 2006 + ----------------------------------------------------------------------------*/ + +bool sgp4 + ( + gravconsttype whichconst, elsetrec& satrec, double tsince, + double r[3], double v[3] + ) +{ + double am , axnl , aynl , betal , cosim , cnod , + cos2u, coseo1, cosi , cosip , cosisq, cossu , cosu, + delm , delomg, em , emsq , ecose , el2 , eo1 , + ep , esine , argpm, argpp , argpdf, pl, mrt = 0.0, + mvt , rdotl , rl , rvdot , rvdotl, sinim , + sin2u, sineo1, sini , sinip , sinsu , sinu , + snod , su , t2 , t3 , t4 , tem5 , temp, + temp1, temp2 , tempa, tempe , templ , u , ux , + uy , uz , vx , vy , vz , inclm , mm , + nm , nodem, xinc , xincp , xl , xlm , mp , + xmdf , xmx , xmy , nodedf, xnode , nodep, tc , dndt, + twopi, x2o3 , j2 , j3 , tumin, j4 , xke , j3oj2, radiusearthkm, + mu, vkmpersec; + int ktr; + + /* ------------------ set mathematical constants --------------- */ + // sgp4fix divisor for divide by zero check on inclination + // the old check used 1.0 + cos(pi-1.0e-9), but then compared it to + // 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency + const double temp4 = 1.5e-12; + twopi = 2.0 * pi; + x2o3 = 2.0 / 3.0; + // sgp4fix identify constants and allow alternate values + getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 ); + vkmpersec = radiusearthkm * xke/60.0; + + /* --------------------- clear sgp4 error flag ----------------- */ + satrec.t = tsince; + satrec.error = 0; + + /* ------- update for secular gravity and atmospheric drag ----- */ + xmdf = satrec.mo + satrec.mdot * satrec.t; + argpdf = satrec.argpo + satrec.argpdot * satrec.t; + nodedf = satrec.nodeo + satrec.nodedot * satrec.t; + argpm = argpdf; + mm = xmdf; + t2 = satrec.t * satrec.t; + nodem = nodedf + satrec.nodecf * t2; + tempa = 1.0 - satrec.cc1 * satrec.t; + tempe = satrec.bstar * satrec.cc4 * satrec.t; + templ = satrec.t2cof * t2; + + if (satrec.isimp != 1) + { + delomg = satrec.omgcof * satrec.t; + delm = satrec.xmcof * + (pow((1.0 + satrec.eta * cos(xmdf)), 3) - + satrec.delmo); + temp = delomg + delm; + mm = xmdf + temp; + argpm = argpdf - temp; + t3 = t2 * satrec.t; + t4 = t3 * satrec.t; + tempa = tempa - satrec.d2 * t2 - satrec.d3 * t3 - + satrec.d4 * t4; + tempe = tempe + satrec.bstar * satrec.cc5 * (sin(mm) - + satrec.sinmao); + templ = templ + satrec.t3cof * t3 + t4 * (satrec.t4cof + + satrec.t * satrec.t5cof); + } + + nm = satrec.no; + em = satrec.ecco; + inclm = satrec.inclo; + if (satrec.method == 'd') + { + tc = satrec.t; + dspace + ( + satrec.irez, + satrec.d2201, satrec.d2211, satrec.d3210, + satrec.d3222, satrec.d4410, satrec.d4422, + satrec.d5220, satrec.d5232, satrec.d5421, + satrec.d5433, satrec.dedt, satrec.del1, + satrec.del2, satrec.del3, satrec.didt, + satrec.dmdt, satrec.dnodt, satrec.domdt, + satrec.argpo, satrec.argpdot, satrec.t, tc, + satrec.gsto, satrec.xfact, satrec.xlamo, + satrec.no, satrec.atime, + em, argpm, inclm, satrec.xli, mm, satrec.xni, + nodem, dndt, nm + ); + } // if method = d + + if (nm <= 0.0) + { +// printf("# error nm %f\n", nm); + satrec.error = 2; + // sgp4fix add return + return false; + } + am = pow((xke / nm),x2o3) * tempa * tempa; + nm = xke / pow(am, 1.5); + em = em - tempe; + + // fix tolerance for error recognition + // sgp4fix am is fixed from the previous nm check + if ((em >= 1.0) || (em < -0.001)/* || (am < 0.95)*/ ) + { +// printf("# error em %f\n", em); + satrec.error = 1; + // sgp4fix to return if there is an error in eccentricity + return false; + } + // sgp4fix fix tolerance to avoid a divide by zero + if (em < 1.0e-6) + em = 1.0e-6; + mm = mm + satrec.no * templ; + xlm = mm + argpm + nodem; + emsq = em * em; + temp = 1.0 - emsq; + + nodem = fmod(nodem, twopi); + argpm = fmod(argpm, twopi); + xlm = fmod(xlm, twopi); + mm = fmod(xlm - argpm - nodem, twopi); + + /* ----------------- compute extra mean quantities ------------- */ + sinim = sin(inclm); + cosim = cos(inclm); + + /* -------------------- add lunar-solar periodics -------------- */ + ep = em; + xincp = inclm; + argpp = argpm; + nodep = nodem; + mp = mm; + sinip = sinim; + cosip = cosim; + if (satrec.method == 'd') + { + dpper + ( + satrec.e3, satrec.ee2, satrec.peo, + satrec.pgho, satrec.pho, satrec.pinco, + satrec.plo, satrec.se2, satrec.se3, + satrec.sgh2, satrec.sgh3, satrec.sgh4, + satrec.sh2, satrec.sh3, satrec.si2, + satrec.si3, satrec.sl2, satrec.sl3, + satrec.sl4, satrec.t, satrec.xgh2, + satrec.xgh3, satrec.xgh4, satrec.xh2, + satrec.xh3, satrec.xi2, satrec.xi3, + satrec.xl2, satrec.xl3, satrec.xl4, + satrec.zmol, satrec.zmos, satrec.inclo, + 'n', ep, xincp, nodep, argpp, mp, satrec.operationmode + ); + if (xincp < 0.0) + { + xincp = -xincp; + nodep = nodep + pi; + argpp = argpp - pi; + } + if ((ep < 0.0 ) || ( ep > 1.0)) + { +// printf("# error ep %f\n", ep); + satrec.error = 3; + // sgp4fix add return + return false; + } + } // if method = d + + /* -------------------- long period periodics ------------------ */ + if (satrec.method == 'd') + { + sinip = sin(xincp); + cosip = cos(xincp); + satrec.aycof = -0.5*j3oj2*sinip; + // sgp4fix for divide by zero for xincp = 180 deg + if (fabs(cosip+1.0) > 1.5e-12) + satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / (1.0 + cosip); + else + satrec.xlcof = -0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip) / temp4; + } + axnl = ep * cos(argpp); + temp = 1.0 / (am * (1.0 - ep * ep)); + aynl = ep* sin(argpp) + temp * satrec.aycof; + xl = mp + argpp + nodep + temp * satrec.xlcof * axnl; + + /* --------------------- solve kepler's equation --------------- */ + u = fmod(xl - nodep, twopi); + eo1 = u; + tem5 = 9999.9; + ktr = 1; + // sgp4fix for kepler iteration + // the following iteration needs better limits on corrections + while (( fabs(tem5) >= 1.0e-12) && (ktr <= 10) ) + { + sineo1 = sin(eo1); + coseo1 = cos(eo1); + tem5 = 1.0 - coseo1 * axnl - sineo1 * aynl; + tem5 = (u - aynl * coseo1 + axnl * sineo1 - eo1) / tem5; + if(fabs(tem5) >= 0.95) + tem5 = tem5 > 0.0 ? 0.95 : -0.95; + eo1 = eo1 + tem5; + ktr = ktr + 1; + } + + /* ------------- short period preliminary quantities ----------- */ + ecose = axnl*coseo1 + aynl*sineo1; + esine = axnl*sineo1 - aynl*coseo1; + el2 = axnl*axnl + aynl*aynl; + pl = am*(1.0-el2); + if (pl < 0.0) + { +// printf("# error pl %f\n", pl); + satrec.error = 4; + // sgp4fix add return + return false; + } + else + { + rl = am * (1.0 - ecose); + rdotl = sqrt(am) * esine/rl; + rvdotl = sqrt(pl) / rl; + betal = sqrt(1.0 - el2); + temp = esine / (1.0 + betal); + sinu = am / rl * (sineo1 - aynl - axnl * temp); + cosu = am / rl * (coseo1 - axnl + aynl * temp); + su = atan2(sinu, cosu); + sin2u = (cosu + cosu) * sinu; + cos2u = 1.0 - 2.0 * sinu * sinu; + temp = 1.0 / pl; + temp1 = 0.5 * j2 * temp; + temp2 = temp1 * temp; + + /* -------------- update for short period periodics ------------ */ + if (satrec.method == 'd') + { + cosisq = cosip * cosip; + satrec.con41 = 3.0*cosisq - 1.0; + satrec.x1mth2 = 1.0 - cosisq; + satrec.x7thm1 = 7.0*cosisq - 1.0; + } + mrt = rl * (1.0 - 1.5 * temp2 * betal * satrec.con41) + + 0.5 * temp1 * satrec.x1mth2 * cos2u; + su = su - 0.25 * temp2 * satrec.x7thm1 * sin2u; + xnode = nodep + 1.5 * temp2 * cosip * sin2u; + xinc = xincp + 1.5 * temp2 * cosip * sinip * cos2u; + mvt = rdotl - nm * temp1 * satrec.x1mth2 * sin2u / xke; + rvdot = rvdotl + nm * temp1 * (satrec.x1mth2 * cos2u + + 1.5 * satrec.con41) / xke; + + /* --------------------- orientation vectors ------------------- */ + sinsu = sin(su); + cossu = cos(su); + snod = sin(xnode); + cnod = cos(xnode); + sini = sin(xinc); + cosi = cos(xinc); + xmx = -snod * cosi; + xmy = cnod * cosi; + ux = xmx * sinsu + cnod * cossu; + uy = xmy * sinsu + snod * cossu; + uz = sini * sinsu; + vx = xmx * cossu - cnod * sinsu; + vy = xmy * cossu - snod * sinsu; + vz = sini * cossu; + + /* --------- position and velocity (in km and km/sec) ---------- */ + r[0] = (mrt * ux)* radiusearthkm; + r[1] = (mrt * uy)* radiusearthkm; + r[2] = (mrt * uz)* radiusearthkm; + v[0] = (mvt * ux + rvdot * vx) * vkmpersec; + v[1] = (mvt * uy + rvdot * vy) * vkmpersec; + v[2] = (mvt * uz + rvdot * vz) * vkmpersec; + } // if pl > 0 + + // sgp4fix for decaying satellites + if (mrt < 1.0) + { +// printf("# decay condition %11.6f \n",mrt); + satrec.error = 6; + return false; + } + +//#include "debug7.cpp" + return true; +} // end sgp4 + + +/* ----------------------------------------------------------------------------- +* +* function gstime +* +* this function finds the greenwich sidereal time. +* +* author : david vallado 719-573-2600 1 mar 2001 +* +* inputs description range / units +* jdut1 - julian date in ut1 days from 4713 bc +* +* outputs : +* gstime - greenwich sidereal time 0 to 2pi rad +* +* locals : +* temp - temporary variable for doubles rad +* tut1 - julian centuries from the +* jan 1, 2000 12 h epoch (ut1) +* +* coupling : +* none +* +* references : +* vallado 2004, 191, eq 3-45 +* --------------------------------------------------------------------------- */ + +double gstime + ( + double jdut1 + ) + { + const double twopi = 2.0 * pi; + const double deg2rad = pi / 180.0; + double temp, tut1; + + tut1 = (jdut1 - 2451545.0) / 36525.0; + temp = -6.2e-6* tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + + (876600.0*3600 + 8640184.812866) * tut1 + 67310.54841; // sec + temp = fmod(temp * deg2rad / 240.0, twopi); //360/86400 = 1/240, to deg, to rad + + // ------------------------ check quadrants --------------------- + if (temp < 0.0) + temp += twopi; + + return temp; + } // end gstime + +/* ----------------------------------------------------------------------------- +* +* function getgravconst +* +* this function gets constants for the propagator. note that mu is identified to +* facilitiate comparisons with newer models. the common useage is wgs72. +* +* author : david vallado 719-573-2600 21 jul 2006 +* +* inputs : +* whichconst - which set of constants to use wgs72old, wgs72, wgs84 +* +* outputs : +* tumin - minutes in one time unit +* mu - earth gravitational parameter +* radiusearthkm - radius of the earth in km +* xke - reciprocal of tumin +* j2, j3, j4 - un-normalized zonal harmonic values +* j3oj2 - j3 divided by j2 +* +* locals : +* +* coupling : +* none +* +* references : +* norad spacetrack report #3 +* vallado, crawford, hujsak, kelso 2006 + --------------------------------------------------------------------------- */ + +void getgravconst + ( + gravconsttype whichconst, + double& tumin, + double& mu, + double& radiusearthkm, + double& xke, + double& j2, + double& j3, + double& j4, + double& j3oj2 + ) + { + + switch (whichconst) + { + // -- wgs-72 low precision str#3 constants -- + case wgs72old: + mu = 398600.79964; // in km3 / s2 + radiusearthkm = 6378.135; // km + xke = 0.0743669161; + tumin = 1.0 / xke; + j2 = 0.001082616; + j3 = -0.00000253881; + j4 = -0.00000165597; + j3oj2 = j3 / j2; + break; + // ------------ wgs-72 constants ------------ + case wgs72: + mu = 398600.8; // in km3 / s2 + radiusearthkm = 6378.135; // km + xke = 60.0 / sqrt(radiusearthkm*radiusearthkm*radiusearthkm/mu); + tumin = 1.0 / xke; + j2 = 0.001082616; + j3 = -0.00000253881; + j4 = -0.00000165597; + j3oj2 = j3 / j2; + break; + case wgs84: + // ------------ wgs-84 constants ------------ + mu = 398600.5; // in km3 / s2 + radiusearthkm = 6378.137; // km + xke = 60.0 / sqrt(radiusearthkm*radiusearthkm*radiusearthkm/mu); + tumin = 1.0 / xke; + j2 = 0.00108262998905; + j3 = -0.00000253215306; + j4 = -0.00000161098761; + j3oj2 = j3 / j2; + break; + default: + fprintf(stderr,"unknown gravity option (%d)\n",whichconst); + break; + } + + } // end getgravconst + + + + + diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.h similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.h index 9de25e4..5d71430 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4unit.h +++ b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/sgp4unit.h @@ -1,126 +1,126 @@ -#ifndef _sgp4unit_ -#define _sgp4unit_ -/* ---------------------------------------------------------------- -* -* sgp4unit.h -* -* this file contains the sgp4 procedures for analytical propagation -* of a satellite. the code was originally released in the 1980 and 1986 -* spacetrack papers. a detailed discussion of the theory and history -* may be found in the 2006 aiaa paper by vallado, crawford, hujsak, -* and kelso. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 3 Nov 08 david vallado -* put returns in for error codes -* changes : -* 29 sep 08 david vallado -* fix atime for faster operation in dspace -* add operationmode for afspc (a) or improved (i) -* performance mode -* 20 apr 07 david vallado -* misc fixes for constants -* 11 aug 06 david vallado -* chg lyddane choice back to strn3, constants, misc doc -* 15 dec 05 david vallado -* misc fixes -* 26 jul 05 david vallado -* fixes for paper -* note that each fix is preceded by a -* comment with "sgp4fix" and an explanation of -* what was changed -* 10 aug 04 david vallado -* 2nd printing baseline working -* 14 may 01 david vallado -* 2nd edition baseline -* 80 norad -* original baseline -* ---------------------------------------------------------------- */ - -#include -#include -#define SGP4Version "SGP4 Version 2008-11-03" - -#define pi 3.14159265358979323846 - -// -------------------------- structure declarations ---------------------------- -typedef enum -{ - wgs72old, - wgs72, - wgs84 -} gravconsttype; - -typedef struct elsetrec -{ - long int satnum; - int epochyr, epochtynumrev; - int error; - char operationmode; - char init, method; - - /* Near Earth */ - int isimp; - double aycof , con41 , cc1 , cc4 , cc5 , d2 , d3 , d4 , - delmo , eta , argpdot, omgcof , sinmao , t , t2cof, t3cof , - t4cof , t5cof , x1mth2 , x7thm1 , mdot , nodedot, xlcof , xmcof , - nodecf; - - /* Deep Space */ - int irez; - double d2201 , d2211 , d3210 , d3222 , d4410 , d4422 , d5220 , d5232 , - d5421 , d5433 , dedt , del1 , del2 , del3 , didt , dmdt , - dnodt , domdt , e3 , ee2 , peo , pgho , pho , pinco , - plo , se2 , se3 , sgh2 , sgh3 , sgh4 , sh2 , sh3 , - si2 , si3 , sl2 , sl3 , sl4 , gsto , xfact , xgh2 , - xgh3 , xgh4 , xh2 , xh3 , xi2 , xi3 , xl2 , xl3 , - xl4 , xlamo , zmol , zmos , atime , xli , xni; - - double a , altp , alta , epochdays, jdsatepoch , nddot , ndot , - bstar , rcse , inclo , nodeo , ecco , argpo , mo , - no; -} elsetrec; - - -// --------------------------- function declarations ---------------------------- -bool sgp4init - ( - gravconsttype whichconst, char opsmode, const int satn, const double epoch, - const double xbstar, const double xecco, const double xargpo, - const double xinclo, const double xmo, const double xno, - const double xnodeo, elsetrec& satrec - ); - -bool sgp4 - ( - gravconsttype whichconst, elsetrec& satrec, double tsince, - double r[3], double v[3] - ); - -double gstime - ( - double jdut1 - ); - -void getgravconst - ( - gravconsttype whichconst, - double& tumin, - double& mu, - double& radiusearthkm, - double& xke, - double& j2, - double& j3, - double& j4, - double& j3oj2 - ); - -#endif - +#ifndef _sgp4unit_ +#define _sgp4unit_ +/* ---------------------------------------------------------------- +* +* sgp4unit.h +* +* this file contains the sgp4 procedures for analytical propagation +* of a satellite. the code was originally released in the 1980 and 1986 +* spacetrack papers. a detailed discussion of the theory and history +* may be found in the 2006 aiaa paper by vallado, crawford, hujsak, +* and kelso. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 3 Nov 08 david vallado +* put returns in for error codes +* changes : +* 29 sep 08 david vallado +* fix atime for faster operation in dspace +* add operationmode for afspc (a) or improved (i) +* performance mode +* 20 apr 07 david vallado +* misc fixes for constants +* 11 aug 06 david vallado +* chg lyddane choice back to strn3, constants, misc doc +* 15 dec 05 david vallado +* misc fixes +* 26 jul 05 david vallado +* fixes for paper +* note that each fix is preceded by a +* comment with "sgp4fix" and an explanation of +* what was changed +* 10 aug 04 david vallado +* 2nd printing baseline working +* 14 may 01 david vallado +* 2nd edition baseline +* 80 norad +* original baseline +* ---------------------------------------------------------------- */ + +#include +#include +#define SGP4Version "SGP4 Version 2008-11-03" + +#define pi 3.14159265358979323846 + +// -------------------------- structure declarations ---------------------------- +typedef enum +{ + wgs72old, + wgs72, + wgs84 +} gravconsttype; + +typedef struct elsetrec +{ + long int satnum; + int epochyr, epochtynumrev; + int error; + char operationmode; + char init, method; + + /* Near Earth */ + int isimp; + double aycof , con41 , cc1 , cc4 , cc5 , d2 , d3 , d4 , + delmo , eta , argpdot, omgcof , sinmao , t , t2cof, t3cof , + t4cof , t5cof , x1mth2 , x7thm1 , mdot , nodedot, xlcof , xmcof , + nodecf; + + /* Deep Space */ + int irez; + double d2201 , d2211 , d3210 , d3222 , d4410 , d4422 , d5220 , d5232 , + d5421 , d5433 , dedt , del1 , del2 , del3 , didt , dmdt , + dnodt , domdt , e3 , ee2 , peo , pgho , pho , pinco , + plo , se2 , se3 , sgh2 , sgh3 , sgh4 , sh2 , sh3 , + si2 , si3 , sl2 , sl3 , sl4 , gsto , xfact , xgh2 , + xgh3 , xgh4 , xh2 , xh3 , xi2 , xi3 , xl2 , xl3 , + xl4 , xlamo , zmol , zmos , atime , xli , xni; + + double a , altp , alta , epochdays, jdsatepoch , nddot , ndot , + bstar , rcse , inclo , nodeo , ecco , argpo , mo , + no; +} elsetrec; + + +// --------------------------- function declarations ---------------------------- +bool sgp4init + ( + gravconsttype whichconst, char opsmode, const int satn, const double epoch, + const double xbstar, const double xecco, const double xargpo, + const double xinclo, const double xmo, const double xno, + const double xnodeo, elsetrec& satrec + ); + +bool sgp4 + ( + gravconsttype whichconst, elsetrec& satrec, double tsince, + double r[3], double v[3] + ); + +double gstime + ( + double jdut1 + ); + +void getgravconst + ( + gravconsttype whichconst, + double& tumin, + double& mu, + double& radiusearthkm, + double& xke, + double& j2, + double& j3, + double& j4, + double& j3oj2 + ); + +#endif + diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/solarProcedures.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/solarProcedures.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/solarProcedures.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/solarProcedures.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/solarProcedures.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/solarProcedures.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/solarProcedures.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/solarProcedures.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/stdsat.h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/stdsat.h similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/stdsat.h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/src/stdsat.h diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/templates/cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/templates/cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/templates/cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/templates/cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/templates/h b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/templates/h similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/templates/h rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/templates/h diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gMatrix_Runner.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gMatrix_Runner.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gMatrix_Runner.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gMatrix_Runner.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gMatrix_Test.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gMatrix_Test.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gMatrix_Test.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gMatrix_Test.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gObserver_Runner.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gObserver_Runner.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gObserver_Runner.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gObserver_Runner.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gObserver_Test.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gObserver_Test.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gObserver_Test.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gObserver_Test.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatTEME0005_Test.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatTEME0005_Test.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatTEME0005_Test.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatTEME0005_Test.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatTEME_Runner.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatTEME_Runner.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatTEME_Runner.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatTEME_Runner.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatVisibility_Runner.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatVisibility_Runner.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatVisibility_Runner.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatVisibility_Runner.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatVisibility_Test.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatVisibility_Test.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatVisibility_Test.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gSatVisibility_Test.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gTime_Runner.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gTime_Runner.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gTime_Runner.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gTime_Runner.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gTime_Test.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gTime_Test.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gTime_Test.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11/test/gTime_Test.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/372020.x b/Misc/FOSSASatTracker/FOSSASatTracker/src/372020.x similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/372020.x rename to Misc/FOSSASatTracker/FOSSASatTracker/src/372020.x diff --git a/FOSSASatTracker/FOSSASatTracker/src/ObserverInformation.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/ObserverInformation.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/ObserverInformation.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/ObserverInformation.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/ObserverInformation.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/ObserverInformation.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/ObserverInformation.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/ObserverInformation.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/SatelliteInformation.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/SatelliteInformation.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/SatelliteInformation.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/SatelliteInformation.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/SatelliteInformation.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/SatelliteInformation.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/SatelliteInformation.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/SatelliteInformation.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/SatelliteSimulation.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/SatelliteSimulation.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/SatelliteSimulation.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/SatelliteSimulation.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/SatelliteSimulation.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/SatelliteSimulation.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/SatelliteSimulation.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/SatelliteSimulation.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/SimulationResult.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/SimulationResult.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/SimulationResult.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/SimulationResult.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/SimulationResult.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/SimulationResult.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/SimulationResult.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/SimulationResult.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/TLE.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/TLE.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/TLE.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/TLE.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/TLE.hpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/TLE.hpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/TLE.hpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/TLE.hpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/main.cpp b/Misc/FOSSASatTracker/FOSSASatTracker/src/main.cpp similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/main.cpp rename to Misc/FOSSASatTracker/FOSSASatTracker/src/main.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/src/sunpos.x b/Misc/FOSSASatTracker/FOSSASatTracker/src/sunpos.x similarity index 100% rename from FOSSASatTracker/FOSSASatTracker/src/sunpos.x rename to Misc/FOSSASatTracker/FOSSASatTracker/src/sunpos.x diff --git a/FOSSASatTracker/SGP4_experiments/AIAA-2006-6753-Rev2.pdf b/Misc/FOSSASatTracker/SGP4_experiments/AIAA-2006-6753-Rev2.pdf similarity index 100% rename from FOSSASatTracker/SGP4_experiments/AIAA-2006-6753-Rev2.pdf rename to Misc/FOSSASatTracker/SGP4_experiments/AIAA-2006-6753-Rev2.pdf diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/SGP4-VER.TLE b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/SGP4-VER.TLE similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/SGP4-VER.TLE rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/SGP4-VER.TLE diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug1.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug1.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug1.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug1.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug2.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug2.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug2.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug2.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug3.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug3.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug3.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug3.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug4.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug4.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug4.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug4.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug5.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug5.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug5.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug5.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug6.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug6.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug6.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug6.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug7.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug7.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug7.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/debug7.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.h b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.h similarity index 95% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.h rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.h index 593f498..7967bcc 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4ext.h +++ b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4ext.h @@ -1,97 +1,97 @@ -#ifndef _sgp4ext_ -#define _sgp4ext_ -/* ---------------------------------------------------------------- -* -* sgp4ext.h -* -* this file contains extra routines needed for the main test program for sgp4. -* these routines are derived from the astro libraries. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 20 apr 07 david vallado -* misc documentation updates -* changes : -* 14 aug 06 david vallado -* original baseline -* ---------------------------------------------------------------- */ - -#include -#include - -#include "sgp4unit.h" - - -// ------------------------- function declarations ------------------------- - -double sgn - ( - double x - ); - -double mag - ( - double x[3] - ); - -void cross - ( - double vec1[3], double vec2[3], double outvec[3] - ); - -double dot - ( - double x[3], double y[3] - ); - -double angle - ( - double vec1[3], - double vec2[3] - ); - -void newtonnu - ( - double ecc, double nu, - double& e0, double& m - ); - -double asinh - ( - double xval - ); - -void rv2coe - ( - double r[3], double v[3], double mu, - double& p, double& a, double& ecc, double& incl, double& omega, double& argp, - double& nu, double& m, double& arglat, double& truelon, double& lonper - ); - -void jday - ( - int year, int mon, int day, int hr, int minute, double sec, - double& jd - ); - -void days2mdhms - ( - int year, double days, - int& mon, int& day, int& hr, int& minute, double& sec - ); - -void invjday - ( - double jd, - int& year, int& mon, int& day, - int& hr, int& minute, double& sec - ); - -#endif - +#ifndef _sgp4ext_ +#define _sgp4ext_ +/* ---------------------------------------------------------------- +* +* sgp4ext.h +* +* this file contains extra routines needed for the main test program for sgp4. +* these routines are derived from the astro libraries. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 20 apr 07 david vallado +* misc documentation updates +* changes : +* 14 aug 06 david vallado +* original baseline +* ---------------------------------------------------------------- */ + +#include +#include + +#include "sgp4unit.h" + + +// ------------------------- function declarations ------------------------- + +double sgn + ( + double x + ); + +double mag + ( + double x[3] + ); + +void cross + ( + double vec1[3], double vec2[3], double outvec[3] + ); + +double dot + ( + double x[3], double y[3] + ); + +double angle + ( + double vec1[3], + double vec2[3] + ); + +void newtonnu + ( + double ecc, double nu, + double& e0, double& m + ); + +double asinh + ( + double xval + ); + +void rv2coe + ( + double r[3], double v[3], double mu, + double& p, double& a, double& ecc, double& incl, double& omega, double& argp, + double& nu, double& m, double& arglat, double& truelon, double& lonper + ); + +void jday + ( + int year, int mon, int day, int hr, int minute, double sec, + double& jd + ); + +void days2mdhms + ( + int year, double days, + int& mon, int& day, int& hr, int& minute, double& sec + ); + +void invjday + ( + double jd, + int& year, int& mon, int& day, + int& hr, int& minute, double& sec + ); + +#endif + diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.cpp diff --git a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.h b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.h similarity index 97% rename from FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.h rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.h index 20fb599..613cce8 100644 --- a/FOSSASatTracker/FOSSASatTracker/libs/gsat-r11-fixed/src/sgp4io.h +++ b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4io.h @@ -1,46 +1,46 @@ -#ifndef _sgp4io_ -#define _sgp4io_ -/* ---------------------------------------------------------------- -* -* sgp4io.h; -* -* this file contains a function to read two line element sets. while -* not formerly part of the sgp4 mathematical theory, it is -* required for practical implemenation. -* -* companion code for -* fundamentals of astrodynamics and applications -* 2007 -* by david vallado -* -* (w) 719-573-2600, email dvallado@agi.com -* -* current : -* 3 sep 07 david vallado -* add operationmode for afspc (a) or improved (i) -* changes : -* 20 apr 07 david vallado -* misc updates for manual operation -* 14 aug 06 david vallado -* original baseline -* ---------------------------------------------------------------- */ - -#include -#include - -#include "sgp4ext.h" // for several misc routines -#include "sgp4unit.h" // for sgp4init and getgravconst - -// ------------------------- function declarations ------------------------- - -void twoline2rv - ( - char longstr1[130], char longstr2[130], - char typerun, char typeinput, char opsmode, - gravconsttype whichconst, - double& startmfe, double& stopmfe, double& deltamin, - elsetrec& satrec - ); - -#endif - +#ifndef _sgp4io_ +#define _sgp4io_ +/* ---------------------------------------------------------------- +* +* sgp4io.h; +* +* this file contains a function to read two line element sets. while +* not formerly part of the sgp4 mathematical theory, it is +* required for practical implemenation. +* +* companion code for +* fundamentals of astrodynamics and applications +* 2007 +* by david vallado +* +* (w) 719-573-2600, email dvallado@agi.com +* +* current : +* 3 sep 07 david vallado +* add operationmode for afspc (a) or improved (i) +* changes : +* 20 apr 07 david vallado +* misc updates for manual operation +* 14 aug 06 david vallado +* original baseline +* ---------------------------------------------------------------- */ + +#include +#include + +#include "sgp4ext.h" // for several misc routines +#include "sgp4unit.h" // for sgp4init and getgravconst + +// ------------------------- function declarations ------------------------- + +void twoline2rv + ( + char longstr1[130], char longstr2[130], + char typerun, char typeinput, char opsmode, + gravconsttype whichconst, + double& startmfe, double& stopmfe, double& deltamin, + elsetrec& satrec + ); + +#endif + diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4unit.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4unit.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4unit.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4unit.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4unit.h b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4unit.h similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4unit.h rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/sgp4unit.h diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/tcppver.out b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/tcppver.out similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/tcppver.out rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/tcppver.out diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/tcppvera.out b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/tcppvera.out similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/tcppvera.out rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/tcppvera.out diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/cpp/testcpp.cpp b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/testcpp.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/cpp/testcpp.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/cpp/testcpp.cpp diff --git a/FOSSASatTracker/SGP4_experiments/SGP4/sgp4_CodeReadme.pdf b/Misc/FOSSASatTracker/SGP4_experiments/SGP4/sgp4_CodeReadme.pdf similarity index 100% rename from FOSSASatTracker/SGP4_experiments/SGP4/sgp4_CodeReadme.pdf rename to Misc/FOSSASatTracker/SGP4_experiments/SGP4/sgp4_CodeReadme.pdf diff --git a/FOSSASatTracker/SGP4_experiments/download spg4.txt b/Misc/FOSSASatTracker/SGP4_experiments/download spg4.txt similarity index 100% rename from FOSSASatTracker/SGP4_experiments/download spg4.txt rename to Misc/FOSSASatTracker/SGP4_experiments/download spg4.txt diff --git a/FOSSASatTracker/SGP4_experiments/main.cpp b/Misc/FOSSASatTracker/SGP4_experiments/main.cpp similarity index 100% rename from FOSSASatTracker/SGP4_experiments/main.cpp rename to Misc/FOSSASatTracker/SGP4_experiments/main.cpp diff --git a/FOSSASatTracker/SGP4_experiments/sgp4_CodeReadme.pdf b/Misc/FOSSASatTracker/SGP4_experiments/sgp4_CodeReadme.pdf similarity index 100% rename from FOSSASatTracker/SGP4_experiments/sgp4_CodeReadme.pdf rename to Misc/FOSSASatTracker/SGP4_experiments/sgp4_CodeReadme.pdf