@@ -66,10 +66,11 @@ def generate_cabin_door(self, lift_model_ele, name):
66
66
door_pose .text = \
67
67
f'{ x } { y } 0 0 0 { self .motion_axis_orientation } '
68
68
69
- self .generate_door_link_and_joint (door_model_ele , parent = 'platform' )
69
+ self .generate_door_link (door_model_ele , parent = 'platform' )
70
+ self .generate_joint (lift_model_ele , "platform" , name )
70
71
71
72
if self .plugin :
72
- self .generate_door_plugin (door_model_ele , name )
73
+ self .generate_door_plugin (door_model_ele , name , True )
73
74
74
75
def generate_shaft_door (self , world_ele , x , y , z , yaw , name ):
75
76
model_ele = SubElement (world_ele , 'model' )
@@ -82,7 +83,8 @@ def generate_shaft_door(self, world_ele, x, y, z, yaw, name):
82
83
yaw_new = yaw + self .motion_axis_orientation
83
84
door_pose .text = f'{ x_new } { y_new } { z } 0 0 { yaw_new } '
84
85
85
- self .generate_door_link_and_joint (model_ele )
86
+ self .generate_door_link (model_ele )
87
+ self .generate_joint (model_ele )
86
88
87
89
floor_thickness = 0.05
88
90
ramp_depth = self .gap * 2
@@ -97,9 +99,33 @@ def generate_shaft_door(self, world_ele, x, y, z, yaw, name):
97
99
model_ele .append (joint ('ramp_joint' , 'fixed' , 'world' , 'ramp' ))
98
100
99
101
if self .plugin :
100
- self .generate_door_plugin (model_ele , name )
102
+ self .generate_door_plugin (model_ele , name , False )
101
103
102
- def generate_door_link_and_joint (self , model_ele , parent = 'world' ):
104
+ def generate_joint (
105
+ self , parent_element , parent_name = "world" , child_name = None ):
106
+ if child_name is not None :
107
+ name_prefix = f'{ child_name } _'
108
+ joint_child_prefix = f'{ child_name } ::'
109
+ else :
110
+ name_prefix = ''
111
+ joint_child_prefix = f''
112
+ parent_element .append (joint (f'{ name_prefix } right_joint' ,
113
+ 'prismatic' ,
114
+ parent_name ,
115
+ f'{ joint_child_prefix } right_door' ,
116
+ joint_axis = 'x' ,
117
+ lower_limit = 0 ,
118
+ upper_limit = self .width / 2 ))
119
+
120
+ parent_element .append (joint (f'{ name_prefix } left_joint' ,
121
+ 'prismatic' ,
122
+ parent_name ,
123
+ f'{ joint_child_prefix } left_door' ,
124
+ joint_axis = 'x' ,
125
+ lower_limit = - self .width / 2 ,
126
+ upper_limit = 0 ))
127
+
128
+ def generate_door_link (self , model_ele , parent = 'world' ):
103
129
door_size = [self .width / 2 , self .thickness , self .height ]
104
130
right_door_pose = Element ('pose' )
105
131
right_door_pose .text = f'{ self .width / 4 } 0 { self .height / 2 } 0 0 0'
@@ -110,14 +136,6 @@ def generate_door_link_and_joint(self, model_ele, parent='world'):
110
136
material = lift_material (),
111
137
bitmask = '0x02' ))
112
138
113
- model_ele .append (joint ('right_joint' ,
114
- 'prismatic' ,
115
- parent ,
116
- 'right_door' ,
117
- joint_axis = 'x' ,
118
- lower_limit = 0 ,
119
- upper_limit = self .width / 2 ))
120
-
121
139
left_door_pose = Element ('pose' )
122
140
left_door_pose .text = f'{ - self .width / 4 } 0 { self .height / 2 } 0 0 0'
123
141
@@ -127,88 +145,25 @@ def generate_door_link_and_joint(self, model_ele, parent='world'):
127
145
material = lift_material (),
128
146
bitmask = '0x02' ))
129
147
130
- model_ele .append (joint ('left_joint' ,
131
- 'prismatic' ,
132
- parent ,
133
- 'left_door' ,
134
- joint_axis = 'x' ,
135
- lower_limit = - self .width / 2 ,
136
- upper_limit = 0 ))
137
-
138
- def generate_door_plugin (self , model_ele , name ):
148
+ def generate_door_plugin (self , model_ele , name , append_prefix = False ):
149
+ if append_prefix is True :
150
+ prefix = f'{ name } _'
151
+ else :
152
+ prefix = ''
139
153
plugin_ele = SubElement (model_ele , 'plugin' )
140
- plugin_ele .set ('name' , 'door' )
141
- plugin_ele .set ('filename' , 'libdoor.so' )
154
+ plugin_ele .set ('name' , 'register_component' )
155
+ plugin_ele .set ('filename' , 'libregister_component.so' )
156
+ component_ele = SubElement (plugin_ele , 'component' )
157
+ component_ele .set ('name' , 'Door' )
142
158
for param_name , param_value in self .params .items ():
143
- ele = SubElement (plugin_ele , param_name )
159
+ ele = SubElement (component_ele , param_name )
144
160
ele .text = f'{ param_value } '
145
- door_ele = SubElement (plugin_ele , 'door' )
146
- door_ele .set ('left_joint_name' , ' left_joint' )
161
+ door_ele = SubElement (component_ele , 'door' )
162
+ door_ele .set ('left_joint_name' , f' { prefix } left_joint' )
147
163
door_ele .set ('name' , f'{ name } ' )
148
- door_ele .set ('right_joint_name' , ' right_joint' )
164
+ door_ele .set ('right_joint_name' , f' { prefix } right_joint' )
149
165
door_ele .set ('type' , 'DoubleSlidingDoor' )
150
166
151
- # TODO: remove this function once nesting model is supported in ignition.
152
- def generate_cabin_door_ign (self , lift_model_ele , name ):
153
- # This is for cabin door generation for ignition gazebo as it doesn't
154
- # support nested models yet. Once ignition gazebo supports nested
155
- # models, this should be removed.
156
- (x , y ) = self .cabin_door_pose
157
- yaw = self .motion_axis_orientation
158
- right_x = x + np .cos (yaw ) * self .width / 4
159
- left_x = x - np .cos (yaw ) * self .width / 4
160
- right_y = y + np .sin (yaw ) * self .width / 4
161
- left_y = y - np .sin (yaw ) * self .width / 4
162
-
163
- door_size = [self .width / 2 , self .thickness , self .height ]
164
- right_door_pose = Element ('pose' )
165
- right_door_pose .text = \
166
- f'{ right_x } { right_y } { self .height / 2 } 0 0 { yaw } '
167
-
168
- lift_model_ele .append (box_link (f'{ name } _right_door' ,
169
- door_size ,
170
- right_door_pose ,
171
- material = lift_material (),
172
- bitmask = '0x02' ))
173
-
174
- lift_model_ele .append (joint (f'{ name } _right_joint' ,
175
- 'prismatic' ,
176
- 'platform' ,
177
- f'{ name } _right_door' ,
178
- joint_axis = 'x' ,
179
- lower_limit = 0 ,
180
- upper_limit = self .width / 2 ))
181
-
182
- left_door_pose = Element ('pose' )
183
- left_door_pose .text = f'{ left_x } { left_y } { self .height / 2 } 0 0 { yaw } '
184
-
185
- lift_model_ele .append (box_link (f'{ name } _left_door' ,
186
- door_size ,
187
- left_door_pose ,
188
- material = lift_material (),
189
- bitmask = '0x02' ))
190
-
191
- lift_model_ele .append (joint (f'{ name } _left_joint' ,
192
- 'prismatic' ,
193
- 'platform' ,
194
- f'{ name } _left_door' ,
195
- joint_axis = 'x' ,
196
- lower_limit = - self .width / 2 ,
197
- upper_limit = 0 ))
198
-
199
- if self .plugin :
200
- plugin_ele = SubElement (lift_model_ele , 'plugin' )
201
- plugin_ele .set ('name' , 'door' )
202
- plugin_ele .set ('filename' , 'libdoor.so' )
203
- for param_name , param_value in self .params .items ():
204
- ele = SubElement (plugin_ele , param_name )
205
- ele .text = f'{ param_value } '
206
- door_ele = SubElement (plugin_ele , 'door' )
207
- door_ele .set ('left_joint_name' , f'{ name } _left_joint' )
208
- door_ele .set ('name' , f'{ name } ' )
209
- door_ele .set ('right_joint_name' , f'{ name } _right_joint' )
210
- door_ele .set ('type' , 'DoubleSlidingDoor' )
211
-
212
167
213
168
class Lift :
214
169
def __init__ (self , yaml_node , name , transform , levels , coordinate_system ):
@@ -429,28 +384,23 @@ def generate_cabin(self, world_ele, options):
429
384
joint_axis = 'z' ))
430
385
431
386
# cabin doors
432
- # TODO: remove the if statement here once nesting model is supported
433
- # in ignition.
434
- if 'ignition' in options :
435
- for lift_door in self .doors :
436
- lift_door .generate_cabin_door_ign (
437
- lift_model_ele , f'CabinDoor_{ self .name } _{ lift_door .name } ' )
438
- else :
439
- for lift_door in self .doors :
440
- lift_door .generate_cabin_door (
441
- lift_model_ele , f'CabinDoor_{ self .name } _{ lift_door .name } ' )
387
+ for lift_door in self .doors :
388
+ lift_door .generate_cabin_door (
389
+ lift_model_ele , f'CabinDoor_{ self .name } _{ lift_door .name } ' )
442
390
443
391
# lift cabin plugin
444
392
if self .plugins :
445
393
plugin_ele = SubElement (lift_model_ele , 'plugin' )
446
- plugin_ele .set ('name' , 'lift' )
447
- plugin_ele .set ('filename' , 'liblift.so' )
394
+ plugin_ele .set ('name' , 'register_component' )
395
+ plugin_ele .set ('filename' , 'libregister_component.so' )
396
+ component_ele = SubElement (plugin_ele , 'component' )
397
+ component_ele .set ('name' , 'Lift' )
448
398
449
- lift_name_ele = SubElement (plugin_ele , 'lift_name' )
399
+ lift_name_ele = SubElement (component_ele , 'lift_name' )
450
400
lift_name_ele .text = f'{ self .name } '
451
401
452
402
for level_name , door_names in self .level_doors .items ():
453
- floor_ele = SubElement (plugin_ele , 'floor' )
403
+ floor_ele = SubElement (component_ele , 'floor' )
454
404
floor_ele .set ('name' , f'{ level_name } ' )
455
405
floor_ele .set (
456
406
'elevation' , f'{ self .level_elevation [level_name ]} ' )
@@ -464,13 +414,13 @@ def generate_cabin(self, world_ele, options):
464
414
'shaft_door' ,
465
415
f'ShaftDoor_{ self .name } _{ level_name } _{ door .name } ' )
466
416
467
- initial_floor_ele = SubElement (plugin_ele , 'initial_floor' )
417
+ initial_floor_ele = SubElement (component_ele , 'initial_floor' )
468
418
initial_floor_ele .text = f'{ self .initial_floor_name } '
469
419
for param_name , param_value in self .params .items ():
470
- ele = SubElement (plugin_ele , param_name )
420
+ ele = SubElement (component_ele , param_name )
471
421
ele .text = f'{ param_value } '
472
422
473
- cabin_joint_ele = SubElement (plugin_ele , 'cabin_joint_name' )
423
+ cabin_joint_ele = SubElement (component_ele , 'cabin_joint_name' )
474
424
cabin_joint_ele .text = 'cabin_joint'
475
425
else :
476
426
static_lift_ele = SubElement (lift_model_ele , 'static' )
@@ -479,3 +429,4 @@ def generate_cabin(self, world_ele, options):
479
429
# pose
480
430
model_pose = SubElement (lift_model_ele , 'pose' )
481
431
model_pose .text = f'{ self .x } { self .y } 0 0 0 { self .yaw } '
432
+
0 commit comments