ft_sensor_interface.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 # FSRobo-R Package BSDL
5 # ---------
6 # Copyright (C) 2019 FUJISOFT. All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without modification,
9 # are permitted provided that the following conditions are met:
10 # 1. Redistributions of source code must retain the above copyright notice,
11 # this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright notice,
13 # this list of conditions and the following disclaimer in the documentation and/or
14 # other materials provided with the distribution.
15 # 3. Neither the name of the copyright holder nor the names of its contributors
16 # may be used to endorse or promote products derived from this software without
17 # specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 # --------
30 
31 import rospy
32 from fsrobo_r_msgs.srv import SetStopForce, GetWrench
33 from std_srvs.srv import Empty, Trigger
34 
36 
37  def __init__(self, robot_name=None):
38  if robot_name == '':
39  self.ns = '/'
40  elif robot_name:
41  self.ns = '/' + robot_name + '/'
42  else:
43  self.ns = ''
44  self._set_stop_force = rospy.ServiceProxy(self.ns + 'set_stop_force', SetStopForce)
45  self._clear_stop_force = rospy.ServiceProxy(self.ns + 'clear_stop_force', Empty)
46  self._get_current_force = rospy.ServiceProxy(self.ns + 'get_current_force', GetWrench)
47  self._is_stopped = rospy.ServiceProxy(self.ns + 'is_stopped', Trigger)
48 
49  def set_stop_force(self, axis, val):
50  rospy.wait_for_service(self.ns + 'set_stop_force', timeout=3)
51  self._set_stop_force(axis, val)
52 
53  def clear_stop_force(self):
54  rospy.wait_for_service(self.ns + 'clear_stop_force', timeout=3)
55  self._clear_stop_force()
56 
57  def get_current_force(self):
58  rospy.wait_for_service(self.ns + 'get_current_force', timeout=3)
59  return self._get_current_force()
60 
61  def is_stopped(self):
62  rospy.wait_for_service(self.ns + 'is_stopped', timeout=3)
63  res = self._is_stopped()
64  return res.success
65 
66 if __name__ == '__main__':
68  ft.clear_stop_force()
69  ft.set_stop_force('z', -3)
70  print(ft.is_stopped())


fsrobo_r_driver
Author(s): F-ROSROBO
autogenerated on Sun Feb 9 2020 03:58:29