本文整理汇总了C++中OMPL_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ OMPL_ERROR函数的具体用法?C++ OMPL_ERROR怎么用?C++ OMPL_ERROR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OMPL_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OMPL_ERROR
ompl::base::Cost ompl::base::OptimizationObjective::getCost(const Path &path) const
{
// Cast path down to a PathGeometric
const geometric::PathGeometric *pathGeom = dynamic_cast<const geometric::PathGeometric*>(&path);
// Give up if this isn't a PathGeometric or if the path is empty.
if (!pathGeom)
{
OMPL_ERROR("Error: Cost computation is only implemented for paths of type PathGeometric.");
return this->identityCost();
}
else
{
std::size_t numStates = pathGeom->getStateCount();
if (numStates == 0)
{
OMPL_ERROR("Cannot compute cost of an empty path.");
return this->identityCost();
}
else
{
// Compute path cost by accumulating the cost along the path
Cost cost(this->identityCost());
for (std::size_t i = 1; i < numStates; ++i)
{
const State *s1 = pathGeom->getState(i-1);
const State *s2 = pathGeom->getState(i);
cost = this->combineCosts(cost, this->motionCost(s1, s2));
}
return cost;
}
}
}
示例2: assert
bool ompl::app::RigidBodyGeometry::addEnvironmentMesh(const std::string &env)
{
assert(!env.empty());
std::size_t p = importerEnv_.size();
importerEnv_.resize(p + 1);
importerEnv_[p] = std::make_shared<Assimp::Importer>();
const aiScene* envScene = importerEnv_[p]->ReadFile(env.c_str(),
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType |
aiProcess_OptimizeGraph |
aiProcess_OptimizeMeshes);
if (envScene != nullptr)
{
if (!envScene->HasMeshes())
{
OMPL_ERROR("There is no mesh specified in the indicated environment resource: %s", env.c_str());
importerEnv_.resize(p);
}
}
else
{
OMPL_ERROR("Unable to load environment scene: %s", env.c_str());
importerEnv_.resize(p);
}
if (p < importerEnv_.size())
{
computeGeometrySpecification();
return true;
}
return false;
}
示例3: OMPL_ERROR
void ompl::base::PlannerDataStorage::store(const PlannerData &pd, std::ostream &out)
{
const SpaceInformationPtr &si = pd.getSpaceInformation();
if (!out.good())
{
OMPL_ERROR("Failed to store PlannerData: output stream is invalid");
return;
}
if (!si)
{
OMPL_ERROR("Failed to store PlannerData: SpaceInformation is invalid");
return;
}
try
{
boost::archive::binary_oarchive oa(out);
// Writing the header
Header h;
h.marker = OMPL_PLANNER_DATA_ARCHIVE_MARKER;
h.vertex_count = pd.numVertices();
h.edge_count = pd.numEdges();
si->getStateSpace()->computeSignature(h.signature);
oa << h;
storeVertices(pd, oa);
storeEdges(pd, oa);
}
catch (boost::archive::archive_exception &ae)
{
OMPL_ERROR("Failed to store PlannerData: %s", ae.what());
}
}
示例4: OMPL_ERROR
bool ompl::base::ProblemDefinition::isTrivial(unsigned int *startIndex, double *distance) const
{
if (!goal_)
{
OMPL_ERROR("Goal undefined");
return false;
}
for (unsigned int i = 0 ; i < startStates_.size() ; ++i)
{
const State *start = startStates_[i];
if (start && si_->isValid(start) && si_->satisfiesBounds(start))
{
double dist;
if (goal_->isSatisfied(start, &dist))
{
if (startIndex)
*startIndex = i;
if (distance)
*distance = dist;
return true;
}
}
else
{
OMPL_ERROR("Initial state is in collision!");
}
}
return false;
}
示例5: getGeometrySpecification
const ompl::base::StateValidityCheckerPtr& ompl::app::RigidBodyGeometry::allocStateValidityChecker(const base::SpaceInformationPtr &si, const GeometricStateExtractor &se, bool selfCollision)
{
if (validitySvc_)
return validitySvc_;
GeometrySpecification geom = getGeometrySpecification();
switch (ctype_)
{
#if OMPL_HAS_PQP
case PQP:
if (mtype_ == Motion_2D)
validitySvc_ = std::make_shared<PQPStateValidityChecker<Motion_2D>>(si, geom, se, selfCollision);
else
validitySvc_ = std::make_shared<PQPStateValidityChecker<Motion_3D>>(si, geom, se, selfCollision);
break;
#endif
case FCL:
if (mtype_ == Motion_2D)
validitySvc_ = std::make_shared<FCLStateValidityChecker<Motion_2D>>(si, geom, se, selfCollision);
else
validitySvc_ = std::make_shared<FCLStateValidityChecker<Motion_3D>>(si, geom, se, selfCollision);
break;
default:
OMPL_ERROR("Unexpected collision checker type (%d) encountered", ctype_);
};
return validitySvc_;
}
示例6: catch
void ompl::base::SpaceInformation::printProperties(std::ostream &out) const
{
out << "Properties of the state space '" << stateSpace_->getName() << "'" << std::endl;
out << " - signature: ";
std::vector<int> sig;
stateSpace_->computeSignature(sig);
for (std::size_t i = 0 ; i < sig.size() ; ++i)
out << sig[i] << " ";
out << std::endl;
out << " - dimension: " << stateSpace_->getDimension() << std::endl;
out << " - extent: " << stateSpace_->getMaximumExtent() << std::endl;
if (isSetup())
{
bool result = true;
try
{
stateSpace_->sanityChecks();
}
catch(Exception &e)
{
result = false;
out << std::endl << " - SANITY CHECKS FOR STATE SPACE ***DID NOT PASS*** (" << e.what() << ")" << std::endl << std::endl;
OMPL_ERROR(e.what());
}
if (result)
out << " - sanity checks for state space passed" << std::endl;
out << " - probability of valid states: " << probabilityOfValidState(magic::TEST_STATE_COUNT) << std::endl;
out << " - average length of a valid motion: " << averageValidMotionLength(magic::TEST_STATE_COUNT) << std::endl;
double uniform, near, gaussian;
samplesPerSecond(uniform, near, gaussian, magic::TEST_STATE_COUNT);
out << " - average number of samples drawn per second: sampleUniform()=" << uniform << " sampleUniformNear()=" << near << " sampleGaussian()=" << gaussian << std::endl;
}
else
out << "Call setup() before to get more information" << std::endl;
}
示例7: Plane2DEnvironment
Plane2DEnvironment(const char *ppm_file)
{
bool ok = false;
try
{
ppm_.loadFile(ppm_file);
ok = true;
}
catch(ompl::Exception &ex)
{
OMPL_ERROR("Unable to load %s.\n%s", ppm_file, ex.what());
}
if (ok)
{
ob::RealVectorStateSpace *space = new ob::RealVectorStateSpace();
space->addDimension(0.0, ppm_.getWidth());
space->addDimension(0.0, ppm_.getHeight());
maxWidth_ = ppm_.getWidth() - 1;
maxHeight_ = ppm_.getHeight() - 1;
lightning_.reset(new ot::Lightning(ob::StateSpacePtr(space)));
lightning_->setFilePath("lightning.db");
// set state validity checking for this space
lightning_->setStateValidityChecker(boost::bind(&Plane2DEnvironment::isStateValid, this, _1));
space->setup();
lightning_->getSpaceInformation()->setStateValidityCheckingResolution(1.0 / space->getMaximumExtent());
vss_ = lightning_->getSpaceInformation()->allocValidStateSampler();
}
}
示例8: OMPL_INFORM
void ompl::geometric::RRTstar::setSampleRejection(const bool reject)
{
if (static_cast<bool>(opt_) == true)
{
if (opt_->hasCostToGoHeuristic() == false)
{
OMPL_INFORM("%s: No cost-to-go heuristic set. Informed techniques will not work well.", getName().c_str());
}
}
// This option is mutually exclusive with setSampleRejection, assert that:
if (reject == true && useInformedSampling_ == true)
{
OMPL_ERROR("%s: InformedSampling and SampleRejection are mutually exclusive options.", getName().c_str());
}
// Check if we're changing the setting of rejection sampling. If we are, we will need to create a new sampler, which we only want to do if one is already allocated.
if (reject != useRejectionSampling_)
{
// Store the setting
useRejectionSampling_ = reject;
// If we currently have a sampler, we need to make a new one
if (sampler_ || infSampler_)
{
// Reset the samplers
sampler_.reset();
infSampler_.reset();
// Create the sampler
allocSampler();
}
}
}
示例9: allocatePlanner
ob::PlannerPtr allocatePlanner(ob::SpaceInformationPtr si, optimalPlanner plannerType)
{
switch (plannerType)
{
case PLANNER_BITSTAR:
return boost::make_shared<og::BITstar>(si);
break;
case PLANNER_CFOREST:
return boost::make_shared<og::CForest>(si);
break;
case PLANNER_FMTSTAR:
return boost::make_shared<og::FMT>(si);
break;
case PLANNER_PRMSTAR:
return boost::make_shared<og::PRMstar>(si);;
break;
case PLANNER_RRTSTAR:
return boost::make_shared<og::RRTstar>(si);;
break;
default:
OMPL_ERROR("Planner-type enum is not implemented in allocation function.");
return ob::PlannerPtr();
break;
}
}
示例10: Plane2DEnvironment
Plane2DEnvironment(const char *ppm_file)
{
bool ok = false;
try
{
ppm_.loadFile(ppm_file);
ok = true;
}
catch(ompl::Exception &ex)
{
OMPL_ERROR("Unable to load %s.\n%s", ppm_file, ex.what());
}
if (ok)
{
auto *space = new ob::RealVectorStateSpace();
space->addDimension(0.0, ppm_.getWidth());
space->addDimension(0.0, ppm_.getHeight());
maxWidth_ = ppm_.getWidth() - 1;
maxHeight_ = ppm_.getHeight() - 1;
ss_.reset(new og::SimpleSetup(ob::StateSpacePtr(space)));
// set state validity checking for this space
ss_->setStateValidityChecker(std::bind(&Plane2DEnvironment::isStateValid, this, std::placeholders::_1));
space->setup();
ss_->getSpaceInformation()->setStateValidityCheckingResolution(1.0 / space->getMaximumExtent());
// ss_->setPlanner(ob::PlannerPtr(new og::RRTConnect(ss_->getSpaceInformation())));
}
}
示例11: OMPL_ERROR
bool ompl::tools::ThunderDB::addPath(ompl::geometric::PathGeometric &solutionPath, double &insertionTime)
{
// Error check
if (!spars_)
{
OMPL_ERROR("SPARSdb planner has not been passed into the ThunderDB yet");
insertionTime = 0;
return false;
}
// Prevent inserting into database
if (!saving_enabled_)
{
OMPL_WARN("ThunderDB: Saving is disabled so not adding path");
return false;
}
bool result;
double seconds = 120; // 10; // a large number, should never need to use this
ompl::base::PlannerTerminationCondition ptc = ompl::base::timedPlannerTerminationCondition(seconds, 0.1);
// Benchmark runtime
time::point startTime = time::now();
{
result = spars_->addPathToRoadmap(ptc, solutionPath);
}
insertionTime = time::seconds(time::now() - startTime);
OMPL_INFORM("SPARSdb now has %d states", spars_->getNumVertices());
// Record this new addition
numPathsInserted_++;
return result;
}
示例12: OMPL_ERROR
bool ompl::control::World::operator[](unsigned int i) const
{
auto p = props_.find(i);
if (p == props_.end())
OMPL_ERROR("Proposition %u is not set in world", i);
return p->second;
}
示例13: OMPL_ERROR
double ompl::base::ProjectionEvaluator::getCellSizes(unsigned int dim) const
{
if (cellSizes_.size() > dim)
return cellSizes_[dim];
OMPL_ERROR("Dimension %u is not defined for projection evaluator", dim);
return 0.0;
}
示例14: Plane2DEnvironment
Plane2DEnvironment(const char *ppm_file)
{
bool ok = false;
try
{
ppm_.loadFile(ppm_file);
ok = true;
}
catch(ompl::Exception &ex)
{
OMPL_ERROR("Unable to load %s.\n%s", ppm_file, ex.what());
}
if (ok)
{
auto space(std::make_shared<ob::RealVectorStateSpace>());
space->addDimension(0.0, ppm_.getWidth());
space->addDimension(0.0, ppm_.getHeight());
maxWidth_ = ppm_.getWidth() - 1;
maxHeight_ = ppm_.getHeight() - 1;
ss_ = std::make_shared<og::SimpleSetup>(space);
// set state validity checking for this space
ss_->setStateValidityChecker([this](const ob::State *state) { return isStateValid(state); });
space->setup();
ss_->getSpaceInformation()->setStateValidityCheckingResolution(1.0 / space->getMaximumExtent());
// ss_->setPlanner(std::make_shared<og::RRTConnect>(ss_->getSpaceInformation()));
}
}
示例15: OMPL_ERROR
bool ompl::tools::Lightning::saveIfChanged()
{
if (filePath_.empty())
{
OMPL_ERROR("No file path has been specified, unable to save experience DB");
return false;
}
return experienceDB_->saveIfChanged(filePath_);
}