Verified Commit ffb75a4e authored by Tobias WEBER's avatar Tobias WEBER
Browse files

showing minimum distance to walls for the path

parent 7e324d3f
......@@ -1258,6 +1258,28 @@ std::vector<t_vec2> PathsBuilder::GetPathVertices(
}
/**
* get the angular distances to the nearest walls for each point of a given path
* @arg path in angular coordinates (deg or rad)
* @return vector of angular distances in rad
*/
std::vector<t_real> PathsBuilder::GetDistancesToNearestWall(const std::vector<t_vec2>& path, bool deg) const
{
std::vector<t_real> dists{};
dists.reserve(path.size());
for(const t_vec2& pos : path)
{
t_vec2 pix = AngleToPixel(pos, deg, false);
t_real dist = GetDistToNearestWall(pix);
dists.push_back(dist);
}
return dists;
}
/**
* get individual vertices on an instrument path
* helper function for the scripting interface
......@@ -1658,6 +1680,7 @@ PathsBuilder::FindClosestSegment(std::size_t vert_idx_1, std::size_t vert_idx_2,
/**
* get the angular distance of a vertex to the nearest wall
* @arg vertex in pixel coordinates
* @return angular distance in rad
*/
t_real PathsBuilder::GetDistToNearestWall(const t_vec2& vertex) const
{
......
......@@ -120,13 +120,13 @@ protected:
// get path length, taking into account the motor speeds
t_real GetPathLength(const t_vec2& vec) const;
// check if a position leads to a collision
// check if a position (in angular coordinates) leads to a collision
bool DoesPositionCollide(const t_vec2& pos, bool deg = false) const;
// check if a direct path between the two vertices leads to a collision
bool DoesDirectPathCollide(const t_vec2& vert1, const t_vec2& vert2, bool deg = false) const;
// get the angular distance of a vertex to the nearest wall
// get the angular distance of a vertex to the nearest wall from pixel coordinates
t_real GetDistToNearestWall(const t_vec2& vertex) const;
// find the closest point on a path segment
......@@ -217,6 +217,9 @@ public:
std::vector<t_vec2> GetPathVertices(const InstrumentPath& path,
bool subdivide_lines = false, bool deg = false) const;
// get the distances to the nearest walls for each point of a given path
std::vector<t_real> GetDistancesToNearestWall(const std::vector<t_vec2>& path, bool deg = false) const;
// get individual vertices on an instrument path -- for scripting interface
std::vector<std::pair<t_real, t_real>>
GetPathVerticesAsPairs(const InstrumentPath& path,
......
......@@ -185,14 +185,14 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
m_spinDelta2ThM = new QDoubleSpinBox(this);
m_spinDelta2ThS->setPrefix("Δθ_S = ");
m_spinDelta2ThS->setSuffix(" deg");
m_spinDelta2ThS->setSuffix("°");
m_spinDelta2ThS->setValue(g_a4_delta / tl2::pi<t_real>*180.);
m_spinDelta2ThS->setMinimum(0.001);
m_spinDelta2ThS->setMaximum(180.);
m_spinDelta2ThS->setSingleStep(0.1);
m_spinDelta2ThM->setPrefix("Δθ_M = ");
m_spinDelta2ThM->setSuffix(" deg");
m_spinDelta2ThM->setSuffix("°");
m_spinDelta2ThM->setValue(g_a2_delta / tl2::pi<t_real>*180.);
m_spinDelta2ThM->setMinimum(0.001);
m_spinDelta2ThM->setMaximum(180.);
......@@ -531,11 +531,11 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
ostr.precision(g_prec_gui);
// show angular coordinates
ostr << "2θ_S = " << _a4 << " deg";
ostr << "2θ_S = " << _a4 << "°";
if(kf_fixed)
ostr << ", 2θ_M = " << _a2 << " deg.";
ostr << ", 2θ_M = " << _a2 << "°.";
else
ostr << ", 2θ_A = " << _a2 << " deg.";
ostr << ", 2θ_A = " << _a2 << "°.";
// show pixel coordinates
if(m_pathsbuilder)
......
......@@ -2094,14 +2094,29 @@ void PathsTool::ExternalPathAvailable(const InstrumentPath& path)
if(!path.ok)
{
m_pathvertices.clear();
SetTmpStatus("Path not ok.");
SetTmpStatus("Invalid path.");
}
else
{
// get the vertices on the path
m_pathvertices = m_pathsbuilder.GetPathVertices(path, true, false);
emit PathAvailable(m_pathvertices.size());
SetTmpStatus("Path calculated.");
std::ostringstream ostrMsg;
ostrMsg.precision(g_prec_gui);
ostrMsg << "Path calculated";
if(g_verifypath && m_pathvertices.size())
{
auto distances = m_pathsbuilder.GetDistancesToNearestWall(m_pathvertices, false);
t_real min_dist = *std::min_element(distances.begin(), distances.end());
min_dist = min_dist / tl2::pi<t_real>*t_real(180);
ostrMsg << ", min. wall dist.: " << min_dist << "°";
}
ostrMsg << ".";
SetTmpStatus(ostrMsg.str());
}
}
......@@ -2276,7 +2291,22 @@ void PathsTool::CalculatePath()
}
emit PathAvailable(m_pathvertices.size());
SetTmpStatus("Path calculated.");
std::ostringstream ostrMsg;
ostrMsg.precision(g_prec_gui);
ostrMsg << "Path calculated";
if(g_verifypath && m_pathvertices.size())
{
auto distances = m_pathsbuilder.GetDistancesToNearestWall(m_pathvertices, false);
t_real min_dist = *std::min_element(distances.begin(), distances.end());
min_dist = min_dist / tl2::pi<t_real>*t_real(180);
ostrMsg << ", min. wall dist.: " << min_dist << "°";
}
ostrMsg << ".";
SetTmpStatus(ostrMsg.str());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment