20 CopyPose::CopyPose(
unsigned int control_output,
unsigned int dynamic_output,
double armlength,
double accuracy,
unsigned int maximum_iterations):
23 m_poseCCh(-1),m_poseCTs(0)
25 m_maxerror = armlength/2.0;
26 m_outputControl = (control_output &
CTL_ALL);
27 unsigned int _nc = nBitsOn(m_outputControl);
31 reset(_nc, accuracy, maximum_iterations);
34 int nrot = 0, npos = 0;
35 int nposCache = 0, nrotCache = 0;
36 m_outputDynamic = (dynamic_output & m_outputControl);
37 memset(m_values, 0,
sizeof(m_values));
38 memset(m_posData, 0,
sizeof(m_posData));
39 memset(m_rotData, 0,
sizeof(m_rotData));
40 memset(&m_rot, 0,
sizeof(m_rot));
41 memset(&m_pos, 0,
sizeof(m_pos));
45 m_pos.tolerance = 0.05;
46 m_values[m_nvalues].
alpha = m_pos.alpha;
47 m_values[m_nvalues].
feedback = m_pos.K;
48 m_values[m_nvalues].
tolerance = m_pos.tolerance;
51 m_Wy(_nc) = m_pos.alpha;
58 m_Wy(_nc) = m_pos.alpha;
65 m_Wy(_nc) = m_pos.alpha;
71 m_values[m_nvalues].
number = npos;
72 m_values[m_nvalues++].
values = m_posData;
79 m_rot.tolerance = 0.05;
80 m_values[m_nvalues].
alpha = m_rot.alpha;
81 m_values[m_nvalues].
feedback = m_rot.K;
82 m_values[m_nvalues].
tolerance = m_rot.tolerance;
85 m_Wy(_nc) = m_rot.alpha;
92 m_Wy(_nc) = m_rot.alpha;
99 m_Wy(_nc) = m_rot.alpha;
105 m_values[m_nvalues].
number = nrot;
106 m_values[m_nvalues++].
values = m_rotData;
112 m_poseCacheSize = ((nrotCache)?(3+nrotCache*2):0)+((nposCache)?(3+nposCache*2):0);
138 m_poseCCh = m_cache->
addChannel(
this,
"Xf", m_poseCacheSize*
sizeof(
double));
144 double* CopyPose::pushValues(
double* item, ControlState* _state,
unsigned int mask)
146 ControlState::ControlValue* _yval;
149 *item++ = _state->alpha;
151 *item++ = _state->tolerance;
153 for (i=0, _yval=_state->output; i<_state->
ny;
mask<<=1) {
154 if (m_outputControl &
mask) {
155 if (m_outputDynamic &
mask) {
157 *item++ = _yval->yddot;
166 void CopyPose::pushPose(
CacheTS timestamp)
168 if (m_poseCCh >= 0) {
169 if (m_poseCacheSize) {
179 m_poseCTs = timestamp;
183 double* CopyPose::restoreValues(
double* item, ConstraintValues* _values, ControlState* _state,
unsigned int mask)
185 ConstraintSingleValue* _data;
186 ControlState::ControlValue* _yval;
189 _values->alpha = _state->alpha = *item++;
190 _values->feedback = _state->K = *item++;
191 _values->tolerance = _state->tolerance = *item++;
193 for (i=_state->firsty, j=i+_state->ny, _yval=_state->output, _data=_values->values; i<j;
mask<<=1) {
194 if (m_outputControl &
mask) {
195 m_Wy(i) = _state->alpha;
196 if (m_outputDynamic &
mask) {
197 _data->yd = _yval->yd = *item++;
198 _data->yddot = _yval->yddot = *item++;
208 bool CopyPose::popPose(
CacheTS timestamp)
211 if (m_poseCCh >= 0) {
215 if (timestamp != m_poseCTs) {
219 item = restoreValues(item, &m_values[i], &m_pos,
CTL_POSITIONX);
225 item = restoreValues(item, &m_values[i], &m_rot,
CTL_ROTATIONX);
229 m_poseCTs = timestamp;
237 void CopyPose::interpolateOutput(ControlState* _state,
unsigned int mask,
const Timestamp& timestamp)
239 ControlState::ControlValue* _yval;
242 for (i=0, _yval=_state->output; i<_state->
ny;
mask <<= 1) {
243 if (m_outputControl &
mask) {
244 if (m_outputDynamic &
mask) {
245 if (timestamp.substep && timestamp.interpolate) {
246 _yval->yd += _yval->yddot*timestamp.realTimestep;
248 _yval->yd = _yval->nextyd;
249 _yval->yddot = _yval->nextyddot;
288 void CopyPose::updateState(
ConstraintValues* _values, ControlState* _state,
unsigned int mask,
double timestep)
291 ControlState::ControlValue* _yval;
297 _state->alpha = _values->
alpha;
308 for (i=_state->firsty, j=_state->firsty+_state->ny, _yval=_state->output; i<j;
mask <<= 1,
id++) {
309 if (m_outputControl &
mask) {
311 m_Wy(i) = _state->alpha;
313 for (k=0, _data=_values->
values; k<_values->number; k++, _data++) {
314 if (_data->
id ==
id) {
321 _data->
yd = _yval->yd+_data->
yddot*timestep;
324 _yval->nextyd = _data->
yd;
329 _yval->yddot = (_data->
yd-_yval->yd)/timestep;
333 _yval->yd = _yval->nextyd;
334 _yval->yddot = _yval->nextyddot;
341 _yval->yd = _data->
yd - _data->
yddot*timestep;
342 _yval->nextyd = _data->
yd;
343 _yval->nextyddot = _data->
yddot;
345 _yval->yddot = (_data->
yd-_yval->yd)/timestep;
347 _yval->yd = _yval->nextyd;
348 _yval->yddot = _yval->nextyddot;
363 while (_nvalues > 0) {
379 ControlState::ControlValue* _yval;
384 for (i=_state->firsty, j=0, _yval=_state->output, _data=_values->
values; j<3; j++,
mask<<=1) {
385 if (m_outputControl &
mask) {
386 *(
double*)&_data->
y = vel(j);
388 _data->
yd = _yval->yd;
389 _data->
yddot = _yval->yddot;
398 void CopyPose::updateOutput(Vector& vel, ControlState* _state,
unsigned int mask)
400 ControlState::ControlValue* _yval;
406 for (j=0, _yval=_state->output; j<3; j++) {
407 if (m_outputControl & (
mask<<j)) {
413 if (
len > m_maxerror)
414 coef = m_maxerror/
len;
416 for (i=_state->firsty, j=0, _yval=_state->output; j<3; j++) {
417 if (m_outputControl & (
mask<<j)) {
418 m_ydot(i)=_yval->yddot+_state->K*coef*(_yval->yd-vel(j));
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble ny
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
represents a frame transformation in 3D space (rotation + translation)
represents both translational and rotational velocities.
A concrete implementation of a 3 dimensional vector class.
int addChannel(const void *device, const char *name, unsigned int maxItemSize)
double * addCacheVectorIfDifferent(const void *device, int channel, CacheTS timestamp, double *data, unsigned int length, double threshold)
const void * getPreviousCacheItem(const void *device, int channel, CacheTS *timestamp)
KDL::Frame m_internalPose
KDL::Frame m_externalPose
virtual void reset(unsigned int nc, double accuracy, unsigned int maximum_iterations)
ConstraintCallback m_constraintCallback
virtual void initCache(Cache *_cache)
virtual double getMaxTimestep(double ×tep)
virtual bool initialise(Frame &init_pose)
virtual bool setControlParameters(struct ConstraintValues *_values, unsigned int _nvalues, double timestep)
virtual void updateJacobian()
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)
virtual void modelUpdate(Frame &_external_pose, const Timestamp ×tamp)
virtual void pushCache(const Timestamp ×tamp)
virtual const ConstraintValues * getControlParameters(unsigned int *_nvalues)
virtual void updateKinematics(const Timestamp ×tamp)
virtual void updateControlOutput(const Timestamp ×tamp)
#define e_identity_matrix
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt=1)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
double epsilon
default precision while comparing with Equal(..,..) functions. Initialized at 0.0000001.
INLINE Rall1d< T, V, S > sqr(const Rall1d< T, V, S > &arg)
const unsigned int maxPoseCacheSize
struct ConstraintSingleValue * values
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)