Skip to content

Commit

Permalink
Updates Bundle Observation Vector to support Csm observations. (#4457)
Browse files Browse the repository at this point in the history
* Remove duplicated member variables and accesor functions from BundleObservation and add Csm camera type to Camera enum

* Remove commented-out code

* Imagecoeff migrated into BundleObservation class working

* Get base level working for all coeffs in ISIS

* Fix accidental move into if statement to get tests passing again

* Updated RHS for CsmBundleObservation to work

* Adds point3D support to CSM Camera observations and also adds ground Partials member function to CSMCamera

* Draft of sensor partials code

* Add docs, some fixes based on review requests

* move computation of weights and observation values to bundle observations

* Add observationvalue function to CsmBundleObservation and move the weighting that it is possible to to the observation classes

* Make CSMSolveSet an optional parameter to get jigsaw tests passing again

* cleanup

* Move observation weights into MLE if block

* Added isis vs. csm support to Bundle Observation Vector class to allow jigsaw to proceed past the setup stage for csm networks

* Comment cleanup

* Fix failing unit tests

* Add docs

* Updated based on feedback with potentially temporary fix to get unit tests passing

* Update tests a bit

* Aligned signature definitions and cleaned up

* remove unneeded functions

* More comment cleanup

Co-authored-by: Kristin Berry <kberry@gyro.wr.usgs.gov>
  • Loading branch information
2 people authored and jessemapel committed Jun 17, 2021
1 parent 8709485 commit 28fb579
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 107 deletions.
10 changes: 0 additions & 10 deletions isis/src/control/objs/BundleAdjust/BundleAdjust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,6 @@ namespace Isis {
}
}

// initialize exterior orientation (spice) for all BundleImages in all BundleObservations
//
// TODO!!! - should these initializations just be done when we add the new observation above?
m_bundleObservations.initializeExteriorOrientation();

// TODO
if (m_bundleSettings->solveTargetBody()) {
m_bundleObservations.initializeBodyRotation();
}

// set up vector of BundleControlPoints
int numControlPoints = m_controlNet->GetNumPoints();
for (int i = 0; i < numControlPoints; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ namespace Isis {
virtual AbstractBundleObservation &operator=(const AbstractBundleObservation &src);

// copy method
// not implementedn in BundleObservation either???
// virtual void copy(const AbstractBundleObservation &src);

void copy(const AbstractBundleObservation &src);

virtual bool setSolveSettings(BundleObservationSolveSettings solveSettings) = 0;

virtual void append(const BundleImageQsp &value);

Expand Down Expand Up @@ -93,7 +95,7 @@ namespace Isis {
QMap<QString, BundleImageQsp> m_cubeSerialNumberToBundleImageMap;
QStringList m_serialNumbers; //!< List of all cube serial numbers in observation.
QStringList m_imageNames; //!< List of all cube names.
QString m_instrumentId; //!< Spacecraft instrument id.
QString m_instrumentId; //!< Spacecraft instrument id.

// TODO??? change these to LinearAlgebra vectors...
LinearAlgebra::Vector m_weights; //!< Parameter weights.
Expand Down
2 changes: 1 addition & 1 deletion isis/src/control/objs/BundleUtilities/BundleObservation.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace Isis {
// copy method
void copy(const BundleObservation &src);

bool setSolveSettings(BundleObservationSolveSettings solveSettings);
virtual bool setSolveSettings(BundleObservationSolveSettings solveSettings);

int numberPositionParameters();
int numberPointingParameters();
Expand Down
85 changes: 38 additions & 47 deletions isis/src/control/objs/BundleUtilities/BundleObservationVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ find files of those names at the top level of this repository. **/

#include "AbstractBundleObservation.h"
#include "BundleObservation.h"
#include "Camera.h"
#include "CsmBundleObservation.h"
#include "IException.h"

namespace Isis {
Expand Down Expand Up @@ -101,7 +103,6 @@ namespace Isis {
AbstractBundleObservationQsp bundleObservation;
bool addToExisting = false;

// TODO it looks like this can just become 1 if statement
if (bundleSettings->solveObservationMode() &&
m_observationNumberToObservationMap.contains(observationNumber)) {
bundleObservation = m_observationNumberToObservationMap.value(observationNumber);
Expand All @@ -117,20 +118,37 @@ namespace Isis {
bundleImage->setParentObservation(bundleObservation);

// updateo observation number to observation ptr map
m_observationNumberToObservationMap.insertMulti(observationNumber,bundleObservation);
m_observationNumberToObservationMap.insertMulti(observationNumber, bundleObservation);

// update image serial number to observation ptr map
m_imageSerialToObservationMap.insertMulti(bundleImage->serialNumber(), bundleObservation);
}
else {
// create new BundleObservation and append to this vector
BundleObservation *isisObservation = new BundleObservation(bundleImage,
observationNumber,
instrumentId,
bundleSettings->bundleTargetBody());

bool isIsisObservation = true;

// This NULL check is needed solely for the unit test
if (bundleImage->camera() != NULL) {
isIsisObservation = bundleImage->camera()->GetCameraType() != Camera::Csm;
}

AbstractBundleObservation *observation = NULL;

if (isIsisObservation) {
observation = new BundleObservation(bundleImage,
observationNumber,
instrumentId,
bundleSettings->bundleTargetBody());
}
else {
observation = new CsmBundleObservation(bundleImage,
observationNumber,
instrumentId,
bundleSettings->bundleTargetBody());
}

if (!isisObservation) {
if (!observation) {
QString message = "Unable to allocate new BundleObservation ";
message += "for " + bundleImage->fileName();
throw IException(IException::Programmer, message, _FILEINFO_);
Expand All @@ -148,16 +166,26 @@ namespace Isis {
solveSettings = bundleSettings->observationSolveSettings(observationNumber);
}

isisObservation->setSolveSettings(solveSettings);

bundleObservation.reset(isisObservation);
observation->setSolveSettings(solveSettings);
bundleObservation.reset(observation);

bundleObservation->setIndex(size());

bundleImage->setParentObservation(bundleObservation);

append(bundleObservation);

if (isIsisObservation) {
QSharedPointer<BundleObservation> isisObs = qSharedPointerDynamicCast<BundleObservation>(bundleObservation);
// This check is needed for the current unit test
if (bundleImage->camera() != NULL) {
isisObs->initializeExteriorOrientation();
if (bundleSettings->solveTargetBody()) {
isisObs->initializeBodyRotation();
}
}
}

// update observation number to observation ptr map
m_observationNumberToObservationMap.insertMulti(observationNumber, bundleObservation);

Expand Down Expand Up @@ -233,41 +261,4 @@ namespace Isis {
std::reverse(std::begin(list), std::end(list));
return list;
}


/**
* Initializes the exterior orientations for the contained ISIS
* BundleObservations.
*
* @return @b bool Returns true upon successful initialization
*/
bool BundleObservationVector::initializeExteriorOrientation() {
// get isis observations
// get csm observations
int nObservations = size();
// just do it for ISIS observations
for (int i = 0; i < nObservations; i++) {
// TODO: how to only do this if ISIS observations
QSharedPointer<BundleObservation> observation = qSharedPointerDynamicCast<BundleObservation>( at(i) );
observation->initializeExteriorOrientation();
}
return true;
}


/**
* Initializes the body rotations for the contained BundleObservations.
*
* @return @b bool Returns true upon successful initialization
*/
bool BundleObservationVector::initializeBodyRotation() {
int nObservations = size();
//TODO: just do it for ISIS observations
for (int i = 0; i < nObservations; i++) {
QSharedPointer<BundleObservation> observation = qSharedPointerDynamicCast<BundleObservation>( at(i) );
observation->initializeBodyRotation();
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ find files of those names at the top level of this repository. **/
#include "BundleImage.h"
#include "AbstractBundleObservation.h"
#include "BundleObservation.h"
#include "CsmBundleObservation.h"
#include "BundleSettings.h"

namespace Isis {
Expand Down Expand Up @@ -71,14 +72,6 @@ namespace Isis {
QList<QString> instrumentIds() const;
QList<AbstractBundleObservationQsp> observationsByInstId(QString instrumentId) const;

bool initializeExteriorOrientation();
bool initializeBodyRotation();

// To add:
// getCsmObservations()
// getIsisObservations()
// addNewIsis()?

private:
//! Map between observation number and pointer to observation.
QMap<QString, AbstractBundleObservationQsp> m_observationNumberToObservationMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Testing BundleObservationVector...

number of parameters: "0"
init exterior orientiation successful? "Yes"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Expand Down
2 changes: 1 addition & 1 deletion isis/src/control/objs/BundleUtilities/unitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ int main(int argc, char *argv[]) {
qDebug() << obs1b.formatBundleOutputString(true);
#endif
// Following segfaults (see #4157)
qDebug() << "init exterior orientiation successful? " << toString(bov.initializeExteriorOrientation());
// qDebug() << "init exterior orientiation successful? " << toString(bov.initializeExteriorOrientation());
qDebug() << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
qDebug() << "";
qDebug() << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
Expand Down
51 changes: 26 additions & 25 deletions isis/src/control/objs/CsmBundleObservation/CsmBundleObservation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ namespace Isis {
*
* @return @b bool Returns true if settings were successfully set
*/
bool CsmBundleObservation::setSolveSettings(BundleObservationSolveSettingsQsp solveSettings) {
m_solveSettings = solveSettings;
bool CsmBundleObservation::setSolveSettings(BundleObservationSolveSettings solveSettings) {
m_solveSettings = BundleObservationSolveSettingsQsp(
new BundleObservationSolveSettings(solveSettings));

CSMCamera *csmCamera = dynamic_cast<CSMCamera*>(front()->camera());

Expand All @@ -107,14 +108,14 @@ namespace Isis {
m_corrections.clear();
m_adjustedSigmas.clear();

if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::Set) {
m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterSet());
if (m_solveSettings->csmSolveOption() == BundleObservationSolveSettings::Set) {
m_paramIndices = csmCamera->getParameterIndices(m_solveSettings->csmParameterSet());
}
else if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::Type) {
m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterType());
else if (m_solveSettings->csmSolveOption() == BundleObservationSolveSettings::Type) {
m_paramIndices = csmCamera->getParameterIndices(m_solveSettings->csmParameterType());
}
else if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::List) {
m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterList());
else if (m_solveSettings->csmSolveOption() == BundleObservationSolveSettings::List) {
m_paramIndices = csmCamera->getParameterIndices(m_solveSettings->csmParameterList());
}
else {
return false;
Expand Down Expand Up @@ -696,19 +697,19 @@ QString CsmBundleObservation::formatBundleOutputString(bool errorPropagation, bo


/**
* Calculates the sensor partials with respect to the solve
* parameters and populates the coeffImage matrix.
*
* @param coeffImage A matrix that will be populated with the
* Calculates the sensor partials with respect to the solve
* parameters and populates the coeffImage matrix.
*
* @param coeffImage A matrix that will be populated with the
* sensor partials with respect to the solve
* parameters.
* @param measure The measure that the partials are being
* @param measure The measure that the partials are being
* computed for.
*
* @return bool
*
* @return bool
*/
bool CsmBundleObservation::computeImagePartials(LinearAlgebra::Matrix &coeffImage, BundleMeasure &measure) {
coeffImage.clear();
coeffImage.clear();

CSMCamera *csmCamera = dynamic_cast<CSMCamera*>(measure.camera());
SurfacePoint groundPoint = measure.parentControlPoint()->adjustedSurfacePoint();
Expand Down Expand Up @@ -743,8 +744,8 @@ QString CsmBundleObservation::formatBundleOutputString(bool errorPropagation, bo

CSMCamera *measureCamera = dynamic_cast<CSMCamera*>(measure.camera());

// do ground partials
vector<double> groundPartials = measureCamera->GroundPartials();
// do ground partials
vector<double> groundPartials = measureCamera->GroundPartials();

// groundPartials is:
// line WRT x
Expand Down Expand Up @@ -805,15 +806,15 @@ QString CsmBundleObservation::formatBundleOutputString(bool errorPropagation, bo


/**
* Returns the observed value in (sample, line) coordinates.
* This requires no modification for Csm.
*
* @param measure measure The measure that the partials are
* Returns the observed value in (sample, line) coordinates.
* This requires no modification for Csm.
*
* @param measure measure The measure that the partials are
* being computed for.
* @param deltaVal The difference between the measured and
* @param deltaVal The difference between the measured and
* calculate sample, line coordinates
*
* @return double The The difference between the measured and
*
* @return double The The difference between the measured and
* calculated (line, sample) coordinate
*/
double CsmBundleObservation::computeObservationValue(BundleMeasure &measure, double deltaVal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace Isis {
// copy method
void copy(const CsmBundleObservation &src);

bool setSolveSettings(BundleObservationSolveSettingsQsp solveSettings);
virtual bool setSolveSettings(BundleObservationSolveSettings solveSettings);

int numberParameters();

Expand Down
Loading

0 comments on commit 28fb579

Please # to comment.