@@ -115,8 +115,10 @@ Device::
115
115
Device ( const std::string& n )
116
116
:Entity(n)
117
117
,state_(6 )
118
+ ,robotState_(" Device(" + n + " )::output(vector)::robotState" )
119
+ ,robotVelocity_(" Device(" + n + " )::output(vector)::robotVelocity" )
118
120
,vel_controlInit_(false )
119
- ,controlInputType_(CONTROL_INPUT_VELOCITY )
121
+ ,controlInputType_(CONTROL_INPUT_ONE_INTEGRATION )
120
122
,controlSIN( NULL ," Device(" +n+" )::input(double)::control" )
121
123
// ,attitudeSIN(NULL,"Device::input(matrixRot)::attitudeIN")
122
124
,attitudeSIN(NULL ," Device::input(vector3)::attitudeIN" )
@@ -142,7 +144,8 @@ Device( const std::string& n )
142
144
forcesSOUT[3 ] =
143
145
new Signal<Vector, int >(" OpenHRP::output(vector6)::forceLARM" );
144
146
145
- signalRegistration ( controlSIN<<stateSOUT<<velocitySOUT<<attitudeSOUT
147
+ signalRegistration ( controlSIN<<stateSOUT<<robotState_<<robotVelocity_
148
+ <<velocitySOUT<<attitudeSOUT
146
149
<<attitudeSIN<<zmpSIN <<*forcesSOUT[0 ]<<*forcesSOUT[1 ]
147
150
<<*forcesSOUT[2 ]<<*forcesSOUT[3 ] <<previousControlSOUT
148
151
<<pseudoTorqueSOUT << motorcontrolSOUT << ZMPPreviousControllerSOUT );
@@ -273,7 +276,16 @@ setRoot( const MatrixHomogeneous & worldMwaist )
273
276
void Device::
274
277
setSecondOrderIntegration ()
275
278
{
276
- controlInputType_ = CONTROL_INPUT_ACCELERATION;
279
+ controlInputType_ = CONTROL_INPUT_TWO_INTEGRATION;
280
+ velocity_.resize (state_.size ());
281
+ velocity_.setZero ();
282
+ velocitySOUT.setConstant ( velocity_ );
283
+ }
284
+
285
+ void Device::
286
+ setNoIntegration ()
287
+ {
288
+ controlInputType_ = CONTROL_INPUT_NO_INTEGRATION;
277
289
velocity_.resize (state_.size ());
278
290
velocity_.setZero ();
279
291
velocitySOUT.setConstant ( velocity_ );
@@ -335,12 +347,12 @@ increment( const double & dt )
335
347
/* Position the signals corresponding to sensors. */
336
348
stateSOUT .setConstant ( state_ ); stateSOUT.setTime ( time +1 );
337
349
// computation of the velocity signal
338
- if ( controlInputType_==CONTROL_INPUT_ACCELERATION )
350
+ if ( controlInputType_==CONTROL_INPUT_TWO_INTEGRATION )
339
351
{
340
352
velocitySOUT.setConstant ( velocity_ );
341
353
velocitySOUT.setTime ( time +1 );
342
354
}
343
- else
355
+ else if (controlInputType_==CONTROL_INPUT_ONE_INTEGRATION)
344
356
{
345
357
velocitySOUT.setConstant ( controlSIN.accessCopy () );
346
358
velocitySOUT.setTime ( time +1 );
@@ -383,19 +395,19 @@ increment( const double & dt )
383
395
384
396
void Device::integrate ( const double & dt )
385
397
{
386
- const Vector & control = controlSIN.accessCopy ();
398
+ const Vector & controlIN = controlSIN.accessCopy ();
387
399
388
- if (controlInputType_==CONTROL_INPUT_POSITION )
400
+ if (controlInputType_==CONTROL_INPUT_NO_INTEGRATION )
389
401
{
390
- assert (state_.size ()==control .size ()+6 );
391
- for ( int i=0 ;i<control .size ();++i )
392
- state_ (i+6 ) = control (i);
402
+ assert (state_.size ()==controlIN .size ()+6 );
403
+ for ( int i=0 ;i<controlIN .size ();++i )
404
+ state_ (i+6 ) = controlIN (i);
393
405
return ;
394
406
}
395
407
396
408
if ( !vel_controlInit_ )
397
409
{
398
- vel_control_ = Vector (control .size ());
410
+ vel_control_ = Vector (controlIN .size ());
399
411
vel_control_.setZero ();
400
412
vel_controlInit_ = true ;
401
413
}
@@ -405,20 +417,18 @@ void Device::integrate( const double & dt )
405
417
// freedom as a translation and roll pitch yaw.
406
418
unsigned int offset = 6 ;
407
419
408
-
409
-
410
- if (controlInputType_==CONTROL_INPUT_ACCELERATION)
420
+ if (controlInputType_==CONTROL_INPUT_TWO_INTEGRATION)
411
421
{
412
- for ( int i=0 ;i<control .size ();++i )
422
+ for ( int i=0 ;i<controlIN .size ();++i )
413
423
{
414
- if (control .size () == velocity_.size ()) offset = 0 ;
415
- vel_control_ (i) = velocity_ (i+offset) + control (i)*dt*0.5 ;
416
- velocity_ (i+offset) = velocity_ (i+offset) + control (i)*dt;
424
+ if (controlIN .size () == velocity_.size ()) offset = 0 ;
425
+ vel_control_ (i) = velocity_ (i+offset) + controlIN (i)*dt*0.5 ;
426
+ velocity_ (i+offset) = velocity_ (i+offset) + controlIN (i)*dt;
417
427
}
418
428
}
419
429
else
420
430
{
421
- vel_control_ = control ;
431
+ vel_control_ = controlIN ;
422
432
}
423
433
424
434
if (vel_control_.size () == state_.size ()) {
0 commit comments