ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Error on action_client as topic callback

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

bxl gravatar image

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

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 -0500

gvdhoorn gravatar image

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

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 image bxl  ( 2018-02-13 17:28:15 -0500 )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 image gvdhoorn  ( 2018-02-14 01:51:43 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 2,406 times

Last updated: Feb 13 '18