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

"Attempting to accept the next goal when a new goal is not available"

asked 2017-08-04 12:23:10 -0600

Canni gravatar image

updated 2017-08-05 00:22:41 -0600

NEngelhard gravatar image

Hello! I'm trying to perform an action-client/action-server structure using a callback structure.

So it just has to read info from the goal and publish messages on a turtlesim topic.

When I run this node (either before or after I created the client) every time the server receives a Goal I get this:

[ INFO] [1501865084.462187784]: Server Created    
[ INFO] [1501865086.638608252]: I'm in goalCB() and I'm receiving a new Goal
[ERROR] [1501865086.638780375]: Attempting to accept the next goal when a new goal is not available

This is my code (which btw for now does nothing, I just wanted to see if everything worked)

class polygonAction
{
public
:
polygonAction(std::string name) : 
    as(nh_, name, false),
    action_name_(name)
  {

//register the goal and feeback callbacks
as.registerGoalCallback(boost::bind(&polygonAction::goalCB, this));
as.registerPreemptCallback(boost::bind(&polygonAction::preemptCB, this));
ROS_INFO("Server Created");

//Stuff for turtlesim we don't care
[...]

as.start();


}

  ~polygonAction(void)
  {
  }

  void goalCB()
  {
    ROS_INFO("I'm in goalCB() and I'm receiving a new Goal");
    goal_length = as.acceptNewGoal()->length;
    goal_sides = as.acceptNewGoal()->sides;
    ROS_INFO("Received %d sides and %d lenght", goal_sides, goal_length);

  }

  void preemptCB()
  {
    ROS_INFO("%s: Preempted", action_name_.c_str());
    // set the action state to preempted
    as.setPreempted();
  }

  //Stuff for turtlesim we are not interested in 
 [...]

protected:



  ros::NodeHandle nh_;
  actionlib::SimpleActionServer<es_1::polygonAction> as;
  std::string action_name_;
  int goal_sides, goal_length, sides_count;
  es_1::polygonFeedback feedback_;
  es_1::polygonResult result_;
  ros::Publisher pub;
  ros::Subscriber sub;

    };

int main(int argc, char** argv)
{
  ros::init(argc, argv, "polygon_action_server");

  polygonAction polygon("polygon");

  ros::spin();

  return 0;

}

Any ideas?

edit retag flag offensive close merge delete

Comments

It's better to include only the important information in your question. This question is only about the mechanics of an action server, the turtle-sim or your polygon are not relevant but just a distraction.

NEngelhard gravatar image NEngelhard  ( 2017-08-04 14:26:04 -0600 )edit

Yeah sorry, but they were only few lines and they had comments above so i just copied and pasted my code

Canni gravatar image Canni  ( 2017-08-04 17:45:35 -0600 )edit
1

I modified the code ;)

Canni gravatar image Canni  ( 2017-08-04 17:55:54 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-08-04 14:24:47 -0600

NEngelhard gravatar image

You can only accept a new goal once, but you have two calls of as.acceptNewGoal(). so just call it once to get a pointer to the current goal. You can check the implementation here.

edit flag offensive delete link more

Comments

RIGHT! Thank you so much! Now I'm trying to get my goal in that goalCB but I don't know how to instantiate it ahahah I'm a total noob in ROS so thank you for your advices!

Canni gravatar image Canni  ( 2017-08-04 17:53:08 -0600 )edit

Ok done! Thank you so much!

Canni gravatar image Canni  ( 2017-08-04 18:00:39 -0600 )edit

How did you get around this? I just fixed the same error, also being a total noob

TheMilkman92 gravatar image TheMilkman92  ( 2021-04-14 22:26:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-04 12:23:10 -0600

Seen: 872 times

Last updated: Aug 05 '17