From 02e2544007753f812a6716ce3645bf047e8f1e50 Mon Sep 17 00:00:00 2001 From: wangWking <842749351@qq.com> Date: Thu, 31 Oct 2024 11:48:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BD=E4=BA=A7280JN?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BD=BF=E7=94=A8ROS1=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mycobot_280/mycobot_280jn/scripts/slider_control.py | 5 +++-- mycobot_280/mycobot_280jn/scripts/slider_control_gripper.py | 3 ++- .../scripts/slider_control_parallel_gripper.py | 3 ++- .../mycobot_280jn_gripper_moveit/scripts/sync_plan.py | 3 ++- mycobot_communication/scripts/mycobot_services.py | 6 ++++++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mycobot_280/mycobot_280jn/scripts/slider_control.py b/mycobot_280/mycobot_280jn/scripts/slider_control.py index 3157e70..6fe105e 100755 --- a/mycobot_280/mycobot_280jn/scripts/slider_control.py +++ b/mycobot_280/mycobot_280jn/scripts/slider_control.py @@ -34,8 +34,7 @@ def callback(data): def listener(): global mc rospy.init_node("control_slider", anonymous=True) - - rospy.Subscriber("joint_states", JointState, callback) + port = rospy.get_param("~port", "/dev/ttyTHS1") baud = rospy.get_param("~baud", 1000000) print(port, baud) @@ -44,6 +43,8 @@ def listener(): mc.set_fresh_mode(1) time.sleep(0.05) + rospy.Subscriber("joint_states", JointState, callback) + # spin() simply keeps python from exiting until this node is stopped # spin()只是阻止python退出,直到该节点停止 print("spin ...") diff --git a/mycobot_280/mycobot_280jn/scripts/slider_control_gripper.py b/mycobot_280/mycobot_280jn/scripts/slider_control_gripper.py index d789797..bfdf971 100755 --- a/mycobot_280/mycobot_280jn/scripts/slider_control_gripper.py +++ b/mycobot_280/mycobot_280jn/scripts/slider_control_gripper.py @@ -38,7 +38,6 @@ def listener(): global mc rospy.init_node("control_slider", anonymous=True) - rospy.Subscriber("joint_states", JointState, callback) port = rospy.get_param("~port", "/dev/ttyTHS1") baud = rospy.get_param("~baud", 1000000) print(port, baud) @@ -46,6 +45,8 @@ def listener(): time.sleep(0.05) mc.set_fresh_mode(1) time.sleep(0.05) + + rospy.Subscriber("joint_states", JointState, callback) # spin() simply keeps python from exiting until this node is stopped # spin()只是阻止python退出,直到该节点停止 diff --git a/mycobot_280/mycobot_280jn/scripts/slider_control_parallel_gripper.py b/mycobot_280/mycobot_280jn/scripts/slider_control_parallel_gripper.py index 48dba13..93cb525 100644 --- a/mycobot_280/mycobot_280jn/scripts/slider_control_parallel_gripper.py +++ b/mycobot_280/mycobot_280jn/scripts/slider_control_parallel_gripper.py @@ -39,7 +39,6 @@ def listener(): global mc rospy.init_node("control_slider", anonymous=True) - rospy.Subscriber("joint_states", JointState, callback) port = rospy.get_param("~port", "/dev/ttyTHS1") baud = rospy.get_param("~baud", 1000000) print(port, baud) @@ -48,6 +47,8 @@ def listener(): mc.set_fresh_mode(1) time.sleep(0.05) + rospy.Subscriber("joint_states", JointState, callback) + # spin() simply keeps python from exiting until this node is stopped # spin()只是阻止python退出,直到该节点停止 print("spin ...") diff --git a/mycobot_280/mycobot_280jn_gripper_moveit/scripts/sync_plan.py b/mycobot_280/mycobot_280jn_gripper_moveit/scripts/sync_plan.py index d789797..bfdf971 100644 --- a/mycobot_280/mycobot_280jn_gripper_moveit/scripts/sync_plan.py +++ b/mycobot_280/mycobot_280jn_gripper_moveit/scripts/sync_plan.py @@ -38,7 +38,6 @@ def listener(): global mc rospy.init_node("control_slider", anonymous=True) - rospy.Subscriber("joint_states", JointState, callback) port = rospy.get_param("~port", "/dev/ttyTHS1") baud = rospy.get_param("~baud", 1000000) print(port, baud) @@ -46,6 +45,8 @@ def listener(): time.sleep(0.05) mc.set_fresh_mode(1) time.sleep(0.05) + + rospy.Subscriber("joint_states", JointState, callback) # spin() simply keeps python from exiting until this node is stopped # spin()只是阻止python退出,直到该节点停止 diff --git a/mycobot_communication/scripts/mycobot_services.py b/mycobot_communication/scripts/mycobot_services.py index 4124cbe..3002624 100755 --- a/mycobot_communication/scripts/mycobot_services.py +++ b/mycobot_communication/scripts/mycobot_services.py @@ -97,6 +97,9 @@ def get_angles(req): lock = acquire("/tmp/mycobot_lock") angles = mc.get_angles() release(lock) + if angles is None: + rospy.logwarn('angles is None, no angle data') + return GetAnglesResponse() return GetAnglesResponse(*angles) @@ -125,6 +128,9 @@ def get_coords(req): lock = acquire("/tmp/mycobot_lock") coords = mc.get_coords() release(lock) + if coords is None: + rospy.logwarn('coords is None, no coord data') + return GetCoordsResponse() return GetCoordsResponse(*coords)