Skip to content

Instantly share code, notes, and snippets.

@rethink-imcmahon
Last active August 29, 2015 14:18
Show Gist options
  • Save rethink-imcmahon/04e57bd556667a2fa951 to your computer and use it in GitHub Desktop.
Save rethink-imcmahon/04e57bd556667a2fa951 to your computer and use it in GitHub Desktop.
Limb Tester for baxter_interface
#! /usr/bin/python
import rospy
import baxter_interface
rospy.init_node("foobar")
l = baxter_interface.Limb('left')
def limb_breaker(tid, l):
while not rospy.is_shutdown():
#print("T: {} - {}".format(tid, l.joint_angles()))
ang = l.joint_angles()
#Test 1: thread
#import thread
#thread.start_new_thread( limb_breaker, (1, l,))
#thread.start_new_thread( limb_breaker, (2, l,))
#while not rospy.is_shutdown():
# pass
#Test 2: multiprocessing
#from multiprocessing import Process
#p1 = Process(target=limb_breaker, args=(1, l,))
#p2 = Process(target=limb_breaker, args=(2, l,))
#p1.start()
#p2.start()
#while not rospy.is_shutdown():
# pass
#p1.join()
#p2.join()
#Test 3: threading
import threading
threads = []
num_threads = 10
for i in range(num_threads):
t = threading.Thread(target=limb_breaker, args=(i, l,))
threads.append(t)
threads[i].start()
while not rospy.is_shutdown():
pass
for i in range(num_threads):
threads[i].join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment