From 2eadf0d43de42d8247debe96e5c789353594cca7 Mon Sep 17 00:00:00 2001 From: Loy van Beek Date: Fri, 5 May 2023 11:12:12 +0200 Subject: [PATCH 1/3] Add test client to trigger bug in action_bridge. Not happened yet --- scripts/ros1_action_client.py | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 scripts/ros1_action_client.py diff --git a/scripts/ros1_action_client.py b/scripts/ros1_action_client.py new file mode 100755 index 00000000..7091dffd --- /dev/null +++ b/scripts/ros1_action_client.py @@ -0,0 +1,57 @@ +#! /usr/bin/env python3 + +from __future__ import print_function + +import sys +import random + +import rospy +# Brings in the SimpleActionClient +import actionlib + +# Brings in the messages used by the fibonacci action, including the +# goal message and the result message. +from action_tutorials_interfaces.msg import FibonacciAction, FibonacciGoal, FibonacciFeedback + + +class FibClient: + + def __init__(self): + # Creates the SimpleActionClient, passing the type of the action + # (FibonacciAction) to the constructor. + self._ac = actionlib.SimpleActionClient('fibonacci', FibonacciAction) + + # Waits until the action server has started up and started + # listening for goals. + self._ac.wait_for_server() + + def run(self): + # Creates a goal to send to the action server. + goal = FibonacciGoal(order=20) + + # Sends the goal to the action server. + self._ac.send_goal(goal, feedback_cb=self.accept_feedback) + + # Waits for the server to finish performing the action. + self._ac.wait_for_result() + + # Prints out the result of executing the action + return self._ac.get_result() # A FibonacciResult + + def accept_feedback(self, feedback: FibonacciFeedback): + rospy.loginfo(f"Got feedback: {feedback}") + if random.randint(0, 1): + rospy.loginfo("Randomly aborting") + self._ac.cancel_all_goals() + +if __name__ == '__main__': + try: + # Initializes a rospy node so that the SimpleActionClient can + # publish and subscribe over ROS. + rospy.init_node('fibonacci_client_py') + client = FibClient() + for i in range(1000): + result = client.run() + print(f"Result {i}:", ', '.join([str(n) for n in result.sequence])) + except rospy.ROSInterruptException: + print("program interrupted before completion", file=sys.stderr) \ No newline at end of file From 6325cc5d5b295f2ad376e60b10ccd7d07c346669 Mon Sep 17 00:00:00 2001 From: Loy van Beek Date: Mon, 8 May 2023 13:57:45 +0200 Subject: [PATCH 2/3] Add dummy server to htry and trigger error on action_bridge --- scripts/ros2_action_server.py | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 scripts/ros2_action_server.py diff --git a/scripts/ros2_action_server.py b/scripts/ros2_action_server.py new file mode 100755 index 00000000..3665a714 --- /dev/null +++ b/scripts/ros2_action_server.py @@ -0,0 +1,53 @@ +#! /usr/bin/env python3 + +import time + +import rclpy +from rclpy.action import ActionServer +from rclpy.node import Node + +from action_tutorials_interfaces.action import Fibonacci + + +class FibonacciActionServer(Node): + + def __init__(self): + super().__init__('fibonacci_action_server') + self._action_server = ActionServer( + self, + Fibonacci, + 'fibonacci', + self.execute_callback) + + def execute_callback(self, goal_handle): + self.get_logger().info('Executing goal...') + + feedback_msg = Fibonacci.Feedback() + feedback_msg.partial_sequence = [0, 1] + + for i in range(1, goal_handle.request.order): + feedback_msg.partial_sequence.append( + feedback_msg.partial_sequence[i] + feedback_msg.partial_sequence[i-1]) + self.get_logger().info('Feedback: {0}'.format(feedback_msg.partial_sequence)) + goal_handle.publish_feedback(feedback_msg) + # time.sleep(0.001) + goal_handle.abort() + break + time.sleep(1) + # goal_handle.succeed() + + result = Fibonacci.Result() + result.sequence = feedback_msg.partial_sequence + return result + + +def main(args=None): + rclpy.init(args=args) + + fibonacci_action_server = FibonacciActionServer() + + rclpy.spin(fibonacci_action_server) + + +if __name__ == '__main__': + main() \ No newline at end of file From 607f15dfa9984ff7337dee7fc94d7ffa8283b511 Mon Sep 17 00:00:00 2001 From: Loy van Beek Date: Mon, 8 May 2023 14:22:37 +0200 Subject: [PATCH 3/3] Don't randomly abort actions early, doesn't trigger the bug either --- scripts/debug.yaml | 34 ++++++++++++++++++++++++++++++++++ scripts/ros1_action_client.py | 6 +++--- scripts/ros2_action_server.py | 8 ++++---- 3 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 scripts/debug.yaml diff --git a/scripts/debug.yaml b/scripts/debug.yaml new file mode 100644 index 00000000..b0857ae6 --- /dev/null +++ b/scripts/debug.yaml @@ -0,0 +1,34 @@ +timeout: 240 # how long to wait for the host + +hosts: + localhost: # the hostname of the machine + os: linux # the operating system of the host + user: $USER # the user to be used + port: 22 # the port that is checked to determine if a service on the host already up + # if port is not defined, the check is disabled + check_nfs: false # wait for the nfs mount to be available on the localhost. If not defined + # the check is disabled (only for linux os) + +sessions: + roscore: + host: localhost + user: $USER + command: "source_amr_ros1 && roscore" + prio: 0 + locked: true + wait_for_core: false + server_ros2: + host: localhost + user: $USER + command: "source_amr_ros2 && cd ~/git/amr_ros2_interfaces_ws/src/ros1_bridge/scripts && ./ros2_action_server.py" + prio: 0 + client_ros1: + host: localhost + user: $USER + command: "source_amr_ros1 && cd ~/git/amr_ros2_interfaces_ws/src/ros1_bridge/scripts && ./ros1_action_client.py" + prio: 0 + ab_exec_tj: + host: localhost + user: $USER + command: "source_amr_ros_bridge && ros2 run ros1_bridge action_bridge ros2 action_tutorials_interfaces action/Fibonacci fibonacci" + prio: 2 diff --git a/scripts/ros1_action_client.py b/scripts/ros1_action_client.py index 7091dffd..9b18e9cb 100755 --- a/scripts/ros1_action_client.py +++ b/scripts/ros1_action_client.py @@ -40,9 +40,9 @@ def run(self): def accept_feedback(self, feedback: FibonacciFeedback): rospy.loginfo(f"Got feedback: {feedback}") - if random.randint(0, 1): - rospy.loginfo("Randomly aborting") - self._ac.cancel_all_goals() + # if random.randint(0, 1): + # rospy.loginfo("Randomly aborting") + # self._ac.cancel_all_goals() if __name__ == '__main__': try: diff --git a/scripts/ros2_action_server.py b/scripts/ros2_action_server.py index 3665a714..f8f792b6 100755 --- a/scripts/ros2_action_server.py +++ b/scripts/ros2_action_server.py @@ -30,10 +30,10 @@ def execute_callback(self, goal_handle): feedback_msg.partial_sequence[i] + feedback_msg.partial_sequence[i-1]) self.get_logger().info('Feedback: {0}'.format(feedback_msg.partial_sequence)) goal_handle.publish_feedback(feedback_msg) - # time.sleep(0.001) - goal_handle.abort() - break - time.sleep(1) + time.sleep(0.1) + # goal_handle.abort() + # break + # time.sleep(1) # goal_handle.succeed() result = Fibonacci.Result()