mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-14 09:00:53 +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
|
#!/usr/bin/env python2
|
||||||
# from std_msgs.msg import String
|
# from std_msgs.msg import String
|
||||||
import time
|
import time, subprocess
|
||||||
|
|
||||||
import rospy
|
import rospy
|
||||||
from interactive_markers.interactive_marker_server import *
|
from interactive_markers.interactive_marker_server import *
|
||||||
|
|
@ -210,21 +210,24 @@ def listener():
|
||||||
joint_state_send.header.stamp = rospy.Time.now()
|
joint_state_send.header.stamp = rospy.Time.now()
|
||||||
|
|
||||||
angles = mycobot.get_angles_of_radian()
|
angles = mycobot.get_angles_of_radian()
|
||||||
data_list = []
|
rospy.loginfo(angles)
|
||||||
for index, value in enumerate(angles):
|
if angles:
|
||||||
if index != 2:
|
data_list = []
|
||||||
value *= -1
|
for index, value in enumerate(angles):
|
||||||
data_list.append(value)
|
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()
|
rate.sleep()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mycobot = MyCobot()
|
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
|
||||||
|
shell=True)
|
||||||
|
mycobot = MyCobot(port)
|
||||||
listener()
|
listener()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# from std_msgs.msg import String
|
# from std_msgs.msg import String
|
||||||
import time
|
import time, subprocess
|
||||||
|
|
||||||
import rospy
|
import rospy
|
||||||
from sensor_msgs.msg import JointState
|
from sensor_msgs.msg import JointState
|
||||||
|
|
@ -29,5 +29,7 @@ def listener():
|
||||||
rospy.spin()
|
rospy.spin()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mc = MyCobot()
|
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
|
||||||
|
shell=True)
|
||||||
|
mc = MyCobot(port)
|
||||||
listener()
|
listener()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# license removed for brevity
|
# license removed for brevity
|
||||||
import time
|
import time, subprocess
|
||||||
|
|
||||||
import rospy
|
import rospy
|
||||||
from sensor_msgs.msg import JointState
|
from sensor_msgs.msg import JointState
|
||||||
|
|
@ -77,7 +77,9 @@ def talker():
|
||||||
rate.sleep()
|
rate.sleep()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mycobot = MyCobot()
|
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
|
||||||
|
shell=True)
|
||||||
|
mycobot = MyCobot(port)
|
||||||
try:
|
try:
|
||||||
talker()
|
talker()
|
||||||
except rospy.ROSInterruptException:
|
except rospy.ROSInterruptException:
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,7 @@ class MyCobot():
|
||||||
# print(command)
|
# print(command)
|
||||||
self._write(command)
|
self._write(command)
|
||||||
|
|
||||||
def jog_angle(joint_id, direction, speed):
|
def jog_angle(self, joint_id, direction, speed):
|
||||||
'''Joint control
|
'''Joint control
|
||||||
|
|
||||||
joint_id: string
|
joint_id: string
|
||||||
|
|
@ -218,7 +218,7 @@ class MyCobot():
|
||||||
command += '{}{}{}fa'.format(joint_id, direction, speed)
|
command += '{}{}{}fa'.format(joint_id, direction, speed)
|
||||||
self._write(command)
|
self._write(command)
|
||||||
|
|
||||||
def jog_coord(coord, direction, speed):
|
def jog_coord(self, coord, direction, speed):
|
||||||
'''Coord control
|
'''Coord control
|
||||||
|
|
||||||
coord: string
|
coord: string
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ class MyCobot():
|
||||||
# print(command)
|
# print(command)
|
||||||
self._write(command)
|
self._write(command)
|
||||||
|
|
||||||
def jog_angle(joint_id, direction, speed):
|
def jog_angle(self, joint_id, direction, speed):
|
||||||
'''Joint control
|
'''Joint control
|
||||||
|
|
||||||
joint_id: string
|
joint_id: string
|
||||||
|
|
@ -219,7 +219,7 @@ class MyCobot():
|
||||||
command += '{}{}{}fa'.format(joint_id, direction, speed)
|
command += '{}{}{}fa'.format(joint_id, direction, speed)
|
||||||
self._write(command)
|
self._write(command)
|
||||||
|
|
||||||
def jog_coord(coord, direction, speed):
|
def jog_coord(self, coord, direction, speed):
|
||||||
'''Coord control
|
'''Coord control
|
||||||
|
|
||||||
coord: string
|
coord: string
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue