Exemplo n.º 1
0
def get_available_states(lifecycle_node):
    node = rclpy.create_node('lc_client_py')

    cli = node.create_client(GetAvailableStates, lifecycle_node + '/get_available_states')
    req = GetAvailableStates.Request()
    cli.call(req)
    cli.wait_for_future()
    print('%s has %u available states' % (lifecycle_node, len(cli.response.available_states)))
    for state in cli.response.available_states:
        print('id: %u\tlabel: %s' % (state.id, state.label))
Exemplo n.º 2
0
def get_available_states(lifecycle_node):
    node = rclpy.create_node('lc_client_py')

    service_name = lifecycle_node + '/get_available_states'
    cli = node.create_client(GetAvailableStates, service_name)
    if not cli.wait_for_service(timeout_sec=5.0):
        node.get_logger().warn('Unable to call service %s' % service_name)
        return

    req = GetAvailableStates.Request()
    cli.call(req)
    cli.wait_for_future()
    node.get_logger().info(
        '%s has %u available states' %
        (lifecycle_node, len(cli.response.available_states)))
    for state in cli.response.available_states:
        node.get_logger().info('id: %u\tlabel: %s' % (state.id, state.label))
Exemplo n.º 3
0
def get_available_states(lifecycle_node):
    node = rclpy.create_node('lc_client_py')

    service_name = lifecycle_node + '/get_available_states'
    cli = node.create_client(GetAvailableStates, service_name)
    if not cli.wait_for_service(timeout_sec=5.0):
        node.get_logger().warn('Unable to call service %s' % service_name)
        return

    req = GetAvailableStates.Request()
    future = cli.call_async(req)
    rclpy.spin_until_future_complete(node, future)
    if future.result() is not None:
        resp = future.result()
        node.get_logger().info('%s has %u available states' %
                               (lifecycle_node, len(resp.available_states)))
        for state in resp.available_states:
            node.get_logger().info('id: %u\tlabel: %s' %
                                   (state.id, state.label))
    else:
        node.get_logger.error('Exception %r during call %s' %
                              (future.exception(), service_name))