Very simple implementation of GraspItDatabaseManager which just keeps loaded objects in a std::map. More...
#include <GraspItSimpleDBManager.h>
Public Member Functions | |
virtual void | getAllLoadedObjectIDs (std::vector< int > &ids) const |
virtual void | getAllLoadedObjectNames (std::vector< std::string > &names) const |
virtual void | getAllLoadedRobotIDs (std::vector< int > &ids) const |
virtual void | getAllLoadedRobotNames (std::vector< std::string > &names) const |
virtual bool | getModelNameAndType (const int modelID, std::string &name, bool &isRobot) const |
virtual bool | getObjectModelID (const std::string &objectName, int &id) const |
virtual bool | getRobotJointNames (const std::string &robotName, std::vector< std::string > &jointNames) const |
virtual bool | getRobotModelID (const std::string &robotName, int &id) const |
GraspItSimpleDBManager (const std::string &objectName, const SHARED_PTR< GraspItSceneManager > &interface) | |
virtual int | loadObjectToDatabase (const std::string &filename, const std::string &robotName, const bool asGraspable) |
virtual int | loadRobotToDatabase (const std::string &filename, const std::string &robotName, const std::vector< std::string > &jointNames) |
virtual | ~GraspItSimpleDBManager () |
Protected Member Functions | |
virtual int | getModelType (const int modelID) const |
virtual Body * | getObjectFromDatabase (const std::string &objectName) |
virtual Body * | getObjectFromDatabase (const int modelID) |
virtual Robot * | getRobotFromDatabase (const std::string &robotName) |
virtual Robot * | getRobotFromDatabase (const int modelID) |
virtual void | idleEventFromSceneManager () |
virtual void | onSceneManagerShutdown () |
Private Types | |
typedef std::map< int, std::pair< std::string, bool > > | ModelIdMap |
typedef std::map< std::string, std::vector< std::string > > | RobotJointNamesMap |
Private Attributes | |
RECURSIVE_MUTEX | dbMtx |
int | modelIdCounter |
ModelIdMap | modelIDs |
std::map< std::string, Body * > | objects |
RobotJointNamesMap | robotJointNames |
std::map< std::string, Robot * > | robots |
Very simple implementation of GraspItDatabaseManager which just keeps loaded objects in a std::map.
Definition at line 44 of file GraspItSimpleDBManager.h.
typedef std::map<int, std::pair<std::string, bool> > GraspIt::GraspItSimpleDBManager::ModelIdMap [private] |
Definition at line 107 of file GraspItSimpleDBManager.h.
typedef std::map<std::string, std::vector<std::string> > GraspIt::GraspItSimpleDBManager::RobotJointNamesMap [private] |
Definition at line 111 of file GraspItSimpleDBManager.h.
GraspIt::GraspItSimpleDBManager::GraspItSimpleDBManager | ( | const std::string & | objectName, |
const SHARED_PTR< GraspItSceneManager > & | interface | ||
) | [inline] |
Definition at line 49 of file GraspItSimpleDBManager.h.
virtual GraspIt::GraspItSimpleDBManager::~GraspItSimpleDBManager | ( | ) | [inline, virtual] |
Definition at line 54 of file GraspItSimpleDBManager.h.
void GraspItSimpleDBManager::getAllLoadedObjectIDs | ( | std::vector< int > & | ids | ) | const [virtual] |
Adds the ids of all objects currently loaded in the GraspIt world in the vector Does not clear the vector!
Implements GraspIt::GraspItDatabaseManager.
Definition at line 319 of file GraspItSimpleDBManager.cpp.
void GraspItSimpleDBManager::getAllLoadedObjectNames | ( | std::vector< std::string > & | names | ) | const [virtual] |
Adds the names of all objects currently loaded in the GraspIt world in the vector Does not clear the vector!
Implements GraspIt::GraspItDatabaseManager.
Definition at line 306 of file GraspItSimpleDBManager.cpp.
void GraspItSimpleDBManager::getAllLoadedRobotIDs | ( | std::vector< int > & | ids | ) | const [virtual] |
Adds the ids of all robots currently loaded in the GraspIt world in the vector Does not clear the vector!
Implements GraspIt::GraspItDatabaseManager.
Definition at line 292 of file GraspItSimpleDBManager.cpp.
void GraspItSimpleDBManager::getAllLoadedRobotNames | ( | std::vector< std::string > & | names | ) | const [virtual] |
Adds the names of all robots currently loaded in the GraspIt world in the vector. Does not clear the vector!
Implements GraspIt::GraspItDatabaseManager.
Definition at line 279 of file GraspItSimpleDBManager.cpp.
bool GraspItSimpleDBManager::getModelNameAndType | ( | const int | modelID, |
std::string & | name, | ||
bool & | isRobot | ||
) | const [virtual] |
Returns the name and type of the model with this ID which is also used in the GraspIt world.
isRobot | true if model is a robot, false if it is an object. |
Implements GraspIt::GraspItDatabaseManager.
Definition at line 264 of file GraspItSimpleDBManager.cpp.
int GraspItSimpleDBManager::getModelType | ( | const int | modelID | ) | const [protected, virtual] |
Checks whether this model ID is a robot or an object
2 | is an object |
1 | is a robot |
-1 | does not exist |
Implements GraspIt::GraspItDatabaseManager.
Definition at line 250 of file GraspItSimpleDBManager.cpp.
Body * GraspItSimpleDBManager::getObjectFromDatabase | ( | const std::string & | objectName | ) | [protected, virtual] |
Retrieves the Body object from the database, if it exists in there.
Implements GraspIt::GraspItDatabaseManager.
Definition at line 186 of file GraspItSimpleDBManager.cpp.
Body * GraspItSimpleDBManager::getObjectFromDatabase | ( | const int | modelID | ) | [protected, virtual] |
Retrieves the Body object from the database, if it exists in there.
Implements GraspIt::GraspItDatabaseManager.
Definition at line 211 of file GraspItSimpleDBManager.cpp.
bool GraspItSimpleDBManager::getObjectModelID | ( | const std::string & | objectName, |
int & | id | ||
) | const [virtual] |
id | the model ID of the object with this name |
Implements GraspIt::GraspItDatabaseManager.
Definition at line 351 of file GraspItSimpleDBManager.cpp.
Robot * GraspItSimpleDBManager::getRobotFromDatabase | ( | const std::string & | robotName | ) | [protected, virtual] |
Retrieves the Robot object from the database, if it exists in there.
Implements GraspIt::GraspItDatabaseManager.
Definition at line 198 of file GraspItSimpleDBManager.cpp.
Robot * GraspItSimpleDBManager::getRobotFromDatabase | ( | const int | modelID | ) | [protected, virtual] |
Retrieves the Robot object from the database, if it exists in there.
Implements GraspIt::GraspItDatabaseManager.
Definition at line 229 of file GraspItSimpleDBManager.cpp.
bool GraspItSimpleDBManager::getRobotJointNames | ( | const std::string & | robotName, |
std::vector< std::string > & | jointNames | ||
) | const [virtual] |
Returns the joint names for this robot as used in loadRobotToDatabase(). These are all joints that are involved in resulting grasps, so mostly these are only the fingers.
Implements GraspIt::GraspItDatabaseManager.
Definition at line 168 of file GraspItSimpleDBManager.cpp.
bool GraspItSimpleDBManager::getRobotModelID | ( | const std::string & | robotName, |
int & | id | ||
) | const [virtual] |
id | the model ID of the robot with this name |
Implements GraspIt::GraspItDatabaseManager.
Definition at line 335 of file GraspItSimpleDBManager.cpp.
virtual void GraspIt::GraspItSimpleDBManager::idleEventFromSceneManager | ( | ) | [inline, protected, virtual] |
No need for getting updates from inventor thread.
Implements GraspIt::GraspItDatabaseManager.
Definition at line 86 of file GraspItSimpleDBManager.h.
int GraspItSimpleDBManager::loadObjectToDatabase | ( | const std::string & | filename, |
const std::string & | objectName, | ||
const bool | asGraspable | ||
) | [virtual] |
Loads an object from XML file and adds it to the database. See also GraspItSceneManager::loadObject(). After it has been loaded to the database, it is open to the actual GraspItDatabaseManager implementation wheter the object is left in the graspit world, or removed from it.
objectName | the name to store this object with, and also the name to use for this object in the graspit world. |
>=0 | success, and returns int ID of this model (model IDs are for robots and objects) |
-1 | failed to load world with graspit source. |
-2 | graspit not initialized. |
-3 | file does not exist. |
-4 | could not add object to database because it already exists |
-5 | no object name specified |
-6 | other error when adding the object to the database. |
Implements GraspIt::GraspItDatabaseManager.
Definition at line 104 of file GraspItSimpleDBManager.cpp.
int GraspItSimpleDBManager::loadRobotToDatabase | ( | const std::string & | filename, |
const std::string & | robotName, | ||
const std::vector< std::string > & | jointNames | ||
) | [virtual] |
Loads robot (hand) from XML file and adds it to the database. See also GraspItSceneManager::loadRobot(). After it has been loaded to the database, it is open to the actual GraspItDatabaseManager implementation wheter the robot is left in the graspit world, or removed from it.
robotName | the name to store this robot with, and also the name to use for this robot in the graspit world. |
jointNames | The URDF names of the joints in the order as they appear in the graspit file These are all joints that are involved in resulting grasps, so mostly these are only the fingers. |
>=0 | success, and returns int ID of this model (model IDs are for robots and objects) |
-1 | failed to load world with graspit source. |
-2 | graspit not initialized. |
-3 | file does not exist. |
-4 | could not add robot to database because it already exists |
-5 | no robot name specified |
-6 | other error when adding the robot to the database. |
Implements GraspIt::GraspItDatabaseManager.
Definition at line 33 of file GraspItSimpleDBManager.cpp.
virtual void GraspIt::GraspItSimpleDBManager::onSceneManagerShutdown | ( | ) | [inline, protected, virtual] |
This class is meant to remain abstract. Subclasses can decide whether they need access to the inventor thread.
Implements GraspIt::GraspItDatabaseManager.
Definition at line 87 of file GraspItSimpleDBManager.h.
Definition at line 120 of file GraspItSimpleDBManager.h.
int GraspIt::GraspItSimpleDBManager::modelIdCounter [private] |
Definition at line 123 of file GraspItSimpleDBManager.h.
Definition at line 113 of file GraspItSimpleDBManager.h.
std::map<std::string, Body*> GraspIt::GraspItSimpleDBManager::objects [private] |
Definition at line 99 of file GraspItSimpleDBManager.h.
Definition at line 115 of file GraspItSimpleDBManager.h.
std::map<std::string, Robot*> GraspIt::GraspItSimpleDBManager::robots [private] |
Definition at line 102 of file GraspItSimpleDBManager.h.