Blender V4.3
ControlledObject.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Ruben Smits
2 *
3 * SPDX-License-Identifier: LGPL-2.1-or-later */
4
10
11
12namespace iTaSC {
14 Object(Controlled),m_nq(0),m_nc(0),m_nee(0)
15{
16 // max joint variable = 0.52 radian or 0.52 meter in one timestep
17 m_maxDeltaQ = e_scalar(0.52);
18}
19
20void ControlledObject::initialize(unsigned int _nq,unsigned int _nc, unsigned int _nee)
21{
22 assert(_nee >= 1);
23 m_nq = _nq;
24 m_nc = _nc;
25 m_nee = _nee;
26 if (m_nq > 0) {
29 }
30 if (m_nc > 0) {
33 }
34 if (m_nc > 0 && m_nq > 0)
36 // clear all Jacobian if any
37 m_JqArray.clear();
38 // reserve one more to have a zero matrix handy
39 if (m_nq > 0)
40 m_JqArray.resize(m_nee+1, e_zero_matrix(6,m_nq));
41}
42
44
45
46
47const e_matrix& ControlledObject::getJq(unsigned int ee) const
48{
49 assert(m_nq > 0);
50 return m_JqArray[(ee>m_nee)?m_nee:ee];
51}
52
53double ControlledObject::getMaxTimestep(double& timestep)
54{
55 e_scalar maxQdot = m_qdot.array().abs().maxCoeff();
56 if (timestep*maxQdot > m_maxDeltaQ) {
57 timestep = m_maxDeltaQ/maxQdot;
58 }
59 return timestep;
60}
61
62}
std::vector< e_matrix > m_JqArray
virtual const e_matrix & getJq(unsigned int ee) const
virtual double getMaxTimestep(double &timestep)
virtual void initialize(unsigned int _nq, unsigned int _nc, unsigned int _nee)
#define e_scalar_vector
#define e_scalar
#define e_zero_vector
#define e_identity_matrix
#define e_zero_matrix
#define e_matrix