test_biotac_collada_name.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright 2019 Shadow Robot Company Ltd.
4 #
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation version 2 of the License.
8 #
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 # more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 import sys
18 import os
19 from xml.dom.minidom import parse
20 from urdf_parser_py.urdf import URDF
21 import xacro
22 import rospkg
23 
24 from unittest import TestCase
25 #
26 PKG = "sr_multi_moveit_config"
27 
28 
29 class TestBiotacColladaName(TestCase):
30 
31  """
32  Test class for checking that the collada name "biotac_decimated.dae" of the urdf of the
33  biotac hands has not been changed so they can be identified
34  """
35 
36  def setUp(self):
37  self.rospack = rospkg.RosPack()
38 
39  def check_name(self, hand_urdf_path):
40  with open(hand_urdf_path, 'r') as hand_urdf_xacro_file:
41  hand_urdf_xml = parse(hand_urdf_xacro_file)
42  xacro.process_includes(hand_urdf_xml, os.path.dirname(sys.argv[0]))
43  macros = {}
44  xacro.grab_macros(hand_urdf_xml, macros)
45  symbols = xacro.Table()
46  xacro.grab_properties(hand_urdf_xml, symbols)
47  xacro.eval_all(hand_urdf_xml.documentElement, macros, symbols)
48 
49  hand_urdf = hand_urdf_xml.toprettyxml(indent=' ')
50  robot = URDF.from_xml_string(hand_urdf)
51 
52  is_biotac = False
53  # Check if hand has the old biotac sensors
54  for key in robot.link_map:
55  link = robot.link_map[key]
56  if link.visual:
57  if hasattr(link.visual.geometry, 'filename'):
58  filename = os.path.basename(link.visual.geometry.filename)
59  if filename == "biotac_decimated.dae":
60  is_biotac = True
61  break
62  return is_biotac
63 
64  def test_motor_hand(self):
65  hand_urdf_path = self.rospack.get_path('sr_description')+"/robots/" + "shadowhand_motor.urdf.xacro"
66  is_biotac = self.check_name(hand_urdf_path)
67  self.assertFalse(is_biotac, msg="Wrong biotac hand")
68 
70  hand_urdf_path = self.rospack.get_path('sr_description')+"/robots/" + "shadowhand_motor_biotac.urdf.xacro"
71  is_biotac = self.check_name(hand_urdf_path)
72  self.assertTrue(is_biotac, msg="No file name is called biotac_decimated.dae")
73 
75  hand_urdf_path = self.rospack.get_path('sr_description')+"/robots/" + "shadowhand_motor_ff_biotac.urdf.xacro"
76  is_biotac = self.check_name(hand_urdf_path)
77  self.assertTrue(is_biotac, msg="No file name is called biotac_decimated.dae")
78 
80  hand_urdf_path = self.rospack.get_path('sr_description')+"/robots/" + "shadowhand_muscle_biotac.urdf.xacro"
81  is_biotac = self.check_name(hand_urdf_path)
82  self.assertTrue(is_biotac, msg="No file name is called biotac_decimated.dae")
83 
84 if __name__ == "__main__":
85  import rostest
86  rostest.rosrun(PKG, "test_biotac_collada_name", TestBiotacColladaName)
def process_includes(elt, macros=None, symbols=None)
def grab_properties(elt, table)
def grab_macros(elt, macros)
def eval_all(node, macros, symbols)


sr_multi_moveit_test
Author(s): Beatriz Leon
autogenerated on Wed Oct 14 2020 04:05:26