GithubHelp home page GithubHelp logo

Comments (3)

v-lopez avatar v-lopez commented on August 22, 2024 1

We had to implement a hacky workaround. I believe we use a single shot timer to send the new goal later, instead of right at the doneCb.

from actionlib.

guohefu avatar guohefu commented on August 22, 2024

After #155 one of our use cases is broken.

If you are using a SimpleActionClient, and on your done_cb send another goal, it is possible that a status message or result message from the previous goal is interpreted for the current goal.

This code sample fails on 1.13.2 but works fine on 1.12.1:


#include <actionlib_tutorials/FibonacciAction.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/server/simple_action_server.h>
#include <ros/ros.h>

class FibonacciAction
{
protected:
  ros::NodeHandle nh_;
  actionlib::SimpleActionServer<actionlib_tutorials::FibonacciAction>
      as_;  // NodeHandle instance must be created before this line. Otherwise strange error occurs.
  std::string action_name_;

public:
  FibonacciAction(std::string name)
    : as_(nh_, name, boost::bind(&FibonacciAction::executeCB, this, _1), false)
    , action_name_(name)
  {
    as_.start();
  }

  void executeCB(const actionlib_tutorials::FibonacciGoalConstPtr &goal)
  {
    as_.setSucceeded();
  }
};


std::unique_ptr<actionlib::SimpleActionClient<actionlib_tutorials::FibonacciAction>> client;
void done_cb(const actionlib::SimpleClientGoalState &state,
             const actionlib_tutorials::FibonacciResultConstPtr &result)
{
  ROS_INFO_STREAM("Goal done ");
  actionlib_tutorials::FibonacciGoal goal;
  goal.order = 1;
  client->sendGoal(goal, &done_cb);
}

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

  ros::AsyncSpinner spinner(1);
  spinner.start();
  FibonacciAction server("fibonacci");
  client.reset(new actionlib::SimpleActionClient<actionlib_tutorials::FibonacciAction>(
      "fibonacci", true));

  ROS_INFO("Waiting for action server to start.");
  // wait for the action server to start
  client->waitForServer();  // will wait for infinite time

  ROS_INFO("Action server started, sending goal.");
  // send a goal to the action
  actionlib_tutorials::FibonacciGoal goal;
  client->sendGoal(goal, &done_cb);

  while (ros::ok())
  {
    ros::Duration(.1).sleep();
  }

  // exit
  return 0;
}

After #155 it gets stuck with:

[ INFO] [1631185426.628695785]: Waiting for action server to start.
[ INFO] [1631185426.822095819]: Action server started, sending goal.
[ INFO] [1631185426.822328039]: Goal done
[ERROR] [1631185426.822456738]: BUG: Got a transition to CommState [ACTIVE] when in SimpleGoalState [DONE]
[ERROR] [1631185426.822487358]: BUG: Got a second transition to DONE:

I have the same problem,do you have a solution?

image

from actionlib.

guohefu avatar guohefu commented on August 22, 2024

We had to implement a hacky workaround. I believe we use a single shot timer to send the new goal later, instead of right at the doneCb.

I think this is not the optimal solution, I hope it can be solved completely

from actionlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.