Skip to content

Commit

Permalink
Topo: init, #NEW, errors, doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmuller committed Aug 13, 2024
1 parent ad3cf4a commit 5e30bc4
Show file tree
Hide file tree
Showing 20 changed files with 446 additions and 100 deletions.
117 changes: 106 additions & 11 deletions MMVII/Doc/CommandReferences/SysCo.tex
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,16 @@ \section{Survey introduction}
\item direct Euclidian vector observation
\end{itemize}

The measurements can be made between cameras poses, GCPs or undeclared points that will be inserted into the last GCP set of the adjustment.
The measurements can be made between cameras poses, GCPs or undeclared points that will be inserted into the last GCP set of the adjustment
(if automatic coordinates initialization succeeds).

Two \CdPPP\ commands can use topo measurements in compensation:
\begin{itemize}
\item \texttt{OriBundleAdj} via the \texttt{TopoFile} option
\item \texttt{TopoAdj} (see \ref{subsec:TopoAdj})
\end{itemize}

The topo measurements file can be given as a set of \CdPPP\ json or xml file, or in a simplified text format (named \texttt{OBS} file) inherited from IGN's
The topo measurements files can be given as a set of \CdPPP\ json or xml files, or in a simplified text format (named \texttt{OBS} file) inherited from IGN's
Comp3D\footnote{\url{https://github.com/IGNF/Comp3D}} micro-geodesy compensation software.

All the measurements files must be in the \texttt{MMVII-PhgrProj/Topo/[TopoObsName]} folder.
Expand Down Expand Up @@ -248,15 +249,15 @@ \subsection{3D points file}

To import these coordinates in \CdPPP\ we use the \texttt{ImportGCP} command, where we give the text format
(additional\_info, name, x, y, z), the name of the resulting \texttt{PointsMeasure} and the coordinates SysCo.
We also specify that the points who have an additional\_info of '0' are free points, that the sigma for
We also specify that the points that have '0' for their additional\_info are free points, that the sigma for
known points is 0.001m and that lines starting with '*' are comment lines.

\begin{lstlisting}
MMVII ImportGCP inputs/coords.txt ANXYZ InitL93 ChSys=[L93] AddInfoFree=0 Sigma=0.001 Comment=*
\end{lstlisting}

In the resulting file \texttt{MMVII-PhgrProj/PointsMeasure/InitL93/MesGCP-coords.xml},
the points PtA and PtD have a \texttt{\_\_Opt\_\_Sigma2} set to 0.001 m $\sigma$,
the points PtA and PtD have a set \texttt{\_\_Opt\_\_Sigma2} equivalent to $\sigma = 0.001 m$ ,
the points PtB and PtC have no \texttt{\_\_Opt\_\_Sigma2}, making them free points.


Expand Down Expand Up @@ -387,22 +388,51 @@ \subsection{Adjustment}

\section{Stations orientation constraints}

Each station has orientation constraints that have to be given before the station observations lines in the \texttt{{obs}} file.
Each station has orientation constraints that have to be given before the station observations lines in the \texttt{OBS} file.
Each orientation constraint is indicated as a line starting with \texttt{\#} (from now on, called a \texttt{\#}-line).
\\

The possible orientation constraints are:
\begin{itemize}
\item \texttt{\#FIX}: the station is axis-aligned, it is verticalized and oriented to North
\item \texttt{\#VERT}: the station is verticalized and only horizontal orientation is free
\item \texttt{\#BASC}: the station orientation has 3 degrees of freedom, meaning non-verticalized and not oriented to North
\item TODO \texttt{\#CAM}:the station orientation is the camera orientation (only allowed for point names that correspond to image file names)
\end{itemize}

After a \texttt{\#} line (\texttt{\#FIX}, \texttt{\#VERT} or \texttt{\#BASC}), all the following stations have the new orientation constraint until the next \texttt{\#} line.
After a \texttt{\#}-line, all the following stations have the new orientation constraint until the next \texttt{\#}-line with new orientation unknowns.
For convenience, \texttt{\#NEW} can be used to keep current orientation constraint type and just add new unknowns for orientation (see \ref{subsec:SeveralStationsSamePoint}).


Each \texttt{OBS} file starts with an implicit \texttt{\#VERT}, making the stations verticalized by default.

For now, the vertical is modeled as the Earth's ellipsoid normal. Vertical deflection grids may be added later.



\subsection{Frames for survey stations}

The computation must take place in a 3D euclidian frame. For now, only RTL SysCo is supported.
Figure \ref{fig:topoFrames} shows the frames used in topo compensation.

\begin{figure}[!h]
\centering
\includegraphics[width=12cm]{Programmer/framesTopo.png}
\caption{The different frames types used in compensation:
\texttt{Green}: a projection SysCo. As it is not euclidian, compensation should not be done in this frame.
\texttt{Blue}: the RTL SysCo for the computation. Every parameter is in this frame.
\texttt{Purple}: each 3D point has its own local euclidian frame tangent to the ellipsoid
\texttt{Yellow}: each topometric station has a rotation between the local euclidian tangent frame and the instrument frame.
}
\label{fig:topoFrames}
\end{figure}


Stations orientation constraints fix some parts of the rotation between local tangent frame and instrument frame:
no rotation (\textbf{\#FIX}), rotation around $Z$ only (\textbf{\#VERT}), or free rotation (\textbf{\#BASC}).



\subsection{Return to quickstart example}
The example \texttt{OBS} file was:
\begin{verbatim}
Expand Down Expand Up @@ -465,20 +495,85 @@ \subsection{Return to quickstart example}


\subsection{Several stations on the same point}
\label{subsec:SeveralStationsSamePoint}

\CdPPP\ automatically creates a new station when a point is used for the first time as the origin of a measurement.

If we have to make a new set of orientation unknowns because two instruments were set on the same point with different
orientations, we can:
orientations, we can either:

\begin{itemize}
\item use separated \texttt{OBS} files
\item add a \texttt{\#} line to separate the measurements sets
\item use a code \textbf{7} for the first measurement
\item use separate \texttt{OBS} files
\item add a \texttt{\#}-line to separate the measurements sets (\texttt{\#NEW} is useful in this case to make a station with the same orientation constraints as before)
\item use a code \textbf{7} instead of \textbf{5} for the first measurement of the new station
\end{itemize}

A separate \texttt{OBS} files or a \texttt{\#}-line closes all current stations.
Code \textbf{7} only closes the previous station on one point.

Some illustrations :
\begin{verbatim}
7 St1 PtA 100.000 0.001 * creates a station on St1
5 St1 PtB 110.000 0.001
7 St1 PtA 150.000 0.001 * closes current station on St1, creates a new one on St1
5 St1 PtC 210.000 0.001
\end{verbatim}
Creates two stations originating on point \texttt{St1}. Each of these station
is vericalized (thanks to the implicit \texttt{\#VERT} at the start of the file) and each has one horizontal orientation unknown.
Here, there is a 50 grades difference between the two stations orientations.

With:
\begin{verbatim}
7 St1 PtA 100.000 0.001 * creates a station on St1
5 St1 PtB 110.000 0.001
5 St1 PtA 150.000 0.001
5 St1 PtC 210.000 0.001
\end{verbatim}
There is only one station on \texttt{St1}. The incoherent horizontal angles values
will make the computation fail.

Another way to fix it:
\begin{verbatim}
5 St1 PtA 100.000 0.001 * creates a station on St1
5 St1 PtB 110.000 0.001
#NEW * closes all current stations
5 St1 PtA 150.000 0.001 * creates a station on St1
5 St1 PtC 210.000 0.001
\end{verbatim}
The fisrt \textbf{7} is not mandatory since it is the start of a file, there is no
current stations. \texttt{\#NEW} closes all the current stations, keeping the same orientations constraints (stations verticalized).

Code \textbf{7} only closes the current station on one point :
\begin{verbatim}
5 St1 PtA 100.000 0.001 * creates a station on St1
5 St1 PtB 110.000 0.001
5 St2 PtA 200.000 0.001 * creates a station on St2
5 St2 PtD 300.000 0.001
7 St1 PtA 150.000 0.001 * closes station on St1, creates a new one on St1
5 St1 PtC 210.000 0.001
5 St2 PtE 250.000 0.001 * uses previous station on St2
\end{verbatim}
But:
\begin{verbatim}
5 St1 PtA 100.000 0.001 * creates a station on St1
5 St1 PtB 110.000 0.001
5 St2 PtA 200.000 0.001 * creates a station on St2
5 St2 PtD 300.000 0.001
#NEW * closes all the stations
5 St1 PtA 150.000 0.001 * creates a station on St1
5 St1 PtC 210.000 0.001
5 St2 PtE 250.000 0.001 * creates a station on St2
\end{verbatim}


\subsection{Special case of distance-only measurements}
\subsection{Special case for distance-only measurements}

If a station only has distances measurements, it is automatically
set as a \texttt{\#FIX} station, since this station orientation unknowns
Expand Down
42 changes: 21 additions & 21 deletions MMVII/Doc/Programmer/NonLinearOptim.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1315,36 +1315,25 @@ \section{Survey measurements}
\label{Chap:TopoProg}
\subsection{Global presentation}

The premises of a topographic survey compensation system can be found in \texttt{MMVII/src/Topo/}.
Topographic survey compensation system can be found in \texttt{MMVII/src/Topo/}.

For now it is used in commands \texttt{OriBundleAdj} and \texttt{TopoAdj}, and in the Bench \texttt{TopoComp}.
For now it is used in commands \texttt{OriBundleAdj} and \texttt{TopoAdj}, and in the Bench \texttt{TopoComp} (see \ref{Chap:TopoUser}).

This Bench will be used to illustrate the survey classes and their usage.


\subsection{Frames for survey stations}

\begin{figure}[!h]
\centering
\includegraphics[width=12cm]{Programmer/framesTopo.png}
\caption{The different frames types used in compensation}
\label{fig:topoFrames}
\end{figure}

\subsubsection{Topo survey classes}

The topo files are:
\begin{itemize}
\item \texttt{Green}: a projection SysCo. As it is not euclidian, all point coordinates must be converted into RTL before compensation.
\item \texttt{Blue}: the RTL SysCo for the computation. Every parameter is in this frame.
\item \texttt{Purple}: each point has its own local euclidian tangent frame depending on its position.
\item \texttt{Yellow}: each topoemtric station has a rotation between the local euclidian tangent frame and the instrument frame.
\item \texttt{src/Topo/ctopopoint.h, src/Topo/ctopopoint.cpp}: class \texttt{cTopoPoint} (see below)
\item \texttt{src/Topo/ctopoobs.h, src/Topo/ctopoobs.cpp}: class \texttt{cTopoObs} (see below)
\item \texttt{src/Topo/ctopoobsset.h, src/Topo/ctopoobsset.cpp}: classes \texttt{cTopoObsSet} and derived classes (see below)
\item \texttt{src/Topo/topoinit.h, src/Topo/topoinit.cpp}: coordinates initialisation algorithms
\item \texttt{src/Topo/ctopodata.h, src/Topo/ctopodata.cpp}: classes for data serialization and deserialization
\item \texttt{include/MMVII\_Topo.h, src/Topo/Topo.cpp}: class \texttt{cBA\_Topo} (see below)
\end{itemize}

The computation must take place in a 3D euclidian frame.
For now, only RTL SysCo is supported.


\subsubsection{Topo survey classes}

The topo computation classes are :
\begin{itemize}
\item \texttt{cTopoPoint}: a point used with survey measurements. Keeps a pointer to the unknowns from GCP or Ori.
Expand All @@ -1363,6 +1352,17 @@ \subsubsection{Topo survey classes}
It has a notion of {\tt origin} (the point where the instrument is positionned), and an orientation matrix in the RTL SysCo.
If the station is verticalized, the initial orientation matrix corresponds to the vertical orientation on the origin point, and only a rotation arround the vertical direction is free.

\subsubsection{Integration into photogrammetric compensation}

Each topo measurement is between 3D points corresponding to system unknowns. These 3D points can be camera origins or GCPs.

It is allowed to have topo measurements referencing points that are not cameras origins nor declared in GCP list.
In this case, new 3D points will be created, and added to the last GCP set of the adjustment (during the last \texttt{cAppliBundlAdj::AddOneSetGCP()} call).

Those points will have no coordinates constraints (free), and will be initialized by the topo system. If there is no initialization method usable for the point,
an error will occure and the user will have to provide initial coordinates in the GCP 3D file.


\subsubsection{Topo survey equations}

For \texttt{cTopoObsSetStation}, all the measurements are expressed in the local survey station frame.
Expand Down
1 change: 1 addition & 0 deletions MMVII/include/MMVII_MeasuresIm.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class cMes1GCP
std::string mAdditionalInfo;

std::optional<cArray<tREAL4,6> > mOptSigma2; // xx xy xz yy yz zz
bool isInit() const {return mPt.IsValid();}
};

/** A set of cMes1GCP */
Expand Down
18 changes: 13 additions & 5 deletions MMVII/src/Topo/Topo.h → MMVII/include/MMVII_Topo.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#ifndef TOPO_H
#define TOPO_H

#include "MMVII_SysSurR.h"
#include "MMVII_Sensor.h"
#include "MMVII_SysCo.h"
#include "ctopodata.h"
#include "../src/Topo/ctopopoint.h"
#include "../src/Topo/ctopoobs.h"
#include "../src/Topo/ctopoobsset.h"
#include "../src/Topo/ctopodata.h"

using namespace NS_SymbolicDerivative;

Expand All @@ -11,16 +17,14 @@ namespace MMVII
class cMMVII_BundleAdj;
class cPhotogrammetricProject;
class cSensorCamPC;
class cTopoObsSet;
class cTopoObs;
class cTopoPoint;
class cBA_GCP;

typedef std::map<const cTopoPoint*, std::vector<cTopoObsSetStation*>> tStationsMap;

class cBA_Topo : public cMemCheck
{
friend class cTopoData;
public :

cBA_Topo(cPhotogrammetricProject *aPhProj, cMMVII_BundleAdj *aBA);
~cBA_Topo();
void clear();
Expand All @@ -42,6 +46,9 @@ public :
double Sigma0() {return mSigma0;}
std::vector<cTopoObs*> GetObsPoint(std::string aPtName) const;

bool tryInitAll();
bool tryInit(cTopoPoint & aTopoPt, tStationsMap & stationsMap);

bool mergeUnknowns(cResolSysNonLinear<tREAL8> &aSys); //< if several stations share origin etc.
void makeConstraints(cResolSysNonLinear<tREAL8> &aSys);
const std::map<std::string, cTopoPoint> & getAllPts() const { return mAllPts; }
Expand All @@ -65,3 +72,4 @@ private :

};

#endif // TOPO_H
9 changes: 5 additions & 4 deletions MMVII/include/MMVII_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,11 @@ enum class eTopoObsType
// cTopoObsSetStation orientation freedom status
enum class eTopoStOriStat
{
eTopoStOriFixed, ///< no rotation
eTopoStOriVert, ///< z rotation
eTopoStOriBasc, ///< 3d rotation
eNbVals ///< Tag for number of value
eTopoStOriContinue, ///< special case, used only on obs reading: same as previous ori constraint, just a marker to split stations
eTopoStOriFixed, ///< no rotation
eTopoStOriVert, ///< z rotation
eTopoStOriBasc, ///< 3d rotation
eNbVals ///< Tag for number of value
};


Expand Down
2 changes: 1 addition & 1 deletion MMVII/src/BundleAdjustment/cAppliBundAdj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\file cAppliBundAdj.cpp
*/
#include "../Topo/Topo.h"
#include "MMVII_Topo.h"

/*
Track info on bundle adj/push broom in V1 :
Expand Down
5 changes: 1 addition & 4 deletions MMVII/src/BundleAdjustment/cAppliTopoAdj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\file cAppliTopoAdj.cpp
*/
#include "../Topo/Topo.h"
#include "MMVII_Topo.h"



Expand Down Expand Up @@ -169,9 +169,6 @@ int cAppliTopoAdj::Exe()
mBA.OneIterationTopoOnly(mLVM, true);
}

for (auto & aSI : mBA.VSIm())
mPhProj.SaveSensor(*aSI);

mBA.Save_newGCP();
mBA.SaveTopo(); // just for debug for now

Expand Down
3 changes: 1 addition & 2 deletions MMVII/src/BundleAdjustment/cMMVII_BundleAdj.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "BundleAdjustment.h"
#include "MMVII_util_tpl.h"

#include "../Topo/Topo.h"
#include "../Topo/ctopoobs.h"
#include "MMVII_Topo.h"

/**
\file cAppliBundAdj.cpp
Expand Down
2 changes: 1 addition & 1 deletion MMVII/src/Sensors/Measures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ cMes1GCP::cMes1GCP(const cPt3dr & aPt, const std::string & aNamePt, tREAL4 aSigm
}

cMes1GCP::cMes1GCP() :
cMes1GCP (cPt3dr(0,0,0),"??")
cMes1GCP (cPt3dr::Dummy(),"??")
{
}

Expand Down
2 changes: 1 addition & 1 deletion MMVII/src/Sensors/cPhotogrammetricProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "MMVII_DeclareCste.h"
#include "MMVII_Clino.h"
#include "cExternalSensor.h"
#include "../src/Topo/Topo.h" // TODOJM
#include "MMVII_Topo.h"


/**
Expand Down
1 change: 1 addition & 0 deletions MMVII/src/Serial/ElemStrToVal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ template<> cE2Str<eTopoObsType>::tMapE2Str cE2Str<eTopoObsType>::mE2S

template<> cE2Str<eTopoStOriStat>::tMapE2Str cE2Str<eTopoStOriStat>::mE2S
{
{eTopoStOriStat::eTopoStOriContinue,"#NEW"},
{eTopoStOriStat::eTopoStOriFixed,"#FIX"},
{eTopoStOriStat::eTopoStOriVert,"#VERT"},
{eTopoStOriStat::eTopoStOriBasc,"#BASC"},
Expand Down
Loading

0 comments on commit 5e30bc4

Please sign in to comment.