Blender V4.3
CopyPose.hpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Benoit Bolsee
2 *
3 * SPDX-License-Identifier: LGPL-2.1-or-later */
4
9#ifndef COPYPOSE_H_
10#define COPYPOSE_H_
11
12#include "ConstraintSet.hpp"
13namespace iTaSC{
14
15using namespace KDL;
16
18{
19protected:
20 virtual void updateKinematics(const Timestamp& timestamp);
21 virtual void pushCache(const Timestamp& timestamp);
22 virtual void updateJacobian();
23 virtual bool initialise(Frame& init_pose);
24 virtual void initCache(Cache *_cache);
25 virtual void updateControlOutput(const Timestamp& timestamp);
26 virtual void modelUpdate(Frame& _external_pose,const Timestamp& timestamp);
27 virtual double getMaxTimestep(double& timestep);
28
29public:
30 enum ID { // constraint ID in callback and setControlParameter
39 };
40 enum CTL { // control ID in constructor to specify which output is constrainted
42 CTL_POSITIONX=0x01, // the bit order is important: it matches the y output order
50 CTL_ALL=0x3F,
51 };
52
53 // use a combination of CTL_.. in control_output to specify which
54 CopyPose(unsigned int control_output=CTL_ALL, unsigned int dynamic_output=CTL_NONE, double armlength=1.0, double accuracy=1e-6, unsigned int maximum_iterations=100);
55 virtual ~CopyPose();
56
57 virtual bool setControlParameters(struct ConstraintValues* _values, unsigned int _nvalues, double timestep);
58 virtual const ConstraintValues* getControlParameters(unsigned int* _nvalues);
59
60private:
61 struct ConstraintSingleValue m_posData[3]; // index = controlled output in X,Y,Z order
62 struct ConstraintSingleValue m_rotData[3];
63 struct ConstraintValues m_values[2]; // index = group of controlled output, in position, rotation order
64 Cache* m_cache;
65 int m_poseCCh;
66 CacheTS m_poseCTs;
67 unsigned int m_poseCacheSize;
68 unsigned int m_outputDynamic; // combination of CTL_... determine which variables are dynamically controlled by the application
69 unsigned int m_outputControl; // combination of CTL_... determine which output are constrained
70 unsigned int m_nvalues; // number of elements used in m_values[]
71 double m_maxerror;
72
73 struct ControlState {
74 int firsty; // first y index
75 int ny; // number of y in output
76 double alpha;
77 double K;
78 double tolerance;
79 struct ControlValue {
80 double yddot;
81 double yd;
82 double nextyd;
83 double nextyddot;
84 } output[3]; // inded numbex = same as m_rotData
85 } m_rot, m_pos;
86
87 void pushPose(CacheTS timestamp);
88 bool popPose(CacheTS timestamp);
89 int nBitsOn(unsigned int v)
90 { int n=0; while(v) { if (v&1) n++; v>>=1; } return n; }
91 double* restoreValues(double* item, ConstraintValues* _values, ControlState* _state, unsigned int mask);
92 double* pushValues(double* item, ControlState* _state, unsigned int mask);
93 void updateState(ConstraintValues* _values, ControlState* _state, unsigned int mask, double timestep);
94 void updateValues(Vector& vel, ConstraintValues* _values, ControlState* _state, unsigned int mask);
95 void updateOutput(Vector& vel, ControlState* _state, unsigned int mask);
96 void interpolateOutput(ControlState* _state, unsigned int mask, const Timestamp& timestamp);
97
98};
99}
100#endif /* COPYROTATION_H_ */
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
represents a frame transformation in 3D space (rotation + translation)
Definition frames.hpp:526
virtual void initCache(Cache *_cache)
Definition CopyPose.cpp:130
virtual double getMaxTimestep(double &timestep)
Definition CopyPose.cpp:469
virtual bool initialise(Frame &init_pose)
Definition CopyPose.cpp:117
virtual ~CopyPose()
Definition CopyPose.cpp:113
virtual bool setControlParameters(struct ConstraintValues *_values, unsigned int _nvalues, double timestep)
Definition CopyPose.cpp:359
virtual void updateJacobian()
Definition CopyPose.cpp:274
CopyPose(unsigned int control_output=CTL_ALL, unsigned int dynamic_output=CTL_NONE, double armlength=1.0, double accuracy=1e-6, unsigned int maximum_iterations=100)
Definition CopyPose.cpp:18
virtual void modelUpdate(Frame &_external_pose, const Timestamp &timestamp)
Definition CopyPose.cpp:124
virtual void pushCache(const Timestamp &timestamp)
Definition CopyPose.cpp:256
virtual const ConstraintValues * getControlParameters(unsigned int *_nvalues)
Definition CopyPose.cpp:454
virtual void updateKinematics(const Timestamp &timestamp)
Definition CopyPose.cpp:263
virtual void updateControlOutput(const Timestamp &timestamp)
Definition CopyPose.cpp:423
Definition chain.cpp:27
unsigned int CacheTS
Definition Cache.hpp:33
Definition DNA_ID.h:413