sr_ubi_tactile_sensor_publisher.cpp
Go to the documentation of this file.
1 
24 
28 
29 namespace controller
30 {
32 {
33  // initialize time
34  last_publish_time_ = time;
35 
36  // realtime publisher
38  nh_prefix_, "tactile", 4));
40  nh_prefix_, "tactile_mid_prox", 4));
41 }
42 
44 {
45  bool ubi_published = false;
46  // limit rate of publishing
47  if (publish_rate_ > 0.0 && last_publish_time_ + ros::Duration(1.0 / publish_rate_) < time)
48  {
49  // try to publish
50  if (ubi_realtime_pub_->trylock())
51  {
52  // we're actually publishing, so increment time
54  ubi_published = true;
55  // populate message
56  ubi_realtime_pub_->msg_.header.stamp = time;
57  ubi_realtime_pub_->msg_.header.frame_id = prefix_ + "distal";
58  // data
59  for (unsigned i = 0; i < sensors_->size(); i++)
60  {
61  sr_robot_msgs::UBI0 tactile_tmp;
62 
63  tactile_tmp.distal = sensors_->at(i).ubi0.distal;
64  ubi_realtime_pub_->msg_.tactiles[i] = tactile_tmp;
65  }
66  ubi_realtime_pub_->unlockAndPublish();
67  }
68 
69  // try to publish
70  if (midprox_realtime_pub_->trylock())
71  {
72  // we're actually publishing, so increment time
73  if (!ubi_published)
74  {
76  }
77  // populate message
78  midprox_realtime_pub_->msg_.header.stamp = time;
79  midprox_realtime_pub_->msg_.header.frame_id = prefix_ + "proximal";
80  // data
81  for (unsigned i = 0; i < sensors_->size(); i++)
82  {
83  sr_robot_msgs::MidProxData midprox_tmp;
84 
85  midprox_tmp.middle = sensors_->at(i).ubi0.middle;
86  midprox_tmp.proximal = sensors_->at(i).ubi0.proximal;
87  midprox_realtime_pub_->msg_.sensors[i] = midprox_tmp;
88  }
89  midprox_realtime_pub_->unlockAndPublish();
90  }
91  }
92 }
93 } // namespace controller
94 
95 /* For the emacs weenies in the crowd.
96 Local Variables:
97  c-basic-offset: 2
98 End:
99 */
virtual void update(const ros::Time &time, const ros::Duration &period)
boost::shared_ptr< MidProxPublisher > MidProxPublisherPtr
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