refactor: modify for new api, fix control_marker.py bug

This commit is contained in:
张立军 2021-01-08 11:42:28 +08:00 committed by Zachary Zhang
parent 411a2a4c65
commit 1995275b83
5 changed files with 26 additions and 19 deletions

View file

@ -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()

View file

@ -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()

View file

@ -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:

View file

@ -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

View file

@ -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