Skip to content

Commit

Permalink
Fix for issue #462 (#508)
Browse files Browse the repository at this point in the history
* 🔨 Explicit cast waypoint name in building_map_server.py to avoid ROS 2 message Assertion Error.

Signed-off-by: Bey Hao Yun <[email protected]>

* 🔨 Refactored with new function, create_graph_node, in building_map_server.py.

Signed-off-by: Bey Hao Yun <[email protected]>

---------

Signed-off-by: Bey Hao Yun <[email protected]>
Co-authored-by: Luca Della Vedova <[email protected]>
  • Loading branch information
cardboardcode and luca-della-vedova authored Sep 17, 2024
1 parent be0240e commit 2dd298a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions rmf_building_map_tools/building_map_server/building_map_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ def level_msg(self, level):
graph_msg.name = str(i) # todo: someday, string names...
print(f"graph {i} has {len(g['vertices'])} vertices")
for v in g['vertices']:
gn = GraphNode()
gn.x = v[0]
gn.y = v[1]
gn.name = v[2]['name']
gn = self.create_graph_node(v[0], v[1], v[2]['name'])

# add specific params to builidng_map_msg
for str_param in ["dock_name",
Expand Down Expand Up @@ -245,10 +242,7 @@ def level_msg(self, level):
wall_graph = level.generate_wall_graph()
msg.wall_graph.name = "WallGraph"
for v in wall_graph['vertices']:
gn = GraphNode()
gn.x = v[0]
gn.y = v[1]
gn.name = v[2]['name']
gn = self.create_graph_node(v[0], v[1], v[2]['name'])

# Ignore any other vertex params - not needed for wall graph
msg.wall_graph.vertices.append(gn)
Expand Down Expand Up @@ -324,6 +318,14 @@ def get_building_map(self, request, response):
response.building_map = self.map_msg
return response

def create_graph_node(self, wp_x, wp_y, wp_name):
gn = GraphNode()
gn.x = wp_x
gn.y = wp_y
gn.name = str(wp_name)

return gn


def main():
if len(sys.argv) > 1:
Expand Down

0 comments on commit 2dd298a

Please sign in to comment.