diff --git a/include/crocoddyl/multibody/residuals/state.hxx b/include/crocoddyl/multibody/residuals/state.hxx index 244681b7d5..233f5e803b 100644 --- a/include/crocoddyl/multibody/residuals/state.hxx +++ b/include/crocoddyl/multibody/residuals/state.hxx @@ -147,11 +147,11 @@ ResidualModelStateTpl::get_reference() const { template void ResidualModelStateTpl::set_reference(const VectorXs& reference) { - if (static_cast(reference.size()) != nr_) { + if (static_cast(reference.size()) != state_->get_nx()) { throw_pretty("Invalid argument: " << "the state reference has wrong dimension (" << reference.size() - << " provided - it should be " + std::to_string(nr_) + ")") + << " provided - it should be " + std::to_string(state_->get_nx() + ")") } xref_ = reference; }