Unverified Commit 967b238d authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Initial Push Frame sensor model (#374)

* Initial Push Frame model and tests

* Fixed small link error
parent 6d7d044d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ endif(USGSCSM_EXTERNAL_DEPS)
add_library(usgscsm SHARED
            src/UsgsAstroPlugin.cpp
            src/UsgsAstroFrameSensorModel.cpp
            src/UsgsAstroPushFrameSensorModel.cpp
            src/UsgsAstroLsSensorModel.cpp
            src/UsgsAstroSarSensorModel.cpp
            src/Distortion.cpp
@@ -85,7 +86,8 @@ target_link_libraries(usgscsm

add_executable(usgscsm_cam_test bin/usgscsm_cam_test.cc)
target_link_libraries(usgscsm_cam_test
    usgscsm)
    usgscsm
    ${CSM_LIBRARY})

install(TARGETS usgscsm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${USGSCSM_INCLUDE_DIRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+954 −0

File added.

Preview size limit exceeded, changes collapsed.

+170 −0
Original line number Diff line number Diff line
%% Cell type:code id: tags:

``` python
import numpy as np
np.set_printoptions(suppress=True)
```

%% Cell type:code id: tags:

``` python
radius = 1000 # km
altitude = 50 # km
detector_size = 0.1 # mm
focal_length = 50 # mm
framelets = 30
frameletheight = 12
exposure_duration = 0.05 # seconds
interframe_delay = 0.1 # seconds
center_ephemeris_time = 1000
```

%% Cell type:code id: tags:

``` python
positions = []
velocities = []
quats = []
for i in np.arange(0,framelets):
    angle = i*frameletheight*detector_size*altitude/(radius*focal_length)
    position = (radius+altitude) * np.array([np.cos(angle), 0, -np.sin(angle)])
    positions.append(position)
    velocity = (radius+altitude) * np.array([-np.sin(angle), 0, -np.cos(angle)])
    velocities.append(velocity)
    camera_angle = -np.pi/2 + angle
    quat = np.array([-np.sin(camera_angle/2), 0, -np.cos(camera_angle/2), 0])
    quats.append(quat)
for pos in positions:
    print("[", pos[0], ",", pos[1], ",", pos[2], "],")
for vel in velocities:
    print("[", vel[0], ",", vel[1], ",", vel[2], "],")
for quat in quats:
    print("[", quat[0], ",", quat[1], ",", quat[2], ",", quat[3], "],")
```

%% Output

    [ 1050.0 , 0.0 , -0.0 ],
    [ 1049.9992440000908 , 0.0 , -1.2599996976000218 ],
    [ 1049.9969760014515 , 0.0 , -2.519997580800697 ],
    [ 1049.9931960073484 , 0.0 , -3.7799918352052906 ],
    [ 1049.9879040232242 , 0.0 , -5.039980646422296 ],
    [ 1049.9811000567 , 0.0 , -6.299962200068039 ],
    [ 1049.972784117573 , 0.0 , -7.559934681769305 ],
    [ 1049.9629562178181 , 0.0 , -8.819896277165933 ],
    [ 1049.951616371588 , 0.0 , -10.07984517191345 ],
    [ 1049.9387645952115 , 0.0 , -11.339779551685659 ],
    [ 1049.9244009071956 , 0.0 , -12.599697602177274 ],
    [ 1049.9085253282237 , 0.0 , -13.859597509106518 ],
    [ 1049.891137881157 , 0.0 , -15.119477458217743 ],
    [ 1049.872238591033 , 0.0 , -16.379335635284043 ],
    [ 1049.8518274850667 , 0.0 , -17.639170226109854 ],
    [ 1049.8299045926503 , 0.0 , -18.89897941653359 ],
    [ 1049.8064699453528 , 0.0 , -20.158761392430236 ],
    [ 1049.78152357692 , 0.0 , -21.41851433971396 ],
    [ 1049.7550655232747 , 0.0 , -22.67823644434073 ],
    [ 1049.7270958225163 , 0.0 , -23.93792589231094 ],
    [ 1049.6976145149213 , 0.0 , -25.197580869672002 ],
    [ 1049.6666216429428 , 0.0 , -26.457199562520973 ],
    [ 1049.6341172512107 , 0.0 , -27.716780157007136 ],
    [ 1049.600101386531 , 0.0 , -28.976320839334665 ],
    [ 1049.5645740978866 , 0.0 , -30.235819795765195 ],
    [ 1049.527535436437 , 0.0 , -31.495275212620445 ],
    [ 1049.4889854555176 , 0.0 , -32.75468527628483 ],
    [ 1049.4489242106406 , 0.0 , -34.014048173208074 ],
    [ 1049.407351759494 , 0.0 , -35.27336208990783 ],
    [ 1049.3642681619422 , 0.0 , -36.53262521297227 ],
    [ -0.0 , 0.0 , -1050.0 ],
    [ -1.2599996976000218 , 0.0 , -1049.9992440000908 ],
    [ -2.519997580800697 , 0.0 , -1049.9969760014515 ],
    [ -3.7799918352052906 , 0.0 , -1049.9931960073484 ],
    [ -5.039980646422296 , 0.0 , -1049.9879040232242 ],
    [ -6.299962200068039 , 0.0 , -1049.9811000567 ],
    [ -7.559934681769305 , 0.0 , -1049.972784117573 ],
    [ -8.819896277165933 , 0.0 , -1049.9629562178181 ],
    [ -10.07984517191345 , 0.0 , -1049.951616371588 ],
    [ -11.339779551685659 , 0.0 , -1049.9387645952115 ],
    [ -12.599697602177274 , 0.0 , -1049.9244009071956 ],
    [ -13.859597509106518 , 0.0 , -1049.9085253282237 ],
    [ -15.119477458217743 , 0.0 , -1049.891137881157 ],
    [ -16.379335635284043 , 0.0 , -1049.872238591033 ],
    [ -17.639170226109854 , 0.0 , -1049.8518274850667 ],
    [ -18.89897941653359 , 0.0 , -1049.8299045926503 ],
    [ -20.158761392430236 , 0.0 , -1049.8064699453528 ],
    [ -21.41851433971396 , 0.0 , -1049.78152357692 ],
    [ -22.67823644434073 , 0.0 , -1049.7550655232747 ],
    [ -23.93792589231094 , 0.0 , -1049.7270958225163 ],
    [ -25.197580869672002 , 0.0 , -1049.6976145149213 ],
    [ -26.457199562520973 , 0.0 , -1049.6666216429428 ],
    [ -27.716780157007136 , 0.0 , -1049.6341172512107 ],
    [ -28.976320839334665 , 0.0 , -1049.600101386531 ],
    [ -30.235819795765195 , 0.0 , -1049.5645740978866 ],
    [ -31.495275212620445 , 0.0 , -1049.527535436437 ],
    [ -32.75468527628483 , 0.0 , -1049.4889854555176 ],
    [ -34.014048173208074 , 0.0 , -1049.4489242106406 ],
    [ -35.27336208990783 , 0.0 , -1049.407351759494 ],
    [ -36.53262521297227 , 0.0 , -1049.3642681619422 ],
    [ 0.7071067811865475 , 0.0 , -0.7071067811865476 , 0.0 ],
    [ 0.7066823898640746 , 0.0 , -0.7075309179505869 , 0.0 ],
    [ 0.706257744135949 , 0.0 , -0.7079548000035033 , 0.0 ],
    [ 0.7058328441550432 , 0.0 , -0.7083784271926994 , 0.0 ],
    [ 0.705407690074321 , 0.0 , -0.7088017993656693 , 0.0 ],
    [ 0.7049822820468381 , 0.0 , -0.7092249163699993 , 0.0 ],
    [ 0.7045566202257412 , 0.0 , -0.7096477780533669 , 0.0 ],
    [ 0.7041307047642688 , 0.0 , -0.7100703842635421 , 0.0 ],
    [ 0.70370453581575 , 0.0 , -0.7104927348483866 , 0.0 ],
    [ 0.7032781135336061 , 0.0 , -0.7109148296558542 , 0.0 ],
    [ 0.7028514380713489 , 0.0 , -0.7113366685339909 , 0.0 ],
    [ 0.7024245095825815 , 0.0 , -0.7117582513309346 , 0.0 ],
    [ 0.7019973282209984 , 0.0 , -0.7121795778949154 , 0.0 ],
    [ 0.7015698941403846 , 0.0 , -0.7126006480742559 , 0.0 ],
    [ 0.7011422074946165 , 0.0 , -0.7130214617173709 , 0.0 ],
    [ 0.7007142684376613 , 0.0 , -0.7134420186727672 , 0.0 ],
    [ 0.7002860771235769 , 0.0 , -0.7138623187890447 , 0.0 ],
    [ 0.6998576337065125 , 0.0 , -0.7142823619148949 , 0.0 ],
    [ 0.6994289383407074 , 0.0 , -0.7147021478991027 , 0.0 ],
    [ 0.6989999911804922 , 0.0 , -0.7151216765905449 , 0.0 ],
    [ 0.6985707923802875 , 0.0 , -0.7155409478381913 , 0.0 ],
    [ 0.6981413420946052 , 0.0 , -0.7159599614911042 , 0.0 ],
    [ 0.6977116404780473 , 0.0 , -0.7163787173984386 , 0.0 ],
    [ 0.6972816876853064 , 0.0 , -0.7167972154094426 , 0.0 ],
    [ 0.6968514838711655 , 0.0 , -0.7172154553734567 , 0.0 ],
    [ 0.6964210291904978 , 0.0 , -0.7176334371399147 , 0.0 ],
    [ 0.6959903237982671 , 0.0 , -0.7180511605583431 , 0.0 ],
    [ 0.6955593678495274 , 0.0 , -0.7184686254783612 , 0.0 ],
    [ 0.6951281614994228 , 0.0 , -0.7188858317496822 , 0.0 ],
    [ 0.6946967049031876 , 0.0 , -0.7193027792221114 , 0.0 ],

%% Cell type:code id: tags:

``` python
start_time = center_ephemeris_time - interframe_delay * framelets / 2
starting_ephemeris_time = start_time - exposure_duration/2
end_time = start_time + interframe_delay * (framelets - 1) + exposure_duration
ephem_times = np.arange(start_time, end_time, interframe_delay)
print("starting_ephemeris_time", starting_ephemeris_time)
print(ephem_times)
```

%% Output

    starting_ephemeris_time 998.475
    [ 998.5  998.6  998.7  998.8  998.9  999.   999.1  999.2  999.3  999.4
      999.5  999.6  999.7  999.8  999.9 1000.  1000.1 1000.2 1000.3 1000.4
     1000.5 1000.6 1000.7 1000.8 1000.9 1001.  1001.1 1001.2 1001.3 1001.4]

%% Cell type:code id: tags:

``` python
image_lines = frameletheight * framelets
print("image_lines", image_lines)
```

%% Output

    image_lines 360

%% Cell type:code id: tags:

``` python
```
+24 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

#include "UsgsAstroFrameSensorModel.h"
#include "UsgsAstroLsSensorModel.h"
#include "UsgsAstroPushFrameSensorModel.h"
#include "UsgsAstroSarSensorModel.h"

#include <algorithm>
@@ -37,7 +38,7 @@ using json = nlohmann::json;
const std::string UsgsAstroPlugin::_PLUGIN_NAME = "UsgsAstroPluginCSM";
const std::string UsgsAstroPlugin::_MANUFACTURER_NAME = "UsgsAstrogeology";
const std::string UsgsAstroPlugin::_RELEASE_DATE = "20190222";
const int UsgsAstroPlugin::_N_SENSOR_MODELS = 3;
const int UsgsAstroPlugin::_N_SENSOR_MODELS = 4;

// Static Instance of itself
const UsgsAstroPlugin UsgsAstroPlugin::m_registeredPlugin;
@@ -101,7 +102,8 @@ std::string UsgsAstroPlugin::getModelName(size_t modelIndex) const {
  std::vector<std::string> supportedModelNames = {
      UsgsAstroFrameSensorModel::_SENSOR_MODEL_NAME,
      UsgsAstroLsSensorModel::_SENSOR_MODEL_NAME,
      UsgsAstroSarSensorModel::_SENSOR_MODEL_NAME};
      UsgsAstroSarSensorModel::_SENSOR_MODEL_NAME,
      UsgsAstroPushFrameSensorModel::_SENSOR_MODEL_NAME};
  MESSAGE_LOG("Get Model Name: {}. Used index: {}",
              supportedModelNames[modelIndex], modelIndex);
  return supportedModelNames[modelIndex];
@@ -357,6 +359,26 @@ csm::Model *UsgsAstroPlugin::constructModelFromISD(
      throw csm::Error(aErrorType, aMessage, aFunction);
    }
    return model;
  } else if (modelName == UsgsAstroPushFrameSensorModel::_SENSOR_MODEL_NAME) {
    UsgsAstroPushFrameSensorModel *model = new UsgsAstroPushFrameSensorModel();
    MESSAGE_LOG("Trying to construct a UsgsAstroPushFrameSensorModel");
    try {
      model->replaceModelState(
          model->constructStateFromIsd(stringIsd, warnings));
    } catch (std::exception &e) {
      delete model;
      csm::Error::ErrorType aErrorType =
          csm::Error::SENSOR_MODEL_NOT_CONSTRUCTIBLE;
      std::string aMessage = "Could not construct model [";
      aMessage += modelName;
      aMessage += "] with error [";
      aMessage += e.what();
      aMessage += "]";
      std::string aFunction = "UsgsAstroPlugin::constructModelFromISD()";
      MESSAGE_LOG(aMessage);
      throw csm::Error(aErrorType, aMessage, aFunction);
    }
    return model;
  } else {
    csm::Error::ErrorType aErrorType = csm::Error::SENSOR_MODEL_NOT_SUPPORTED;
    std::string aMessage = "Model [" + modelName + "] not supported: ";
+2461 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading