Unsupported Operand *
Hi, I'm using Indigo on a RPi,
I'm running a code and am getting the error
pi@raspberrypi ~/catkin_ws/src/servo $ rosrun servo pigpio_listner.py
[ERROR] [WallTime: 1423671413.743414] bad callback: <function set at 0x1f12670>
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 13, in set
pulswidth=1000+angle*5.5556
TypeError: unsupported operand type(s) for *: 'Float32' and 'float'
Unhandled exception in thread started by
sys.excepthook is missing
lost sys.stderr
I'm not sure what this means, doesn't * mean multiply? Can't you multiply floats? I'll include the code:
#!/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*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()