Commit 070322ea authored by florent's avatar florent
Browse files

Replaced ChppDevice by CkppDeviceComponent in ChppPlanner and ChppProblem since

  1 ChppDevice derives from CkppDeviceComponent and
  2 The operations performed on objects of this type only concern CkppDeviceComponent part.
parent 0f9725d8
2007/08/23
Replaced ChppDevice by CkppDeviceComponent in ChppPlanner and ChppProblem since
1 ChppDevice derives from CkppDeviceComponent and
2 The operations performed on objects of this type only concern CkppDeviceComponent part.
2007/08/01
15. Added a default implementation of ChppPlanner::solve so that the class is not pure virtual.
......
......@@ -19,8 +19,9 @@ INCLUDE
#include "hppProblem.h"
#ifndef WITHOUT_CHPPDEVICE
KIT_PREDEF_CLASS( ChppBody );
KIT_PREDEF_CLASS( ChppDevice );
#endif
using namespace std ;
......@@ -59,7 +60,7 @@ class ChppPlanner {
\return a int
\xrefitem <send-notif> "Notification" "Send Notification" Send ID_HPP_ADD_ROBOT.
*/
ktStatus addHppProblem(ChppDeviceShPtr robot);
ktStatus addHppProblem(CkppDeviceComponentShPtr robot);
/**
\brief Add a Problem at beginning of the Problem vector with the associed robot.
......@@ -68,7 +69,7 @@ class ChppPlanner {
\return a int
\xrefitem <send-notif> "Notification" "Send Notification" Send ID_HPP_ADD_ROBOT.
*/
ktStatus addHppProblemAtBeginning(ChppDeviceShPtr robot);
ktStatus addHppProblemAtBeginning(CkppDeviceComponentShPtr robot);
/**
\brief Get the number of problems in vector.
......@@ -82,7 +83,7 @@ class ChppPlanner {
\param rank
\return the shared pointer on the robot
*/
const ChppDeviceShPtr robotIthProblem(unsigned int rank) const;
const CkppDeviceComponentShPtr robotIthProblem(unsigned int rank) const;
/**
\brief Get current configuration of i-th robot.
......@@ -258,6 +259,7 @@ class ChppPlanner {
*/
ChppBodyConstShPtr findBodyByName(std::string inBodyName) const;
/**
*@}*
*/
......
......@@ -17,7 +17,10 @@ INCLUDE
#include "KineoWorks2/kwsRoadmapBuilder.h"
#include "KineoWorks2/kwsConfig.h"
#include "hppDevice.h"
#include "KineoModel/kppDeviceComponent.h"
#include "kcd2/kcdInterface.h"
#include "kwsKcd2/kwsKCDBody.h"
#include "kwsPlusRoadmap.h"
#include "KineoUtility/kitNotificator.h"
......@@ -42,7 +45,7 @@ public:
* \brief Create a path planning problem with no initial nor goal configuration.
* \param inRobot robot associated to the path planning problem.
*/
ChppProblem(ChppDeviceShPtr inRobot);
ChppProblem(CkppDeviceComponentShPtr inRobot);
/**
\name Problem definition
......@@ -52,7 +55,7 @@ public:
/**
* \brief return shared pointer to robot.
*/
ChppDeviceShPtr getRobot() const;
CkppDeviceComponentShPtr getRobot() const;
/**
* \brief Get shared pointer to initial configuration.
*/
......@@ -171,7 +174,7 @@ private :
/**
\brief the robot is a KineoWorks Device.
*/
ChppDeviceShPtr attRobot;
CkppDeviceComponentShPtr attRobot;
/**
\brief Shared pointer to initial configuration.
*/
......
......@@ -15,9 +15,11 @@
#include <iostream>
#include <fstream>
#include "KineoModel/kppDeviceComponent.h"
#include "hppPlanner.h"
#include "hppProblem.h"
#include "hppDevice.h"
#include "hppBody.h"
#include "KineoUtility/kitNotificator.h"
......@@ -55,7 +57,7 @@ ChppPlanner::~ChppPlanner()
// ==========================================================================
ktStatus ChppPlanner::addHppProblem(ChppDeviceShPtr robot)
ktStatus ChppPlanner::addHppProblem(CkppDeviceComponentShPtr robot)
{
ChppProblem hppProblem(robot);
......@@ -67,7 +69,7 @@ ktStatus ChppPlanner::addHppProblem(ChppDeviceShPtr robot)
CkitNotificationShPtr notification
= CkitNotification::createWithPtr<ChppPlanner>(ChppPlanner::ID_HPP_ADD_ROBOT, this);
// set attribute if necessary
notification->shPtrValue<ChppDevice>(ROBOT_KEY, robot);
notification->shPtrValue<CkppDeviceComponent>(ROBOT_KEY, robot);
attNotificator->notify(notification);
......@@ -77,7 +79,7 @@ ktStatus ChppPlanner::addHppProblem(ChppDeviceShPtr robot)
// ==========================================================================
ktStatus ChppPlanner::addHppProblemAtBeginning(ChppDeviceShPtr robot)
ktStatus ChppPlanner::addHppProblemAtBeginning(CkppDeviceComponentShPtr robot)
{
ChppProblem hppProblem(robot);
......@@ -87,7 +89,7 @@ ktStatus ChppPlanner::addHppProblemAtBeginning(ChppDeviceShPtr robot)
CkitNotificationShPtr notification = CkitNotification::createWithPtr<ChppPlanner>(ChppPlanner::ID_HPP_ADD_ROBOT, this);
// set attribute if necessary
notification->shPtrValue<ChppDevice>(ROBOT_KEY, robot);
notification->shPtrValue<CkppDeviceComponent>(ROBOT_KEY, robot);
attNotificator->notify(notification);
......@@ -97,9 +99,9 @@ ktStatus ChppPlanner::addHppProblemAtBeginning(ChppDeviceShPtr robot)
// ==========================================================================
const ChppDeviceShPtr ChppPlanner::robotIthProblem(unsigned int rank) const
const CkppDeviceComponentShPtr ChppPlanner::robotIthProblem(unsigned int rank) const
{
ChppDeviceShPtr nullShPtr;
CkppDeviceComponentShPtr nullShPtr;
if (rank < getNbHppProblems()) {
return hppProblemVector[rank].getRobot();
......@@ -115,7 +117,7 @@ CkwsConfigShPtr ChppPlanner::robotCurrentConfIthProblem(unsigned int rank) const
CkwsConfigShPtr outConfig;
if (rank < getNbHppProblems()) {
const ChppDeviceShPtr robot = robotIthProblem(rank);
const CkppDeviceComponentShPtr robot = robotIthProblem(rank);
CkwsConfig config(robot);
status = robot->getCurrentConfig(config);
if (status == KD_OK) {
......@@ -394,7 +396,7 @@ ktStatus ChppPlanner::solveOneProblem(unsigned int problemId)
ChppProblem& hppProblem = hppProblemVector[problemId];
CkwsPathShPtr kwsPath;
ChppDeviceShPtr hppDevice = hppProblem.getRobot();
CkppDeviceComponentShPtr hppDevice = hppProblem.getRobot();
if (!hppDevice)
return KD_ERROR ;
......@@ -489,7 +491,7 @@ ChppBodyConstShPtr ChppPlanner::findBodyByName(std::string inBodyName) const
// Loop over hppProblem.
for (unsigned int iProblem=0; iProblem < nbProblems; iProblem++) {
CkwsDevice::TBodyVector bodyVector;
const ChppDeviceShPtr hppRobot = robotIthProblem(iProblem);
const CkppDeviceComponentShPtr hppRobot = robotIthProblem(iProblem);
hppRobot->getBodyVector(bodyVector);
// Loop over bodies of the robot.
......
......@@ -31,7 +31,7 @@ const std::string ChppProblem::DEVICE_KEY("device");
// ==========================================================================
ChppProblem::ChppProblem(ChppDeviceShPtr inRobot)
ChppProblem::ChppProblem(CkppDeviceComponentShPtr inRobot)
{
attNotificator = CkitNotificator::defaultNotificator();
attRobot = inRobot;
......@@ -39,7 +39,7 @@ ChppProblem::ChppProblem(ChppDeviceShPtr inRobot)
// ==========================================================================
ChppDeviceShPtr ChppProblem::getRobot() const
CkppDeviceComponentShPtr ChppProblem::getRobot() const
{
return attRobot;
}
......@@ -121,7 +121,31 @@ const std::vector<CkcdObjectShPtr>& ChppProblem::obstacleList()
ktStatus ChppProblem::addObstacle(const CkcdObjectShPtr& inObject)
{
return attRobot->addObstacle(inObject);
// Get robot vector of bodies.
CkwsDevice::TBodyVector bodyVector;
attRobot->getBodyVector(bodyVector);
// Loop over bodies of robot.
for (CkwsDevice::TBodyIterator bodyIter = bodyVector.begin(); bodyIter < bodyVector.end(); bodyIter++) {
// Try to cast body into CkwsKCDBody
CkwsKCDBodyShPtr kcdBody;
ChppBodyShPtr hppBody;
if (kcdBody = boost::dynamic_pointer_cast<CkwsKCDBody>(*bodyIter)) {
std::vector< CkcdObjectShPtr > collisionList = kcdBody->outerObjects();
collisionList.push_back(inObject);
if(hppBody = boost::dynamic_pointer_cast<ChppBody>(kcdBody)){
hppBody->setOuterObjects(collisionList);
}
else
kcdBody->outerObjects(collisionList);
}
else {
std::cout << "ChppProblem::addObstacle: body is not KCD body. Obstacle is not inserted." << std::endl;
}
}
return KD_OK;
}
// ==========================================================================
......@@ -151,7 +175,7 @@ void ChppProblem::addPath(CkwsPathShPtr kwsPath)
= CkitNotification::createWithPtr<ChppProblem>(ChppProblem::ID_HPP_ADD_PATH, this);
// set attribute to retreave
notification->shPtrValue<CkwsPath>(PATH_KEY, kwsPath);
notification->shPtrValue<ChppDevice>(DEVICE_KEY, attRobot);
notification->shPtrValue<CkppDeviceComponent>(DEVICE_KEY, attRobot);
// set path number
notification->unsignedIntValue(PATH_ID_KEY, attPathVector.size());
attNotificator->notify(notification);
......
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