Commit fb056bc0 authored by florent's avatar florent
Browse files

Added API function to optimize a path.

Added API functions to display a roadmap in the interface.
parent 2f48a60a
$Id: ChangeLog 2007/08/27 14:54:42 mallet $
2007/09/29
20. Added API function to optimize a path.
19. Added API functions to display a roadmap in the interface.
2007/09/12
Add virtual method ChppPlanner::initializeProblem(). This method implemented in ChppWalkPlanner can thus be called by Corba server.
18. Add virtual method ChppPlanner::initializeProblem(). This method implemented in ChppWalkPlanner can thus be called by Corba server.
hppCore 1.1 released August 27, 2007
......
......@@ -239,6 +239,13 @@ class ChppPlanner {
*/
ktStatus solveOneProblem(unsigned int problemId);
/**
\brief Optimize a given path
\param inProblemId Id of the problem owning the path.
\param inPathId Id of the path in this problem.
*/
ktStatus optimizePath(unsigned int inProblemId, unsigned int inPathId);
/**
\brief Get number of paths in given problem.
*/
......@@ -254,7 +261,34 @@ class ChppPlanner {
\return KD_ERROR if problemId too big, KD_OK otherwise.
*/
ktStatus addPath(unsigned int problemId, CkwsPathShPtr kwsPath);
ktStatus addPath(unsigned int problemId, CkwsPathShPtr kwsPath);
/**
*@}*
*/
/**
\name Drawing the roadmap
@{
*/
/**
\brief Draws the roadmap of given problem in interface.
\param inProblemId the rank of the problem in vector.
Works only if the roadmap builder of corresponding problem has been initialized with
a CkwsPlusRoadmap.
*/
ktStatus drawRoadmap(unsigned int inProblemId);
/**
\brief Stop drawing the roadmap of given problem in interface.
\param inProblemId the rank of the problem in vector.
Works only if the roadmap builder of corresponding problem has been initialized with
a CkwsPlusRoadmap.
*/
ktStatus stopdrawingRoadmap(unsigned int inProblemId);
/**
*@}*
......
......@@ -24,6 +24,7 @@ INCLUDE
#include "kwsPlusRoadmap.h"
#include "KineoUtility/kitNotificator.h"
class CkwsPlusDrawRdmBuilderDelegate;
/*************************************
CLASS
......@@ -162,6 +163,25 @@ public:
*/
unsigned int getNbPaths() const;
/**
*@}
*/
/**
\name Drawing the roadmap
@{
*/
/**
\brief Draws the roadmap by inserting a delegate in the roadmapBuilder
*/
ktStatus drawRoadmap();
/**
\brief Stop drawing the roadmap
*/
ktStatus stopDrawingRoadmap();
/**
*@}
*/
......@@ -208,6 +228,10 @@ private :
*/
std::vector<CkwsPathShPtr> attPathVector;
/**
\brief Pointer to a drawing roadmap delegate.
*/
CkwsPlusDrawRdmBuilderDelegate* attDrawRoadmapDelegate;
public:
// for notification:
static const CkitNotification::TType ID_HPP_ADD_PATH;
......
......@@ -440,30 +440,62 @@ ktStatus ChppPlanner::solveOneProblem(unsigned int problemId)
return KD_OK ;
}
ktStatus ChppPlanner::optimizePath(unsigned int inProblemId, unsigned int inPathId)
{
if (inProblemId >= getNbHppProblems()) {
cerr << "ChppPlanner::optimizePath: problem Id="
<< inProblemId << " is bigger than vector size="
<< getNbHppProblems();
return KD_ERROR;
}
ChppProblem& hppProblem = hppProblemVector[inProblemId];
if (inPathId >= hppProblem.getNbPaths()) {
cerr << "ChppPlanner::optimizePath: problem Id="
<< inPathId << " is bigger than number of paths="
<< hppProblem.getNbPaths();
return KD_ERROR;
}
CkwsPathShPtr kwsPath = hppProblem.getIthPath(inPathId);
// optimizer for the path
if (hppProblem.pathOptimizer()) {
hppProblem.pathOptimizer()->optimizePath(kwsPath, hppProblem.roadmapBuilder()->penetration());
cout << "ChppPlanner::solveOneProblem: path optimized with penetration "
<< hppProblem.roadmapBuilder()->penetration()<<endl;
} else {
cerr << " no Optimizer Defined " << endl ;
}
return KD_OK;
}
// ==========================================================================
unsigned int ChppPlanner::getNbPaths(unsigned int problemId) const
unsigned int ChppPlanner::getNbPaths(unsigned int inProblemId) const
{
unsigned int nbPaths = 0;
if (problemId < getNbHppProblems()) {
nbPaths = hppProblemVector[problemId].getNbPaths();
if (inProblemId < getNbHppProblems()) {
nbPaths = hppProblemVector[inProblemId].getNbPaths();
} else {
cerr << "ChppPlanner::getNbPaths : problemId = "<< problemId << " should be smaller than nb of problems: " << getNbHppProblems() << endl;
cerr << "ChppPlanner::getNbPaths : inProblemId = "<< inProblemId << " should be smaller than nb of problems: " << getNbHppProblems() << endl;
}
return nbPaths;
}
// ==========================================================================
CkwsPathShPtr ChppPlanner::getPath(unsigned int problemId,
unsigned int pathId) const
CkwsPathShPtr ChppPlanner::getPath(unsigned int inProblemId,
unsigned int inPathId) const
{
CkwsPathShPtr resultPath;
if (problemId < getNbHppProblems()) {
if (pathId < hppProblemVector[problemId].getNbPaths()) {
resultPath = hppProblemVector[problemId].getIthPath(pathId);
if (inProblemId < getNbHppProblems()) {
if (inPathId < hppProblemVector[inProblemId].getNbPaths()) {
resultPath = hppProblemVector[inProblemId].getIthPath(inPathId);
}
}
return resultPath;
......@@ -471,13 +503,42 @@ CkwsPathShPtr ChppPlanner::getPath(unsigned int problemId,
// ==========================================================================
ktStatus ChppPlanner::addPath(unsigned int problemId, CkwsPathShPtr kwsPath)
ktStatus ChppPlanner::addPath(unsigned int inProblemId, CkwsPathShPtr kwsPath)
{
if (inProblemId >= hppProblemVector.size()) {
cerr << "ChppPlanner::addPath : inProblemId bigger than vector size." << endl;
return KD_ERROR;
}
hppProblemVector[inProblemId].addPath(kwsPath);
return KD_OK;
}
// ==========================================================================
ktStatus ChppPlanner::drawRoadmap(unsigned int inProblemId)
{
if (inProblemId >= hppProblemVector.size()) {
cerr << "ChppPlanner::drawRoadmap : inProblemId bigger than vector size." << endl;
return KD_ERROR;
}
ChppProblem& hppProblem = hppProblemVector[inProblemId];
if (hppProblem.drawRoadmap() == KD_ERROR) {
return KD_ERROR;
}
return KD_OK;
}
// ==========================================================================
ktStatus ChppPlanner::stopdrawingRoadmap(unsigned int inProblemId)
{
if (problemId > hppProblemVector.size()) {
cerr << "ChppPlanner::addPath : problemId bigger than vector size." << endl;
if (inProblemId >= hppProblemVector.size()) {
cerr << "ChppPlanner::drawRoadmap : inProblemId bigger than vector size." << endl;
return KD_ERROR;
}
hppProblemVector[problemId].addPath(kwsPath);
ChppProblem& hppProblem = hppProblemVector[inProblemId];
hppProblem.stopDrawingRoadmap();
return KD_OK;
}
......
......@@ -11,8 +11,10 @@
*******************************************/
#include <iostream>
#include "hppProblem.h"
#include "kwsPlusDrawRdmBuilderDelegate.h"
#include "hppProblem.h"
#include "hppBody.h"
const CkitNotification::TType ChppProblem::ID_HPP_ADD_PATH(CkitNotification::makeID());
......@@ -21,17 +23,13 @@ const std::string ChppProblem::PATH_KEY("path");
const std::string ChppProblem::PATH_ID_KEY("path_id");
const std::string ChppProblem::DEVICE_KEY("device");
/*! \addtogroup hpp
*@{
*/
/*****************************************
PUBLIC METHODS
*******************************************/
// ==========================================================================
ChppProblem::ChppProblem(CkppDeviceComponentShPtr inRobot)
ChppProblem::ChppProblem(CkppDeviceComponentShPtr inRobot) : attDrawRoadmapDelegate(NULL)
{
attNotificator = CkitNotificator::defaultNotificator();
attRobot = inRobot;
......@@ -245,7 +243,25 @@ CkwsPathOptimizerShPtr ChppProblem::pathOptimizer() {
}
ktStatus ChppProblem::drawRoadmap()
{
if (attDrawRoadmapDelegate != NULL) {
return KD_OK;
}
attDrawRoadmapDelegate = new CkwsPlusDrawRdmBuilderDelegate();
if (!attRoadmapBuilder) {
return KD_ERROR;
}
attRoadmapBuilder->addDelegate(attDrawRoadmapDelegate);
}
/** @}
*/
ktStatus ChppProblem::stopDrawingRoadmap()
{
if (attDrawRoadmapDelegate == NULL) {
return KD_OK;
}
if (!attRoadmapBuilder) {
return KD_OK;
}
return attRoadmapBuilder->removeDelegate(attDrawRoadmapDelegate);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment