From d46fba0fabd2d088222c5070996f69e6a9b1dcaa Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Fri, 19 Jan 2024 14:39:48 +0800 Subject: [PATCH 1/9] ECS refactor for lifts and doors Signed-off-by: Luca Della Vedova --- .../building_map/building.py | 2 +- .../building_map/doors/double_sliding_door.py | 13 +- .../building_map/doors/double_swing_door.py | 13 +- .../building_map/doors/sliding_door.py | 14 +- .../building_map/doors/swing_door.py | 14 +- rmf_building_map_tools/building_map/lift.py | 163 ++++------ .../building_map/templates/ign_world.sdf | 288 ++++++++++++------ 7 files changed, 293 insertions(+), 214 deletions(-) diff --git a/rmf_building_map_tools/building_map/building.py b/rmf_building_map_tools/building_map/building.py index a0ab55db2..42ea3f0b0 100644 --- a/rmf_building_map_tools/building_map/building.py +++ b/rmf_building_map_tools/building_map/building.py @@ -503,7 +503,7 @@ def generate_sdf_world(self, options): {'name': 'toggle_floors', 'filename': 'libtoggle_floors.so'}) elif 'ignition' in options: - plugin_ele = gui_ele.find('.//plugin[@filename="GzScene3D"]') + plugin_ele = gui_ele.find('.//plugin[@filename="MinimalScene"]') camera_pose_ele = plugin_ele.find('camera_pose') camera_pose_ele.text = camera_pose diff --git a/rmf_building_map_tools/building_map/doors/double_sliding_door.py b/rmf_building_map_tools/building_map/doors/double_sliding_door.py index 7c984c961..00132f699 100644 --- a/rmf_building_map_tools/building_map/doors/double_sliding_door.py +++ b/rmf_building_map_tools/building_map/doors/double_sliding_door.py @@ -30,20 +30,23 @@ def generate(self, world_ele, options): if not self.plugin == 'none': plugin_ele = SubElement(self.model_ele, 'plugin') - plugin_ele.set('name', 'door') - plugin_ele.set('filename', 'libdoor.so') + plugin_ele.set('name', 'register_component') + plugin_ele.set('filename', 'libregister_component.so') + component_ele = SubElement(plugin_ele, 'component') + component_ele.set('name', 'Door') plugin_params = { 'v_max_door': '0.2', 'a_max_door': '0.2', 'a_nom_door': '0.08', 'dx_min_door': '0.001', - 'f_max_door': '100.0' + 'f_max_door': '100.0', + 'ros_interface': 'true' } for param_name, param_value in plugin_params.items(): - ele = SubElement(plugin_ele, param_name) + ele = SubElement(component_ele, param_name) ele.text = param_value - door_ele = SubElement(plugin_ele, 'door') + door_ele = SubElement(component_ele, 'door') door_ele.set('name', self.name) door_ele.set('type', 'DoubleSlidingDoor') door_ele.set('left_joint_name', 'left_joint') diff --git a/rmf_building_map_tools/building_map/doors/double_swing_door.py b/rmf_building_map_tools/building_map/doors/double_swing_door.py index 3bd0e19f9..d768849f7 100644 --- a/rmf_building_map_tools/building_map/doors/double_swing_door.py +++ b/rmf_building_map_tools/building_map/doors/double_swing_door.py @@ -48,20 +48,23 @@ def generate(self, world_ele, options): if not self.plugin == 'none': plugin_ele = SubElement(self.model_ele, 'plugin') - plugin_ele.set('name', 'door') - plugin_ele.set('filename', 'libdoor.so') + plugin_ele.set('name', 'register_component') + plugin_ele.set('filename', 'libregister_component.so') + component_ele = SubElement(plugin_ele, 'component') + component_ele.set('name', 'Door') plugin_params = { 'v_max_door': '0.5', 'a_max_door': '0.3', 'a_nom_door': '0.15', 'dx_min_door': '0.01', - 'f_max_door': '500.0' + 'f_max_door': '500.0', + 'ros_interface': 'true' } for param_name, param_value in plugin_params.items(): - ele = SubElement(plugin_ele, param_name) + ele = SubElement(component_ele, param_name) ele.text = param_value - door_ele = SubElement(plugin_ele, 'door') + door_ele = SubElement(component_ele, 'door') door_ele.set('name', self.name) door_ele.set('type', 'DoubleSwingDoor') door_ele.set('left_joint_name', 'left_joint') diff --git a/rmf_building_map_tools/building_map/doors/sliding_door.py b/rmf_building_map_tools/building_map/doors/sliding_door.py index 781db3b80..4c47b811a 100644 --- a/rmf_building_map_tools/building_map/doors/sliding_door.py +++ b/rmf_building_map_tools/building_map/doors/sliding_door.py @@ -16,23 +16,27 @@ def generate(self, world_ele, options): if not self.plugin == 'none': plugin_ele = SubElement(self.model_ele, 'plugin') - plugin_ele.set('name', 'door') - plugin_ele.set('filename', 'libdoor.so') + plugin_ele.set('name', 'register_component') + plugin_ele.set('filename', 'libregister_component.so') + component_ele = SubElement(plugin_ele, 'component') + component_ele.set('name', 'Door') plugin_params = { 'v_max_door': '0.2', 'a_max_door': '0.2', 'a_nom_door': '0.08', 'dx_min_door': '0.001', - 'f_max_door': '100.0' + 'f_max_door': '100.0', + 'ros_interface': 'true' } for param_name, param_value in plugin_params.items(): - ele = SubElement(plugin_ele, param_name) + ele = SubElement(component_ele, param_name) ele.text = param_value - door_ele = SubElement(plugin_ele, 'door') + door_ele = SubElement(component_ele, 'door') door_ele.set('name', self.name) door_ele.set('type', 'SlidingDoor') door_ele.set('left_joint_name', 'empty_joint') door_ele.set('right_joint_name', 'right_joint') world_ele.append(self.model_ele) + diff --git a/rmf_building_map_tools/building_map/doors/swing_door.py b/rmf_building_map_tools/building_map/doors/swing_door.py index eba38280a..166b5571d 100644 --- a/rmf_building_map_tools/building_map/doors/swing_door.py +++ b/rmf_building_map_tools/building_map/doors/swing_door.py @@ -25,23 +25,27 @@ def generate(self, world_ele, options): if not self.plugin == 'none': plugin_ele = SubElement(self.model_ele, 'plugin') - plugin_ele.set('name', 'door') - plugin_ele.set('filename', 'libdoor.so') + plugin_ele.set('name', 'register_component') + plugin_ele.set('filename', 'libregister_component.so') + component_ele = SubElement(plugin_ele, 'component') + component_ele.set('name', 'Door') plugin_params = { 'v_max_door': '0.5', 'a_max_door': '0.3', 'a_nom_door': '0.15', 'dx_min_door': '0.01', - 'f_max_door': '500.0' + 'f_max_door': '500.0', + 'ros_interface': 'true' } for param_name, param_value in plugin_params.items(): - ele = SubElement(plugin_ele, param_name) + ele = SubElement(component_ele, param_name) ele.text = param_value - door_ele = SubElement(plugin_ele, 'door') + door_ele = SubElement(component_ele, 'door') door_ele.set('name', self.name) door_ele.set('type', 'SwingDoor') door_ele.set('left_joint_name', 'empty_joint') door_ele.set('right_joint_name', 'right_joint') world_ele.append(self.model_ele) + diff --git a/rmf_building_map_tools/building_map/lift.py b/rmf_building_map_tools/building_map/lift.py index dd286b5e3..0ea8846b2 100644 --- a/rmf_building_map_tools/building_map/lift.py +++ b/rmf_building_map_tools/building_map/lift.py @@ -66,10 +66,11 @@ def generate_cabin_door(self, lift_model_ele, name): door_pose.text = \ f'{x} {y} 0 0 0 {self.motion_axis_orientation}' - self.generate_door_link_and_joint(door_model_ele, parent='platform') + self.generate_door_link(door_model_ele, parent='platform') + self.generate_joint(lift_model_ele, "platform", name) if self.plugin: - self.generate_door_plugin(door_model_ele, name) + self.generate_door_plugin(door_model_ele, name, True) def generate_shaft_door(self, world_ele, x, y, z, yaw, name): model_ele = SubElement(world_ele, 'model') @@ -82,7 +83,8 @@ def generate_shaft_door(self, world_ele, x, y, z, yaw, name): yaw_new = yaw + self.motion_axis_orientation door_pose.text = f'{x_new} {y_new} {z} 0 0 {yaw_new}' - self.generate_door_link_and_joint(model_ele) + self.generate_door_link(model_ele) + self.generate_joint(model_ele) floor_thickness = 0.05 ramp_depth = self.gap * 2 @@ -97,9 +99,33 @@ def generate_shaft_door(self, world_ele, x, y, z, yaw, name): model_ele.append(joint('ramp_joint', 'fixed', 'world', 'ramp')) if self.plugin: - self.generate_door_plugin(model_ele, name) + self.generate_door_plugin(model_ele, name, False) - def generate_door_link_and_joint(self, model_ele, parent='world'): + def generate_joint( + self, parent_element, parent_name="world", child_name=None): + if child_name is not None: + name_prefix = f'{child_name}_' + joint_child_prefix = f'{child_name}::' + else: + name_prefix = '' + joint_child_prefix = f'' + parent_element.append(joint(f'{name_prefix}right_joint', + 'prismatic', + parent_name, + f'{joint_child_prefix}right_door', + joint_axis='x', + lower_limit=0, + upper_limit=self.width / 2)) + + parent_element.append(joint(f'{name_prefix}left_joint', + 'prismatic', + parent_name, + f'{joint_child_prefix}left_door', + joint_axis='x', + lower_limit=-self.width / 2, + upper_limit=0)) + + def generate_door_link(self, model_ele, parent='world'): door_size = [self.width / 2, self.thickness, self.height] right_door_pose = Element('pose') 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'): material=lift_material(), bitmask='0x02')) - model_ele.append(joint('right_joint', - 'prismatic', - parent, - 'right_door', - joint_axis='x', - lower_limit=0, - upper_limit=self.width / 2)) - left_door_pose = Element('pose') left_door_pose.text = f'{-self.width / 4} 0 {self.height / 2} 0 0 0' @@ -127,88 +145,25 @@ def generate_door_link_and_joint(self, model_ele, parent='world'): material=lift_material(), bitmask='0x02')) - model_ele.append(joint('left_joint', - 'prismatic', - parent, - 'left_door', - joint_axis='x', - lower_limit=-self.width / 2, - upper_limit=0)) - - def generate_door_plugin(self, model_ele, name): + def generate_door_plugin(self, model_ele, name, append_prefix=False): + if append_prefix is True: + prefix = f'{name}_' + else: + prefix = '' plugin_ele = SubElement(model_ele, 'plugin') - plugin_ele.set('name', 'door') - plugin_ele.set('filename', 'libdoor.so') + plugin_ele.set('name', 'register_component') + plugin_ele.set('filename', 'libregister_component.so') + component_ele = SubElement(plugin_ele, 'component') + component_ele.set('name', 'Door') for param_name, param_value in self.params.items(): - ele = SubElement(plugin_ele, param_name) + ele = SubElement(component_ele, param_name) ele.text = f'{param_value}' - door_ele = SubElement(plugin_ele, 'door') - door_ele.set('left_joint_name', 'left_joint') + door_ele = SubElement(component_ele, 'door') + door_ele.set('left_joint_name', f'{prefix}left_joint') door_ele.set('name', f'{name}') - door_ele.set('right_joint_name', 'right_joint') + door_ele.set('right_joint_name', f'{prefix}right_joint') door_ele.set('type', 'DoubleSlidingDoor') - # TODO: remove this function once nesting model is supported in ignition. - def generate_cabin_door_ign(self, lift_model_ele, name): - # This is for cabin door generation for ignition gazebo as it doesn't - # support nested models yet. Once ignition gazebo supports nested - # models, this should be removed. - (x, y) = self.cabin_door_pose - yaw = self.motion_axis_orientation - right_x = x + np.cos(yaw) * self.width/4 - left_x = x - np.cos(yaw) * self.width/4 - right_y = y + np.sin(yaw) * self.width/4 - left_y = y - np.sin(yaw) * self.width/4 - - door_size = [self.width / 2, self.thickness, self.height] - right_door_pose = Element('pose') - right_door_pose.text = \ - f'{right_x} {right_y} {self.height / 2} 0 0 {yaw}' - - lift_model_ele.append(box_link(f'{name}_right_door', - door_size, - right_door_pose, - material=lift_material(), - bitmask='0x02')) - - lift_model_ele.append(joint(f'{name}_right_joint', - 'prismatic', - 'platform', - f'{name}_right_door', - joint_axis='x', - lower_limit=0, - upper_limit=self.width / 2)) - - left_door_pose = Element('pose') - left_door_pose.text = f'{left_x} {left_y} {self.height / 2} 0 0 {yaw}' - - lift_model_ele.append(box_link(f'{name}_left_door', - door_size, - left_door_pose, - material=lift_material(), - bitmask='0x02')) - - lift_model_ele.append(joint(f'{name}_left_joint', - 'prismatic', - 'platform', - f'{name}_left_door', - joint_axis='x', - lower_limit=-self.width / 2, - upper_limit=0)) - - if self.plugin: - plugin_ele = SubElement(lift_model_ele, 'plugin') - plugin_ele.set('name', 'door') - plugin_ele.set('filename', 'libdoor.so') - for param_name, param_value in self.params.items(): - ele = SubElement(plugin_ele, param_name) - ele.text = f'{param_value}' - door_ele = SubElement(plugin_ele, 'door') - door_ele.set('left_joint_name', f'{name}_left_joint') - door_ele.set('name', f'{name}') - door_ele.set('right_joint_name', f'{name}_right_joint') - door_ele.set('type', 'DoubleSlidingDoor') - class Lift: def __init__(self, yaml_node, name, transform, levels, coordinate_system): @@ -429,28 +384,23 @@ def generate_cabin(self, world_ele, options): joint_axis='z')) # cabin doors - # TODO: remove the if statement here once nesting model is supported - # in ignition. - if 'ignition' in options: - for lift_door in self.doors: - lift_door.generate_cabin_door_ign( - lift_model_ele, f'CabinDoor_{self.name}_{lift_door.name}') - else: - for lift_door in self.doors: - lift_door.generate_cabin_door( - lift_model_ele, f'CabinDoor_{self.name}_{lift_door.name}') + for lift_door in self.doors: + lift_door.generate_cabin_door( + lift_model_ele, f'CabinDoor_{self.name}_{lift_door.name}') # lift cabin plugin if self.plugins: plugin_ele = SubElement(lift_model_ele, 'plugin') - plugin_ele.set('name', 'lift') - plugin_ele.set('filename', 'liblift.so') + plugin_ele.set('name', 'register_component') + plugin_ele.set('filename', 'libregister_component.so') + component_ele = SubElement(plugin_ele, 'component') + component_ele.set('name', 'Lift') - lift_name_ele = SubElement(plugin_ele, 'lift_name') + lift_name_ele = SubElement(component_ele, 'lift_name') lift_name_ele.text = f'{self.name}' for level_name, door_names in self.level_doors.items(): - floor_ele = SubElement(plugin_ele, 'floor') + floor_ele = SubElement(component_ele, 'floor') floor_ele.set('name', f'{level_name}') floor_ele.set( 'elevation', f'{self.level_elevation[level_name]}') @@ -464,13 +414,13 @@ def generate_cabin(self, world_ele, options): 'shaft_door', f'ShaftDoor_{self.name}_{level_name}_{door.name}') - initial_floor_ele = SubElement(plugin_ele, 'initial_floor') + initial_floor_ele = SubElement(component_ele, 'initial_floor') initial_floor_ele.text = f'{self.initial_floor_name}' for param_name, param_value in self.params.items(): - ele = SubElement(plugin_ele, param_name) + ele = SubElement(component_ele, param_name) ele.text = f'{param_value}' - cabin_joint_ele = SubElement(plugin_ele, 'cabin_joint_name') + cabin_joint_ele = SubElement(component_ele, 'cabin_joint_name') cabin_joint_ele.text = 'cabin_joint' else: static_lift_ele = SubElement(lift_model_ele, 'static') @@ -479,3 +429,4 @@ def generate_cabin(self, world_ele, options): # pose model_pose = SubElement(lift_model_ele, 'pose') model_pose.text = f'{self.x} {self.y} 0 0 0 {self.yaw}' + diff --git a/rmf_building_map_tools/building_map/templates/ign_world.sdf b/rmf_building_map_tools/building_map/templates/ign_world.sdf index 81444b97f..d7c75108d 100644 --- a/rmf_building_map_tools/building_map/templates/ign_world.sdf +++ b/rmf_building_map_tools/building_map/templates/ign_world.sdf @@ -17,6 +17,14 @@ filename="libignition-gazebo-scene-broadcaster-system.so" name="ignition::gazebo::systems::SceneBroadcaster"> + + + + 1 1 1 @@ -49,120 +57,225 @@ + + + 3D View + false + docked + + ogre2 + scene + 0.4 0.4 0.4 + 0.8 0.8 0.8 + -6 0 6 0 0.5 0 + - - - - 3D View - false - docked - + + + + floating + 5 + 5 + false + + - ogre2 - scene - 0.4 0.4 0.4 - 0.8 0.8 0.8 - 6 0 6 0 0.5 3.14 + + + false + 5 + 5 + floating + false + - - - - World control - false - false - 72 - 121 - 1 + + + false + 5 + 5 + floating + false + + - floating - - - - - + + + false + 5 + 5 + floating + false + + - true - true - true + + + false + 5 + 5 + floating + false + + + + + false + 5 + 5 + floating + false + - - - - World stats - false - false - 110 - 290 - 1 + + + false + 5 + 5 + floating + false + + + + + + false + 5 + 5 + floating + false + + - floating - - - - - + + + + World control + false + false + 72 + 1 + floating + + + + + + true + true + true + true + - true - true - true - true + + + + World stats + false + false + 110 + 290 + 1 + floating + + + + + + true + true + true + true + + + + + + false + 0 + 0 + 250 + 50 + floating + false + #666666 + + + + + + false + 250 + 0 + 150 + 50 + floating + false + #666666 + - - Transform control - - - - - false - 230 - 50 - floating - false - #666666 - + + false + 0 + 50 + 250 + 50 + floating + false + #777777 + - - - - - - - - false - 200 - 50 - floating - false - #666666 - + + + + false + 250 + 50 + 50 + 50 + floating + false + #777777 + + + + + + + false + 300 + 50 + 100 + 50 + floating + false + #777777 + - - false - docked - + + false + docked + - - false - docked - + + false + docked + - - - @@ -181,3 +294,4 @@ + From 755905f0098fa08d10e55d4f2dd3e3d26b4bcadc Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Fri, 19 Jan 2024 14:42:33 +0800 Subject: [PATCH 2/9] Style Signed-off-by: Luca Della Vedova --- rmf_building_map_tools/building_map/doors/sliding_door.py | 1 - rmf_building_map_tools/building_map/doors/swing_door.py | 1 - rmf_building_map_tools/building_map/lift.py | 1 - 3 files changed, 3 deletions(-) diff --git a/rmf_building_map_tools/building_map/doors/sliding_door.py b/rmf_building_map_tools/building_map/doors/sliding_door.py index 4c47b811a..ab93f2291 100644 --- a/rmf_building_map_tools/building_map/doors/sliding_door.py +++ b/rmf_building_map_tools/building_map/doors/sliding_door.py @@ -39,4 +39,3 @@ def generate(self, world_ele, options): door_ele.set('right_joint_name', 'right_joint') world_ele.append(self.model_ele) - diff --git a/rmf_building_map_tools/building_map/doors/swing_door.py b/rmf_building_map_tools/building_map/doors/swing_door.py index 166b5571d..dcf3ef700 100644 --- a/rmf_building_map_tools/building_map/doors/swing_door.py +++ b/rmf_building_map_tools/building_map/doors/swing_door.py @@ -48,4 +48,3 @@ def generate(self, world_ele, options): door_ele.set('right_joint_name', 'right_joint') world_ele.append(self.model_ele) - diff --git a/rmf_building_map_tools/building_map/lift.py b/rmf_building_map_tools/building_map/lift.py index 0ea8846b2..2002c25e0 100644 --- a/rmf_building_map_tools/building_map/lift.py +++ b/rmf_building_map_tools/building_map/lift.py @@ -429,4 +429,3 @@ def generate_cabin(self, world_ele, options): # pose model_pose = SubElement(lift_model_ele, 'pose') model_pose.text = f'{self.x} {self.y} 0 0 0 {self.yaw}' - From 2844b8bd64187beda577982a3844fbc8795ab3ca Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Tue, 23 Jan 2024 15:37:55 +0800 Subject: [PATCH 3/9] Remove generator options Signed-off-by: Luca Della Vedova --- .../building_map/building.py | 46 +-- .../building_map/doors/door.py | 13 +- .../building_map/doors/double_sliding_door.py | 8 +- .../building_map/doors/double_swing_door.py | 8 +- .../building_map/doors/sliding_door.py | 5 +- .../building_map/doors/swing_door.py | 5 +- .../building_map/generator.py | 31 +- rmf_building_map_tools/building_map/level.py | 8 +- rmf_building_map_tools/building_map/lift.py | 2 +- .../building_map/templates/gz_world.sdf | 297 +++++++++++++++++- .../building_map/templates/ign_world.sdf | 297 ------------------ rmf_building_map_tools/building_map/utils.py | 11 +- .../building_map_generator/_init_argparse.py | 10 +- .../building_map_generator.py | 13 +- 14 files changed, 329 insertions(+), 425 deletions(-) delete mode 100644 rmf_building_map_tools/building_map/templates/ign_world.sdf diff --git a/rmf_building_map_tools/building_map/building.py b/rmf_building_map_tools/building_map/building.py index 42ea3f0b0..5955689ae 100644 --- a/rmf_building_map_tools/building_map/building.py +++ b/rmf_building_map_tools/building_map/building.py @@ -394,15 +394,9 @@ def generate_nav_graphs(self): nav_graphs[f'{i}'] = g return nav_graphs - def generate_sdf_world(self, options): + def generate_sdf_world(self): """ Return an etree of this Building in SDF starting from a template""" - print(f'generator options: {options}') - if 'gazebo' in options: - template_name = 'gz_world.sdf' - elif 'ignition' in options: - template_name = 'ign_world.sdf' - else: - raise RuntimeError("expected either gazebo or ignition in options") + template_name = 'gz_world.sdf' template_path = os.path.join( get_package_share_directory('rmf_building_map_tools'), @@ -414,7 +408,7 @@ def generate_sdf_world(self, options): for level_name, level in self.levels.items(): level.generate_sdf_models(world) # todo: a better name - level.generate_doors(world, options) + level.generate_doors(world) level_include_ele = SubElement(world, 'include') level_model_name = f'{self.name}_{level_name}' @@ -436,7 +430,7 @@ def generate_sdf_world(self, options): print(f'[{lift_name}] is not serving any floor, ignoring.') continue lift.generate_shaft_doors(world) - lift.generate_cabin(world, options) + lift.generate_cabin(world) charger_waypoints_ele = SubElement( world, @@ -487,30 +481,14 @@ def generate_sdf_world(self, options): else: camera_pose = f'{c[0]} {c[1]-20} 10 0 0.6 1.57' # add floor-toggle GUI plugin parameters - if 'gazebo' in options: - camera_pose_ele = gui_ele.find('camera').find('pose') - camera_pose_ele.text = camera_pose - - toggle_charge_ele = SubElement( - gui_ele, - 'plugin', - {'name': 'toggle_charging', - 'filename': 'libtoggle_charging.so'}) - - toggle_floors_ele = SubElement( - gui_ele, - 'plugin', - {'name': 'toggle_floors', 'filename': 'libtoggle_floors.so'}) - - elif 'ignition' in options: - plugin_ele = gui_ele.find('.//plugin[@filename="MinimalScene"]') - camera_pose_ele = plugin_ele.find('camera_pose') - camera_pose_ele.text = camera_pose - - toggle_floors_ele = SubElement( - gui_ele, - 'plugin', - {'name': 'toggle_floors', 'filename': 'toggle_floors'}) + plugin_ele = gui_ele.find('.//plugin[@filename="MinimalScene"]') + camera_pose_ele = plugin_ele.find('camera_pose') + camera_pose_ele.text = camera_pose + + toggle_floors_ele = SubElement( + gui_ele, + 'plugin', + {'name': 'toggle_floors', 'filename': 'toggle_floors'}) for level_name, level in self.levels.items(): floor_ele = SubElement( diff --git a/rmf_building_map_tools/building_map/doors/door.py b/rmf_building_map_tools/building_map/doors/door.py index 5cdd74017..5639eb636 100644 --- a/rmf_building_map_tools/building_map/doors/door.py +++ b/rmf_building_map_tools/building_map/doors/door.py @@ -29,14 +29,14 @@ def __init__(self, door_edge, level_elevation=0.0): static_ele = SubElement(self.model_ele, 'static') static_ele.text = 'true' - def generate_section(self, name, width, x_offset, options): + def generate_section(self, name, width, x_offset): pose_ele = Element('pose') pose_ele.text = f'{x_offset} 0 {self.height/2+0.01} 0 0 0' size = [width, self.thickness, self.height] link_ele = box_link(name, size, pose_ele, - material=door_material(options), + material=door_material(), bitmask='0x02') mass = 50.0 @@ -54,8 +54,8 @@ def generate_section(self, name, width, x_offset, options): self.model_ele.append(link_ele) return link_ele - def generate_sliding_section(self, name, width, x_offset, bounds, options): - self.generate_section(name, width, x_offset, options) + def generate_sliding_section(self, name, width, x_offset, bounds): + self.generate_section(name, width, x_offset) self.model_ele.append(joint(f'{name}_joint', 'prismatic', @@ -83,10 +83,9 @@ def generate_swing_section( x_offset, bounds, axis_pose, - axis, - options + axis ): - self.generate_section(name, width, x_offset, options) + self.generate_section(name, width, x_offset) pose_ele = Element('pose') pose_ele.text = f'{axis_pose[0]} {axis_pose[1]} {axis_pose[2]} 0 0 0' diff --git a/rmf_building_map_tools/building_map/doors/double_sliding_door.py b/rmf_building_map_tools/building_map/doors/double_sliding_door.py index 00132f699..58af6605a 100644 --- a/rmf_building_map_tools/building_map/doors/double_sliding_door.py +++ b/rmf_building_map_tools/building_map/doors/double_sliding_door.py @@ -9,7 +9,7 @@ def __init__(self, door_edge, level_elevation): if 'right_left_ratio' in door_edge.params: self.right_left_ratio = door_edge.params['right_left_ratio'].value - def generate(self, world_ele, options): + def generate(self, world_ele): right_segment_length = \ (self.right_left_ratio / (1 + self.right_left_ratio)) * self.length left_segment_length = self.length - right_segment_length @@ -18,15 +18,13 @@ def generate(self, world_ele, options): 'right', right_segment_length - 0.01, self.length / 2 - right_segment_length / 2, - (0.0, right_segment_length), - options) + (0.0, right_segment_length)) self.generate_sliding_section( 'left', left_segment_length - 0.01, -self.length / 2 + left_segment_length / 2, - (-left_segment_length, 0.0), - options) + (-left_segment_length, 0.0)) if not self.plugin == 'none': plugin_ele = SubElement(self.model_ele, 'plugin') diff --git a/rmf_building_map_tools/building_map/doors/double_swing_door.py b/rmf_building_map_tools/building_map/doors/double_swing_door.py index d768849f7..c3b65c17f 100644 --- a/rmf_building_map_tools/building_map/doors/double_swing_door.py +++ b/rmf_building_map_tools/building_map/doors/double_swing_door.py @@ -12,7 +12,7 @@ def __init__(self, door_edge, level_elevation): if 'right_left_ratio' in door_edge.params: self.right_left_ratio = door_edge.params['right_left_ratio'].value - def generate(self, world_ele, options): + def generate(self, world_ele): right_segment_length = \ (self.right_left_ratio / (1 + self.right_left_ratio)) * self.length left_segment_length = self.length - right_segment_length @@ -34,8 +34,7 @@ def generate(self, world_ele, options): x_offsets[0], bounds[0], axis_pose[0], - axis, - options) + axis) self.generate_swing_section( 'left', @@ -43,8 +42,7 @@ def generate(self, world_ele, options): x_offsets[1], bounds[1], axis_pose[1], - axis, - options) + axis) if not self.plugin == 'none': plugin_ele = SubElement(self.model_ele, 'plugin') diff --git a/rmf_building_map_tools/building_map/doors/sliding_door.py b/rmf_building_map_tools/building_map/doors/sliding_door.py index ab93f2291..adec3cb04 100644 --- a/rmf_building_map_tools/building_map/doors/sliding_door.py +++ b/rmf_building_map_tools/building_map/doors/sliding_door.py @@ -6,13 +6,12 @@ class SlidingDoor(Door): def __init__(self, door_edge, level_elevation): super().__init__(door_edge, level_elevation) - def generate(self, world_ele, options): + def generate(self, world_ele): self.generate_sliding_section( 'right', self.length - 0.01, 0, - (0.0, self.length), - options) + (0.0, self.length)) if not self.plugin == 'none': plugin_ele = SubElement(self.model_ele, 'plugin') diff --git a/rmf_building_map_tools/building_map/doors/swing_door.py b/rmf_building_map_tools/building_map/doors/swing_door.py index dcf3ef700..e7abe2486 100644 --- a/rmf_building_map_tools/building_map/doors/swing_door.py +++ b/rmf_building_map_tools/building_map/doors/swing_door.py @@ -9,7 +9,7 @@ def __init__(self, door_edge, level_elevation): self.motion_radians = 3.14 * motion_degrees / 180.0 self.motion_direction = door_edge.params['motion_direction'].value - def generate(self, world_ele, options): + def generate(self, world_ele): # This is configured to be negative by default to reflect how it is # rendered on rmf_traffic_editor. axis = 'z' if self.motion_direction < 0 else '-z' @@ -20,8 +20,7 @@ def generate(self, world_ele, options): 0, (0, self.motion_radians), (self.length / 2, 0, 0), - axis, - options) + axis) if not self.plugin == 'none': plugin_ele = SubElement(self.model_ele, 'plugin') diff --git a/rmf_building_map_tools/building_map/generator.py b/rmf_building_map_tools/building_map/generator.py index ec50a240c..f47d5afa1 100644 --- a/rmf_building_map_tools/building_map/generator.py +++ b/rmf_building_map_tools/building_map/generator.py @@ -21,8 +21,7 @@ def generate_sdf( self, input_filename, output_filename, - output_models_dir, - options + output_models_dir) ): print('generating {} from {}'.format(output_filename, input_filename)) @@ -41,7 +40,7 @@ def generate_sdf( building.generate_sdf_models(output_models_dir) # generate a top-level SDF for convenience - sdf = building.generate_sdf_world(options) + sdf = building.generate_sdf_world() indent_etree(sdf) sdf_str = str(ElementToString(sdf), 'utf-8') @@ -49,32 +48,6 @@ def generate_sdf( f.write(sdf_str) print(f'{len(sdf_str)} bytes written to {output_filename}') - def generate_gazebo_sdf( - self, - input_filename, - output_filename, - output_models_dir, - options - ): - self.generate_sdf( - input_filename, - output_filename, - output_models_dir, - options + ['gazebo']) - - def generate_ignition_sdf( - self, - input_filename, - output_filename, - output_models_dir, - options - ): - self.generate_sdf( - input_filename, - output_filename, - output_models_dir, - options + ['ignition']) - def generate_nav(self, input_filename, output_dir): building = self.parse_editor_yaml(input_filename) nav_graphs = building.generate_nav_graphs() diff --git a/rmf_building_map_tools/building_map/level.py b/rmf_building_map_tools/building_map/level.py index 66b036aea..71b00b6a3 100644 --- a/rmf_building_map_tools/building_map/level.py +++ b/rmf_building_map_tools/building_map/level.py @@ -256,12 +256,12 @@ def generate_sdf_models(self, world_ele): if 'spawn_robot_type' in vertex.params: self.generate_robot_at_vertex_idx(vertex_idx, world_ele) - def generate_doors(self, world_ele, options): + def generate_doors(self, world_ele): for door_edge in self.doors: door_edge.calc_statistics(self.transformed_vertices) - self.generate_door(door_edge, world_ele, options) + self.generate_door(door_edge, world_ele) - def generate_door(self, door_edge, world_ele, options): + def generate_door(self, door_edge, world_ele): door_name = door_edge.params['name'].value door_type = door_edge.params['type'].value print(f'generate door name={door_name} type={door_type}') @@ -279,7 +279,7 @@ def generate_door(self, door_edge, world_ele, options): print(f'door type {door_type} not yet implemented') if door: - door.generate(world_ele, options) + door.generate(world_ele) def generate_robot_at_vertex_idx(self, vertex_idx, world_ele): vertex = self.transformed_vertices[vertex_idx] diff --git a/rmf_building_map_tools/building_map/lift.py b/rmf_building_map_tools/building_map/lift.py index 2002c25e0..22fc7ec76 100644 --- a/rmf_building_map_tools/building_map/lift.py +++ b/rmf_building_map_tools/building_map/lift.py @@ -333,7 +333,7 @@ def generate_wall(self, side, pair, name, platform): platform.append(visual(f'{name}_visual', pose, dims, lift_material())) platform.append(collision(f'{name}_collision', pose, dims, '0x01')) - def generate_cabin(self, world_ele, options): + def generate_cabin(self, world_ele): # materials missing for now lift_model_name = f'{self.name}' lift_model_ele = SubElement(world_ele, 'model') diff --git a/rmf_building_map_tools/building_map/templates/gz_world.sdf b/rmf_building_map_tools/building_map/templates/gz_world.sdf index 7dc243700..e8e959acf 100644 --- a/rmf_building_map_tools/building_map/templates/gz_world.sdf +++ b/rmf_building_map_tools/building_map/templates/gz_world.sdf @@ -1,21 +1,296 @@ - + + + 0.01 + 1.0 + + + + + + + + + + + + - 0.8 0.8 0.8 1.0 - 0 0 0 + 1 1 1 + 0.8 0.8 0.8 false - - model://sun - + + + + 1000 + 845 +