Error on action_client as topic callback
I'm trying to implement a node that subscribes to a topic to get a list of geometry_msgs/Points
and then send it to action_lib client
(implemented on the callback function of the subscriber) that communicate to the server.
I'm on ROS Kinetic
.
Here are my subscriber:
rospy.Subscriber(topic_name, topic_type,__goal_action_callback)
And my callback function:
def __goal_action_callback(data):
rospy.loginfo(RobotMoving.get_name() + " " + "I heard {}".format(data))
ac = SimpleActionClient("nav_server", NavigateAction)
rospy.loginfo("goalCallback: Waiting for action server to start.")
ac.wait_for_server()
rospy.loginfo("goalCallback: Navigation service found.")
goal = NavigateGoal
goal.target_pos = data
ac.send_goal_and_wait(goal)
if ac.get_state() == GoalStatus.SUCCEEDED:
rospy.loginfo("Navigate action is completed!")
else:
rospy.loginfo("Navigate action failed!")
Things are working fine for the first point read. However , for the second point and further it gets this error:
[ERROR] [1518537259.290802, 30.718000]: bad callback: <function __goal_action_callback at 0x7fa5d05e5488>
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "/home/bruno/rodain/src/rodain_get_directions/nodes/retrieve_content.py", line 27, in __goal_action_callback
ac = SimpleActionClient("nav_server", NavigateAction)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/actionlib/simple_action_client.py", line 55, in __init__
self.action_client = ActionClient(ns, ActionSpec)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/actionlib/action_client.py", line 519, in __init__
raise ActionException("Type is not an action spec: %s" % str(ActionSpec))
ActionException: Type is not an action spec: <class 'move_quadcopter.msg._NavigateAction.NavigateAction'>
It seems to me that relys on how things are done on background. Anyone know why it is happening?