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

Fixed executor conflict #126

Merged

Conversation

Bitterisland6
Copy link

Rqt spawns a multi threaded executor, and provides all open plugins in a single node which is spun inside it. But in the rqt_reconfigure plugin when calling service, there was added waiting for the end of the call with spin_until_future_complete. This method was giving the control of the rqt to the default rclpy executor.
This issue caused problems like:

  • not updating parameters values in rqt_reconfigure to values set from the outside of the rqt
  • blocking working of rqt_plot

To fix this issue it's enough to wait for the service request without the spin_until_future_complete method. One solution is to use python events and add_done_callback method from the future object returned by call_async method. The waiting is done with event wait function and provided timeout, and can be interrupted by setting the event flag in the callback specified in the add_done_callback.

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>
Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>
Copy link

@huemerj huemerj left a comment

Choose a reason for hiding this comment

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

Works as expected!

@quarkytale
Copy link
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@quarkytale
Copy link
Contributor

quarkytale commented May 24, 2023

I'm not sure if overriding the rclpy method is the best way to go here, is there any other method that could serve this purpose, implementing spin_once_until_future_complete https://github.com/ros2/rclpy/blob/rolling/rclpy/rclpy/executors.py#L332 perhaps?
(Looking into it)

Comment on lines +123 to +127
event = Event()
future = client.call_async(request)
rclpy.spin_until_future_complete(self._node, future, None, timeout)
future.add_done_callback(lambda _: event.set())

event.wait(timeout)
Copy link

Choose a reason for hiding this comment

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

This is what client.call() does. I'd recommend this instead:

try:
    return client.call(request)
except:
    raise AsyncServiceCallFailed(hint='the target node may not be spinning')

Copy link
Contributor

Choose a reason for hiding this comment

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

@Bitterisland6 Would you prefer rlcpy client class function that Shane recommended or keep using python events?

Copy link
Author

Choose a reason for hiding this comment

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

@quarkytale the problem with solution recommended by Shane is that in the call method the waiting for event is started without timeout, so there is a risk that it'll never end. Therefore I'd prefer to keep on using python events.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay I see, using the rclpy function would be preferred but I don't see any reason to block this. Thanks for your patience, I'll run CI.

@MarcoMagriDev
Copy link

Any update on this?
Are you planning to backport to humble?

@quarkytale
Copy link
Contributor

CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@quarkytale quarkytale merged commit e199a0d into ros-visualization:rolling Oct 5, 2023
2 checks passed
@bjsowa
Copy link

bjsowa commented Nov 8, 2023

@quarkytale Could you please backport it to humble and iron?

@clalancette
Copy link

@Mergifyio backport iron humble

Copy link

mergify bot commented Nov 8, 2023

backport iron humble

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 8, 2023
* fixed executor conflict

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>

* fixed formatting errors

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>

---------

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>
(cherry picked from commit e199a0d)
mergify bot pushed a commit that referenced this pull request Nov 8, 2023
* fixed executor conflict

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>

* fixed formatting errors

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>

---------

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>
(cherry picked from commit e199a0d)
clalancette pushed a commit that referenced this pull request Nov 8, 2023
Fixed executor conflict (#126)

* fixed executor conflict

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>

* fixed formatting errors

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>

---------

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>
(cherry picked from commit e199a0d)

Co-authored-by: Aleksander Szymański <bitterisland6@gmail.com>
clalancette pushed a commit that referenced this pull request Nov 8, 2023
Fixed executor conflict (#126)

* fixed executor conflict

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>

* fixed formatting errors

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>

---------

Signed-off-by: Bitterisland6 <bitterisland6@gmail.com>
(cherry picked from commit e199a0d)

Co-authored-by: Aleksander Szymański <bitterisland6@gmail.com>
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.

None yet

7 participants