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 pigpio_listner.py
Exception in thread Thread-6 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 505, in run
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/impl/tcpros_pubsub.py", line 418, in _run
  File "/usr/lib/python2.7/threading.py", 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/topics.py", line 702, in _invoke_callback
    cb(msg)
  File "/home/pi/catkin_ws/src/servo/pigpio_listner.py", line 14, in set
    pi.set_servo_pulsewidth(servos, pulswidth)
  File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 1203, in set_servo_pulsewidth
    self.sl, _PI_CMD_SERVO, user_gpio, int(pulsewidth)))
  File "/usr/local/lib/python2.7/dist-packages/pigpio.py", 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

pi=pigpio.pi()


def set(angle):
        pulswidth=1000+angle.data*5.5556
        pi.set_servo_pulsewidth(servos, pulswidth)

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

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

        rospy.spin

if __name__ == '__main__':
        try:
                listener()


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

Comments

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