my_robot_hw_4.cpp
Go to the documentation of this file.
1 // Copyright (C) 2015, Shadow Robot Company Ltd.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name of Shadow Robot Company Ltd. nor the names of its
12 // contributors may be used to endorse or promote products derived from
13 // this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 // POSSIBILITY OF SUCH DAMAGE.
27 
28 
30 
32 {
33 
35 {
36 }
37 
38 bool MyRobotHW4::init(ros::NodeHandle& root_nh, ros::NodeHandle &robot_hw_nh)
39 {
40  using namespace hardware_interface;
41 
42  force_[0] = 0.0;
43  force_[1] = 0.1;
44  force_[2] = 0.2;
45  torque_[0] = 0.0;
46  torque_[1] = 0.1;
47  torque_[2] = 0.2;
48  sensor_name_ = "ft_sensor_1";
49  frame_id_ = "link_1";
50 
52 
55 
56  return true;
57 }
58 
59 
60 void MyRobotHW4::read(const ros::Time& time, const ros::Duration& period)
61 {
62  force_[2] = 1.2;
63 }
64 
65 void MyRobotHW4::write(const ros::Time& time, const ros::Duration& period)
66 {
67 }
68 
69 bool MyRobotHW4::prepareSwitch(const std::list<hardware_interface::ControllerInfo>& start_list,
70  const std::list<hardware_interface::ControllerInfo>& stop_list)
71 {
72  // To easily test a failure case, any controller that claims resources on MyRobotHW4 will fail
73  if (!start_list.empty() || !stop_list.empty())
74  {
75  for (std::list<hardware_interface::ControllerInfo>::const_iterator it = start_list.begin(); it != start_list.end(); ++it)
76  {
77  if (it->claimed_resources.empty())
78  {
79  continue;
80  }
81  else
82  {
83  return false;
84  }
85  }
86  }
87  return true;
88 }
89 
90 void MyRobotHW4::doSwitch(const std::list<hardware_interface::ControllerInfo>& start_list,
91  const std::list<hardware_interface::ControllerInfo>& stop_list)
92 {
93  // To easily test a failure case, any controller that claims resources on MyRobotHW4 will fail
94  if (!start_list.empty() || !stop_list.empty())
95  {
96  for (std::list<hardware_interface::ControllerInfo>::const_iterator it = start_list.begin(); it != start_list.end(); ++it)
97  {
98  if (it->claimed_resources.empty())
99  {
100  continue;
101  }
102  else
103  {
104  throw hardware_interface::HardwareInterfaceException("MyRobotHW4 can't switch controllers");
105  }
106  }
107  }
108 }
109 
110 }
111 
113 
void write(const ros::Time &time, const ros::Duration &period)
virtual bool init(ros::NodeHandle &root_nh, ros::NodeHandle &robot_hw_nh)
void registerHandle(const ForceTorqueSensorHandle &handle)
hardware_interface::ForceTorqueSensorInterface ft_sensor_interface_
Definition: my_robot_hw_4.h:56
virtual void doSwitch(const std::list< hardware_interface::ControllerInfo > &start_list, const std::list< hardware_interface::ControllerInfo > &stop_list)
void read(const ros::Time &time, const ros::Duration &period)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
hardware_interface::HardwareInterface a_plain_hw_interface_
Definition: my_robot_hw_4.h:57
virtual bool prepareSwitch(const std::list< hardware_interface::ControllerInfo > &start_list, const std::list< hardware_interface::ControllerInfo > &stop_list)


combined_robot_hw_tests
Author(s): Toni Oliver
autogenerated on Mon Apr 20 2020 03:52:11