Skip to content

Commit

Permalink
fix to handle nan even when checklimits == CLA_Nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
YutaKojio committed Feb 13, 2024
1 parent 4c72927 commit e5d9420
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions src/libopenrave/kinbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2160,42 +2160,33 @@ void KinBody::SetDOFValues(const dReal* pJointValues, int dof, uint32_t checklim
int expecteddof = dofindices.size() > 0 ? (int)dofindices.size() : GetDOF();
OPENRAVE_ASSERT_OP_FORMAT((int)dof,>=,expecteddof, "env=%s, not enough values %d<%d", GetEnv()->GetNameId()%dof%GetDOF(),ORE_InvalidArguments);

if(checklimits == CLA_Nothing && dofindices.empty()) {
_vTempJoints.assign(pJointValues, pJointValues + dof);
}
else {
GetDOFValues(_vTempJoints);
if( dofindices.size() > 0 ) {
// user only set a certain number of indices, so have to fill the temporary array with the full set of values first
// and then overwrite with the user set values
for(size_t i = 0; i < dofindices.size(); ++i) {
if( !std::isnan(pJointValues[i]) ) {
_vTempJoints.at(dofindices[i]) = pJointValues[i];
}
GetDOFValues(_vTempJoints);
if( dofindices.size() > 0 ) {
// user only set a certain number of indices, so have to fill the temporary array with the full set of values first
// and then overwrite with the user set values
for(size_t i = 0; i < dofindices.size(); ++i) {
if( !std::isnan(pJointValues[i]) ) {
_vTempJoints.at(dofindices[i]) = pJointValues[i];
}
}
else {
for(size_t i = 0; i < _vTempJoints.size(); ++i) {
if( !std::isnan(pJointValues[i]) ) {
_vTempJoints[i] = pJointValues[i];
}
}
else {
for(size_t i = 0; i < _vTempJoints.size(); ++i) {
if( !std::isnan(pJointValues[i]) ) {
_vTempJoints[i] = pJointValues[i];
}
}
pJointValues = &_vTempJoints[0];
}
pJointValues = &_vTempJoints[0];

if( checklimits != CLA_Nothing ) {
dReal* ptempjoints = &_vTempJoints[0];

// check the limits
for(const JointPtr& pjoint : _vecjoints) {
const Joint& joint = *pjoint;

const dReal* p = pJointValues+joint.GetDOFIndex();
if( checklimits == CLA_Nothing ) {
// limits should not be checked, so just copy
for(int i = 0; i < joint.GetDOF(); ++i) {
*ptempjoints++ = p[i];
}
continue;
}
if( joint.GetType() == JointSpherical ) {
dReal fcurang = fmod(RaveSqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),2*PI);
dReal lowerlimit = joint.GetLowerLimit(0);
Expand Down

0 comments on commit e5d9420

Please sign in to comment.