rospy.init_node() has already been called with different arguments
Hi, I'm running indigo on a RPi.
I have a script to use a joystick to run a servo, which I'll paste below. I know the code subscribing to this is working, because when I publish angles to it using rostopic, the servo turns. I was hoping that when I use this script, I could push the joystick up, and the servo would turn more positive. I based my usage of the joy node on this link from the ROS Wiki page. I got the following error.
[ERROR] [WallTime: 1425312842.009290] bad callback: <function joy_talker at 0x224c1b0>
Traceback (most recent call last):
File "/home/pi/catkin_ws/src/ros_comm/rospy/src/rospy/topics.py", line 702, in _invoke_callback
cb(msg)
File "/home/pi/catkin_ws/src/servo/joy.py", line 8, in joy_talker
rospy.init_node('talker', anonymous=True)
File "/home/pi/catkin_ws/src/ros_comm/rospy/src/rospy/client.py", line 274, in init_node
raise rospy.exceptions.ROSException("rospy.init_node() has already been called with different arguments: "+str(_init_node_args))
ROSException: rospy.init_node() has already been called with different arguments: ('servo_joy', ['/home/pi/catkin_ws/src/servo/joy.py'], False, None, False, False)
#!/usr/bin/env python
import rospy
from std_msgs.msg import Float32
from sensor_msgs.msg import Joy
def joy_talker(msg):
pub = rospy.Publisher('angle', Float32, queue_size=10)
rospy.init_node('talker', anonymous=True)
while not rospy.is_shutdown():
rospy.logdebug("Joy Recieved: [Vx:%f, Wz:%f]"%(msg.axes[1],msg.$
angle = msg.axes[1] * 180
rospy.loginfo(angle)
pub.publish(angle)
rate.sleep()
if __name__ == '__main__':
rospy.init_node('servo_joy')
rospy.Subscriber("joy", Joy, joy_talker)
rospy.spin()