Robotics StackExchange | Archived questions

Python: serialHelper with rospy (threading conflict?)

Hi,

here a little script which works fine until I remove the remark for init of the roc node

#!/usr/bin/env python

import threading
from time import sleep
import rospy

import serialHelper


sh = serialHelper.SerialHelper()
NODE_NAME ='SerialHelperTestRos'

if __name__ == '__main__':
    try:
        t = threading.Thread(target=sh.serialReader)
        t.setDaemon(True)
        t.start()
        h = 0
        #rospy.init_node(NODE_NAME, anonymous=True)
        while True:
            sh.writeToSerial('Hello Nr' + str(h))
            h = h + 1
            resp = sh.getResponse()
            print ('response ' + resp)
            sleep(3)
    except Exception as e:
        print (e)

it's on ubuntu mate with python 2.7. Any idea why I don't see serial input when rod did init ? I am new to python and ros so any input is greatly appreciated

Asked by vKuehn on 2017-12-01 02:30:24 UTC

Comments

@vKuehn: I've edited the title of your post to better reflect the question. "not working" is too vague.

Asked by gvdhoorn on 2017-12-01 04:08:41 UTC

thanks, hopefully someone has at least any hint

Asked by vKuehn on 2017-12-01 10:46:53 UTC

Answers