2 #include "hrpsys/util/BodyRTC.h" 5 : log(i_log), adjustTime(false)
12 std::cout <<
"number of receivers:" <<
receivers.size() << std::endl;
19 for(
size_t colIndex=0; colIndex <
pairs.size(); ++colIndex){
23 OpenHRP::LinkPair& pair =
collisions[colIndex].pair;
24 pair.charName1 = CORBA::string_dup(link0->
body->
name().c_str());
25 pair.charName2 = CORBA::string_dup(link1->
body->
name().c_str());
26 pair.linkName1 = CORBA::string_dup(link0->
name.c_str());
27 pair.linkName2 = CORBA::string_dup(link1->
name.c_str());
51 body(
i)->updateLinkColdetModelPositions();
53 for(
size_t colIndex=0; colIndex <
pairs.size(); ++colIndex){
55 OpenHRP::Collision& collision = collisions[colIndex];
56 OpenHRP::CollisionPointSequence* pCollisionPoints = &collision.points;
57 std::vector<hrp::collision_data>& cdata = linkPair->detectCollisions();
60 pCollisionPoints->length(0);
63 for(
unsigned int i = 0;
i < cdata.size();
i++) {
64 for(
int j = 0;
j < cdata[
i].num_of_i_points;
j++){
65 if(cdata[
i].i_point_new[
j]) npoints++;
68 pCollisionPoints->length(npoints);
70 for (
unsigned int i = 0;
i < cdata.size();
i++) {
74 OpenHRP::CollisionPoint& point = (*pCollisionPoints)[idx];
75 for(
int k=0; k < 3; k++){
78 for(
int k=0; k < 3; k++){
81 point.idepth = cd.
depth;
102 const struct timeval& first =
startTimes.front();
103 const struct timeval& last =
startTimes.back();
104 int realT = (last.tv_sec - first.tv_sec)*1e6
105 + (last.tv_usec - first.tv_usec);
107 int usec = simT - realT;
143 body(
i)->calcForwardKinematics();
158 struct timeval endTime;
160 double realT = (endTime.tv_sec -
beginTime.tv_sec)
161 + (endTime.tv_usec -
beginTime.tv_usec)/1e6;
162 printf(
"total :%8.3f[s], %8.3f[sim/real]\n",
164 printf(
"controller:%8.3f[s], %8.3f[ms/frame]\n",
166 printf(
"collision :%8.3f[s], %8.3f[ms/frame]\n",
168 printf(
"dynamics :%8.3f[s], %8.3f[ms/frame]\n",
173 for (
unsigned int j=0;
j<body->numLinks();
j++){
179 printf(
"num of triangles : %s : %d\n", body->name().c_str(), ntri);
208 std::vector<hrp::Link*> links1;
210 links1.resize(traverse1.
numLinks());
211 std::copy(traverse1.
begin(), traverse1.
end(), links1.begin());
213 std::vector<hrp::Link*> links2;
215 links2.resize(traverse2.
numLinks());
216 std::copy(traverse2.
begin(), traverse2.
end(), links2.begin());
218 for(
size_t j=0;
j < links1.size(); ++
j){
219 for(
size_t k=0; k < links2.size(); ++k){
223 if(link1 && link2 && link1 != link2){
225 (bodyIndex1, link1, bodyIndex2, link2,
226 0.5, 0.5, 0.01, 0.0, 0.0);
233 for(
size_t colIndex=0; colIndex <
pairs.size(); ++colIndex){
237 OpenHRP::LinkPair& pair =
collisions[colIndex].pair;
238 pair.charName1 = CORBA::string_dup(link0->
body->
name().c_str());
239 pair.charName2 = CORBA::string_dup(link1->
body->
name().c_str());
240 pair.linkName1 = CORBA::string_dup(link0->
name.c_str());
241 pair.linkName2 = CORBA::string_dup(link1->
name.c_str());
void set(hrp::WorldBase &i_world, OpenHRP::CollisionSequence &i_collisions)
int bodyIndex(const std::string &name)
double timeStep(void) const
virtual void calcNextState()
std::vector< Link * >::const_iterator end() const
void clearCollisionCheckLinkPairs()
ColdetModelPtr coldetModel
void setCurrentTime(double tm)
Simulator(RTC::Manager *manager)
Constructor.
std::vector< Link * >::const_iterator begin() const
static Manager & instance()
std::vector< ClockReceiver > receivers
void kinematicsOnly(bool flag)
int gettimeofday(struct timeval *tv, struct timezone *tz)
unsigned int numLinks() const
const LinkTraverse & linkTraverse() const
def j(str, encoding="cp932")
const std::string & name()
OpenHRP::CollisionSequence collisions
void writeDataPorts(double time)
double averageTime() const
virtual ReturnCode_t exit()
std::vector< hrp::ColdetLinkPairPtr > pairs
bool addCollisionCheckLinkPair(int bodyIndex1, Link *link1, int bodyIndex2, Link *link2, double muStatic, double muDynamic, double culling_thresh, double restitution, double epsilon)
void initRTS(Project &prj, std::vector< ClockReceiver > &receivers)
hrp::ConstraintForceSolver constraintForceSolver
void clearExternalForces()
void addCollisionCheckPair(BodyRTC *b1, BodyRTC *b2)
LogManager< SceneState > * log
std::deque< struct timeval > startTimes
double currentTime(void) const
boost::intrusive_ptr< ColdetLinkPair > ColdetLinkPairPtr
boost::function2< hrp::BodyPtr, const std::string &, const ModelItem & > BodyFactory
void initWorld(Project &prj, BodyFactory &factory, hrp::World< hrp::ConstraintForceSolver > &world, std::vector< hrp::ColdetLinkPairPtr > &pairs)
int usleep(useconds_t usec)