Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finish doneCb before waitForResult returns #156

Merged
merged 12 commits into from
Apr 23, 2020

Conversation

jschleicher
Copy link
Contributor

@jschleicher jschleicher commented Nov 20, 2019

Fixes #155

Is indigo-devel the correct branch? Or should this be targeted to noetic to avoid breaking old use-cases?

@jschleicher jschleicher changed the title call doneCb before setting client state WIP: call doneCb before setting client state Nov 21, 2019
jschleicher added a commit to PilzDE/actionlib that referenced this pull request Nov 28, 2019
@jschleicher jschleicher changed the title WIP: call doneCb before setting client state finish doneCb before waitForResult returns Nov 28, 2019
@jschleicher
Copy link
Contributor Author

@mjcarroll Please review.
And also have a look at #150 which fixes the same problem in the python client.

@mjcarroll
Copy link
Member

@jschleicher Looks good, but please retarget to noetic-devel.

@jschleicher jschleicher changed the base branch from indigo-devel to noetic-devel February 25, 2020 10:58
by introducing a short sleep (essentially inducing a scheduler context
switch) in the done-callback
@jschleicher
Copy link
Contributor Author

@mjcarroll Thank you! I've rebased onto noetic-devel.

to fix the corresponding CMake warning
@mjcarroll
Copy link
Member

@ros-pull-request-builder retest this please

@jschleicher
Copy link
Contributor Author

@mjcarroll The tests are still unstable, which seems to be an occurrence of #119 (comment). Adding a delay time after waitForServer() does fix the tests, but we would have to introduce it into every single test case.

@@ -104,18 +98,21 @@ TEST(SimpleClient, easy_callback)
bool started = client.waitForServer(ros::Duration(10.0));
ASSERT_TRUE(started);

// sleep a bit to make sure that all topics are properly connected to the server.
ros::Duration(0.01).sleep();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe this should be done by waitForServer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it should. But actually it isn't, see my comment above: #156 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i understand this is just a work-around to pass the test, but even with this duration SimpleClientFixture fails with server state is still ACTIVE (expected to be SUCCESS). so I expect this additional duration is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the unrelated test file exercise_simple_client.cpp that fails - adding another sleep over there would help.

[actionlib.rosunit-test_cpp_simple_client/just_succeed][FAILURE]
 /tmp/ws/src/actionlib/actionlib/test/exercise_simple_client.cpp:72

void easyOldDoneCallback(bool * called, const TerminalState & terminal_state,
const TestResultConstPtr &)
{
ros::Duration(0.1).sleep();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this duration for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a callback, that takes some time and gives execution back to the main thread in the mean time. Without the fix, this test case easy_callback fails.

Copy link
Contributor Author

@jschleicher jschleicher Apr 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also reproduction step 2. in #155.

Copy link
Contributor

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@v4hn
Copy link

v4hn commented Apr 23, 2020

@mjcarroll: @jschleicher continuously provided feedback on this for over four months now,
the only test that fails is not related to his patch but to a racing condition to setup a topic connection in time and it fixes a long-standing issue we have to work around in MoveIt.

It would be great to see this merged and released in noetic (and best-case also a backport to melodic, but at this point I would be happy to see this merged in any branch)!

@mjcarroll
Copy link
Member

@v4hn Yes, I appreciate the iteration from @jschleicher.

At this point, I think it's acceptable to land on noetic, and I would be happy to review a backport to melodic

@mjcarroll
Copy link
Member

@ros-pull-request-builder retest this please

@mjcarroll
Copy link
Member

@mjcarroll The tests are still unstable, which seems to be an occurrence of #119 (comment). Adding a delay time after waitForServer() does fix the tests, but we would have to introduce it into every single test case.

@jschleicher Do you want to do this in a follow up PR?

@mjcarroll mjcarroll merged commit 9beedb8 into ros:noetic-devel Apr 23, 2020
LeroyR pushed a commit to CentralLabFacilities/actionlib that referenced this pull request Mar 29, 2022
* call doneCb before setting client state (Fixes ros#155)
* add testcase to fail without the fix
* also test getState() in the callback
* wait until the server is ready
* increase time limit for unrelated test
* separate exercise_simple_client into cpp and python
* increase debug output
* wait for longer for server
* bump CMake minimum version to use new behavior of CMP0048
* test build with more debug output
* Revert "wait for longer for server"
* Revert "test build with more debug output"
rhaschke added a commit to ubi-agni/moveit that referenced this pull request Jul 10, 2024
LeroyR pushed a commit to CentralLabFacilities/moveit that referenced this pull request Jul 11, 2024
LeroyR pushed a commit to CentralLabFacilities/moveit that referenced this pull request Jul 11, 2024
rhaschke added a commit to moveit/moveit that referenced this pull request Aug 30, 2024
* cleanup after actionlib fix
  actionlib was fixed via ros/actionlib#156

* Reset status variables before calling sendGoal()
  This fixes a race condition, where the execution status is set to RUNNING after the doneCallback has been called,
  e.g. because the controller immediately reports success.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

waitForResult returns before doneCb
6 participants