Simox
2.3.74.0
|
A c-space interface for motion planning. More...
Public Member Functions | |
EIGEN_MAKE_ALIGNED_OPERATOR_NEW | CSpace (VirtualRobot::RobotPtr robot, VirtualRobot::CDManagerPtr collisionManager, VirtualRobot::RobotNodeSetPtr robotNodes, unsigned int maxConfigs=50000, unsigned int randomSeed=0) |
virtual | ~CSpace () |
destructor More... | |
virtual CSpacePathPtr | createPath (const Eigen::VectorXf &start, const Eigen::VectorXf &goal) |
virtual CSpacePathPtr | createPathUntilInvalid (const Eigen::VectorXf &start, const Eigen::VectorXf &goal, float &storeAddedLength) |
void | setBoundaries (const Eigen::VectorXf &min, const Eigen::VectorXf &max) |
void | setBoundary (unsigned int dim, float min, float max) |
void | setMetricWeights (const Eigen::VectorXf &weights) |
float | getBoundaryMin (unsigned int d) |
get minimum boundary of an index More... | |
float | getBoundaryMax (unsigned int d) |
get maximum boundary of an index More... | |
float | getBoundaryDist (unsigned int d) |
get boundary distance of an index More... | |
bool | isBorderlessDimension (unsigned int dim) const |
unsigned int | getDimension () const |
get cspace dimension More... | |
VirtualRobot::RobotPtr | getRobot () const |
get the robot of cspace More... | |
VirtualRobot::RobotNodeSetPtr | getRobotNodeSet () const |
get the sets of robotnodes representing of cspace More... | |
VirtualRobot::CDManagerPtr | getCDManager () const |
virtual float | getRandomConfig_UniformSampling (unsigned int dim) |
void | getRandomConfig (Eigen::VectorXf &storeValues, bool checkValid=false) |
virtual void | respectBoundaries (Eigen::VectorXf &config) |
set values of configuration considering boundaries More... | |
virtual bool | isPathValid (const Eigen::VectorXf &q1, const Eigen::VectorXf &q2) |
void | requestStop () |
void | setRandomSeed (unsigned int random_seed) |
virtual bool | checkSolution (CSpacePathPtr path, bool verbose=false) |
checks complete solution path (with the pathCheck methods provided by the CSpace implementation) More... | |
virtual bool | checkTree (CSpaceTreePtr tree) |
checks complete tree (with the pathCheck methods provided by the CSpace implementation) More... | |
void | resetPerformanceVars () |
virtual void | reset () |
Eigen::VectorXf | getMetricWeights () |
void | enableWeights (bool enable) |
void | exclusiveRobotAccess (bool bGranted=true) |
bool | hasExclusiveRobotAccess () |
virtual CSpacePtr | clone (VirtualRobot::CollisionCheckerPtr newCollisionChecker, VirtualRobot::RobotPtr newRobot, VirtualRobot::CDManagerPtr newCDM, unsigned int nNewRandomSeed=0)=0 |
void | setRandomSampler (SamplerPtr sampler) |
float | calcDist (const Eigen::VectorXf &c1, const Eigen::VectorXf &c2, bool forceDisablingMetricWeights=false) |
float | calcDist2 (const Eigen::VectorXf &c1, const Eigen::VectorXf &c2, bool forceDisablingMetricWeights=false) |
virtual float | calculateObstacleDistance (const Eigen::VectorXf &config) |
calculate distance to obstacles More... | |
CSpaceNodePtr | getNode (unsigned int id) |
virtual CSpaceNodePtr | createNewNode () |
virtual void | removeNode (CSpaceNodePtr node) |
virtual bool | isCollisionFree (const Eigen::VectorXf &config) |
returns the collision status (true for a valid config) More... | |
virtual bool | isInBoundary (const Eigen::VectorXf &config) |
returns the boundary violation status (true for a valid config) More... | |
virtual bool | isSatisfyingConstraints (const Eigen::VectorXf &config) |
returns the constraint violation status (true for a valid config) More... | |
void | printConfig (const Eigen::VectorXf &c) const |
void | checkForBorderlessDimensions (bool enable) |
float | interpolate (const Eigen::VectorXf &q1, const Eigen::VectorXf &q2, int dim, float step) |
Eigen::VectorXf | interpolate (const Eigen::VectorXf &q1, const Eigen::VectorXf &q2, float step) |
virtual bool | isConfigValid (const Eigen::VectorXf &pConfig, bool checkBorders=true, bool checkCollisions=true, bool checkConstraints=true) |
check whether a configuration is valid (collision, boundary, and constraints check) More... | |
virtual void | addConstraintCheck (Saba::ConfigurationConstraintPtr constraint) |
Static Public Member Functions | |
static void | lock () |
if multithreading is enabled, the colChecking mutex can be locked/unlocked externally More... | |
static void | unlock () |
if multithreading is enabled, the colChecking mutex can be locked/unlocked externally More... | |
Data Fields | |
int | performaceVars_collisionCheck |
int | performaceVars_distanceCheck |
Protected Member Functions | |
virtual void | getDirectionVector (const Eigen::VectorXf &c1, const Eigen::VectorXf &c2, Eigen::VectorXf &storeDir, float length) |
virtual void | generateNewConfig (const Eigen::VectorXf &randomConfig, const Eigen::VectorXf &nearestConfig, Eigen::VectorXf &storeNewConfig, float stepSize, float preCalculatedDist=-1.0) |
virtual float | getDirectedMaxMovement (const Eigen::VectorXf &config, const Eigen::VectorXf &nextConfig) |
return upper limit for movement of any point on joints if moving from config to nextConfig More... | |
float | interpolateLinear (float a, float b, float step) |
interpolates linear between a and b using step as step size More... | |
float | interpolateRotational (float a, float b, float step) |
Protected Attributes | |
unsigned int | dimension |
dimension of this c-space More... | |
Eigen::VectorXf | boundaryMax |
Eigen::VectorXf | boundaryMin |
Eigen::VectorXf | boundaryDist |
boundaries of this c-space More... | |
Eigen::VectorXf | metricWeights |
weights for distance computation More... | |
bool | stopPathCheck |
VirtualRobot::RobotPtr | robo |
the robot for collision checking More... | |
VirtualRobot::RobotNodeSetPtr | robotNodes |
the robot nodes defining the c-space More... | |
VirtualRobot::CDManagerPtr | cdm |
handling of collision detections More... | |
int | maxNodes |
std::vector< CSpaceNodePtr > | nodes |
std::vector< CSpaceNodePtr > | freeNodes |
vector with pointers to really used nodes More... | |
std::vector< VirtualRobot::RobotNodePtr > | robotJoints |
vector with pointers to free (not used) nodes More... | |
bool | useMetricWeights |
bool | checkForBorderlessDims |
std::vector< bool > | borderLessDimension |
bool | multiThreaded |
std::vector< ConfigurationConstraintPtr > | constraints |
SamplerPtr | sampleAlgorithm |
Static Protected Attributes | |
static int | cloneCounter = 0 |
static std::mutex | colCheckMutex |
A c-space interface for motion planning.
A CSpace is defined by a set of robot nodes and a collision manager. The RobotNodeSet specifies the dimension and the borders of the CSpace. The collision manager is used to check configurations for collisions. Here, multiple sets of objects can be defined which are internally mutually checked for collisions. This allows to specify complex collision queries. When performing sampling-based motion planning, usually paths in c-space have to be verified if constraints are violated or collisions occur. Therefore this class provides an interface, in order to combine various planning approaches with different collision detection methods
Please note: This implementation is not able to determine the collision status of path segments. Use CSpaceSampled for discrete collision detection.
Saba::CSpace::CSpace | ( | VirtualRobot::RobotPtr | robot, |
VirtualRobot::CDManagerPtr | collisionManager, | ||
VirtualRobot::RobotNodeSetPtr | robotNodes, | ||
unsigned int | maxConfigs = 50000 , |
||
unsigned int | randomSeed = 0 |
||
) |
Construct a c-space that represents the given set of joints. The dimensionality of this c-space is set by the number of nodes in robotNodes. The boundaries of this c-space are set according to definitions in robotNodes. On startup, memory is allocate din order to allow fats processing on runtime.
|
virtual |
destructor
|
virtual |
Add a configuration constraint to be checked within this cspace. Standard: No constraints, meaning that a check for constraints will report a valid status
float Saba::CSpace::calcDist | ( | const Eigen::VectorXf & | c1, |
const Eigen::VectorXf & | c2, | ||
bool | forceDisablingMetricWeights = false |
||
) |
Compute the distance in c-space. The modes useMetricWeights (standard:disabled) and checkForBorderlessDims (stanbdard:enabled) may affect the results.
float Saba::CSpace::calcDist2 | ( | const Eigen::VectorXf & | c1, |
const Eigen::VectorXf & | c2, | ||
bool | forceDisablingMetricWeights = false |
||
) |
|
virtual |
calculate distance to obstacles
config | The config for which the obstacle distance should be calculated (according to the cdm of this cspace) |
void Saba::CSpace::checkForBorderlessDimensions | ( | bool | enable | ) |
When the size of a c-space dimension is > 2PI and the corresponding joint is rotational, it is assumed that there are no borders
enable | When set, for each c-space dimension the (rotational) corresponding joints are checked: Borderless dimension, if the distance between Lo and Hi limit is >2PI This is useful e.g. for free flying or holonomic moving robots. Translational joints are not considered. |
|
virtual |
checks complete solution path (with the pathCheck methods provided by the CSpace implementation)
|
virtual |
checks complete tree (with the pathCheck methods provided by the CSpace implementation)
|
pure virtual |
Clone this CSpace structure The new Robot and the new CCM are used, the robot and the ccm have to be linked to the new ColChecker!
Implemented in Saba::CSpaceSampled.
|
virtual |
|
virtual |
Create a path from start to goal without any checks. Intermediate configurations are added according to the current implementation of the cspace. In this implementation only the start and goal config are added to the path.
Reimplemented in Saba::CSpaceSampled.
|
virtual |
Create a path from start to the goal configuration until an invalid (collision,constraints) configuration is found. Intermediate configurations are added according to the current implementation of the cspace In this implementation only the start and goal config are added to the path.
start | The start configuration. |
goal | The goal configuration. |
storeAddedLength | The length of the collision free path is stored here (1.0 means the complete path from start to goal was valid) |
Reimplemented in Saba::CSpaceSampled.
void Saba::CSpace::enableWeights | ( | bool | enable | ) |
Enable/Disable weighting of c-space dimensions. (standard: disabled) By setting the weights with setMetricWeights() the weighting is enabled.
enable | When set, the metric weights of this c-space are used to compute distances (when no metric weights have been specified for this c-space the option has no effect). |
void Saba::CSpace::exclusiveRobotAccess | ( | bool | bGranted = true | ) |
Method to allow concurrent/parallel access on robot. Enabling the multiThreading support is only needed when sharing robot or environment models between multiple CSpaces and the collision detection is done in parallel. If each CSpace operates on it's own instances of robot and environment, the multithreading support must not be enabled. Also rrtBiPlanners do not need to enable these option. If enabled, the robot is locked for collision checking, so that only one instance operates on the model. Planners operate much faster when doing "real" parallel collision checking, meaning that multiple instances of the models are created and these instances have their own collision checker.
bGranted | When set to true, no mutex protection is used to access the robot and to perform the collision detection. (standard) If set to false, the Robot and CD calls are protected by a mutex. |
|
protectedvirtual |
float Saba::CSpace::getBoundaryDist | ( | unsigned int | d | ) |
get boundary distance of an index
float Saba::CSpace::getBoundaryMax | ( | unsigned int | d | ) |
get maximum boundary of an index
float Saba::CSpace::getBoundaryMin | ( | unsigned int | d | ) |
get minimum boundary of an index
VirtualRobot::CDManagerPtr Saba::CSpace::getCDManager | ( | ) | const |
unsigned int Saba::CSpace::getDimension | ( | ) | const |
get cspace dimension
|
protectedvirtual |
return upper limit for movement of any point on joints if moving from config to nextConfig
|
protectedvirtual |
|
inline |
Returns array of size dimension.
CSpaceNodePtr Saba::CSpace::getNode | ( | unsigned int | id | ) |
void Saba::CSpace::getRandomConfig | ( | Eigen::VectorXf & | storeValues, |
bool | checkValid = false |
||
) |
This method returns a random configuration. The value is generated uniformly (standard) or, in case a sampler is defined a custom sampling strategy can be used.
storeValues | Store the values here. |
checkValid | When set to true, it is guaranteed that the sample not in collision and all constraints are considered |
|
virtual |
Returns a uniformly sampled random value for dimension dim.
VirtualRobot::RobotPtr Saba::CSpace::getRobot | ( | ) | const |
get the robot of cspace
VirtualRobot::RobotNodeSetPtr Saba::CSpace::getRobotNodeSet | ( | ) | const |
get the sets of robotnodes representing of cspace
bool Saba::CSpace::hasExclusiveRobotAccess | ( | ) |
float Saba::CSpace::interpolate | ( | const Eigen::VectorXf & | q1, |
const Eigen::VectorXf & | q2, | ||
int | dim, | ||
float | step | ||
) |
Interpolates between two values in dimension dim. Checks weather the corresponding joint moves translational or a rotational and performs the interpolation accordingly. When a rotational joint is limitless (and checkForBorderlessDimensions was not disabled), the correct direction for interpolating is determined automatically.
Eigen::VectorXf Saba::CSpace::interpolate | ( | const Eigen::VectorXf & | q1, |
const Eigen::VectorXf & | q2, | ||
float | step | ||
) |
|
protected |
interpolates linear between a and b using step as step size
|
protected |
interpolates rotational between a and b using step as step size ('a' and 'b' are expected to be in [0,2pi]). The interpolation takes the direction of the shorter path between 'a' and 'b'.
bool Saba::CSpace::isBorderlessDimension | ( | unsigned int | dim | ) | const |
|
virtual |
returns the collision status (true for a valid config)
|
virtual |
check whether a configuration is valid (collision, boundary, and constraints check)
|
virtual |
returns the boundary violation status (true for a valid config)
|
virtual |
Check path between two configurations. This cspace implementation just checks q2!
q1 | first configuration (from) |
q2 | second configuration (to) |
Reimplemented in Saba::CSpaceSampled.
|
virtual |
returns the constraint violation status (true for a valid config)
|
static |
if multithreading is enabled, the colChecking mutex can be locked/unlocked externally
void Saba::CSpace::printConfig | ( | const Eigen::VectorXf & | c | ) | const |
|
virtual |
void Saba::CSpace::requestStop | ( | ) |
Method for externally stopping the path checking routines. Only useful in multi-threaded planners.
|
virtual |
|
inline |
|
virtual |
set values of configuration considering boundaries
void Saba::CSpace::setBoundaries | ( | const Eigen::VectorXf & | min, |
const Eigen::VectorXf & | max | ||
) |
Set boundary values for each dimension of the cspace. Only needed when other values needed than those defined in the corresponding robotNodes.
min | minimum values (array has to have same dimension as the cspace) |
max | maximum values (array has to have same dimension as the cspace) |
void Saba::CSpace::setBoundary | ( | unsigned int | dim, |
float | min, | ||
float | max | ||
) |
void Saba::CSpace::setMetricWeights | ( | const Eigen::VectorXf & | weights | ) |
Set weights to uniformly handle differing dimensions in c-space. Setting the weights with this methods enables weighting of distance calculations in c-space. This affects path-creation and distance calculations.
void Saba::CSpace::setRandomSampler | ( | SamplerPtr | sampler | ) |
In the standard setup no sampler is used and the method getRandomConfig() performs a uniformly sampling of random configurations. Since most planners use the getRandomConfig() method for generating their random configurations (
void Saba::CSpace::setRandomSeed | ( | unsigned int | random_seed | ) |
|
static |
if multithreading is enabled, the colChecking mutex can be locked/unlocked externally
|
protected |
|
protected |
boundaries of this c-space
|
protected |
|
protected |
|
protected |
handling of collision detections
|
protected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
dimension of this c-space
|
protected |
vector with pointers to really used nodes
|
protected |
|
protected |
weights for distance computation
|
protected |
|
protected |
int Saba::CSpace::performaceVars_collisionCheck |
int Saba::CSpace::performaceVars_distanceCheck |
|
protected |
the robot for collision checking
|
protected |
vector with pointers to free (not used) nodes
joints of the robot that we are manipulating
|
protected |
the robot nodes defining the c-space
|
protected |
|
protected |
|
protected |