mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-05 19:47:04 +00:00
feat: add listen plan exec script.
This commit is contained in:
parent
215ce256b2
commit
13ced40a6f
1 changed files with 31 additions and 0 deletions
31
scripts/sync_signal.py
Executable file
31
scripts/sync_signal.py
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python2
|
||||
import time, subprocess
|
||||
import rospy
|
||||
from sensor_msgs.msg import JointState
|
||||
|
||||
from pymycobot.mycobot import MyCobot
|
||||
|
||||
|
||||
def callback(data):
|
||||
rospy.loginfo(rospy.get_caller_id() + "%s", data)
|
||||
data_list = []
|
||||
for index, value in enumerate(data.position):
|
||||
# if index != 2:
|
||||
# value *= -1
|
||||
data_list.append(value)
|
||||
|
||||
mc.send_radians(data_list, 80)
|
||||
|
||||
def listener():
|
||||
rospy.init_node('mycobot_reciver', anonymous=True)
|
||||
|
||||
rospy.Subscriber("joint_states", JointState, callback)
|
||||
|
||||
# spin() simply keeps python from exiting until this node is stopped
|
||||
rospy.spin()
|
||||
|
||||
if __name__ == '__main__':
|
||||
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
|
||||
shell=True)
|
||||
mc = MyCobot(port)
|
||||
listener()
|
||||
Loading…
Add table
Reference in a new issue