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