diff --git a/source/Navigation/components/Navigator/Navigator.cpp b/source/Navigation/components/Navigator/Navigator.cpp index 98d80fc4aa38d7c1651c7b2731987cc8861eabbd..a98856e9ab7bd64997057242bd405ecdb27ae57a 100644 --- a/source/Navigation/components/Navigator/Navigator.cpp +++ b/source/Navigation/components/Navigator/Navigator.cpp @@ -22,6 +22,7 @@ #include "Navigator.h" +#include <cmath> #include <iterator> #include <boost/uuid/uuid.hpp> @@ -198,32 +199,121 @@ void armarx::nav::components::Navigator::createRemoteGuiTab() // Setup the widgets. - tab.boxLayerName.setValue(0); - tab.numBoxes.setValue(1); - tab.numBoxes.setRange(0, 100); + { + tab.targetPoseGroup.group.setLabel("Target pose"); + + { + float max = 10'000; + tab.targetPoseGroup.targetPoseX.setRange(-max, max); + tab.targetPoseGroup.targetPoseX.setDecimals(0); + tab.targetPoseGroup.targetPoseX.setSteps(int(max / 10)); + tab.targetPoseGroup.targetPoseX.setValue(0.F); + } + + { + float max = 10'000; + tab.targetPoseGroup.targetPoseY.setRange(-max, max); + tab.targetPoseGroup.targetPoseY.setDecimals(0); + tab.targetPoseGroup.targetPoseY.setSteps(int(max / 10)); + tab.targetPoseGroup.targetPoseY.setValue(0.F); + } + + { + float max = 10'000; + tab.targetPoseGroup.targetPoseZ.setRange(-max, max); + tab.targetPoseGroup.targetPoseZ.setDecimals(0); + tab.targetPoseGroup.targetPoseZ.setSteps(int(max / 10)); + tab.targetPoseGroup.targetPoseZ.setValue(0.F); + } + + { + float max = 180; + tab.targetPoseGroup.targetPoseRoll.setRange(-max, max); + tab.targetPoseGroup.targetPoseRoll.setDecimals(0); + tab.targetPoseGroup.targetPoseRoll.setSteps(2 * max); + tab.targetPoseGroup.targetPoseRoll.setValue(0.F); + } + + { + float max = 180; + tab.targetPoseGroup.targetPosePitch.setRange(-max, max); + tab.targetPoseGroup.targetPosePitch.setDecimals(0); + tab.targetPoseGroup.targetPosePitch.setSteps(2 * max); + tab.targetPoseGroup.targetPosePitch.setValue(0.F); + } + + { + float max = 180; + tab.targetPoseGroup.targetPoseYaw.setRange(-max, max); + tab.targetPoseGroup.targetPoseYaw.setDecimals(0); + tab.targetPoseGroup.targetPoseYaw.setSteps(2 * max); + tab.targetPoseGroup.targetPoseYaw.setValue(0.F); + } + + // tab.boxLayerName.setValue(0); + // tab.numBoxes.setValue(1); + // tab.numBoxes.setRange(0, 100); + + // tab.drawBoxes.setLabel("Draw Boxes"); + + // Setup the layout. + + GridLayout grid; + int row = 0; + { + grid.add(Label("X"), {row, 0}).add(tab.targetPoseGroup.targetPoseX, {row, 1}); + ++row; + + grid.add(Label("Y"), {row, 0}).add(tab.targetPoseGroup.targetPoseY, {row, 1}); + ++row; + + grid.add(Label("Z"), {row, 0}).add(tab.targetPoseGroup.targetPoseZ, {row, 1}); + ++row; + + grid.add(Label("Roll"), {row, 0}).add(tab.targetPoseGroup.targetPoseRoll, {row, 1}); + ++row; + + grid.add(Label("Pitch"), {row, 0}).add(tab.targetPoseGroup.targetPosePitch, {row, 1}); + ++row; + + grid.add(Label("Yaw"), {row, 0}).add(tab.targetPoseGroup.targetPoseYaw, {row, 1}); + ++row; + + // grid.add(Label("Num Boxes"), {row, 0}).add(tab.numBoxes, {row, 1}); + // ++row; + + // grid.add(tab.drawBoxes, {row, 0}, {2, 1}); + // ++row; + } + + VBoxLayout root = {grid, VSpacer()}; + + tab.targetPoseGroup.group.addChild(root); + } - tab.drawBoxes.setLabel("Draw Boxes"); + { + tab.controlGroup.group.setLabel("Control"); - // Setup the layout. + GridLayout grid; + int row = 0; + { + grid.add(tab.controlGroup.moveToButton, {row, 1}); + ++row; - GridLayout grid; - int row = 0; - { - grid.add(Label("Box Layer"), {row, 0}).add(tab.boxLayerName, {row, 1}); - ++row; + grid.add(tab.controlGroup.pauseButton, {row, 1}); + ++row; - grid.add(Label("Num Boxes"), {row, 0}).add(tab.numBoxes, {row, 1}); - ++row; + grid.add(tab.controlGroup.continueButton, {row, 1}); + ++row; + } - grid.add(tab.drawBoxes, {row, 0}, {2, 1}); - ++row; + VBoxLayout root = {grid, VSpacer()}; + tab.controlGroup.group.addChild(root); } - VBoxLayout root = {grid, VSpacer()}; - ARMARX_TRACE; - RemoteGui_createTab(getName(), root, &tab); + RemoteGui_createTab(getName(), tab.targetPoseGroup.group, &tab); } void armarx::nav::components::Navigator::RemoteGui_update() @@ -242,12 +332,13 @@ void armarx::nav::components::Navigator::RemoteGui_update() // sendDebugObserverBatch(); // } // } - if (tab.drawBoxes.wasClicked()) - { - // Lock shared variables in methods running in seperate threads - // and pass them to functions. This way, the called functions do - // not need to think about locking. - std::scoped_lock lock(propertiesMutex); - // drawBoxes(properties, arviz); - } + // if (tab.drawBoxes.wasClicked()) + // { + // ARMARX_INFO << "Navigator control requested from remote GUI"; + // // Lock shared variables in methods running in seperate threads + // // and pass them to functions. This way, the called functions do + // // not need to think about locking. + // std::scoped_lock lock(propertiesMutex); + // // drawBoxes(properties, arviz); + // } } diff --git a/source/Navigation/components/Navigator/Navigator.h b/source/Navigation/components/Navigator/Navigator.h index 16ad98af456be7461d78847456433a9836e0c072..a3ec542b7884cc5d1e862ccd5d36232802c7d4dc 100644 --- a/source/Navigation/components/Navigator/Navigator.h +++ b/source/Navigation/components/Navigator/Navigator.h @@ -114,11 +114,9 @@ namespace armarx::nav::components VirtualRobot::RobotPtr getRobot(); - void createRemoteGuiTab(); void RemoteGui_update() override; - private: // TODO update context periodically @@ -128,17 +126,32 @@ namespace armarx::nav::components server::PlatformUnitExecutor executor; std::map<std::string, server::Navigator> navigators; - - std::mutex propertiesMutex; struct RemoteGuiTab : armarx::RemoteGui::Client::Tab { - armarx::RemoteGui::Client::LineEdit boxLayerName; - armarx::RemoteGui::Client::IntSpinBox numBoxes; + struct + { + armarx::RemoteGui::Client::GroupBox group; + + armarx::RemoteGui::Client::FloatSpinBox targetPoseX; + armarx::RemoteGui::Client::FloatSpinBox targetPoseY; + armarx::RemoteGui::Client::FloatSpinBox targetPoseZ; + armarx::RemoteGui::Client::FloatSpinBox targetPoseRoll; + armarx::RemoteGui::Client::FloatSpinBox targetPosePitch; + armarx::RemoteGui::Client::FloatSpinBox targetPoseYaw; + } targetPoseGroup; + + struct + { + armarx::RemoteGui::Client::GroupBox group; + + armarx::RemoteGui::Client::Button moveToButton; + armarx::RemoteGui::Client::Button pauseButton; + armarx::RemoteGui::Client::Button continueButton; + } controlGroup; - armarx::RemoteGui::Client::Button drawBoxes; }; RemoteGuiTab tab; };