sr_biotac_tactile_sensor_publisher.cpp
Go to the documentation of this file.
1 
23 
27 
28 
29 namespace controller
30 {
32 {
33  // initialize time
34  last_publish_time_ = time;
35 
36  // realtime publisher
39  biotac_realtime_pub_->lock();
40  for (unsigned i = 0; i < sensors_->size(); i++)
41  {
42  biotac_realtime_pub_->msg_.tactiles[i].electrodes.resize(sensors_->at(i).biotac.electrodes.size());
43  biotac_realtime_pub_->msg_.tactiles[i].pac.reserve(270);
44  }
45  biotac_realtime_pub_->unlock();
46 }
47 
49 {
50  bool biotac_published = false;
51  // limit rate of publishing
52  if (publish_rate_ > 0.0 && last_publish_time_ + ros::Duration(1.0 / publish_rate_) < time)
53  {
54  // try to publish
55  if (biotac_realtime_pub_->trylock())
56  {
57  // we're actually publishing, so increment time
59  biotac_published = true;
60  // populate message
61  biotac_realtime_pub_->msg_.header.stamp = time;
62  biotac_realtime_pub_->msg_.header.frame_id = prefix_+"distal";
63  // data
64  for (unsigned i = 0; i < sensors_->size(); i++)
65  {
66  biotac_realtime_pub_->msg_.tactiles[i].pac0 = sensors_->at(i).biotac.pac0;
67  biotac_realtime_pub_->msg_.tactiles[i].pac1 = sensors_->at(i).biotac.pac1;
68  biotac_realtime_pub_->msg_.tactiles[i].pdc = sensors_->at(i).biotac.pdc;
69  biotac_realtime_pub_->msg_.tactiles[i].tac = sensors_->at(i).biotac.tac;
70  biotac_realtime_pub_->msg_.tactiles[i].tdc = sensors_->at(i).biotac.tdc;
71  biotac_realtime_pub_->msg_.tactiles[i].electrodes = sensors_->at(i).biotac.electrodes;
72  biotac_realtime_pub_->msg_.tactiles[i].pac = sensors_->at(i).biotac.consume_pac();
73  }
74  biotac_realtime_pub_->unlockAndPublish();
75  }
76  }
77 }
78 } // end namespace controller
79 
80 /* For the emacs weenies in the crowd.
81 Local Variables:
82  c-basic-offset: 2
83 End:
84 */
Publishes Biotac tactile state.
virtual void update(const ros::Time &time, const ros::Duration &period)
std::vector< tactiles::AllTactileData > * sensors_
derived from ImuSensorController author: Adolfo Rodriguez Tsouroukdissian


sr_tactile_sensor_controller
Author(s): Guillaume Walck
autogenerated on Tue Oct 13 2020 04:02:07