Skip to content

Commit

Permalink
comply with new node representation (#149)
Browse files Browse the repository at this point in the history
* comply with new node representation

* python oneliner

* get_node_names return full struct
  • Loading branch information
Karsten1987 committed Sep 12, 2018
1 parent ce9077f commit 54749d2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions ros2lifecycle/ros2lifecycle/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def get_node_names(*, node, include_hidden_nodes=False):
service_names_and_types = get_service_names_and_types(node=node)
return [
n for n in node_names
if _has_lifecycle(n, service_names_and_types)]
if _has_lifecycle(n.full_name, service_names_and_types)]


def _has_lifecycle(node_name, service_names_and_types):
for (service_name, service_types) in service_names_and_types:
if (
service_name == '/{node_name}/get_state'.format_map(locals()) and
service_name == '{node_name}/get_state'.format_map(locals()) and
'lifecycle_msgs/GetState' in service_types
):
return True
Expand All @@ -48,7 +48,7 @@ def call_get_states(*, node, node_names):
for node_name in node_names:
client = node.create_client(
GetState,
'/{node_name}/get_state'.format_map(locals()))
'{node_name}/get_state'.format_map(locals()))
clients[node_name] = client

# wait until all clients have been called
Expand Down Expand Up @@ -88,7 +88,7 @@ def call_get_available_transitions(*, node, states):
for node_name in states.keys():
client = node.create_client(
GetAvailableTransitions,
'/{node_name}/get_available_transitions'.format_map(locals()))
'{node_name}/get_available_transitions'.format_map(locals()))
clients[node_name] = client

# wait until all clients have been called
Expand Down Expand Up @@ -135,7 +135,7 @@ def call_change_states(*, node, transitions):
for node_name in transitions.keys():
client = node.create_client(
ChangeState,
'/{node_name}/change_state'.format_map(locals()))
'{node_name}/change_state'.format_map(locals()))
clients[node_name] = client

# wait until all clients have been called
Expand Down
2 changes: 1 addition & 1 deletion ros2lifecycle/ros2lifecycle/verb/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main(self, *, args): # noqa: D102
node=node, include_hidden_nodes=args.include_hidden_nodes)

if args.node_name:
if args.node_name not in node_names:
if args.node_name not in {n.full_name for n in node_names}:
return 'Node not found'
node_names = [args.node_name]

Expand Down
2 changes: 1 addition & 1 deletion ros2lifecycle/ros2lifecycle/verb/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def main(self, *, args): # noqa: D102
if args.count_nodes:
print(len(node_names))
elif node_names:
print(*node_names, sep='\n')
print(*{n.full_name for n in node_names}, sep='\n')
2 changes: 1 addition & 1 deletion ros2lifecycle/ros2lifecycle/verb/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main(self, *, args): # noqa: D102
node_names = get_node_names(
node=node, include_hidden_nodes=args.include_hidden_nodes)

if args.node_name not in node_names:
if args.node_name not in {n.full_name for n in node_names}:
return 'Node not found'

with DirectNode(args) as node:
Expand Down

0 comments on commit 54749d2

Please sign in to comment.