@@ -71,55 +71,55 @@ def get_joint_limits(node, joints_names, use_smallest_joint_limits=True):
7171 continue
7272 name = child .getAttribute ("name" )
7373
74- if name in joints_names :
74+ try :
75+ limit = child .getElementsByTagName ("limit" )[0 ]
7576 try :
76- limit = child .getElementsByTagName ("limit" )[0 ]
77- try :
78- minval = float (limit .getAttribute ("lower" ))
79- maxval = float (limit .getAttribute ("upper" ))
80- except ValueError :
81- if jtype == "continuous" :
82- minval = - pi
83- maxval = pi
84- else :
85- raise Exception (
86- f"Missing lower/upper position limits for the joint : { name } of type : { jtype } in the robot_description!"
87- )
88- try :
89- maxvel = float (limit .getAttribute ("velocity" ))
90- except ValueError :
77+ minval = float (limit .getAttribute ("lower" ))
78+ maxval = float (limit .getAttribute ("upper" ))
79+ except ValueError :
80+ if jtype == "continuous" :
81+ minval = - pi
82+ maxval = pi
83+ else :
9184 raise Exception (
92- f"Missing velocity limits for the joint : { name } of type : { jtype } in the robot_description!"
85+ f"Missing lower/upper position limits for the joint : { name } of type : { jtype } in the robot_description!"
9386 )
94- except IndexError :
87+ try :
88+ maxvel = float (limit .getAttribute ("velocity" ))
89+ except ValueError :
90+ raise Exception (
91+ f"Missing velocity limits for the joint : { name } of type : { jtype } in the robot_description!"
92+ )
93+ except IndexError :
94+ if name in joints_names :
9595 raise Exception (
9696 f"Missing limits tag for the joint : { name } in the robot_description!"
9797 )
98- safety_tags = child .getElementsByTagName ("safety_controller" )
99- if use_small and len (safety_tags ) == 1 :
100- tag = safety_tags [0 ]
101- if tag .hasAttribute ("soft_lower_limit" ):
102- minval = max (minval , float (tag .getAttribute ("soft_lower_limit" )))
103- if tag .hasAttribute ("soft_upper_limit" ):
104- maxval = min (maxval , float (tag .getAttribute ("soft_upper_limit" )))
105-
106- mimic_tags = child .getElementsByTagName ("mimic" )
107- if use_mimic and len (mimic_tags ) == 1 :
108- tag = mimic_tags [0 ]
109- entry = {"parent" : tag .getAttribute ("joint" )}
110- if tag .hasAttribute ("multiplier" ):
111- entry ["factor" ] = float (tag .getAttribute ("multiplier" ))
112- if tag .hasAttribute ("offset" ):
113- entry ["offset" ] = float (tag .getAttribute ("offset" ))
114-
115- dependent_joints [name ] = entry
116- continue
117-
118- if name in dependent_joints :
119- continue
120-
121- joint = {"min_position" : minval , "max_position" : maxval }
122- joint ["has_position_limits" ] = jtype != "continuous"
123- joint ["max_velocity" ] = maxvel
124- free_joints [name ] = joint
98+ safety_tags = child .getElementsByTagName ("safety_controller" )
99+ if use_small and len (safety_tags ) == 1 :
100+ tag = safety_tags [0 ]
101+ if tag .hasAttribute ("soft_lower_limit" ):
102+ minval = max (minval , float (tag .getAttribute ("soft_lower_limit" )))
103+ if tag .hasAttribute ("soft_upper_limit" ):
104+ maxval = min (maxval , float (tag .getAttribute ("soft_upper_limit" )))
105+
106+ mimic_tags = child .getElementsByTagName ("mimic" )
107+ if use_mimic and len (mimic_tags ) == 1 :
108+ tag = mimic_tags [0 ]
109+ entry = {"parent" : tag .getAttribute ("joint" )}
110+ if tag .hasAttribute ("multiplier" ):
111+ entry ["factor" ] = float (tag .getAttribute ("multiplier" ))
112+ if tag .hasAttribute ("offset" ):
113+ entry ["offset" ] = float (tag .getAttribute ("offset" ))
114+
115+ dependent_joints [name ] = entry
116+ continue
117+
118+ if name in dependent_joints :
119+ continue
120+
121+ joint = {"min_position" : minval , "max_position" : maxval }
122+ joint ["has_position_limits" ] = jtype != "continuous"
123+ joint ["max_velocity" ] = maxvel
124+ free_joints [name ] = joint
125125 return free_joints
0 commit comments