Blender V2.61 - r43446

Scene.hpp

Go to the documentation of this file.
00001 /*
00002  * Scene.hpp
00003  *
00004  *  Created on: Jan 5, 2009
00005  *      Author: rubensmits
00006  */
00007 
00008 #ifndef SCENE_HPP_
00009 #define SCENE_HPP_
00010 
00011 #include "eigen_types.hpp"
00012 
00013 #include "WorldObject.hpp"
00014 #include "ConstraintSet.hpp"
00015 #include "Solver.hpp"
00016 
00017 #include <map>
00018 
00019 namespace iTaSC {
00020 
00021 class SceneLock;
00022 
00023 class Scene {
00024     friend class SceneLock; 
00025 public:
00026     enum SceneParam {
00027         MIN_TIMESTEP    = 0,
00028         MAX_TIMESTEP,
00029 
00030         COUNT
00031     };
00032 
00033 
00034     Scene();
00035     virtual ~Scene();
00036 
00037     bool addObject(const std::string& name, Object* object, UncontrolledObject* base=&Object::world, const std::string& baseFrame="");
00038     bool addConstraintSet(const std::string& name, ConstraintSet* task,const std::string& object1,const std::string& object2,const std::string& ee1="",const std::string& ee2="");
00039     bool addSolver(Solver* _solver);
00040     bool addCache(Cache* _cache);
00041     bool initialize();
00042     bool update(double timestamp, double timestep, unsigned int numsubstep=1, bool reiterate=false, bool cache=true, bool interpolate=true);
00043     bool setParam(SceneParam paramId, double value);
00044 
00045     EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00046 
00047 private:
00048     e_matrix m_A,m_B,m_Atemp,m_Wq,m_Jf,m_Jq,m_Ju,m_Cf,m_Cq,m_Jf_inv;
00049     e_matrix6 m_Vf,m_Uf;
00050     e_vector m_Wy,m_ydot,m_qdot,m_xdot;
00051     e_vector6 m_Sf,m_tempf;
00052     double m_minstep;
00053     double m_maxstep;
00054     unsigned int m_ncTotal,m_nqTotal,m_nuTotal,m_nsets;
00055     std::vector<bool> m_ytask;
00056 
00057     Solver* m_solver;
00058     Cache* m_cache;
00059 
00060 
00061     struct Object_struct{
00062         Object* object;
00063         UncontrolledObject* base;
00064         unsigned int baseFrameIndex;
00065         Range constraintrange;
00066         Range jointrange;
00067         Range coordinaterange;  // Xu range of base when object is controlled
00068                                         // Xu range of object when object is uncontrolled 
00069 
00070         Object_struct(Object* _object,UncontrolledObject* _base,unsigned int _baseFrameIndex,Range nq_range,Range nc_range,Range nu_range):
00071             object(_object),base(_base),baseFrameIndex(_baseFrameIndex),constraintrange(nc_range),jointrange(nq_range),coordinaterange(nu_range)
00072             {};
00073     };
00074     typedef std::map<std::string,Object_struct*> ObjectMap;
00075 
00076     struct ConstraintSet_struct{
00077         ConstraintSet* task;
00078         ObjectMap::iterator object1;
00079         ObjectMap::iterator object2;
00080         Range constraintrange;
00081         Range featurerange;
00082         unsigned int ee1index;
00083         unsigned int ee2index;
00084         ConstraintSet_struct(ConstraintSet* _task,
00085             ObjectMap::iterator _object1,unsigned int _ee1index,
00086             ObjectMap::iterator _object2,unsigned int _ee2index,
00087             Range nc_range,Range coord_range):
00088                 task(_task),
00089                 object1(_object1),object2(_object2),
00090                 constraintrange(nc_range),featurerange(coord_range),
00091                 ee1index(_ee1index), ee2index(_ee2index)
00092             {};
00093     };
00094     typedef std::map<std::string,ConstraintSet_struct*> ConstraintMap;
00095 
00096     ObjectMap objects;
00097     ConstraintMap constraints;
00098 
00099     static bool getConstraintPose(ConstraintSet* constraint, void *_param, KDL::Frame& _pose);
00100 };
00101 
00102 }
00103 
00104 #endif /* SCENE_HPP_ */