Commit b618a255 authored by dcookastro's avatar dcookastro Committed by Stuart Sides
Browse files

Minor Update to Fix Voyager Bundle Adjustment (#3343)

* Added argument to CameraGroundMap::GetXY to allow back-of-planet test to be skipped for the bundle adjust

* Added ability to turn off back-of-planet test while iterating in a bundle adjust

* Replaced DBL_EPSILON as a testing constant for valid distances and angles in SurfacePoint.

* Corrected a bool check in CameraGroundMap::GetXY
parent 56431d4d
Loading
Loading
Loading
Loading
+40 −22
Original line number Diff line number Diff line
@@ -159,12 +159,14 @@ namespace Isis {
   * class value for m_lookJ is set by this method.
   *
   * @param point Surface point (ground position) 
   * @param cudx [out] Pointer to computed undistored x focal plane coordinate
   * @param cudy [out] Pointer to computed undistored y focal plane coordinate
   * @param cudx [out] Pointer to computed undistorted x focal plane coordinate
   * @param cudy [out] Pointer to computed undistorted y focal plane coordinate
   * @param test Optional parameter to indicate whether to do the back-of-planet test.
   *
   * @return @b bool If conversion was successful
   */
  bool CameraGroundMap::GetXY(const SurfacePoint &point, double *cudx, double *cudy) {
  bool CameraGroundMap::GetXY(const SurfacePoint &point, double *cudx, 
                              double *cudy, bool test) {

    vector<double> pB(3);
    pB[0] = point.GetX().kilometers();
@@ -193,29 +195,43 @@ namespace Isis {
    // Save pB for target body partial derivative calculations NEW *** DAC 8-14-2015
    m_pB = pB;
    
    // During iterations in the bundle adjustment do not do the back-of-planet test.
    // Failures are expected to happen during the bundle adjustment due to bad camera
    // pointing or position, poor a priori points, or inaccurate target body information.  For
    // instance, control points near the limb of an image often fail the test.  The hope is
    // that during the bundle adjustment, any variables causing points to fail the test will
    // be corrected.  If not, the point residuals will likely be large on a point that fails the
    // test.  The back-of-planet test is still a valid check for a control net diagnostic
    // program, but not for the bundle adjustment.
    // 
    // TODO It might be useful to have a separate diagnostic program test all points in a 
    //            control net to see if any of the control points fail the back-of-planet test on 
    //            any of the images.

    // Check for point on back of planet by checking to see if surface point is viewable 
    //   (test emission angle)
    // During iterations, we may not want to do the back of planet test???
    if (test) {
      vector<double> lookB = bodyRot->ReferenceVector(lookJ);
      double upsB[3], upB[3], dist;
      vminus_c((SpiceDouble *) &lookB[0], upsB);
      unorm_c(upsB, upsB, &dist);
      unorm_c((SpiceDouble *) &pB[0], upB, &dist);
    double angle = vdot_c(upB, upsB);
      double cosangle = vdot_c(upB, upsB);
      double emission;
    if (angle > 1) {
      if (cosangle > 1) {
        emission = 0;
      }
    else if (angle < -1) {
      else if (cosangle < -1) {
        emission = 180.;
      }
      else {
      emission = acos(angle) * 180.0 / Isis::PI;
        emission = acos(cosangle) * 180.0 / Isis::PI;
      }

      if (fabs(emission) > 90.) {
        return false;
      }
    }

    // Get the look vector in the camera frame and the instrument rotation
    m_lookJ.resize(3);
@@ -248,6 +264,8 @@ namespace Isis {
   * @param cudy [out] Pointer to computed undistored y focal plane coordinate
   *
   * @return @b bool If conversion was successful
   *
   * @see the application socetlinescankeywords
   */
  bool CameraGroundMap::GetXY(const double lat, const double lon,
                              const double radius, double *cudx, double *cudy) {
+6 −1
Original line number Diff line number Diff line
@@ -82,6 +82,10 @@ namespace Isis {
   *                          p_pB. References Mantis ticket TBD.
   *  @history 2016-06-27 Ian Humphrey - Updated documentation and coding standards. Fixes #3971.
   *  @history 2017-08-30 Summer Stapleton - Updated documentation. References #4807.
   *  @history 2019-04-15 Debbie A. Cook - Added optional bool argument to main GetXY method to 
   *                          allow the bundle adjustment to skip the back of planet test during iterations. 
   *                          Also changed the name of the angle variable to cosangle to be more 
   *                          descriptive. References #2591.
   */
  class CameraGroundMap {
    public:
@@ -108,7 +112,8 @@ namespace Isis {

      virtual bool SetGround(const Latitude &lat, const Longitude &lon);
      virtual bool SetGround(const SurfacePoint &surfacePoint);
      virtual bool GetXY(const SurfacePoint &spoint, double *cudx, double *cudy);
      virtual bool GetXY(const SurfacePoint &spoint, double *cudx, 
                       double *cudy, bool test=true);
      virtual bool GetXY(const double lat, const double lon,
                         const double radius, double *cudx, double *cudy);
      virtual bool GetdXYdPosition(const SpicePosition::PartialType varType,
+10 −1
Original line number Diff line number Diff line
@@ -366,12 +366,16 @@ namespace Isis {
   * without resetting the current point values for lat/lon/radius/x/y and
   * related radar parameter p_slantRange.
   *
   *  @history 2019-05-15 Debbie A. Cook - Added optional bool argument to match parent GetXY 
   *                          method to allow the bundle adjustment to skip the back of planet test during 
   *                          iterations. References #2591.
   *
   * @param spoint
   *
   * @return conversion was successful
   */
  bool RadarGroundMap::GetXY(const SurfacePoint &spoint, double *cudx,
                             double *cudy) {
                             double *cudy, bool test) {

    // Get the ground point in rectangular body-fixed coordinates (X)
    double X[3];
@@ -406,6 +410,11 @@ namespace Isis {
    *cudx = p_groundSlantRange * 1000.0 / p_rangeSigma;  // to meters, then to focal plane coord
    *cudy = p_groundDopplerFreq / p_dopplerSigma;   // htx to focal plane coord

    if (test == true) {
      QString msg = "Back of planet test is not enabled for Radar images";
       throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    return true;
  }

+4 −1
Original line number Diff line number Diff line
@@ -104,6 +104,9 @@ namespace Isis {
   *                       in the ShapeModel so that photometric angles can be calculated.  References #775
   * @history 2016-07-19 Kristin Berry, Updated SetGround to call p_camera->Sensor::SetGround so that 
   *                       RA, DEC values will be set on level 2 images. References #2400.  
   *  @history 2019-05-15 Debbie A. Cook - Added optional bool argument to match parent GetXY 
   *                          method to allow the bundle adjustment to skip the back of planet test during 
   *                          iterations. References #2591.
   */
  class RadarGroundMap : public CameraGroundMap {
    public:
@@ -117,7 +120,7 @@ namespace Isis {
      virtual bool SetGround(const Latitude &lat, const Longitude &lon);
      virtual bool SetGround(const SurfacePoint &surfacePoint);
      virtual bool GetXY(const SurfacePoint &spoint, double *cudx,
                         double *cudy);
                         double *cudy, bool test=false);
      virtual bool GetdXYdPosition(const SpicePosition::PartialType varType,
                                   int coefIndex, double *cudx, double *cudy);
      virtual bool GetdXYdPoint(std::vector<double> d_lookB, double *dx,
+13 −2
Original line number Diff line number Diff line
@@ -1261,6 +1261,11 @@ namespace Isis {
   * @param lonLength The delta longitude distance in meters  to convert to radians
   * @return @b LonDistAngle The converted delta length in radians
   *
   * @internal
   *   @history  2019-05-29 Debbie A. Cook  Changed test constant from DBL_EPSILON
   *                                            to 1.0e-50 to fix possible false errors from reasonably 
   *                                            small distances on fixed or tightly constrained points 
   *                                            occurring during error propagation in jigsaw.
   */
  double SurfacePoint::MetersToLongitude(double deltaLonMeters) {
    
@@ -1269,7 +1274,7 @@ namespace Isis {
      double deltaLonRadians;

      // Convert angle displacement to radians relative to longitude of SurfacePoint.      
      if (convFactor > DBL_EPSILON) {             
      if (convFactor > 1.0e-50) {             
        deltaLonRadians = deltaLonMeters / (convFactor*GetLocalRadius().meters());
      }
      else {
@@ -1726,11 +1731,17 @@ namespace Isis {
  /**
   * Return the latitude sigma as a Distance
   *
   * @internal
   *   @history  2019-05-29 Debbie A. Cook  Changed test constant from DBL_EPSILON
   *                                            to 1.0e-50 to fix possible false errors from reasonably 
   *                                            small distances on fixed or tightly constrained points 
   *                                            occurring during error propagation in jigsaw.
   *
   */
  Distance SurfacePoint::GetLatSigmaDistance() const {
    double d = LatitudeToMeters(GetLatSigma().radians());

    if (d > DBL_EPSILON)  {
    if (d > 1.0e-50)  {
      return Distance(d,  Distance::Meters);
    }
    else {
Loading