mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-05 19:47:04 +00:00
refactor: modify for new api, fix control_marker.py bug
This commit is contained in:
parent
411a2a4c65
commit
1995275b83
5 changed files with 26 additions and 19 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python2
|
||||
# from std_msgs.msg import String
|
||||
import time
|
||||
import time, subprocess
|
||||
|
||||
import rospy
|
||||
from interactive_markers.interactive_marker_server import *
|
||||
|
|
@ -210,21 +210,24 @@ def listener():
|
|||
joint_state_send.header.stamp = rospy.Time.now()
|
||||
|
||||
angles = mycobot.get_angles_of_radian()
|
||||
data_list = []
|
||||
for index, value in enumerate(angles):
|
||||
if index != 2:
|
||||
value *= -1
|
||||
data_list.append(value)
|
||||
rospy.loginfo(angles)
|
||||
if angles:
|
||||
data_list = []
|
||||
for index, value in enumerate(angles):
|
||||
if index != 2:
|
||||
value *= -1
|
||||
data_list.append(value)
|
||||
|
||||
rospy.loginfo(data_list)
|
||||
|
||||
joint_state_send.position = data_list
|
||||
|
||||
joint_state_send.position = data_list
|
||||
|
||||
pub.publish(joint_state_send)
|
||||
pub.publish(joint_state_send)
|
||||
|
||||
rate.sleep()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mycobot = MyCobot()
|
||||
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
|
||||
shell=True)
|
||||
mycobot = MyCobot(port)
|
||||
listener()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python2
|
||||
# from std_msgs.msg import String
|
||||
import time
|
||||
import time, subprocess
|
||||
|
||||
import rospy
|
||||
from sensor_msgs.msg import JointState
|
||||
|
|
@ -29,5 +29,7 @@ def listener():
|
|||
rospy.spin()
|
||||
|
||||
if __name__ == '__main__':
|
||||
mc = MyCobot()
|
||||
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
|
||||
shell=True)
|
||||
mc = MyCobot(port)
|
||||
listener()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python2
|
||||
# license removed for brevity
|
||||
import time
|
||||
import time, subprocess
|
||||
|
||||
import rospy
|
||||
from sensor_msgs.msg import JointState
|
||||
|
|
@ -77,7 +77,9 @@ def talker():
|
|||
rate.sleep()
|
||||
|
||||
if __name__ == '__main__':
|
||||
mycobot = MyCobot()
|
||||
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
|
||||
shell=True)
|
||||
mycobot = MyCobot(port)
|
||||
try:
|
||||
talker()
|
||||
except rospy.ROSInterruptException:
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class MyCobot():
|
|||
# print(command)
|
||||
self._write(command)
|
||||
|
||||
def jog_angle(joint_id, direction, speed):
|
||||
def jog_angle(self, joint_id, direction, speed):
|
||||
'''Joint control
|
||||
|
||||
joint_id: string
|
||||
|
|
@ -218,7 +218,7 @@ class MyCobot():
|
|||
command += '{}{}{}fa'.format(joint_id, direction, speed)
|
||||
self._write(command)
|
||||
|
||||
def jog_coord(coord, direction, speed):
|
||||
def jog_coord(self, coord, direction, speed):
|
||||
'''Coord control
|
||||
|
||||
coord: string
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ class MyCobot():
|
|||
# print(command)
|
||||
self._write(command)
|
||||
|
||||
def jog_angle(joint_id, direction, speed):
|
||||
def jog_angle(self, joint_id, direction, speed):
|
||||
'''Joint control
|
||||
|
||||
joint_id: string
|
||||
|
|
@ -219,7 +219,7 @@ class MyCobot():
|
|||
command += '{}{}{}fa'.format(joint_id, direction, speed)
|
||||
self._write(command)
|
||||
|
||||
def jog_coord(coord, direction, speed):
|
||||
def jog_coord(self, coord, direction, speed):
|
||||
'''Coord control
|
||||
|
||||
coord: string
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue