00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #ifndef ROS_DATABASE_MANAGER_H
00031 #define ROS_DATABASE_MANAGER_H
00032
00033 #include <string>
00034 #include <vector>
00035 #include <utility>
00036
00037 #include "db_manager.h"
00038 #include "model.h"
00039 #include "task.h"
00040 #include "grasp.h"
00041
00042 namespace household_objects_database {
00043 class ObjectsDatabase;
00044 class DatabaseScaledModel;
00045 }
00046
00047 using std::pair;
00048 using std::string;
00049 using std::vector;
00050
00051 namespace db_planner {
00052
00054 class RosDatabaseManager : public DatabaseManager
00055 {
00056 protected:
00057
00059 household_objects_database::ObjectsDatabase* database_;
00060
00062 void modelFromDBModel(Model *model,
00063 const household_objects_database::DatabaseScaledModel &db_model,
00064 std::string model_root) const;
00065 public:
00066 RosDatabaseManager(std::string host, std::string port, std::string user,
00067 std::string password, std::string dbname,
00068 ModelAllocator *model_allocator, GraspAllocator* grasp_allocator);
00069 ~RosDatabaseManager();
00070
00072 void SetGraspAllocator(GraspAllocator* allocator) {
00073 delete grasp_allocator_;
00074 grasp_allocator_ = allocator;
00075 }
00077 void SetModelAllocator(ModelAllocator* allocator) {
00078 delete model_allocator_;
00079 model_allocator_ = allocator;
00080 }
00081
00083 virtual bool GetAlignment(const Model&, const Model&, const string&, float*) const {return false;}
00085 virtual bool SaveAlignment(const Model&, const Model&, const string&, const float*) const {return false;}
00087 virtual bool GetNeighbors(const Model&, const string&, const int,
00088 vector<pair<Model*, double> >*) const {return false;}
00090 virtual bool SaveNeighbors(const Model&, const string&,
00091 const vector<pair<Model*, double> >&) const {return false;}
00093 virtual bool DistanceFunctionList(vector<string>*) const {return false;}
00095 virtual bool AlignmentMethodList(vector<string>*) const {return false;}
00096
00098 virtual bool isConnected() const;
00099
00101 virtual bool ModelList(vector<Model*>* model_list,
00102 FilterList::FilterType filter = FilterList::NONE) const;
00104 virtual bool ScaledModel(Model* &model, int scaled_model_id) const;
00105
00107
00109 virtual bool AcquireNextTask(TaskRecord *rec);
00111 virtual bool SetTaskStatus(int task_id, const string &status);
00113 virtual bool GetPlanningTaskRecord(int task_id, PlanningTaskRecord *rec);
00115 virtual bool GetOptimizationTaskRecord(int task_id, OptimizationTaskRecord *rec);
00117 virtual bool SaveOptimizationResults(const OptimizationTaskRecord &rec,
00118 const std::vector<double>& parameters,
00119 const std::vector<double>& results);
00121 virtual bool GraspTypeList(vector<string>* type_list) const;
00123 virtual bool GetGrasps(const Model& model, const string& hand_name, vector<Grasp*>* grasp_list) const;
00124
00126 virtual bool SaveGrasp(const Grasp*) const;
00128 virtual bool DeleteGrasp(Grasp* grasp) const;
00130 virtual bool SetGraspClusterRep(Grasp *grasp, bool rep) const;
00132 virtual bool SetGraspTableClearance(Grasp *grasp, double clearance) const;
00134 virtual bool InsertGraspPair(const Grasp *grasp1, const Grasp *grasp2) const;
00136 virtual bool LoadModelGeometry(Model* model) const;
00137 };
00138
00139 }
00140 #endif // ROS_DATABASE_MANAGER_H