Beispiel #1
0
    async def send_goal(self):
        self.get_logger().info('Waiting for action server...')
        self._action_client.wait_for_server()

        goal_msg = Fibonacci.Goal()
        goal_msg.order = 10

        self.get_logger().info('Sending goal request...')

        goal_handle = await self._action_client.send_goal_async(
            goal_msg, feedback_callback=self.feedback_callback)

        if not goal_handle.accepted:
            self.get_logger().info('Goal rejected :(')
            return

        self.get_logger().info('Goal accepted :)')

        res = await goal_handle.get_result_async()
        result = res.result
        status = res.status
        if status == GoalStatus.STATUS_SUCCEEDED:
            self.get_logger().info('Goal succeeded! Result: {0}'.format(
                result.sequence))
        else:
            self.get_logger().info(
                'Goal failed with status: {0}'.format(status))
        return result, status
Beispiel #2
0
    def send_goal(self):
        self.get_logger().info('waiting...')
        self._action_client.wait_for_server()
        goal_msg = Fibonacci.Goal()
        goal_msg.order = 10

        self._send_goal_future = self._action_client.send_goal_async(
            goal_msg, feedback_callback=self.feedback_callback)
        self._send_goal_future.add_done_callback(self.goal_response_callback)
Beispiel #3
0
 def send_goal(self):
     self.get_logger().info('waiting...')
     self._action_client.wait_for_server()
     # 10要素のフィボナッチ数列を標値に設定
     goal_msg = Fibonacci.Goal()
     goal_msg.order = 10
     # アクションの非同期実行
     # (フィードバックと実行結果の受信コールバック関数も設定)
     self._send_goal_future = self._action_client.send_goal_async(
         goal_msg, feedback_callback=self.feedback_callback)
     self._send_goal_future.add_done_callback(
         self.goal_response_callback)
Beispiel #4
0
def main(args=None):
    rclpy.init(args=args)

    node = rclpy.create_node('minimal_action_client')

    action_client = ActionClient(node, Fibonacci, 'fibonacci')

    node.get_logger().info('Waiting for action server...')

    action_client.wait_for_server()

    goal_msg = Fibonacci.Goal()
    goal_msg.order = 10

    node.get_logger().info('Sending goal request...')

    send_goal_future = action_client.send_goal_async(
        goal_msg,
        feedback_callback=lambda feedback: feedback_cb(node.get_logger(),
                                                       feedback))

    rclpy.spin_until_future_complete(node, send_goal_future)

    goal_handle = send_goal_future.result()

    if not goal_handle.accepted:
        node.get_logger().info('Goal rejected :(')
        action_client.destroy()
        node.destroy_node()
        rclpy.shutdown()
        return

    node.get_logger().info('Goal accepted :)')

    get_result_future = goal_handle.get_result_async()

    rclpy.spin_until_future_complete(node, get_result_future)

    result = get_result_future.result().result
    status = get_result_future.result().status
    if status == GoalStatus.STATUS_SUCCEEDED:
        node.get_logger().info('Goal succeeded! Result: {0}'.format(
            result.sequence))
    else:
        node.get_logger().info(
            'Goal failed with status code: {0}'.format(status))

    action_client.destroy()
    node.destroy_node()
    rclpy.shutdown()
    def send_goal(self, order):
        # self.get_logger().info('Waiting for action server '+self._server_name)
        print('Waiting for action server ' + self._server_name)
        self._action_client.wait_for_server()

        goal_msg = Fibonacci.Goal()
        goal_msg.order = order

        # self.get_logger().info('Sending goal request to '+self._server_name)
        print('Sending goal request to ' + self._server_name)

        self._send_goal_future = self._action_client.send_goal_async(
            goal_msg, feedback_callback=self.feedback_callback)

        self._send_goal_future.add_done_callback(self.goal_response_callback)
Beispiel #6
0
    def send_goal(self):
        self.logger.info('waiting...')

        while not self._cli.wait_for_server(timeout_sec=1.0):
            self.logger.info("Waiting for \"fibonacci\" server...")

        # 10要素のフィボナッチ数列を標値に設定
        goal_msg = Fibonacci.Goal()
        goal_msg.order = 10
        # アクションの非同期実行
        # (フィードバックと実行結果の受信コールバック関数も設定)

        goal = goal_msg
        feedback_callback = self._feedback_callback
        self._goal_future = self._cli.send_goal_async(goal, feedback_callback)
        callback = self._goal_response_callback
        self._goal_future.add_done_callback(callback)