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 <mutex>
27 #include <chrono>
28 #include <atomic>
29 #include <random>
30 
32 
34 #include <ArmarXCore/interface/core/RemoteObjectNode.h>
35 
36 #include <RobotComponents/interface/components/MotionPlanning/Tasks/RandomShortcutPostprocessor/Task.h>
37 #include "../../util/Metrics.h"
38 
39 #include "../MotionPlanningTask.h"
40 
41 namespace armarx::rngshortcut
42 {
43  class Task;
45 
46  class Task:
47  public virtual PostprocessingMotionPlanningTask,
48  public virtual TaskBase,
50  {
51  public:
52  Task(
53  MotionPlanningTaskBasePtr previousStep,
54  const std::string& taskName = "RandomShortcutPostprocessorTask",
55  Ice::Long maxTimeForPostprocessingInSeconds = 6000,
56  Ice::Float dcdStep = 0.01,
57  Ice::Long maxTries = 10000,
58  Ice::Float minShortcutImprovementRatio = 0.1,
59  Ice::Float minPathImprovementRatio = 0.01
60  );
61 
62 
63  PathWithCost getPathWithCost(const Ice::Current& = Ice::emptyCurrent) const override
64  {
66  }
67  Path getNthPath(Ice::Long n, const Ice::Current& = Ice::emptyCurrent) const override
68  {
70  }
71  Path getPath(const Ice::Current& = Ice::emptyCurrent) const override
72  {
74  }
75 
76  ~Task() override = default;
77 
78  //PlanningControlInterface
79  /**
80  * @brief Aborts planning.
81  */
82  void abortTask(const Ice::Current& = Ice::emptyCurrent) override;
83 
84  //PlanningTaskBase
85  /**
86  * @brief Runs the task.
87  * @param remoteNodes The list of \ref RemoteObjectNodeInterfacePrx used to distribute work to computers.
88  */
89  void run(const RemoteObjectNodePrxList& nodes, const Ice::Current& = Ice::emptyCurrent) override;
90 
91  Ice::Long getMaximalPlanningTimeInSeconds(const Ice::Current& = Ice::emptyCurrent) const override
92  {
93  return previousStep->getMaximalPlanningTimeInSeconds();
94  }
95 
96  Ice::Long getPathCount(const Ice::Current& = Ice::emptyCurrent) const override;
97  PathWithCost getBestPath(const Ice::Current& = Ice::emptyCurrent) const override;
98  PathWithCost getNthPathWithCost(Ice::Long n, const Ice::Current& = Ice::emptyCurrent) const override;
99  PathWithCostSeq getAllPathsWithCost(const Ice::Current& = Ice::emptyCurrent) const override;
100 
101  bool isPathCollisionFree(const VectorXf& from, const VectorXf& to);
102 
103  std::pair<float, float> calcOffsets(float length, std::mt19937& gen);
104 
105  protected:
106  /**
107  * @brief Ctor used by object factories.
108  */
109  Task() = default;
110 
111  mutable std::mutex mtx;
113  PathWithCostSeq paths;
114  std::atomic_bool taskIsAborted {false};
115  private:
116  template<class Base, class Derived> friend class ::armarx::GenericFactory;
117  };
118 }
119 namespace armarx
120 {
124 }
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::rngshortcut::Task::paths
PathWithCostSeq paths
Definition: Task.h:113
armarx::rngshortcut::Task::mtx
std::mutex mtx
Definition: Task.h:111
armarx::rngshortcut::Task::getPath
Path getPath(const Ice::Current &=Ice::emptyCurrent) const override
Definition: Task.h:71
armarx::rngshortcut::Task::getMaximalPlanningTimeInSeconds
Ice::Long getMaximalPlanningTimeInSeconds(const Ice::Current &=Ice::emptyCurrent) const override
Definition: Task.h:91
armarx::rngshortcut::Task::getPathCount
Ice::Long getPathCount(const Ice::Current &=Ice::emptyCurrent) const override
Definition: Task.cpp:305
RemoteHandle.h
FactoryCollectionBase.h
armarx::rngshortcut::Task::calcOffsets
std::pair< float, float > calcOffsets(float length, std::mt19937 &gen)
Definition: Task.cpp:382
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::rngshortcut::Task::getPathWithCost
PathWithCost getPathWithCost(const Ice::Current &=Ice::emptyCurrent) const override
Definition: Task.h:63
armarx::rngshortcut::Task::run
void run(const RemoteObjectNodePrxList &nodes, const Ice::Current &=Ice::emptyCurrent) override
Runs the task.
Definition: Task.cpp:86
armarx::rngshortcut::Task::getNthPathWithCost
PathWithCost getNthPathWithCost(Ice::Long n, const Ice::Current &=Ice::emptyCurrent) const override
Definition: Task.cpp:316
armarx::MotionPlanningMultiPathWithCostTaskCI::getPathWithCost
PathWithCost getPathWithCost(const Ice::Current &=Ice::emptyCurrent) const override
Definition: MotionPlanningTaskControlInterface.h:106
armarx::rngshortcut::Task::getNthPath
Path getNthPath(Ice::Long n, const Ice::Current &=Ice::emptyCurrent) const override
Definition: Task.h:67
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
armarx::rngshortcut::Task::Task
Task()=default
Ctor used by object factories.
armarx::MotionPlanningMultiPathWithCostTaskCI::getNthPath
Path getNthPath(Ice::Long n, const Ice::Current &=Ice::emptyCurrent) const override
Definition: MotionPlanningTaskControlInterface.h:110
armarx::MotionPlanningWithCostTaskCI::getPath
Path getPath(const Ice::Current &=Ice::emptyCurrent) const override
Definition: MotionPlanningTaskControlInterface.h:82
armarx::rngshortcut::Task::taskIsAborted
std::atomic_bool taskIsAborted
Definition: Task.h:114
armarx::rngshortcut::Task::postprocessedSolution
Path postprocessedSolution
Definition: Task.h:112
armarx::rngshortcut::Task::isPathCollisionFree
bool isPathCollisionFree(const VectorXf &from, const VectorXf &to)
Definition: Task.cpp:328
armarx::rngshortcut::Task::getAllPathsWithCost
PathWithCostSeq getAllPathsWithCost(const Ice::Current &=Ice::emptyCurrent) const override
Definition: Task.cpp:322
armarx::PostprocessingMotionPlanningTask
Definition: MotionPlanningTask.h:212
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::RemoteHandle< MotionPlanningMultiPathWithCostTaskControlInterfacePrx >
armarx::rngshortcut::Task::getBestPath
PathWithCost getBestPath(const Ice::Current &=Ice::emptyCurrent) const override
Definition: Task.cpp:311
armarx::rngshortcut::Task
Definition: Task.h:46
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::rngshortcut::Task::~Task
~Task() override=default
armarx::rngshortcut
Definition: Task.cpp:31
armarx::rngshortcut::Task::abortTask
void abortTask(const Ice::Current &=Ice::emptyCurrent) override
Aborts planning.
Definition: Task.cpp:77
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::MotionPlanningMultiPathWithCostTaskCI
Definition: MotionPlanningTaskControlInterface.h:89