mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-05 19:47:04 +00:00
change sync_plan.py
This commit is contained in:
parent
753fb1944d
commit
4e8a1e4155
1 changed files with 14 additions and 13 deletions
|
|
@ -248,6 +248,7 @@ old_list = []
|
|||
|
||||
def callback(data):
|
||||
"""callback function,回调函数"""
|
||||
satrt_time=time.time()
|
||||
global old_list
|
||||
# rospy.loginfo(rospy.get_caller_id() + "%s", data.position)
|
||||
print ("position", data.position)
|
||||
|
|
@ -262,33 +263,33 @@ def callback(data):
|
|||
mc.write_angles(data_list, 1999)
|
||||
elif old_list != data_list:
|
||||
old_list = data_list
|
||||
if mc.check_running():
|
||||
mc.task_stop()
|
||||
time.sleep(0.05)
|
||||
# if mc.check_running():
|
||||
# mc.task_stop()
|
||||
# time.sleep(0.05)
|
||||
|
||||
mc.write_angles(data_list, 1999)
|
||||
|
||||
end_time=time.time()
|
||||
print('loop_time:',end_time-satrt_time)
|
||||
|
||||
def listener():
|
||||
global mc
|
||||
rospy.init_node("control_slider", anonymous=True)
|
||||
|
||||
ip = rospy.get_param("~ip", "192.168.10.66")
|
||||
ip = rospy.get_param("~ip", "192.168.10.159")
|
||||
print (ip)
|
||||
mc = ElephantRobot(ip, 5001)
|
||||
# START CLIENT,启动客户端
|
||||
res = mc.start_client()
|
||||
if res != "":
|
||||
print res
|
||||
print ('start_client->',res)
|
||||
sys.exit(1)
|
||||
print ep.wait(5)
|
||||
print mc.get_angles()
|
||||
print mc.get_coords()
|
||||
mc.set_speed(30)
|
||||
print mc.get_speed()
|
||||
# print ep.wait(5)
|
||||
# print mc.get_angles()
|
||||
# print mc.get_coords()
|
||||
mc.set_speed(90)
|
||||
# print mc.get_speed()
|
||||
|
||||
rospy.Subscriber("joint_states", JointState, callback)
|
||||
|
||||
# spin() simply keeps python from exiting until this node is stopped
|
||||
# spin()只是阻止python退出,直到该节点停止
|
||||
print ("sping ...")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue