scc.cpp
Go to the documentation of this file.
1 #include <hrpModel/Link.h>
2 #include "scc.h"
3 
4 using namespace hrp;
5 
7 {
8  for (unsigned int i=0; i<m_robot->numLinks(); i++){
9  Link *link1 = m_robot->link(i);
10  for (unsigned int j=i+1; j<m_robot->numLinks(); j++){
11  Link *link2 = m_robot->link(j);
12  if (link1->parent != link2 && link2->parent != link1){
13  bool skip = false;
14  for (unsigned int k=0; k<pairs.size(); k++){
15  if ((pairs[k].first == link1->name
16  && pairs[k].second == link2->name)
17  ||(pairs[k].first == link2->name
18  && pairs[k].second == link1->name)){
19  skip = true;
20  break;
21  }
22  }
23  if (!skip){
24  m_checkPairs.push_back(ColdetModelPair(link1->coldetModel,
25  link2->coldetModel));
26  }
27  }
28  }
29  }
30 }
31 
32 
34 {
35  LinkNamePairList pairs;
36 
37  for (unsigned int i=0; i<m_robot->numJoints(); i++){
38  m_robot->joint(i)->q = q[i];
39  }
40  m_robot->calcForwardKinematics();
41  for (unsigned int i=0; i<m_robot->numLinks(); i++){
42  Link *l = m_robot->link(i);
43  l->coldetModel->setPosition(l->attitude(), l->p);
44  }
45  for (unsigned int i=0; i<m_checkPairs.size(); i++){
46  if (m_checkPairs[i].checkCollision()){
47  pairs.push_back(std::make_pair(m_checkPairs[i].model(0)->name(),
48  m_checkPairs[i].model(1)->name()));
49  }
50  }
51  return pairs;
52 }
SelfCollisionChecker(hrp::BodyPtr body, const LinkNamePairList &pairs=LinkNamePairList())
Definition: scc.cpp:6
png_infop png_charpp name
png_uint_32 i
std::vector< hrp::ColdetModelPair > m_checkPairs
Definition: scc.h:17
def j(str, encoding="cp932")
LinkNamePairList check(const double *q)
Definition: scc.cpp:33
std::vector< std::pair< std::string, std::string > > LinkNamePairList
Definition: scc.h:6
hrp::BodyPtr m_robot
Definition: scc.h:16
hrp::BodyPtr m_robot


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Thu May 6 2021 02:41:51