Blender  V2.59
ControlledObject.cpp
Go to the documentation of this file.
00001 
00004 /* $Id: ControlledObject.cpp 35155 2011-02-25 11:45:16Z jesterking $
00005  * ControlledObject.cpp
00006  *
00007  *  Created on: Jan 5, 2009
00008  *      Author: rubensmits
00009  */
00010 
00011 #include "ControlledObject.hpp"
00012 
00013 
00014 namespace iTaSC {
00015 ControlledObject::ControlledObject():
00016     Object(Controlled),m_nq(0),m_nc(0),m_nee(0)
00017 {
00018         // max joint variable = 0.52 radian or 0.52 meter in one timestep
00019         m_maxDeltaQ = e_scalar(0.52);
00020 }
00021 
00022 void ControlledObject::initialize(unsigned int _nq,unsigned int _nc, unsigned int _nee)
00023 {
00024         assert(_nee >= 1);
00025         m_nq = _nq;
00026         m_nc = _nc;
00027         m_nee = _nee;
00028         if (m_nq > 0) {
00029                 m_Wq =  e_identity_matrix(m_nq,m_nq);
00030                 m_qdot = e_zero_vector(m_nq);
00031         }
00032         if (m_nc > 0) {
00033                 m_Wy = e_scalar_vector(m_nc,1.0);
00034                 m_ydot = e_zero_vector(m_nc);
00035         }
00036         if (m_nc > 0 && m_nq > 0)
00037                 m_Cq = e_zero_matrix(m_nc,m_nq);
00038         // clear all Jacobian if any
00039         m_JqArray.clear();
00040         // reserve one more to have a zero matrix handy
00041         if (m_nq > 0)
00042                 m_JqArray.resize(m_nee+1, e_zero_matrix(6,m_nq));
00043 }
00044 
00045 ControlledObject::~ControlledObject() {}
00046 
00047 
00048 
00049 const e_matrix& ControlledObject::getJq(unsigned int ee) const
00050 {
00051         assert(m_nq > 0);
00052         return m_JqArray[(ee>m_nee)?m_nee:ee];
00053 }
00054 
00055 double ControlledObject::getMaxTimestep(double& timestep)
00056 {
00057         e_scalar maxQdot = m_qdot.cwise().abs().maxCoeff();
00058         if (timestep*maxQdot > m_maxDeltaQ) {
00059                 timestep = m_maxDeltaQ/maxQdot;
00060         }
00061         return timestep;
00062 }
00063 
00064 }