RuntimeError: cannot join current thread

Kind folks.

creating a simple interface for the recording function for the ergo robot, I’m running into this when playing back the moves:

Jean-michels-MacBook-Pro:ergo jmm$ python interface_compliant.py 
Exception in thread Thread-10:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/site-packages/pypot/utils/stoppablethread.py", line 119, in _wrapped_target
    self._target()
  File "/usr/local/lib/python2.7/site-packages/pypot/primitive/primitive.py", line 75, in _prim_run
    self.run()
  File "/usr/local/lib/python2.7/site-packages/pypot/primitive/primitive.py", line 163, in run
    make_update_loop(self, self._wrapped_update)
  File "/usr/local/lib/python2.7/site-packages/pypot/utils/stoppablethread.py", line 152, in make_update_loop
    update_func()
  File "/usr/local/lib/python2.7/site-packages/pypot/primitive/primitive.py", line 168, in _wrapped_update
    self.update()
  File "/usr/local/lib/python2.7/site-packages/pypot/primitive/move.py", line 113, in update
    self.stop()
  File "/usr/local/lib/python2.7/site-packages/pypot/primitive/primitive.py", line 125, in stop
    StoppableThread.stop(self, wait)
  File "/usr/local/lib/python2.7/site-packages/pypot/utils/stoppablethread.py", line 56, in stop
    self._thread.join()
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 940, in join
    raise RuntimeError("cannot join current thread")
RuntimeError: cannot join current thread

it does play back, but when arriving at the end, I invariably get the RuntimeError.

Any thoughts?

my script:

import Tkinter as tk  
import time
import pdb

from poppy.creatures import PoppyErgo
ergo = PoppyErgo()

from pypot.primitive.move import Move, MoveRecorder, MovePlayer
record_frequency = 100.0 
recorded_motors = [ergo.m1, ergo.m2, ergo.m3, ergo.m4, ergo.m5, ergo.m6]
recorder = MoveRecorder(ergo, record_frequency, recorded_motors)

root = tk.Tk()
root.title("Ergo, recording fun")


def tapeit():
    for m in recorded_motors:
        m.compliant = True
    recorder.start()
    time.sleep(10)
    recorder.stop()
    toggle_text()
    for m in recorded_motors:
        m.compliant = False 
    recorded_move = recorder.move
    with open('mymove.json', 'w') as f:
        recorded_move.save(f)
     
def playit():
    with open('mymove.json') as f:
        loaded_move = Move.load(f)
    player = MovePlayer(ergo, loaded_move)  
    player.start()
    
def toggle_text():
    if button["text"] == "Record":
        button["text"] = "Recording..."
        tapeit()
    else:
        # reset to Hi
        button["text"] = "Record"
        
button = tk.Button(text="Record", width=12, command=toggle_text)
button2 = tk.Button(text="play", width=12, command=playit)
button.pack(padx=100, pady=10)
button2.pack(padx=120, pady=10)


    
root.mainloop()

Hy JeanMichel

We had the same error with our Cherry team, but it was fixed two week’s ago in the library pypot.
(see the commit : https://github.com/poppy-project/pypot/commit/fe1ad9e011dc7e4451ee2587fc08c263695d32d2)

Have you your pypot library up-to-date ?

1 Like

Excellent, that worked :smile:
Thanks!