ControlledObject.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * ControlledObject.hpp
  3. *
  4. * Created on: Jan 5, 2009
  5. * Author: rubensmits
  6. */
  7. #ifndef CONTROLLEDOBJECT_HPP_
  8. #define CONTROLLEDOBJECT_HPP_
  9. #include "kdl/frames.hpp"
  10. #include "eigen_types.hpp"
  11. #include "Object.hpp"
  12. #include "ConstraintSet.hpp"
  13. #include <vector>
  14. namespace iTaSC {
  15. #define CONSTRAINT_ID_ALL ((unsigned int)-1)
  16. class ControlledObject : public Object {
  17. protected:
  18. e_scalar m_maxDeltaQ;
  19. unsigned int m_nq,m_nc,m_nee;
  20. e_matrix m_Wq,m_Cq;
  21. e_vector m_Wy,m_ydot,m_qdot;
  22. std::vector<e_matrix> m_JqArray;
  23. public:
  24. ControlledObject();
  25. virtual ~ControlledObject();
  26. class JointLockCallback {
  27. public:
  28. JointLockCallback() {}
  29. virtual ~JointLockCallback() {}
  30. // lock a joint, no need to update output
  31. virtual void lockJoint(unsigned int q_nr, unsigned int ndof) = 0;
  32. // lock a joint and update output in view of reiteration
  33. virtual void lockJoint(unsigned int q_nr, unsigned int ndof, double* qdot) = 0;
  34. };
  35. virtual void initialize(unsigned int _nq,unsigned int _nc, unsigned int _nee);
  36. // returns true when a joint has been locked via the callback and the solver must run again
  37. virtual bool updateJoint(const Timestamp& timestamp, JointLockCallback& callback) = 0;
  38. virtual void updateControlOutput(const Timestamp& timestamp)=0;
  39. virtual void setJointVelocity(const e_vector qdot_in){m_qdot = qdot_in;};
  40. virtual double getMaxTimestep(double& timestep);
  41. virtual bool setControlParameter(unsigned int constraintId, unsigned int valueId, ConstraintAction action, e_scalar value, double timestep=0.0)=0;
  42. virtual const e_vector& getControlOutput() const{return m_ydot;}
  43. virtual const e_matrix& getJq(unsigned int ee) const;
  44. virtual const e_matrix& getCq() const{return m_Cq;};
  45. virtual e_matrix& getWq() {return m_Wq;};
  46. virtual void setWq(const e_matrix& Wq_in){m_Wq = Wq_in;};
  47. virtual const e_vector& getWy() const {return m_Wy;};
  48. virtual const unsigned int getNrOfCoordinates(){return m_nq;};
  49. virtual const unsigned int getNrOfConstraints(){return m_nc;};
  50. };
  51. }
  52. #endif /* CONTROLLEDOBJECT_HPP_ */