Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add print message for non adjacent links #1460

Open
wants to merge 5 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE )

# Define here the needed parameters
set (OPENRAVE_VERSION_MAJOR 0)
set (OPENRAVE_VERSION_MINOR 156)
set (OPENRAVE_VERSION_PATCH 1)
set (OPENRAVE_VERSION_MINOR 157)
set (OPENRAVE_VERSION_PATCH 0)
set (OPENRAVE_VERSION ${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR}.${OPENRAVE_VERSION_PATCH})
set (OPENRAVE_SOVERSION ${OPENRAVE_VERSION_MAJOR}.${OPENRAVE_VERSION_MINOR})
message(STATUS "Compiling OpenRAVE Version ${OPENRAVE_VERSION}, soversion=${OPENRAVE_SOVERSION}")
Expand Down
5 changes: 5 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
ChangeLog
#########

Version 0.157.0
===============

- Add print message related to non adjacent links to track the self collision issue.

Version 0.156.1
===============

Expand Down
6 changes: 6 additions & 0 deletions include/openrave/kinbody.h
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,12 @@ class OPENRAVE_API KinBody : public InterfaceBase
/// Ensures that _vAllPairsShortestPaths is initialized if it is not already
void _EnsureAllPairsShortestPaths() const;

/// \brief print the computed _vNonAdjacentLinks contents.
/// \param[in] vNonAdjacentLinks : from KinBody::_vNonAdjacentLinks
/// \param[in] nonAdjacentMask : index of element to print, which is mask. _vNonAdjacentLinks[nonAdjacentMask] is printed.
/// \param[in] envNameId, bodyName : for print message.
static void _PrintNonAdjacentLinks(const boost::array<std::vector<int>, 4>& vNonAdjacentLinks, const size_t nonAdjacentMask, const std::string& envNameId, const std::string& bodyName);

std::string _name; ///< name of body

std::vector<JointPtr> _vecjoints; ///< \see GetJoints
Expand Down
33 changes: 33 additions & 0 deletions src/libopenrave/kinbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ inline void _ResizeVectorFor2DTable(std::vector<int8_t>& vec, size_t vectorSize)
}
}

static void _PrintDOFValuesForInitialLinkTransformations(const KinBody& body, const std::vector<dReal>& vdoflastsetvalues, const char* context)
{
if( body.GetDOF() == 0 ) {
return;
}
std::stringstream ssJoints;
for(size_t iDOF = 0; iDOF < vdoflastsetvalues.size(); ++iDOF) {
if( iDOF > 0 ) {
ssJoints << ",";
}
ssJoints << vdoflastsetvalues[iDOF];
}
RAVELOG_INFO_FORMAT("env='%s', body '%s' _vInitialLinkTransformations is updated in %s by dofValues=[%s]", body.GetEnv()->GetNameId()%body.GetName()%context%ssJoints.str());
snozawa marked this conversation as resolved.
Show resolved Hide resolved
}

class ChangeCallbackData : public UserData
{
public:
Expand Down Expand Up @@ -5111,6 +5126,7 @@ void KinBody::_ComputeInternalInformation()
RAVELOG_VERBOSE(str(boost::format("dof %d has different values after SetDOFValues %d!=%d, this could be due to mimic joint equations kicking into effect.")%i%vprevdoflastsetvalues.at(i)%vnewdoflastsetvalues.at(i)));
}
}
_PrintDOFValuesForInitialLinkTransformations(*this, vnewdoflastsetvalues, __FUNCTION__);
_vInitialLinkTransformations = vnewtrans;
}

Expand Down Expand Up @@ -5568,6 +5584,7 @@ void KinBody::SetNonCollidingConfiguration()
_ResetInternalCollisionCache();
vector<dReal> vdoflastsetvalues;
GetLinkTransformations(_vInitialLinkTransformations, vdoflastsetvalues);
_PrintDOFValuesForInitialLinkTransformations(*this, vdoflastsetvalues, __FUNCTION__);
}

void KinBody::_ResetInternalCollisionCache()
Expand Down Expand Up @@ -5598,6 +5615,20 @@ bool CompareNonAdjacentFarthest(int pair0, int pair1)
return dist0 > dist1;
}

void KinBody::_PrintNonAdjacentLinks(const boost::array<std::vector<int>, 4>& vNonAdjacentLinks, const size_t nonAdjacentMask, const std::string& envNameId, const std::string& bodyName)
{
std::stringstream ssLinks;
const std::vector<int>& vSelectedNonAdjacentLinks = vNonAdjacentLinks[nonAdjacentMask];
for(size_t iLinks = 0; iLinks < vSelectedNonAdjacentLinks.size(); ++iLinks) {
const int value = vSelectedNonAdjacentLinks[iLinks];
if( iLinks > 0 ) {
ssLinks << ",";
}
ssLinks << "(" << (value & 0xffff) << "," << (value>>16) << ")";
}
RAVELOG_INFO_FORMAT("env='%s', body '%s' computes the cache for GetNonAdjacentLinks(%d). linkPairs=[%s]", envNameId%bodyName%nonAdjacentMask%ssLinks.str());
}

const std::vector<int>& KinBody::GetNonAdjacentLinks(int adjacentoptions) const
{
class TransformsSaver
Expand Down Expand Up @@ -5646,6 +5677,7 @@ const std::vector<int>& KinBody::GetNonAdjacentLinks(int adjacentoptions) const
std::sort(_vNonAdjacentLinks[0].begin(), _vNonAdjacentLinks[0].end(), CompareNonAdjacentFarthest);
_nUpdateStampId++; // because transforms were modified
_nNonAdjacentLinkCache = 0;
KinBody::_PrintNonAdjacentLinks(_vNonAdjacentLinks, 0, GetEnv()->GetNameId(), GetName());
}
if( (_nNonAdjacentLinkCache&adjacentoptions) != adjacentoptions ) {
int requestedoptions = (~_nNonAdjacentLinkCache)&adjacentoptions;
Expand All @@ -5660,6 +5692,7 @@ const std::vector<int>& KinBody::GetNonAdjacentLinks(int adjacentoptions) const
}
_nNonAdjacentLinkCache |= AO_Enabled;
std::sort(_vNonAdjacentLinks[AO_Enabled].begin(), _vNonAdjacentLinks[AO_Enabled].end(), CompareNonAdjacentFarthest);
KinBody::_PrintNonAdjacentLinks(_vNonAdjacentLinks, AO_Enabled, GetEnv()->GetNameId(), GetName());
}
else {
throw OPENRAVE_EXCEPTION_FORMAT(_("no support for adjacentoptions %d"), adjacentoptions,ORE_InvalidArguments);
Expand Down
3 changes: 3 additions & 0 deletions src/libopenrave/robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,7 @@ const std::vector<int>& RobotBase::GetNonAdjacentLinks(int adjacentoptions) cons
}
}
std::sort(_vNonAdjacentLinks[AO_Enabled].begin(), _vNonAdjacentLinks[AO_Enabled].end(), CompareNonAdjacentFarthest);
KinBody::_PrintNonAdjacentLinks(_vNonAdjacentLinks, AO_Enabled, GetEnv()->GetNameId(), GetName());
}
if( compute.at(AO_ActiveDOFs) ) {
_vNonAdjacentLinks.at(AO_ActiveDOFs).resize(0);
Expand All @@ -2103,6 +2104,7 @@ const std::vector<int>& RobotBase::GetNonAdjacentLinks(int adjacentoptions) cons
}
}
std::sort(_vNonAdjacentLinks[AO_ActiveDOFs].begin(), _vNonAdjacentLinks[AO_ActiveDOFs].end(), CompareNonAdjacentFarthest);
KinBody::_PrintNonAdjacentLinks(_vNonAdjacentLinks, AO_ActiveDOFs, GetEnv()->GetNameId(), GetName());
}
if( compute.at(AO_Enabled|AO_ActiveDOFs) ) {
_vNonAdjacentLinks.at(AO_Enabled|AO_ActiveDOFs).resize(0);
Expand All @@ -2113,6 +2115,7 @@ const std::vector<int>& RobotBase::GetNonAdjacentLinks(int adjacentoptions) cons
}
}
std::sort(_vNonAdjacentLinks[AO_Enabled|AO_ActiveDOFs].begin(), _vNonAdjacentLinks[AO_Enabled|AO_ActiveDOFs].end(), CompareNonAdjacentFarthest);
KinBody::_PrintNonAdjacentLinks(_vNonAdjacentLinks, AO_Enabled|AO_ActiveDOFs, GetEnv()->GetNameId(), GetName());
}
_nNonAdjacentLinkCache |= requestedoptions;
}
Expand Down
Loading