Task.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package RobotComponents
19 * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
20 * @date 2016
21 * @copyright http://www.gnu.org/licenses/gpl.txt
22 * GNU General Public License
23 */
24#pragma once
25
26#include <atomic>
27#include <chrono>
28#include <mutex>
29#include <random>
30
33#include <ArmarXCore/interface/core/RemoteObjectNode.h>
34
35#include <RobotComponents/interface/components/MotionPlanning/Tasks/RandomShortcutPostprocessor/Task.h>
36
37#include "../../util/Metrics.h"
39
40namespace armarx::rngshortcut
41{
42 class Task;
44
45 class Task :
47 public virtual TaskBase,
49 {
50 public:
51 Task(MotionPlanningTaskBasePtr previousStep,
52 const std::string& taskName = "RandomShortcutPostprocessorTask",
53 Ice::Long maxTimeForPostprocessingInSeconds = 6000,
54 Ice::Float dcdStep = 0.01,
55 Ice::Long maxTries = 10000,
56 Ice::Float minShortcutImprovementRatio = 0.1,
57 Ice::Float minPathImprovementRatio = 0.01);
58
59 PathWithCost
60 getPathWithCost(const Ice::Current& = Ice::emptyCurrent) const override
61 {
63 }
64
65 Path
66 getNthPath(Ice::Long n, const Ice::Current& = Ice::emptyCurrent) const override
67 {
69 }
70
71 Path
72 getPath(const Ice::Current& = Ice::emptyCurrent) const override
73 {
75 }
76
77 ~Task() override = default;
78
79 //PlanningControlInterface
80 /**
81 * @brief Aborts planning.
82 */
83 void abortTask(const Ice::Current& = Ice::emptyCurrent) override;
84
85 //PlanningTaskBase
86 /**
87 * @brief Runs the task.
88 * @param remoteNodes The list of \ref RemoteObjectNodeInterfacePrx used to distribute work to computers.
89 */
90 void run(const RemoteObjectNodePrxList& nodes,
91 const Ice::Current& = Ice::emptyCurrent) override;
92
93 Ice::Long
94 getMaximalPlanningTimeInSeconds(const Ice::Current& = Ice::emptyCurrent) const override
95 {
96 return previousStep->getMaximalPlanningTimeInSeconds();
97 }
98
99 Ice::Long getPathCount(const Ice::Current& = Ice::emptyCurrent) const override;
100 PathWithCost getBestPath(const Ice::Current& = Ice::emptyCurrent) const override;
101 PathWithCost getNthPathWithCost(Ice::Long n,
102 const Ice::Current& = Ice::emptyCurrent) const override;
103 PathWithCostSeq getAllPathsWithCost(const Ice::Current& = Ice::emptyCurrent) const override;
104
105 bool isPathCollisionFree(const VectorXf& from, const VectorXf& to);
106
107 std::pair<float, float> calcOffsets(float length, std::mt19937& gen);
108
109 protected:
110 /**
111 * @brief Ctor used by object factories.
112 */
113 Task() = default;
114
115 mutable std::mutex mtx;
117 PathWithCostSeq paths;
118 std::atomic_bool taskIsAborted{false};
119
120 private:
121 template <class Base, class Derived>
122 friend class ::armarx::GenericFactory;
123 };
124} // namespace armarx::rngshortcut
125
126namespace armarx
127{
132} // namespace armarx
Path getNthPath(Ice::Long n, const Ice::Current &=Ice::emptyCurrent) const override
PathWithCost getPathWithCost(const Ice::Current &=Ice::emptyCurrent) const override
Path getPath(const Ice::Current &=Ice::emptyCurrent) const override
PostprocessingMotionPlanningTask(const MotionPlanningTaskBasePtr &previousStep, const std::string &taskName)
The RemoteHandle class wrapps a ClientSideRemoteHandleControlBlock and can be used just as a Ice prox...
bool isPathCollisionFree(const VectorXf &from, const VectorXf &to)
Definition Task.cpp:361
PathWithCostSeq getAllPathsWithCost(const Ice::Current &=Ice::emptyCurrent) const override
Definition Task.cpp:354
Ice::Long getPathCount(const Ice::Current &=Ice::emptyCurrent) const override
Definition Task.cpp:334
Task()=default
Ctor used by object factories.
Path getPath(const Ice::Current &=Ice::emptyCurrent) const override
Definition Task.h:72
PathWithCostSeq paths
Definition Task.h:117
std::atomic_bool taskIsAborted
Definition Task.h:118
PathWithCost getNthPathWithCost(Ice::Long n, const Ice::Current &=Ice::emptyCurrent) const override
Definition Task.cpp:347
void abortTask(const Ice::Current &=Ice::emptyCurrent) override
Aborts planning.
Definition Task.cpp:91
Ice::Long getMaximalPlanningTimeInSeconds(const Ice::Current &=Ice::emptyCurrent) const override
Definition Task.h:94
Task(MotionPlanningTaskBasePtr previousStep, const std::string &taskName="RandomShortcutPostprocessorTask", Ice::Long maxTimeForPostprocessingInSeconds=6000, Ice::Float dcdStep=0.01, Ice::Long maxTries=10000, Ice::Float minShortcutImprovementRatio=0.1, Ice::Float minPathImprovementRatio=0.01)
Definition Task.cpp:38
PathWithCost getBestPath(const Ice::Current &=Ice::emptyCurrent) const override
Definition Task.cpp:341
~Task() override=default
void run(const RemoteObjectNodePrxList &nodes, const Ice::Current &=Ice::emptyCurrent) override
Runs the task.
Definition Task.cpp:101
Path getNthPath(Ice::Long n, const Ice::Current &=Ice::emptyCurrent) const override
Definition Task.h:66
PathWithCost getPathWithCost(const Ice::Current &=Ice::emptyCurrent) const override
Definition Task.h:60
std::pair< float, float > calcOffsets(float length, std::mt19937 &gen)
Definition Task.cpp:416
IceInternal::Handle< Task > TaskPtr
Definition Task.h:43
This file offers overloads of toIce() and fromIce() functions for STL container types.
rngshortcut::Task RandomShortcutPostprocessorTask
Definition Task.h:128
IceUtil::Handle< RandomShortcutPostprocessorTask > RandomShortcutPostprocessorTaskPtr
Definition Task.h:129
RemoteHandle< MotionPlanningMultiPathWithCostTaskControlInterfacePrx > RandomShortcutPostprocessorTaskHandle
Definition Task.h:130