Skip to content
Snippets Groups Projects
Commit 2e6c06ae authored by Markus Grotz's avatar Markus Grotz
Browse files

updated ViewSelection

- added support for saliency map selection
- added clear button for saliency egosphere
parent 08512d54
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotComponents::ViewSelection
* @package RobotAPI::ViewSelection
* @author David Schiebener (schiebener at kit dot edu)
* @author Markus Grotz ( markus dot grotz at kit dot edu )
* @date 2015
......@@ -311,6 +311,17 @@ void ViewSelection::process()
viewSelectionObserver->nextViewTarget(timeOfLastViewChange.toMilliSeconds() + duration);
/*
*
while (duration > 0 && !hasNewSaliencyMap)
{
//condition.wait_for(syncMutex , boost::chrono::milliseconds(100));
duration -= 100;
}
*/
boost::this_thread::sleep(boost::posix_time::milliseconds(duration));
}
else
......@@ -388,7 +399,8 @@ void armarx::ViewSelection::updateSaliencyMap(const SaliencyMapBasePtr& map, con
}
void ViewSelection::drawSaliencyMap(const Ice::Current& c)
void ViewSelection::drawSaliencySphere(const ::Ice::StringSeq& names, const Ice::Current& c)
{
ARMARX_LOG << "visualizing saliency map";
......@@ -401,20 +413,30 @@ void ViewSelection::drawSaliencyMap(const Ice::Current& c)
IceUtil::Time currentTime = armarx::TimeUtil::GetTime();
std::vector<std::string> activeSaliencyMaps;
for (const auto & p : saliencyMaps)
if (names.size())
{
if (p.second->validUntil)
for (std::string n : names)
{
TimestampVariantPtr time = TimestampVariantPtr::dynamicCast(p.second->validUntil);
if (time->toTime() > currentTime)
activeSaliencyMaps.push_back(n);
}
}
else
{
for (const auto & p : saliencyMaps)
{
if (p.second->validUntil)
{
TimestampVariantPtr time = TimestampVariantPtr::dynamicCast(p.second->validUntil);
if (time->toTime() > currentTime)
{
activeSaliencyMaps.push_back(p.second->name);
}
}
else if ((currentTime - TimestampVariantPtr::dynamicCast(p.second->timeAdded)->toTime()) < IceUtil::Time::seconds(5))
{
activeSaliencyMaps.push_back(p.second->name);
}
}
else if ((currentTime - TimestampVariantPtr::dynamicCast(p.second->timeAdded)->toTime()) < IceUtil::Time::seconds(5))
{
activeSaliencyMaps.push_back(p.second->name);
}
}
......@@ -447,12 +469,19 @@ void ViewSelection::drawSaliencyMap(const Ice::Current& c)
Eigen::Vector3f dim = Eigen::Vector3f::Ones() * 15;
DrawColor color = {r, g, b, 1.0};
// drawer->setLineSetVisu();
drawer->setBoxVisu("saliencyMap", "node_" + std::to_string(i), new Pose(pose), new Vector3(dim), color);
}
}
void ViewSelection::clearSaliencySphere(const Ice::Current& c)
{
drawer->clearLayer("saliencyMap");
}
void ViewSelection::removeSaliencyMap(const string& name, const Ice::Current& c)
{
boost::mutex::scoped_lock lock(syncMutex);
......@@ -465,6 +494,21 @@ void ViewSelection::removeSaliencyMap(const string& name, const Ice::Current& c)
condition.notify_all();
}
Ice::StringSeq ViewSelection::getSaliencyMapNames(const Ice::Current& c)
{
std::vector<std::string> names;
boost::mutex::scoped_lock lock(syncMutex);
for (const auto & p : saliencyMaps)
{
names.push_back(p.second->name);
}
return names;
}
PropertyDefinitionsPtr ViewSelection::createPropertyDefinitions()
{
......
......@@ -84,7 +84,7 @@ namespace armarx
defineOptionalProperty<std::string>("CameraFrameName", "VirtualCentralGaze", "Name of the frame of the head base in the robot model");
defineOptionalProperty<int>("SleepingTimeBetweenViewDirectionChanges", 2500, "Time between two view changes, to keep the head looking into one direction for a while (in ms)");
defineOptionalProperty<bool>("ActiveAtStartup", true, "Decide whether the automatic view selection will be activated (can be changed via the proxy during runtime)");
defineOptionalProperty<bool>("VisualizeViewDirection", false, "Draw view ray on DebugLayer.");
defineOptionalProperty<bool>("VisualizeViewDirection", true, "Draw view ray on DebugLayer.");
defineOptionalProperty<float>("MaxOverallHeadTiltAngle", 55.0f, "Maximal angle the head and eyes can look down (in degrees)");
defineOptionalProperty<float>("CentralHeadTiltAngle", 110.0f, "Defines the height direction that will be considered 'central' in the reachable area of the head (in degrees). Default is looking 20 degrees downwards");
defineOptionalProperty<float>("ProbabilityToLookForALostObject", 0.03f, "Probability that one of the objects that have been seen but could later not been localized again will be included in the view selection");
......@@ -180,7 +180,12 @@ namespace armarx
void removeSaliencyMap(const std::string& name, const Ice::Current& c = ::Ice::Current());
void drawSaliencyMap(const Ice::Current& c = ::Ice::Current());
::Ice::StringSeq getSaliencyMapNames(const Ice::Current& c = ::Ice::Current());
void drawSaliencySphere(const ::Ice::StringSeq& names, const Ice::Current& c = ::Ice::Current());
void clearSaliencySphere(const Ice::Current& c = ::Ice::Current());
private:
......
......@@ -19,28 +19,49 @@
<x>10</x>
<y>10</y>
<width>360</width>
<height>80</height>
<height>114</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Enable automatic view selection</string>
</property>
</widget>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Draw Saliency Map</string>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Draw Saliency Sphere</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Clear Saliency Sphere</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Enable automatic view selection</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
......
......@@ -22,6 +22,7 @@
#include "ViewSelectionWidgetController.h"
#include <QListWidgetItem>
#include <string>
using namespace armarx;
......@@ -32,7 +33,12 @@ ViewSelectionWidgetController::ViewSelectionWidgetController()
connect(widget.pushButton, SIGNAL(clicked()), this, SLOT(triggerSaliencyMapVisualization()));
connect(widget.pushButton_2, SIGNAL(clicked()), this, SLOT(clearSaliencyMapVisualization()));
connect(widget.pushButton_3, SIGNAL(clicked()), this, SLOT(updateSaliencyMapNames()));
connect(widget.checkBox, SIGNAL(toggled(bool)), this, SLOT(toggleViewSelection(bool)));
}
......@@ -69,6 +75,7 @@ void ViewSelectionWidgetController::onInitComponent()
{
usingProxy(viewSelectionName);
usingTopic(viewSelectionName + "Observer");
}
......@@ -104,14 +111,46 @@ void ViewSelectionWidgetController::toggleViewSelection(bool isEnabled)
}
else
{
viewSelection->deactivateAutomaticViewSelection();
}
}
void ViewSelectionWidgetController::triggerSaliencyMapVisualization()
{
viewSelection->drawSaliencyMap();
std::vector<std::string> names;
for (int r = 0; r < widget.listWidget->count(); r++)
{
QListWidgetItem* item = widget.listWidget->item(r);
if (item->checkState() == Qt::Checked)
{
names.push_back(item->text().toStdString());
}
}
viewSelection->drawSaliencySphere(names);
}
void ViewSelectionWidgetController::updateSaliencyMapNames()
{
std::vector<std::string> names = viewSelection->getSaliencyMapNames();
widget.listWidget->clear();
for (std::string name : names)
{
QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(name), widget.listWidget);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(Qt::Unchecked);
}
}
void ViewSelectionWidgetController::clearSaliencyMapVisualization()
{
viewSelection->clearSaliencySphere();
}
void armarx::ViewSelectionWidgetController::configured()
......
......@@ -117,6 +117,8 @@ namespace armarx
public slots:
void triggerSaliencyMapVisualization();
void clearSaliencyMapVisualization();
void updateSaliencyMapNames();
void toggleViewSelection(bool enabled);
/* QT slot declarations */
......
......@@ -77,8 +77,10 @@ module armarx
void updateSaliencyMap(SaliencyMapBase map);
void removeSaliencyMap(string name);
::Ice::StringSeq getSaliencyMapNames();
void drawSaliencyMap();
void drawSaliencySphere(::Ice::StringSeq names);
void clearSaliencySphere();
};
......
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