Home | Tutorials | Wiki | Issues
Ask Your Question
0

why the contact sensor's time data repeat?

asked 2013-04-01 14:53:39 -0600

lugd1229 gravatar image

updated 2013-04-01 15:21:08 -0600

Hi, I use a model plugin to measure the contact force and torque data,I find the time of result repeat to appear, not continue? such as: in the first step, there are 75 groups data, the time from 0 sec 893000000 nsec to 0 sec 991000000 nsec, then, the 2nd group data's time from sec 893000000 nsec to 0 sec 989000000 nsec, like this, the other group data's time are not over 1 sec.I had used class ContactPlugin : public SensorPlugin to measure force data before, the time will continue from 0 second same with the simulation time.but in the new plugin, it appear some question, and my code is same with the previous one. the present code:

for (unsigned int i = 0; i < contacts.contact_size(); ++i)
 //for (unsigned int i = 0; i < 2; ++i)
  {
    math::Vector3 fTotal;
    math::Vector3 tTotal;
    for (unsigned int j = 0; j < contacts.contact(i).position_size(); ++j)
    {
      std::cout << j << "  Position:"
                << contacts.contact(i).position(j).x() << " "
                << contacts.contact(i).position(j).y() << " "
                << contacts.contact(i).position(j).z() << "\n";
      fTotal += math::Vector3(
                            contacts.contact(i).wrench(j).body_1_force().x(),
                            contacts.contact(i).wrench(j).body_1_force().y(),
                            contacts.contact(i).wrench(j).body_1_force().z());
      tTotal += math::Vector3(
                            contacts.contact(i).wrench(j).body_1_torque().x(),
                            contacts.contact(i).wrench(j).body_1_torque().y(),
                            contacts.contact(i).wrench(j).body_1_torque().z());
     }
    double e = 0.99;
    this->llink3_Force = this->llink3_Force * e + fTotal * (1.0 - e);
    this->llink3_Torque = this->llink3_Torque * e + tTotal * (1.0 - e);
    std::cout << " force:"
                       << llink3_Force.x<< " "
                       << llink3_Force.y<< " "
                       << llink3_Force.z<< "\n";
    std::cout << " torque:"
                           << llink3_Torque.x<< " "
                           << llink3_Torque.y<< " "
                           << llink3_Torque.z<< "\n";
    std::cout << " time:"
                          << contacts.contact(i).time().sec()<< " " 
                            <<contacts.contact(i).time().nsec() << "\n";


      }
    }

and I have some doubt about the data, contacts.contactsize() mean the my 75 groups data appear by time? and the contacts.contact(i).positionsize() mean the data appear on different points at same time, so we need add to total? and why use the filter to deal with the data? and the result data as follow:

1 0 893000000 0.0109663 -0.791412 -0.00165563 -0.0366801 -0.000493521 0.00133756  0
2 0 894000000 0.0108009 -1.42664 -0.00182591 -0.0659666 -0.000487837 0.00553323  1
3 0 896000000 0.0107928 -2.62509 -0.00316602 -0.119727 -0.000497939 0.00192567  2
4 0 898000000 0.00970284 -4.42211 -0.00313644 -0.202304 -0.000447923 0.0111408  3
5 0 899000000 0.0103159 -5.02395 -0.00379704 -0.229934 -0.000479064 0.0208921  4
6 0 900000000 0.0112077 -5.93773 -0.00314213 -0.271913 -0.000515583 0.0249442  5
7 0 901000000 0.0152044 -6.52051 -0.00305047 -0.298895 -0.00069924 0.0340604  6
8 0 902000000 0.0341503 -7.04148 -0.00146708 -0.322952 -0.001561 0.04069  7
9 0 904000000 0.0344036 -8.34504 -0.00396462 -0.382565 -0.00159579 0.0507071  8
10 0 906000000 0.0332201 -9.75006 -0.00566672 -0.447299 -0.00156165 0 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-04-10 19:17:15 -0600

nkoenig gravatar image

We don't explicitly clear out all the contacts in the message in order to improve performance. The current time stamp is attached to the message. You can use this time stamp to find the contacts are current.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-01 14:53:39 -0600

Seen: 149 times

Last updated: Apr 10 '13