Help Publishing

asked 2015-02-16 08:45:41 -0500

dshimano gravatar image

updated 2015-02-16 10:31:36 -0500

Hi, I'm running indigo on a RPi. I have a code I'm running to turn a servo using ROS. in one shell I used rosrun to run the script;

pi@raspberrypi ~/catkin_ws/src/servo $ rosrun servo
Exception in thread Thread-6 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/", line 505, in run
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/impl/", line 418, in _run
  File "/usr/lib/python2.7/", line 259, in wait
<type 'exceptions.TypeError'>: 'NoneType' object is not callable

While in another shell I published the angle;

pi@raspberrypi ~/catkin_ws $ rostopic pub angle std_msgs/Float32 65
publishing and latching message. Press ctrl-C to terminate
[WARN] [WallTime: 1424096903.719022] Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.

I'm not sure what the error is. I see one error is traced to a ROS file, while the other errors are due to threading. That is all I was able to work out on my own, which is not a lot. Any ideas?

Note: I also sometimes get the error;

[ERROR] [WallTime: 1424104213.242993] bad callback: <function set at 0x1a996b0>
Traceback (most recent call last):
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/", line 702, in _invoke_callback
  File "/home/pi/catkin_ws/src/servo/", line 14, in set
    pi.set_servo_pulsewidth(servos, pulswidth)
  File "/usr/local/lib/python2.7/dist-packages/", line 1203, in set_servo_pulsewidth, _PI_CMD_SERVO, user_gpio, int(pulsewidth)))
  File "/usr/local/lib/python2.7/dist-packages/", line 753, in _pigpio_command
    sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
AttributeError: 'NoneType' object has no attribute 'send'

My original script is;

#!/usr/bin/env python
import rospy
from std_msgs.msg import Float32
import time
import pigpio

servos = 4 #GPIO number


def set(angle):*5.5556
        pi.set_servo_pulsewidth(servos, pulswidth)

def listener():
        rospy.init_node('servo', anonymous=True)

        rospy.Subscriber("angle", Float32, set)


if __name__ == '__main__':

# switch all servos off
        except KeyboardInterrupt:
                pigpio.set_servo_pulsewidth(servos, 0);
edit retag flag offensive close merge delete


Should it be rospy.spin()?

As you have it currently, you are not actually calling rospy.spin() in your listener function, which could explain the "not callable" error.

slivingston gravatar image slivingston  ( 2015-02-16 13:02:47 -0500 )edit