Commit 7653bed0 authored by florent's avatar florent
Browse files

Added boolean argument in ChppPlanner::roadmapBuilderIthProblem to

specify whether roadmap developed by roadmap builder should be displayed
in the interface.
Communication with interface is handled using notifications.
parent bac99b92
2008/05/01
38. Added boolean argument in ChppPlanner::roadmapBuilderIthProblem to specify whether roadmap
developed by roadmap builder should be displayed in the interface.
Communication with interface is handled using notifications.
2008/04/17
37. If CXXFLAGS and CFLAGS are not defined at configuration, they are set to "-Wall".
......
......@@ -87,8 +87,8 @@ class ChppPlanner {
/**
\brief Retrieve the problem in the problem vector at the given rank.
\param i_rank Rank of the hppProblem to retrieve
\return The i_rank-th problem
\param inRank Rank of the hppProblem to retrieve
\return The inRank-th problem
*/
ChppProblem * hppProblem(unsigned int inRank) {
if(inRank<getNbHppProblems())
......@@ -169,8 +169,12 @@ class ChppPlanner {
\brief Set roadmap builder of i-th problem.
\param rank Rank of problem in ChppPlanner::hppProblemVector.
\param inRoadmapBuilder roadmap builder.
\param inDisplay whether the roadmap should be displayed in the interface.
\xrefitem <send-notif> "Notification" "Send Notification" Send ID_HPP_ADD_ROADMAP.
\xrefitem <send-notif> "Notification" "Send Notification" Send ID_HPP_REMOVE_ROADMAP.
*/
ktStatus roadmapBuilderIthProblem(unsigned int rank, CkwsRoadmapBuilderShPtr inRoadmapBuilder);
ktStatus roadmapBuilderIthProblem(unsigned int rank, CkwsRoadmapBuilderShPtr inRoadmapBuilder,
bool inDisplay=false);
/**
\brief Get roadmap builder of i-th problem.
......@@ -290,7 +294,7 @@ class ChppPlanner {
ktStatus addPath(unsigned int problemId, CkwsPathShPtr kwsPath);
/**
*@}*
*@}
*/
/**
......@@ -309,28 +313,8 @@ class ChppPlanner {
ChppBodyConstShPtr findBodyByName(std::string inBodyName) const;
/**
*@}*
*@}
*/
/**
\name Notification management
@{
*/
/**
\brief Subscribe to an event by calling kwsNotificator->subscribe;
*/
// CkitNotificator::eventRegisterPair subscribe(int inEventType, ktStatus(*inCallback)(void*,void*),void* inPt);
/**
\brief Unsubscribe to an event by calling kwsNotificator->unsubscribe;
*/
// ktStatus unsubscribe(const CkitNotificator::eventRegisterPair& inPair);
/**
* \brief return a pointer to notificator in order for interface to get notification information.
*/
// const ChppNotificator* notificator() const;
/**
@}
*/
protected:
......@@ -359,11 +343,14 @@ protected:
static const CkitNotification::TType ID_HPP_REMOVE_OBSTACLES;
static const CkitNotification::TType ID_HPP_SET_OBSTACLE_LIST;
static const CkitNotification::TType ID_HPP_ADD_OBSTACLE;
static const CkitNotification::TType ID_HPP_REMOVE_ROADMAPBUILDER;
static const CkitNotification::TType ID_HPP_ADD_ROADMAPBUILDER;
// key to retrieve for notification.
static const std::string ROBOT_KEY;
static const std::string OBSTACLE_KEY;
static const std::string CONFIG_KEY;
static const std::string ROADMAP_KEY;
};
......
......@@ -34,7 +34,9 @@ bool ChppColPair::addColPair(unsigned int j1, unsigned int j2)
v.push_back(j2);
sort(v.begin(), v.end());
}
return true;
}
return false;
}
bool ChppColPair::addColPairRange(unsigned int j1, unsigned int j2from, unsigned int j2to)
......@@ -44,9 +46,10 @@ bool ChppColPair::addColPairRange(unsigned int j1, unsigned int j2from, unsigned
return false;
}
for(int j = j2from; j<= j2to; j++){
for(unsigned int j = j2from; j<= j2to; j++) {
addColPair(j1, j);
}
return true;
}
bool ChppColPair::existKey(unsigned int j1)
......@@ -126,7 +129,7 @@ void ChppColPair::printPair()
std::vector<unsigned int> v;
v = getColPairList(current_key, flag);
for(int j=0; j<v.size(); j++)
for(unsigned int j=0; j<v.size(); j++)
std::cout<<" "<<v[j];
std::cout<<std::endl;
}
......
......@@ -29,10 +29,13 @@ const CkitNotification::TType ChppPlanner::ID_HPP_SET_CURRENT_CONFIG(CkitNotific
const CkitNotification::TType ChppPlanner::ID_HPP_REMOVE_OBSTACLES(CkitNotification::makeID());
const CkitNotification::TType ChppPlanner::ID_HPP_SET_OBSTACLE_LIST(CkitNotification::makeID());
const CkitNotification::TType ChppPlanner::ID_HPP_ADD_OBSTACLE(CkitNotification::makeID());
const CkitNotification::TType ChppPlanner::ID_HPP_REMOVE_ROADMAPBUILDER(CkitNotification::makeID());
const CkitNotification::TType ChppPlanner::ID_HPP_ADD_ROADMAPBUILDER(CkitNotification::makeID());
const std::string ChppPlanner::ROBOT_KEY("robot");
const std::string ChppPlanner::OBSTACLE_KEY("obstacle");
const std::string ChppPlanner::CONFIG_KEY("config");
const std::string ChppPlanner::ROADMAP_KEY("roadmap");
/*****************************************
PUBLIC METHODS
......@@ -251,14 +254,36 @@ CkwsConfigShPtr ChppPlanner::goalConfIthProblem(unsigned int rank) const
ktStatus ChppPlanner::roadmapBuilderIthProblem(unsigned int rank,
CkwsRoadmapBuilderShPtr inRoadmapBuilder)
CkwsRoadmapBuilderShPtr inRoadmapBuilder,
bool inDisplay)
{
if (rank >= getNbHppProblems()) {
return KD_ERROR;
}
/*
If a roadmap was already stored, it will be removed. If this roadmap is displayed
in the interface, we need first to remove the corresponding data-structure in the
interface. This is done by sending a notification.
*/
CkitNotificationShPtr notification =
CkitNotification::createWithPtr<ChppPlanner>(ChppPlanner::ID_HPP_REMOVE_ROADMAPBUILDER, this);
notification->unsignedIntValue(ChppPlanner::ROADMAP_KEY, rank);
attNotificator->notify(notification);
ChppProblem& hppProblem = hppProblemVector[rank];
hppProblem.roadmapBuilder(inRoadmapBuilder);
/*
If the new roadmap is displayed in the interface, send a notification to
trigger appropriate action.
*/
if (inDisplay) {
notification =
CkitNotification::createWithPtr<ChppPlanner>(ChppPlanner::ID_HPP_ADD_ROADMAPBUILDER, this);
notification->unsignedIntValue(ChppPlanner::ROADMAP_KEY, rank);
attNotificator->notify(notification);
}
return KD_OK;
}
......
......@@ -285,7 +285,7 @@ unsigned int ChppProblem::getNbPaths() const
void ChppProblem::roadmapBuilder ( CkwsRoadmapBuilderShPtr inRoadmapBuilder )
{
attRoadmapBuilder = inRoadmapBuilder ;
attRoadmapBuilder = inRoadmapBuilder;
}
// ==========================================================================
......
Markdown is supported
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