Home | Tutorials | Wiki | Issues
Ask Your Question
0

and how to control the data update_rate?

asked 2013-04-01 15:11:58 -0500

lugd1229 gravatar image

updated 2013-04-01 15:24:21 -0500

Hi, when I set the parameter of contact sensor, the updaterate is 1, it mean the sensor should updata it's data in 1 second, but when I run the model and plugin, the data would update faster than the setting in showing terminal,I need the updaterate is 1 second.so the data can be shown in figure. the code:

<sensor name="l_finger3_contact_sensor" type="contact">
      <update_rate>1</update_rate>
      <always_on>1</always_on>
      <visualize>1</visualize>
         <pose>0.10 0 .55 3.1400 0.000000 0.000000</pose>
      <contact>
        <collision>test_collision3</collision>
        <topic>/test_collision3_contact</topic>
      </contact>
    </sensor>

and the plugin:

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";


      }
    }

the result data is as follows:

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.0639809  9
11 0 908000000 0.0465141 -11.1582 -0.00643337 -0.510355 -0.00216282 0.0700995  10
12 0 909000000 0.0465168 -11.8857 -0.00632329 -0.54403 -0.00216257 0.0702505  11
13 0 911000000 0.0466223 -12.9884 -0.0023091 -0.594378 -0.00212853 0.0887632  12
14 0 912000000 0.046328 -13.6845 -0.00519224 -0.626684 -0.00213635 0.0814887  13
15 0 913000000 0.0457015 -14.5768 -0 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
-1

answered 2013-04-01 15:15:15 -0500

AndreiHaidu gravatar image

updated 2013-04-01 15:23:12 -0500

Take a look at this answer. Cheers

edit flag offensive delete link more

Comments

wrong link, my bad

AndreiHaidu gravatar imageAndreiHaidu ( 2013-04-01 15:23:46 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-01 15:11:58 -0500

Seen: 98 times

Last updated: Apr 01 '13