Skip to content

Commit 2b7b171

Browse files
jmirabelolivier-stasse
authored andcommitted
Add check that Device bounds are properly set.
1 parent 4bad18a commit 2b7b171

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/tools/device.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,33 @@ setVelocitySize( const unsigned int& size )
245245
void Device::
246246
setState( const Vector& st )
247247
{
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+
}
248275
state_ = st;
249276
stateSOUT .setConstant( state_ );
250277
motorcontrolSOUT .setConstant( state_ );

0 commit comments

Comments
 (0)