Skip to content
Snippets Groups Projects
Commit 1412bb37 authored by Christoph Pohl's avatar Christoph Pohl
Browse files

Add support for getting NDArray values from remote gui and updating config

parent 0ebd49e0
No related branches found
No related tags found
1 merge request!290Draft: Aron/feature/defaults ranges docs
...@@ -57,10 +57,7 @@ namespace armarx ...@@ -57,10 +57,7 @@ namespace armarx
ARMARX_TRACE; ARMARX_TRACE;
auto& config = auto& config =
aron_component_config_plugin_->config_.getWriteBuffer(); aron_component_config_plugin_->config_.getWriteBuffer();
for (const auto& [key, value] : config.subMember.subsubMember.intDictMember) // ARMARX_INFO << VAROUT(config.orientation) << VAROUT(config.pose) << VAROUT(config.position);
{
ARMARX_INFO << key << value;
}
config.intMember--; config.intMember--;
aron_component_config_plugin_->config_.commitWrite(); aron_component_config_plugin_->config_.commitWrite();
}, 1000); }, 1000);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "RemoteGuiVisitors.h" #include "RemoteGuiVisitors.h"
#include <SimoxUtility/math/convert/quat_to_rpy.h> #include <SimoxUtility/math/convert/quat_to_rpy.h>
#include <SimoxUtility/math/convert/rpy_to_quat.h>
#include <ArmarXCore/util/CPPUtility/Iterator.h> #include <ArmarXCore/util/CPPUtility/Iterator.h>
...@@ -259,7 +260,7 @@ namespace armarx::aron::component_config ...@@ -259,7 +260,7 @@ namespace armarx::aron::component_config
auto group = RemoteGui::makeHBoxLayout(name + "_layout"); auto group = RemoteGui::makeHBoxLayout(name + "_layout");
group.addChild(RemoteGui::makeLabel(name + "_label").value(q->getPath().getLastElement())); group.addChild(RemoteGui::makeLabel(name + "_label").value(q->getPath().getLastElement()));
group.addHSpacer(); group.addHSpacer();
group.addChild(RemoteGui::makeVector3fSpinBoxes(name).value(quat).min(-M_PI).max(M_PI).toolTip(name)); group.addChild(RemoteGui::makeVector3fSpinBoxes(name).value(quat).min(-M_PI).max(M_PI).steps(601).decimals(2).toolTip(name));
group_hierarchy_.back()->addChild(group); group_hierarchy_.back()->addChild(group);
} }
...@@ -519,6 +520,78 @@ namespace armarx::aron::component_config ...@@ -519,6 +520,78 @@ namespace armarx::aron::component_config
{ {
return tab_rebuild_required_; return tab_rebuild_required_;
} }
void
GetValueFromMapVisitor::visitMatrix(std::shared_ptr<data::Variant>& o,
const std::shared_ptr<type::Variant>& t)
{
INPUT_GUARD(o);
auto value = data::NDArray::DynamicCastAndCheck(o);
auto type = type::Matrix::DynamicCastAndCheck(t);
const std::string name = pathToName(o);
const auto& cols = type->getCols();
const auto& rows = type->getRows();
// TODO: does double work here?
if (cols == 4 && rows == 4)
{
auto gui_value = proxy_->getValue<Eigen::Matrix4f>(name);
auto config_value = converter::AronEigenConverter::ConvertToMatrix4f(value);
if (config_value != gui_value.get())
{
if (proxy_->hasValueChanged(name))
{
auto variant = converter::AronEigenConverter::ConvertFromMatrix(gui_value.get());
value->setData(gui_value.get().size() * sizeof(float), variant->getData());
}
else
{
proxy_->setValue(config_value, name);
}
}
} else if ((cols == 3 and rows == 1) or (cols == 1 and rows == 3))
{
auto gui_value = proxy_->getValue<Eigen::Vector3f>(name);
auto config_value = converter::AronEigenConverter::ConvertToVector3f(value);
if (config_value != gui_value.get())
{
if (proxy_->hasValueChanged(name))
{
auto variant = converter::AronEigenConverter::ConvertFromMatrix(gui_value.get());
value->setData(gui_value.get().size() * sizeof(float), variant->getData());
}
else
{
proxy_->setValue(config_value, name);
}
}
}
}
void
GetValueFromMapVisitor::visitQuaternion(std::shared_ptr<data::Variant>& o,
const std::shared_ptr<type::Variant>& t)
{
INPUT_GUARD(o);
auto value = data::NDArray::DynamicCastAndCheck(o);
const std::string name = pathToName(o);
// TODO: does double work here?
auto gui_value = proxy_->getValue<Eigen::Vector3f>(name);
const auto& quat = simox::math::quat_to_rpy(converter::AronEigenConverter::ConvertToQuaternionf(value));
ARMARX_INFO << VAROUT(quat) << VAROUT(gui_value.get());
if (quat != gui_value.get())
{
if (proxy_->hasValueChanged(name))
{
auto variant = converter::AronEigenConverter::ConvertFromQuaternion(simox::math::rpy_to_quat(gui_value.get()));
value->setData(4 * sizeof(float), variant->getData());
}
else
{
proxy_->setValue(quat, name);
}
}
}
void void
GetValueFromMapVisitor::visitDictOnEnter(std::shared_ptr<data::Variant>& o, GetValueFromMapVisitor::visitDictOnEnter(std::shared_ptr<data::Variant>& o,
......
...@@ -118,6 +118,8 @@ namespace armarx::aron::component_config ...@@ -118,6 +118,8 @@ namespace armarx::aron::component_config
void visitBool(DataInput&, TypeInput&) override; void visitBool(DataInput&, TypeInput&) override;
void visitString(DataInput&, TypeInput&) override; void visitString(DataInput&, TypeInput&) override;
void visitMatrix(DataInput& elementData, TypeInput& elementType) override;
void visitQuaternion(DataInput& elementData, TypeInput& elementType) override;
bool tabRebuildRequired() const; bool tabRebuildRequired() const;
......
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