13
13
class TestNormalRobotGraph (unittest .TestCase ):
14
14
15
15
def setUp (self ):
16
- self .hyq_path = Path (
17
- Path (__file__ ).cwd (), 'urdf_files' , 'HyQ ' , 'hyq .urdf' ).absolute ()
16
+ self .mini_cheetah_path = Path (
17
+ Path (__file__ ).cwd (), 'urdf_files' , 'MiniCheetah ' , 'miniCheetah .urdf' ).absolute ()
18
18
19
- self .HyQ_URDF = NormalRobotGraph (self .hyq_path ,
20
- 'package://hyq_description/' ,
21
- 'hyq-description' )
19
+ self .mini_cheetah_URDF = NormalRobotGraph (self .mini_cheetah_path ,
20
+ 'package://yobotics_description/' , 'mini-cheetah-gazebo-urdf/yobo_model/yobotics_description' )
22
21
23
22
def test_constructor (self ):
24
23
"""
25
24
Check that the constructor properly assigns all of the links and joints to a node/edge.
26
25
"""
27
26
28
27
joint_names = [
29
- 'floating_base' , 'lf_haa_joint' , 'lf_hfe_joint' , 'lf_kfe_joint' ,
30
- 'lf_foot_joint ' , 'rf_haa_joint ' , 'rf_hfe_joint ' , 'rf_kfe_joint' ,
31
- 'rf_foot_joint ' , 'lh_haa_joint ' , 'lh_hfe_joint ' , 'lh_kfe_joint' ,
32
- 'lh_foot_joint ' , 'rh_haa_joint ' , 'rh_hfe_joint ' , 'rh_kfe_joint' ,
33
- 'rh_foot_joint'
28
+ 'floating_base' ,
29
+ 'FL_hip_joint ' , 'FL_thigh_joint ' , 'FL_calf_joint ' , 'FL_foot_fixed' ,
30
+ 'FR_hip_joint ' , 'FR_thigh_joint ' , 'FR_calf_joint ' , 'FR_foot_fixed' ,
31
+ 'RL_hip_joint ' , 'RL_thigh_joint ' , 'RL_calf_joint ' , 'RL_foot_fixed' ,
32
+ 'RR_hip_joint' , 'RR_thigh_joint' , 'RR_calf_joint' , 'RR_foot_fixed' ,
34
33
]
35
34
36
35
edge_names_copy = copy .deepcopy (joint_names )
37
- for i , node in enumerate (self .HyQ_URDF .nodes ):
36
+ for i , node in enumerate (self .mini_cheetah_URDF .nodes ):
38
37
self .assertTrue (node .name in edge_names_copy )
39
38
edge_names_copy .remove (node .name )
40
39
self .assertEqual (0 , len (edge_names_copy ))
@@ -44,28 +43,28 @@ def test_constructor(self):
44
43
# Additionally, links with multiple children joints get one
45
44
# edge for each child.
46
45
desired_edges = [
47
- RobotGraph .Edge ('trunk_to_lf_haa_joint ' , "floating_base" ,
48
- "lf_haa_joint " , None ),
49
- RobotGraph .Edge ('trunk_to_lh_haa_joint ' , "floating_base" ,
50
- "lh_haa_joint " , None ),
51
- RobotGraph .Edge ('trunk_to_rf_haa_joint ' , "floating_base" ,
52
- "rf_haa_joint " , None ),
53
- RobotGraph .Edge ('trunk_to_rh_haa_joint ' , "floating_base" ,
54
- "rh_haa_joint " , None ),
55
- RobotGraph .Edge ('lf_hipassembly ' , "lf_haa_joint " , "lf_hfe_joint " , None ),
56
- RobotGraph .Edge ('lf_upperleg ' , "lf_hfe_joint " , "lf_kfe_joint " , None ),
57
- RobotGraph .Edge ('lf_lowerleg ' , "lf_kfe_joint " , "lf_foot_joint " , None ),
58
- RobotGraph .Edge ('rf_hipassembly ' , "rf_haa_joint " , "rf_hfe_joint " , None ),
59
- RobotGraph .Edge ('rf_upperleg ' , "rf_hfe_joint " , "rf_kfe_joint " , None ),
60
- RobotGraph .Edge ('rf_lowerleg ' , "rf_kfe_joint " , "rf_foot_joint " , None ),
61
- RobotGraph .Edge ('lh_hipassembly ' , "lh_haa_joint " , "lh_hfe_joint " , None ),
62
- RobotGraph .Edge ('lh_upperleg ' , "lh_hfe_joint " , "lh_kfe_joint " , None ),
63
- RobotGraph .Edge ('lh_lowerleg ' , "lh_kfe_joint " , "lh_foot_joint " , None ),
64
- RobotGraph .Edge ('rh_hipassembly ' , "rh_haa_joint " , "rh_hfe_joint " , None ),
65
- RobotGraph .Edge ('rh_upperleg ' , "rh_hfe_joint " , "rh_kfe_joint " , None ),
66
- RobotGraph .Edge ('rh_lowerleg ' , "rh_kfe_joint " , "rh_foot_joint " , None )
46
+ RobotGraph .Edge ('trunk_to_FL_hip_joint ' , "floating_base" ,
47
+ "FL_hip_joint " , None ),
48
+ RobotGraph .Edge ('trunk_to_FR_hip_joint ' , "floating_base" ,
49
+ "FR_hip_joint " , None ),
50
+ RobotGraph .Edge ('trunk_to_RL_hip_joint ' , "floating_base" ,
51
+ "RL_hip_joint " , None ),
52
+ RobotGraph .Edge ('trunk_to_RR_hip_joint ' , "floating_base" ,
53
+ "RR_hip_joint " , None ),
54
+ RobotGraph .Edge ('FL_hip ' , "FL_hip_joint " , "FL_thigh_joint " , None ),
55
+ RobotGraph .Edge ('FL_thigh ' , "FL_thigh_joint " , "FL_calf_joint " , None ),
56
+ RobotGraph .Edge ('FL_calf ' , "FL_calf_joint " , "FL_foot_fixed " , None ),
57
+ RobotGraph .Edge ('FR_hip ' , "FR_hip_joint " , "FR_thigh_joint " , None ),
58
+ RobotGraph .Edge ('FR_thigh ' , "FR_thigh_joint " , "FR_calf_joint " , None ),
59
+ RobotGraph .Edge ('FR_calf ' , "FR_calf_joint " , "FR_foot_fixed " , None ),
60
+ RobotGraph .Edge ('RL_hip ' , "RL_hip_joint " , "RL_thigh_joint " , None ),
61
+ RobotGraph .Edge ('RL_thigh ' , "RL_thigh_joint " , "RL_calf_joint " , None ),
62
+ RobotGraph .Edge ('RL_calf ' , "RL_calf_joint " , "RL_foot_fixed " , None ),
63
+ RobotGraph .Edge ('RR_hip ' , "RR_hip_joint " , "RR_thigh_joint " , None ),
64
+ RobotGraph .Edge ('RR_thigh ' , "RR_thigh_joint " , "RR_calf_joint " , None ),
65
+ RobotGraph .Edge ('RR_calf ' , "RR_calf_joint " , "RR_foot_fixed " , None )
67
66
]
68
- for i , edge in enumerate (self .HyQ_URDF .edges ):
67
+ for i , edge in enumerate (self .mini_cheetah_URDF .edges ):
69
68
match_found = False
70
69
for j , desired_edge in enumerate (desired_edges ):
71
70
if edge .name == desired_edge .name :
@@ -89,7 +88,7 @@ def test_constructor(self):
89
88
]
90
89
edge_names_copy = copy .deepcopy (joint_names )
91
90
num_matches = 0
92
- for i , node in enumerate (self .HyQ_URDF .nodes ):
91
+ for i , node in enumerate (self .mini_cheetah_URDF .nodes ):
93
92
for j , node_des in enumerate (edge_names_copy ):
94
93
if (node .name == node_des ):
95
94
self .assertEqual (node .get_node_type (), des_node_type [j ])
@@ -103,15 +102,15 @@ def test_constructor(self):
103
102
# is stored for one of the Nodes.
104
103
# ==================
105
104
node_found = False
106
- for i , node in enumerate (self .HyQ_URDF .nodes ):
107
- if node .name == "rh_kfe_joint " :
105
+ for i , node in enumerate (self .mini_cheetah_URDF .nodes ):
106
+ if node .name == "RL_hip_joint " :
108
107
# Test name information
109
108
joint : urchin .Joint = node .joint
110
- self .assertEqual ("rh_kfe_joint " , joint .name )
109
+ self .assertEqual ("RL_hip_joint " , joint .name )
111
110
112
111
# Test joint information
113
- np .testing .assert_array_equal (np .array ([[1.0 , 0.0 , 0.0 , 0.35 ], [0.0 , 1.0 , 0.0 , 0.0 ], [0.0 , 0.0 , 1.0 , 0.0 ], [0.0 , 0.0 , 0.0 , 1.0 ]]), joint .origin )
114
- self .assertEqual (0.1 , joint .dynamics .damping )
112
+ np .testing .assert_array_equal (np .array ([[1.0 , 0.0 , 0.0 , - 0.196 ], [0.0 , 1.0 , 0.0 , 0.049664 ], [0.0 , 0.0 , 1.0 , 0.0 ], [0.0 , 0.0 , 0.0 , 1.0 ]]), joint .origin )
113
+ self .assertEqual (0.0 , joint .dynamics .damping )
115
114
self .assertEqual (0.0 , joint .dynamics .friction )
116
115
117
116
node_found = True
@@ -120,16 +119,16 @@ def test_constructor(self):
120
119
self .assertTrue (node_found )
121
120
122
121
edge_found = False
123
- for i , edge in enumerate (self .HyQ_URDF .edges ):
124
- if edge .name == "lh_hipassembly " :
122
+ for i , edge in enumerate (self .mini_cheetah_URDF .edges ):
123
+ if edge .name == "FL_calf " :
125
124
# Test name information
126
125
link : urchin .Link = edge .link
127
- self .assertEqual ("lh_hipassembly " , link .name )
126
+ self .assertEqual ("FL_calf " , link .name )
128
127
129
128
# Test inertial information
130
- np .testing .assert_array_equal (np .array ([[1.0 , 0.0 , 0.0 , 0.04263 ], [0.0 , 1.0 , 0.0 , - 0.0 ], [0.0 , 0.0 , 1.0 , - 0.16931 ], [0.0 , 0.0 , 0.0 , 1.0 ]]), link .inertial .origin )
131
- self .assertEqual (2.93 , link .inertial .mass )
132
- np .testing .assert_array_equal (np .array ([[0.05071 , 4e-05 , 0.00159 ], [4e-05 , 0.05486 , - 5e-05 ], [0.00159 , - 5e-05 , 0.00571 ]]), link .inertial .inertia )
129
+ np .testing .assert_array_equal (np .array ([[1.0 , 0.0 , 0.0 , 0.0 ], [0.0 , 1.0 , 0.0 , 0.0 ], [0.0 , 0.0 , 1.0 , 0.0 ], [0.0 , 0.0 , 0.0 , 1.0 ]]), link .inertial .origin )
130
+ self .assertEqual (0.064 , link .inertial .mass )
131
+ np .testing .assert_array_equal (np .array ([[0.000214698666667 , 0.0 , 0.0 ], [0.0 , 0.000214698666667 , 0.0 ], [0.0 , 0.0 , 2.73066666667e-06 ]]), link .inertial .inertia )
133
132
134
133
edge_found = True
135
134
break
@@ -141,21 +140,21 @@ def test_get_connections_to_link(self):
141
140
Check that we can properly find the connections to the links in the library.
142
141
"""
143
142
144
- edge_parent , edge_children = self .HyQ_URDF .get_connections_to_link (
143
+ edge_parent , edge_children = self .mini_cheetah_URDF .get_connections_to_link (
145
144
urchin .Link ("base_link" , None , None , None ))
146
145
self .assertEqual (edge_parent , None )
147
146
self .assertSequenceEqual (edge_children , ["floating_base" ])
148
147
149
- edge_parent , edge_children = self .HyQ_URDF .get_connections_to_link (
148
+ edge_parent , edge_children = self .mini_cheetah_URDF .get_connections_to_link (
150
149
urchin .Link ("trunk" , None , None , None ))
151
150
self .assertEqual (edge_parent , "floating_base" )
152
151
self .assertSequenceEqual (
153
152
edge_children ,
154
- ["lf_haa_joint " , "rf_haa_joint " , "lh_haa_joint " , "rh_haa_joint " ])
153
+ ["RL_hip_joint " , "FL_hip_joint " , "RR_hip_joint " , "FR_hip_joint " ])
155
154
156
- edge_parent , edge_children = self .HyQ_URDF .get_connections_to_link (
157
- urchin .Link ("lf_foot " , None , None , None ))
158
- self .assertEqual (edge_parent , "lf_foot_joint " )
155
+ edge_parent , edge_children = self .mini_cheetah_URDF .get_connections_to_link (
156
+ urchin .Link ("FL_foot " , None , None , None ))
157
+ self .assertEqual (edge_parent , "FL_foot_fixed " )
159
158
self .assertSequenceEqual (edge_children , [])
160
159
161
160
def test_create_updated_urdf_file (self ):
@@ -165,26 +164,26 @@ def test_create_updated_urdf_file(self):
165
164
"""
166
165
167
166
# Delete the urdf file
168
- hyq_path_updated = self .hyq_path .parent / "hyq_updated .urdf"
169
- os .remove (str (hyq_path_updated ))
170
- self .assertFalse (os .path .exists (hyq_path_updated ))
167
+ mini_cheetah_path_updated = self .mini_cheetah_path .parent / "miniCheetah_updated .urdf"
168
+ os .remove (str (mini_cheetah_path_updated ))
169
+ self .assertFalse (os .path .exists (mini_cheetah_path_updated ))
171
170
172
171
# Rebuild it
173
- RobotGraph (self .hyq_path , 'package://hyq_description /' ,
174
- 'hyq-description ' )
175
- self .assertTrue (os .path .exists (hyq_path_updated ))
172
+ RobotGraph (self .mini_cheetah_path , 'package://yobotics_description /' ,
173
+ 'mini-cheetah-gazebo-urdf/yobo_model/yobotics_description ' )
174
+ self .assertTrue (os .path .exists (mini_cheetah_path_updated ))
176
175
177
176
def test_get_node_name_to_index_dict (self ):
178
177
"""
179
178
Check if all the indexes of the nodes in the dictionary
180
179
are unique.
181
180
"""
182
181
183
- key = list (self .HyQ_URDF .get_node_name_to_index_dict ())
182
+ key = list (self .mini_cheetah_URDF .get_node_name_to_index_dict ())
184
183
get_nodes_index = []
185
184
186
185
for key in key :
187
- index = self .HyQ_URDF .get_node_name_to_index_dict ()[key ]
186
+ index = self .mini_cheetah_URDF .get_node_name_to_index_dict ()[key ]
188
187
get_nodes_index .append (index )
189
188
190
189
self .assertTrue (pd .Index (get_nodes_index ).is_unique )
@@ -195,12 +194,12 @@ def test_get_node_index_to_name_dict(self):
195
194
index_to_name dict and the name_to_index dict are consistent.
196
195
"""
197
196
198
- index_to_name = list (self .HyQ_URDF .get_node_index_to_name_dict ())
199
- name_to_index = list (self .HyQ_URDF .get_node_name_to_index_dict ())
197
+ index_to_name = list (self .mini_cheetah_URDF .get_node_index_to_name_dict ())
198
+ name_to_index = list (self .mini_cheetah_URDF .get_node_name_to_index_dict ())
200
199
get_nodes_index = []
201
200
202
201
for key in name_to_index :
203
- index = self .HyQ_URDF .get_node_name_to_index_dict ()[key ]
202
+ index = self .mini_cheetah_URDF .get_node_name_to_index_dict ()[key ]
204
203
get_nodes_index .append (index )
205
204
206
205
self .assertEqual (index_to_name , get_nodes_index )
@@ -210,7 +209,7 @@ def test_get_edge_index_matrix(self):
210
209
Check the dimensionality of the edge matrix.
211
210
"""
212
211
213
- edge_matrix = self .HyQ_URDF .get_edge_index_matrix ()
212
+ edge_matrix = self .mini_cheetah_URDF .get_edge_index_matrix ()
214
213
215
214
self .assertEqual (edge_matrix .shape [0 ], 2 )
216
215
self .assertEqual (edge_matrix .shape [1 ], 32 )
@@ -220,7 +219,7 @@ def test_get_num_nodes(self):
220
219
Check that the number of nodes are correct.
221
220
"""
222
221
223
- self .assertEqual (self .HyQ_URDF .get_num_nodes (), 17 )
222
+ self .assertEqual (self .mini_cheetah_URDF .get_num_nodes (), 17 )
224
223
225
224
def test_get_edge_connections_to_name_dict (self ):
226
225
"""
@@ -230,13 +229,13 @@ def test_get_edge_connections_to_name_dict(self):
230
229
"""
231
230
232
231
connections_to_name = list (
233
- self .HyQ_URDF .get_edge_connections_to_name_dict ())
232
+ self .mini_cheetah_URDF .get_edge_connections_to_name_dict ())
234
233
name_to_connections = list (
235
- self .HyQ_URDF .get_edge_name_to_connections_dict ())
234
+ self .mini_cheetah_URDF .get_edge_name_to_connections_dict ())
236
235
237
236
result = []
238
237
for key in name_to_connections :
239
- connections = self .HyQ_URDF .get_edge_name_to_connections_dict (
238
+ connections = self .mini_cheetah_URDF .get_edge_name_to_connections_dict (
240
239
)[key ]
241
240
for i in range (connections .shape [1 ]):
242
241
real_reshaped = np .squeeze (connections [:, i ].reshape (1 , - 1 ))
@@ -252,12 +251,12 @@ def test_get_edge_name_to_connections_dict(self):
252
251
"""
253
252
254
253
name_to_connections = list (
255
- self .HyQ_URDF .get_edge_name_to_connections_dict ())
254
+ self .mini_cheetah_URDF .get_edge_name_to_connections_dict ())
256
255
all_connections = []
257
256
258
257
# Get all connections from dictionary
259
258
for key in name_to_connections :
260
- connections = self .HyQ_URDF .get_edge_name_to_connections_dict (
259
+ connections = self .mini_cheetah_URDF .get_edge_name_to_connections_dict (
261
260
)[key ]
262
261
for i in range (connections .shape [1 ]):
263
262
real_reshaped = np .squeeze (connections [:, i ].reshape (1 , - 1 ))
0 commit comments