15 #include <ArmarXGui/interface/RemoteGuiInterface.h>
33 namespace gui = RemoteGui;
53 RemoteGui::createRemoteGuiTab()
68 tab.targetPoseGroup.group.setLabel(
"Target pose");
72 tab.targetPoseGroup.targetPoseX.setRange(-max, max);
73 tab.targetPoseGroup.targetPoseX.setDecimals(0);
74 tab.targetPoseGroup.targetPoseX.setSteps(int(max / 10));
75 tab.targetPoseGroup.targetPoseX.setValue(0.F);
80 tab.targetPoseGroup.targetPoseY.setRange(-
max,
max);
81 tab.targetPoseGroup.targetPoseY.setDecimals(0);
82 tab.targetPoseGroup.targetPoseY.setSteps(
int(
max / 10));
83 tab.targetPoseGroup.targetPoseY.setValue(0.
F);
88 tab.targetPoseGroup.targetPoseZ.setRange(-max, max);
89 tab.targetPoseGroup.targetPoseZ.setDecimals(0);
90 tab.targetPoseGroup.targetPoseZ.setSteps(int(max / 10));
91 tab.targetPoseGroup.targetPoseZ.setValue(0.F);
96 tab.targetPoseGroup.targetPoseRoll.setRange(-max, max);
97 tab.targetPoseGroup.targetPoseRoll.setDecimals(0);
98 tab.targetPoseGroup.targetPoseRoll.setSteps(2 * max);
99 tab.targetPoseGroup.targetPoseRoll.setValue(0.F);
104 tab.targetPoseGroup.targetPosePitch.setRange(-max, max);
105 tab.targetPoseGroup.targetPosePitch.setDecimals(0);
106 tab.targetPoseGroup.targetPosePitch.setSteps(2 * max);
107 tab.targetPoseGroup.targetPosePitch.setValue(0.F);
112 tab.targetPoseGroup.targetPoseYaw.setRange(-max, max);
113 tab.targetPoseGroup.targetPoseYaw.setDecimals(0);
114 tab.targetPoseGroup.targetPoseYaw.setSteps(2 * max);
115 tab.targetPoseGroup.targetPoseYaw.setValue(0.F);
123 grid.add(Label("X"), {id, 0}).add(tab.targetPoseGroup.targetPoseX, {id, 1});
126 grid.add(Label("Y"), {id, 0}).add(tab.targetPoseGroup.targetPoseY, {id, 1});
129 grid.add(Label("Z"), {id, 0}).add(tab.targetPoseGroup.targetPoseZ, {id, 1});
132 grid.add(armarx::RemoteGui::Client::VSpacer(), {id, 1});
135 grid.add(Label("Roll"), {id, 0}).add(tab.targetPoseGroup.targetPoseRoll, {id, 1});
138 grid.add(Label("Pitch"), {id, 0}).add(tab.targetPoseGroup.targetPosePitch, {id, 1});
141 grid.add(Label("Yaw"), {id, 0}).add(tab.targetPoseGroup.targetPoseYaw, {id, 1});
145 VBoxLayout root = {grid, VSpacer()};
147 tab.targetPoseGroup.group.addChild(root);
151 tab.controlGroup.group.setLabel("Control");
153 tab.controlGroup.moveToButton.setLabel("MoveTo");
154 tab.controlGroup.continueButton.setLabel("Continue");
155 tab.controlGroup.pauseButton.setLabel("Pause");
156 tab.controlGroup.stopButton.setLabel("Stop");
157 tab.controlGroup.stopAllButton.setLabel("StopAll");
161 grid.add(tab.controlGroup.moveToButton, {id, 1});
164 grid.add(armarx::RemoteGui::Client::VSpacer(), {id, 1});
167 grid.add(tab.controlGroup.pauseButton, {id, 1});
170 grid.add(tab.controlGroup.continueButton, {id, 1});
173 grid.add(tab.controlGroup.stopButton, {id, 1});
176 grid.add(armarx::RemoteGui::Client::VSpacer(), {id, 1});
179 grid.add(tab.controlGroup.stopAllButton, {id, 1});
183 VBoxLayout root = {grid, VSpacer()};
184 tab.controlGroup.group.addChild(root);
189 tab.hbox.addChild(tab.targetPoseGroup.group);
190 tab.hbox.addChild(tab.controlGroup.group);
192 tab.create(REMOTE_GUI_TAB_MAME, remoteGui, tab.hbox);
198 constexpr int kCycleDurationMs = 100;
200 CycleUtil c(kCycleDurationMs);
201 while (!runningTask->isStopped())
206 std::lock_guard g{mtx};
209 tab.receiveUpdates();
210 tabPrx.receiveUpdates();
214 handleEvents(tabPrx);
217 std::lock_guard g{mtx};
221 tabPrx.sendUpdates();
225 c.waitForCycleDuration();
230 RemoteGui::handleEvents(::armarx::RemoteGui::TabProxy& tab3)
234 const std::string configId = "RemoteGui";
236 if (tab.controlGroup.moveToButton.wasClicked())
238 ARMARX_INFO << "MoveTo from RemoteGUI requested";
240 // const auto& scene = navigator.getScene();
242 // server::NavigationStack stack
245 // std::make_shared<global_planning::Point2Point>(global_planning::Point2PointParams(), scene),
246 // .trajectoryControl = std::make_shared<traj_ctrl::TrajectoryFollowingController>(
247 // traj_ctrl::TrajectoryFollowingControllerParams(), scene)};
249 // server::NavigationStack stack
252 // std::make_shared<global_planning::AStar>(global_planning::AStarParams(), scene),
253 // .trajectoryControl = std::make_shared<traj_ctrl::TrajectoryFollowingController>(
254 // traj_ctrl::TrajectoryFollowingControllerParams(), scene)};
256 client::NavigationStackConfig cfg;
257 cfg.globalPlanner(global_planning::SPFAParams());
258 cfg.localPlanner(local_planning::TimedElasticBandsParams());
259 cfg.trajectoryController(traj_ctrl::local::TrajectoryFollowingControllerParams());
261 const auto stackConfig = cfg.toAron();
265 navigator.createConfig(stackConfig, "RemoteGui");
267 const Eigen::Vector3f targetPos{tab.targetPoseGroup.targetPoseX.getValue(),
268 tab.targetPoseGroup.targetPoseY.getValue(),
269 tab.targetPoseGroup.targetPoseZ.getValue()};
271 const auto degToRad = [](float deg) -> float { return deg * M_PIf32 / 180.f; };
273 const Eigen::Vector3f targetOri{
274 degToRad(tab.targetPoseGroup.targetPoseRoll.getValue()),
275 degToRad(tab.targetPoseGroup.targetPosePitch.getValue()),
276 degToRad(tab.targetPoseGroup.targetPoseYaw.getValue())};
278 const core::Pose targetPose = core::Pose(Eigen::Translation3f(targetPos)) *
279 core::Pose(simox::math::rpy_to_mat3f(targetOri));
281 std::vector<Eigen::Matrix4f> waypoints;
282 waypoints.emplace_back(targetPose.matrix());
290 core::NavigationFrameNames.to_name(core::NavigationFrame::Absolute),
293 catch (const armarx::LocalException& ex)
295 ARMARX_WARNING << LogSender::eYellow
296 << "Failed moving to target. Reason: " << GetHandledExceptionString()
297 << LogSender::eReset;
301 if (tab.controlGroup.pauseButton.wasClicked())
303 ARMARX_INFO << "pauseMovement() from RemoteGUI requested";
304 navigator.pause(configId);
307 if (tab.controlGroup.continueButton.wasClicked())
309 ARMARX_INFO << "resumeMovement() from RemoteGUI requested";
310 navigator.resume(configId);
313 if (tab.controlGroup.stopButton.wasClicked())
315 ARMARX_INFO << "stop() from RemoteGUI requested";
316 navigator.stop(configId);
319 if (tab.controlGroup.stopAllButton.wasClicked())
321 ARMARX_INFO << "stop() from RemoteGUI requested";
327 RemoteGui::shutdown()
329 // std::lock_guard g{mtx};
331 if (!runningTask->isStopped())
336 ARMARX_DEBUG << "Removing tab: " << REMOTE_GUI_TAB_MAME;
337 remoteGui->removeTab(REMOTE_GUI_TAB_MAME);
345 // std::lock_guard g{mtx};
346 tabPrx.internalSetDisabled(tab.controlGroup.moveToButton.getName(), false);
347 tabPrx.internalSetDisabled(tab.controlGroup.pauseButton.getName(), false);
348 tabPrx.internalSetDisabled(tab.controlGroup.continueButton.getName(), false);
349 tabPrx.internalSetDisabled(tab.controlGroup.stopButton.getName(), false);
350 tabPrx.internalSetDisabled(tab.controlGroup.stopAllButton.getName(), false);
358 // std::unique_lock g{mtx};
360 // it might happen, that this function is triggered from handleEvents
361 // std::unique_lock ul{handleEventsMtx};
364 tabPrx.internalSetDisabled(tab.controlGroup.moveToButton.getName(), true);
365 tabPrx.internalSetDisabled(tab.controlGroup.pauseButton.getName(), true);
366 tabPrx.internalSetDisabled(tab.controlGroup.continueButton.getName(), true);
367 tabPrx.internalSetDisabled(tab.controlGroup.stopButton.getName(), true);
368 tabPrx.internalSetDisabled(tab.controlGroup.stopAllButton.getName(), true);
376 // std::lock_guard g{mtx};
378 tab.targetPoseGroup.targetPoseX.setValue(0.F);
379 tab.targetPoseGroup.targetPoseY.setValue(0.F);
380 tab.targetPoseGroup.targetPoseZ.setValue(0.F);
381 tab.targetPoseGroup.targetPoseRoll.setValue(0.F);
382 tab.targetPoseGroup.targetPosePitch.setValue(0.F);
383 tab.targetPoseGroup.targetPoseYaw.setValue(0.F);
389 } // namespace armarx::navigation::components::navigator