roslaunch api error

asked 2019-08-05 04:55:38 -0500

Ducks gravatar image

updated 2019-08-06 10:09:54 -0500

I made python code and it can't run.

This is a code

Executable:

#!/usr/bin/env python
import roslib; roslib.load_manifest('arduino_ros')

import rospy
import roslaunch

from std_msgs.msg import Bool

def callback(data):
    rospy.loginfo("%d",data.data)
    if data.data == 1 :
        uuid = roslaunch.rlutil.get_or_generate_uuid(None, False)
        roslaunch.configure_logging(uuid)
        launch = roslaunch.parent.ROSLaunchParent(uuid, 
        ["/home/duckbe/catkin_ws/src/romillion/romillion_slam/launch/romillion_slam.launch"])
        launch.start()

def listener():
    rospy.init_node("listener",anonymous=True)
    rospy.Subscriber("pushed",Bool,callback)
    rospy.spin()

if __name__ == "__main__":
    listener()

This is error

Shell returns:

[ERROR] [1564998549.058886]: bad callback: <function callback at 0x7fdc1cc41488>
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "/home/duckbe/catkin_ws/src/arduino_ros/src/arduino_button.py", line 16, in callback
launch.start()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/parent.py", line 279, in start
self.runner.launch()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/launch.py", line 658, in launch
succeeded, failed = self._launch_nodes()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/launch.py", line 367, in _launch_nodes
proc, success = self.launch_node(node)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/launch.py", line 539, in launch_node
process = create_node_process(self.run_id, node, master.uri)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/nodeprocess.py", line 148, in create_node_process
required=node.required, cwd=node.cwd)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/nodeprocess.py", line 184, in __init__
respawn, respawn_delay, required)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/pmon.py", line 201, in __init__
_init_signal_handlers()
File "/opt/ros/kinetic/lib/python2.7/dist-packages/roslaunch/pmon.py", line 171, in _init_signal_handlers
_signal_chain[s] = signal.signal(s, rl_signal)
ValueError: signal only works in main thread

Does anyone know what is the problem?

edit retag flag offensive close merge delete

Comments

1

Hello, any updates/solutions on this? Thx!

tanasis gravatar image tanasis  ( 2020-04-27 15:44:55 -0500 )edit