30#include <unordered_map>
36#include <RobotComponents/interface/components/MotionPlanning/Tasks/AdaptiveDynamicDomainInformedRRTStar/WorkerNode.h>
45 template <
class IceBaseClass,
class DerivedClass>
83 static_assert(std::numeric_limits<Ice::Float>::has_infinity,
84 "requires inf in current implementation");
101 const VectorXf& startCfg,
102 const VectorXf& goalCfg,
103 Ice::Float DCDStepSize,
104 AdaptiveDynamicDomainParameters addParams,
105 const ManagerNodeBasePrx& manager,
108 Ice::Long nodeCountDeltaForGoalConnectionTries,
109 const std::string& topicPrefix,
110 const Ice::FloatSeq& rotationMatrix
113 WorkerNodeBase(cspace,
121 nodeCountDeltaForGoalConnectionTries,
133#pragma GCC diagnostic push
134#pragma GCC diagnostic ignored "-Wterminate"
136#pragma GCC diagnostic pop
168 return "ADDIRRTStarWorkerNode";
182 pauseWorker(
bool pauseFlag,
const Ice::Current& = Ice::emptyCurrent)
override
192 const Ice::Current& = Ice::emptyCurrent)
const override;
200 void updateTree(
const Update& u,
const Ice::Current& = Ice::emptyCurrent)
override;
251 tree.init(manager->getTree(), addParams, workerId);
282 return cspace->getDimensionality();
360 NodeId& outNodeBestId,
361 float& outCostReachedToNodeBest,
362 std::vector<std::pair<NodeId, float>>& outKNearestIdsAndDistances,
363 std::map<NodeId, bool>& outIsCollisionFreeCache);
372 void rewire(
const NodeId& nodeId,
373 const std::vector<std::pair<NodeId, float>>& kNearestIdsAndDistances,
374 const std::map<NodeId, bool>& isCollisionFreeCache);
403 std::pair<const float*, const float*> bufferCDRange;
A structure holding and managing all data connected to the tree used in the ADDIRRT* algorithm.
VectorXf ConfigType
The type of configurations.
Implements the worker side of the batch distributed adaptive dynamic domain informed rrt* planner.
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.
std::size_t onePastLastGoalConnect
The index one past the last node that was considered to be connected to the goal configuration.
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 onInitComponent() override
Initializes the worker and starts the worker thread.
void ice_postUnmarshal() override
noop
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
void applyPendingUpdates()
Applies all pending updates to the tree.
void workerTask()
The worker task.
void onDisconnectComponent() override
noop
std::string updateTopicName
The update topic's name.
void doBatch()
Executes a batch.
std::thread workerThread
Thread executing the worker task.
TreeUpdateInterfacePrx globalWorkers
Proxy used to write to the update topic.
std::atomic_bool killRequest
Wheether the node should shut down.
Update getUpdate(Ice::Long updateId, const Ice::Current &=Ice::emptyCurrent) const override
friend class ManagedIceObject
required for static factory methode create
std::mutex updateMutex
Mutex protecting the update structures.
~WorkerNode() override
dtor.
void addAndRewireConfig(const ConfigType &cfgReached, const NodeId &nodeNearestId)
Adds a configuration to the tree.
std::size_t getDimensionality()
std::unique_ptr< InformedSampler > sampler
Stores the sampler.
void initTree()
initializes the tree by getting the current tree from the manager
void onConnectComponent() override
Gets a proxy to the topic.
static float distance(const ConfigType &from, const ConfigType &to)
Calculates the euclidian distance between from and to.
void pauseWorker(bool pauseFlag, const Ice::Current &=Ice::emptyCurrent) override
std::string workerIdSring
A string representation of the worker id.
Tree::ConfigType ConfigType
Type of a configuration.
Update getRemoteUpdate(Ice::Long workerNodeId, Ice::Long updateSubId)
void doBatchIteration()
Executes one iteration of a batch.
std::atomic_bool workerPaused
workerPaused is true if the worker is currently on hold and does not perform any calculations.
bool isPathCollisionFree(const ConfigType &from, const ConfigType &to)
ConfigType steer(const ConfigType &from, const ConfigType &to)
Does a linear interpolation from from to to and checks the path per DCD.
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.
void onExitComponent() override
Kills the worker thread (if it is still running) and joins it.
WorkerNode()=default
Only used when transmitting through ice.
bool isCollisionFree(const ConfigType &cfg)
std::string getDefaultName() const override
void killWorker(const Ice::Current &=Ice::emptyCurrent) override
Signals the worker thread to exit.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
IceInternal::Handle< WorkerNode > WorkerNodePtr
An ice handle for a WorkerNode of the addirrt* algorithm.
This file offers overloads of toIce() and fromIce() functions for STL container types.
float euclideanDistance(IteratorType1 first1, IteratorType1 last1, IteratorType2 first2)
Returns the euclidean distance.