ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I solved this by implementing my own signal handler. Howerver I'd be still interested why the standard ROS Handler failed.

Here's the code I added:

def exit_gracefully(sig, frame):
    global twist_publisher
    global image_sub

    image_sub.unregister()

    twist = Twist()
    print(twist)
    twist_publisher.publish(twist)

    rospy.signal_shutdown("Stop")

and

if __name__ == '__main__':
     rospy.init_node('my_line_follower', disable_signals=True)

     signal.signal(signal.SIGINT, exit_gracefully)
     signal.signal(signal.SIGTERM, exit_gracefully)

     initRos()
     rospy.spin()

I solved this by implementing my own signal handler. Howerver handler which is sending a final twist message, setting everything to zero. However, I'd be still interested why the standard ROS Handler failed.

Here's the code I added:

def exit_gracefully(sig, frame):
    global twist_publisher
    global image_sub

    image_sub.unregister()

    twist = Twist()
    print(twist)
    twist_publisher.publish(twist)

    rospy.signal_shutdown("Stop")

and

if __name__ == '__main__':
     rospy.init_node('my_line_follower', disable_signals=True)

     signal.signal(signal.SIGINT, exit_gracefully)
     signal.signal(signal.SIGTERM, exit_gracefully)

     initRos()
     rospy.spin()

I solved this by implementing my own signal handler which is sending a final twist message, setting everything to zero. However, I'd be still interested why the standard ROS Handler handler failed.

Here's the code I added:

def exit_gracefully(sig, frame):
    global twist_publisher
    global image_sub

    image_sub.unregister()

    twist = Twist()
    print(twist)
    twist_publisher.publish(twist)

    rospy.signal_shutdown("Stop")

and

if __name__ == '__main__':
     rospy.init_node('my_line_follower', disable_signals=True)

     signal.signal(signal.SIGINT, exit_gracefully)
     signal.signal(signal.SIGTERM, exit_gracefully)

     initRos()
     rospy.spin()