sr_real_tactile_sensor.cpp
Go to the documentation of this file.
1 /*
2 * Copyright 2011 Shadow Robot Company Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 
29 
30 #include <string>
31 #include <vector>
32 
33 namespace shadowrobot
34 {
35 /**********************************
36  * TACTILE SENSOR *
37  **********************************/
39  std::string touch_name) :
40  SrGenericTactileSensor(name, touch_name)
41  {
42  /* We need to attach the program to the robot, or fail if we cannot. */
43  if (robot_init() < 0)
44  {
45  ROS_FATAL("Robot interface broken\n");
46  ROS_BREAK();
47  }
48 
49  res_touch = robot_name_to_sensor(touch_name.c_str(), &sensor_touch);
50 
51  if (res_touch)
52  {
53  ROS_ERROR("Can't open sensor %s", touch_name.c_str());
54  }
55  }
56 
58  {
59  }
60 
62  {
63  if (res_touch)
64  {
65  return -1000.0;
66  }
67 
68  return robot_read_sensor(&sensor_touch);
69  }
70 
71 
72 /**********************************
73  * TACTILE SENSOR MANAGER *
74  **********************************/
77  {
78  std::vector <std::vector<std::string>> all_names = get_all_names();
79 
80  for (unsigned int i = 0; i < all_names[0].size(); ++i)
81  {
82  tactile_sensors.push_back(
84  new SrRealTactileSensor(all_names[0][i],
85  all_names[1][i])));
86  }
87  }
88 
90  {
91  }
92 } // namespace shadowrobot
93 
94 
105 int main(int argc, char **argv)
106 {
107  ros::init(argc, argv, "sr_tactile_sensor");
108  ros::NodeHandle n;
109 
111 
112  while (ros::ok())
113  {
114  tact_sens_mgr.publish_all();
115  }
116 
117  return 0;
118 }
119 
120 /* For the emacs weenies in the crowd.
121 Local Variables:
122  c-basic-offset: 2
123 End:
124 */
#define ROS_FATAL(...)
This is the virtual implementation of the SrGenericTactileSensor. It computes virtual data...
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::vector< boost::shared_ptr< SrGenericTactileSensor > > tactile_sensors
ROSCPP_DECL bool ok()
int main(int argc, char **argv)
#define ROS_BREAK()
#define ROS_ERROR(...)
std::vector< std::vector< std::string > > get_all_names()
SrRealTactileSensor(std::string name, std::string touch_name)


sr_tactile_sensors
Author(s): Ugo Cupcic
autogenerated on Mon Feb 28 2022 23:52:14