Skip to content

Commit

Permalink
修复国产280JN系统使用ROS1报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wangWking committed Oct 31, 2024
1 parent 29b0567 commit 02e2544
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions mycobot_280/mycobot_280jn/scripts/slider_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ...")
Expand Down
3 changes: 2 additions & 1 deletion mycobot_280/mycobot_280jn/scripts/slider_control_gripper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ 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)
mc = MyCobot(port, baud)
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退出,直到该节点停止
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ...")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ 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)
mc = MyCobot(port, baud)
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退出,直到该节点停止
Expand Down
6 changes: 6 additions & 0 deletions mycobot_communication/scripts/mycobot_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit 02e2544

Please sign in to comment.