Go to the documentation of this file.
29 #include <unordered_map>
36 #include "../../util/Samplers.h"
37 #include "../../util/Metrics.h"
38 #include "../../util/PlanningUtil.h"
39 #include <RobotComponents/interface/components/MotionPlanning/Tasks/AdaptiveDynamicDomainInformedRRTStar/WorkerNode.h>
45 template <
class IceBaseClass,
class DerivedClass>
class GenericFactory;
75 virtual public WorkerNodeBase
83 static_assert(std::numeric_limits<Ice::Float>::has_infinity,
"requires inf in current implementation");
100 const CSpaceBasePtr& cspace,
101 const VectorXf& startCfg,
102 const VectorXf& goalCfg,
104 AdaptiveDynamicDomainParameters addParams,
105 const ManagerNodeBasePrx& manager,
108 Ice::Long nodeCountDeltaForGoalConnectionTries,
109 const std::string& topicPrefix,
110 const Ice::FloatSeq& rotationMatrix
118 manager, workerId, batchSize, nodeCountDeltaForGoalConnectionTries, topicPrefix,
130 #pragma GCC diagnostic push
131 #pragma GCC diagnostic ignored "-Wterminate"
133 #pragma GCC diagnostic pop
158 return "ADDIRRTStarWorkerNode";
165 void killWorker(
const Ice::Current& = Ice::emptyCurrent)
override
170 void pauseWorker(
bool pauseFlag,
const Ice::Current& = Ice::emptyCurrent)
override
179 Update
getUpdate(
Ice::Long updateId,
const Ice::Current& = Ice::emptyCurrent)
const override;
187 void updateTree(
const Update& u,
const Ice::Current& = Ice::emptyCurrent)
override;
269 return cspace->getDimensionality();
347 NodeId& outNodeBestId,
348 float& outCostReachedToNodeBest,
349 std::vector<std::pair<NodeId, float>>& outKNearestIdsAndDistances,
350 std::map<NodeId, bool>& outIsCollisionFreeCache
361 const NodeId& nodeId,
362 const std::vector<std::pair<NodeId, float>>& kNearestIdsAndDistances,
363 const std::map<NodeId, bool>& isCollisionFreeCache
393 std::pair<const float*, const float*> bufferCDRange;
std::string getDefaultName() const override
void onInitComponent() override
Initializes the worker and starts the worker thread.
std::atomic_bool killRequest
Wheether the node should shut down.
Update getUpdate(Ice::Long updateId, const Ice::Current &=Ice::emptyCurrent) const override
void applyPendingUpdates()
Applies all pending updates to the tree.
void rewire(const NodeId &nodeId, const std::vector< std::pair< NodeId, float >> &kNearestIdsAndDistances, const std::map< NodeId, bool > &isCollisionFreeCache)
The rewire operation of the rrt* algorithm.
std::string updateTopicName
The update topic's name.
const VariantTypeId Float
void initTree()
initializes the tree by getting the current tree from the manager
Update getRemoteUpdate(Ice::Long workerNodeId, Ice::Long updateSubId)
Tree::ConfigType ConfigType
Type of a configuration.
~WorkerNode() override
dtor.
void init(const FullIceTree &iceTree, AdaptiveDynamicDomainParameters newaddParams, std::size_t newWorkerId)
Initailizes the tree from the given tree.
std::mutex updateMutex
Mutex protecting the update structures.
std::atomic_bool workerPaused
workerPaused is true if the worker is currently on hold and does not perform any calculations.
VectorXf ConfigType
The type of configurations.
WorkerNode()=default
Only used when transmitting through ice.
static float distance(const ConfigType &from, const ConfigType &to)
Calculates the euclidian distance between from and to.
void onDisconnectComponent() override
noop
void doBatchIteration()
Executes one iteration of a batch.
void ice_postUnmarshal() override
noop
void onExitComponent() override
Kills the worker thread (if it is still running) and joins it.
Implements the worker side of the batch distributed adaptive dynamic domain informed rrt* planner.
void onConnectComponent() override
Gets a proxy to the topic.
void workerTask()
The worker task.
std::thread workerThread
Thread executing the worker task.
bool isCollisionFree(const ConfigType &cfg)
ConfigType steer(const ConfigType &from, const ConfigType &to)
Does a linear interpolation from from to to and checks the path per DCD.
bool isPathCollisionFree(const ConfigType &from, const ConfigType &to)
std::size_t getDimensionality()
std::string workerIdSring
A string representation of the worker id.
TreeUpdateInterfacePrx globalWorkers
Proxy used to write to the update topic.
std::size_t onePastLastGoalConnect
The index one past the last node that was considered to be connected to the goal configuration.
void doBatch()
Executes a batch.
WorkerNode(const CSpaceBasePtr &cspace, const VectorXf &startCfg, const VectorXf &goalCfg, Ice::Float DCDStepSize, AdaptiveDynamicDomainParameters addParams, const ManagerNodeBasePrx &manager, Ice::Long workerId, Ice::Long batchSize, Ice::Long nodeCountDeltaForGoalConnectionTries, const std::string &topicPrefix, const Ice::FloatSeq &rotationMatrix)
ctor
std::unique_ptr< InformedSampler > sampler
Stores the sampler.
float euclideanDistance(IteratorType1 first1, IteratorType1 last1, IteratorType2 first2)
Returns the euclidean distance.
The ManagedIceObject is the base class for all ArmarX objects.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
A structure holding and managing all data connected to the tree used in the ADDIRRT* algorithm.
void findBestParent(const NodeId &nodeNearestId, const ConfigType &cfgReached, NodeId &outNodeBestId, float &outCostReachedToNodeBest, std::vector< std::pair< NodeId, float >> &outKNearestIdsAndDistances, std::map< NodeId, bool > &outIsCollisionFreeCache)
Searches the optimal parent for a configuration.
void updateTree(const Update &u, const Ice::Current &=Ice::emptyCurrent) override
Receives an update from other workers and adds it to the queue of pending updates.
void pauseWorker(bool pauseFlag, const Ice::Current &=Ice::emptyCurrent) override
This file offers overloads of toIce() and fromIce() functions for STL container types.
void addAndRewireConfig(const ConfigType &cfgReached, const NodeId &nodeNearestId)
Adds a configuration to the tree.
void killWorker(const Ice::Current &=Ice::emptyCurrent) override
Signals the worker thread to exit.