@@ -245,6 +245,33 @@ setVelocitySize( const unsigned int& size )
245
245
void Device::
246
246
setState ( const Vector& st )
247
247
{
248
+ if (sanityCheck_) {
249
+ const Vector::Index& s = st.size ();
250
+ switch (controlInputType_) {
251
+ case CONTROL_INPUT_TWO_INTEGRATION:
252
+ dgRTLOG ()
253
+ << " Sanity check for this control is not well supported. "
254
+ " In order to make it work, use pinocchio and the contact forces "
255
+ " to estimate the joint torques for the given acceleration.\n " ;
256
+ if ( s != lowerTorque_.size ()
257
+ || s != upperTorque_.size () )
258
+ throw std::invalid_argument (" Upper and/or lower torque bounds "
259
+ " do not match state size. Set them first with setTorqueBounds" );
260
+ case CONTROL_INPUT_ONE_INTEGRATION:
261
+ if ( s != lowerVelocity_.size ()
262
+ || s != upperVelocity_.size () )
263
+ throw std::invalid_argument (" Upper and/or lower velocity bounds "
264
+ " do not match state size. Set them first with setVelocityBounds" );
265
+ case CONTROL_INPUT_NO_INTEGRATION:
266
+ if ( s != lowerPosition_.size ()
267
+ || s != upperPosition_.size () )
268
+ throw std::invalid_argument (" Upper and/or lower position bounds "
269
+ " do not match state size. Set them first with setPositionBounds" );
270
+ break ;
271
+ default :
272
+ throw std::invalid_argument (" Invalid control mode type." );
273
+ }
274
+ }
248
275
state_ = st;
249
276
stateSOUT .setConstant ( state_ );
250
277
motorcontrolSOUT .setConstant ( state_ );
0 commit comments