Ask Your Question
0

Error on action_client as topic callback

asked 2018-02-13 12:44:37 -0600

bxl gravatar image

updated 2018-02-13 13:38:30 -0600

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-02-13 14:25:53 -0600

gvdhoorn gravatar image

updated 2018-02-13 14:36:16 -0600

ActionException: Type is not an action spec: <class 'move_quadcopter.msg._NavigateAction.NavigateAction'>

It's likely that the following statement in your callback is the problem:

goal = NavigateGoal

You're setting goal equal to the NavigateGoal class, not to an instance of it (ie: an object).

Try changing the line to:

goal = NavigateGoal()

and see whether that works any better.

edit flag offensive delete link more

Comments

the way i've done the subscriber function will get one Point than invoke the callback or it will get all the Points and after i have all call the callback? For me seems it's getting one-by-one but I don't know why.

bxl gravatar imagebxl ( 2018-02-13 17:28:15 -0600 )edit

Your callback will be called for each incoming message, so for N msgs, you will submit N goals to your action server.

gvdhoorn gravatar imagegvdhoorn ( 2018-02-14 01:51:43 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-02-13 12:44:37 -0600

Seen: 362 times

Last updated: Feb 13 '18