Skip to content
Snippets Groups Projects
Commit 42393dac authored by Fabian Paus's avatar Fabian Paus
Browse files

Added subpage for LaserScannerGUI

parent 5c4eee31
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -18,4 +18,6 @@ The following Gui Plugins are available:
\subpage RobotAPI-GuiPlugins-ViewSelection
\subpage ArmarXGui-GuiPlugins-DebugDrawerViewer
\subpage ArmarXGui-GuiPlugins-LaserScannerPlugin
*/
......@@ -134,7 +134,7 @@ void LaserScannerPluginWidgetController::onNewSensorValuesReported()
int outerR = std::min(view->width() / 2, view->height() / 2);
scene.addEllipse(-outerR, -outerR, 2 * outerR, 2 * outerR, QPen(QColor(255, 255, 255)));
int r = outerR - 10;
scene.addEllipse(-r, -r, 2 * r, 2 * r, QPen(QColor(200, 200, 200)));
//scene.addEllipse(-r, -r, 2 * r, 2 * r, QPen(QColor(200, 200, 200)));
QColor stepColor(QColor::fromRgb(100, 100, 255));
QPen stepPen(stepColor);
QBrush stepBrush(stepColor);
......@@ -148,9 +148,34 @@ void LaserScannerPluginWidgetController::onNewSensorValuesReported()
};
LaserScan& scan = scans[deviceName];
float maxDistance = 1000.0f;
for (LaserScanStep & step : scan)
{
line(step.angle, step.distance / 10000.0f);
if (step.distance > maxDistance)
{
maxDistance = step.distance;
}
}
float ringDistance = 1000.0f;
int numberOfRings = (std::size_t)std::ceil(maxDistance / ringDistance);
std::deque<int>& history = numberOfRingsHistory[deviceName];
history.push_back(numberOfRings);
if (history.size() > 256)
{
history.pop_front();
}
int maxNumberOfRings = *std::max_element(history.begin(), history.end());
float outerRadius = maxNumberOfRings * ringDistance;
for (LaserScanStep & step : scan)
{
line(step.angle, step.distance / outerRadius);
}
for (int ringIndex = 1; ringIndex <= maxNumberOfRings; ++ringIndex)
{
float ri = 1.0f * ringIndex / maxNumberOfRings * r;
scene.addEllipse(-ri, -ri, 2 * ri, 2 * ri, QPen(QColor(200, 200, 200)));
}
view->fitInView(scene.itemsBoundingRect(), Qt::KeepAspectRatio);
......
......@@ -35,10 +35,7 @@ namespace armarx
{
/**
\page ArmarXGui-GuiPlugins-LaserScannerPlugin LaserScannerPlugin
\brief The LaserScannerPlugin allows visualizing ...
\image html LaserScannerPlugin.png
The user can
\brief The LaserScannerPlugin allows visualizing the raw sensor data captured from multiple laser scanners.
API Documentation \ref LaserScannerPluginWidgetController
......@@ -125,6 +122,7 @@ namespace armarx
Mutex scanMutex;
std::unordered_map<std::string, LaserScan> scans;
std::unordered_map<std::string, std::deque<int>> numberOfRingsHistory;
QGraphicsScene scene;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment