Skip to content

Move initialization of ServoNode into constructor - #761

Merged
tylerjw merged 2 commits into
moveit:mainfrom
tylerjw:servo_init
Oct 29, 2021
Merged

tylerjw merged 2 commits into
moveit:mainfrom
tylerjw:servo_init

Conversation

@tylerjw

@tylerjw tylerjw commented Oct 27, 2021

Copy link
Copy Markdown
Member

Description

While reviewing the hybrid planner I was reading the source for how component nodes get created and realized that the component node class doesn't have to inherit from rclcpp::Node. If instead, you do it this way you don't need that call to make_shared_from_this that can't happen in the constructor.

The major advantage of that is that initialization is more straightforward as it happens in the constructor. You may ask why I didn't get rid of the start and stop interfaces then. The reason I didn't is that when I do it reveals a race condition. This has something to do with the static transform publisher needed for the virtual_joint.

I'm sorry for the lack of description for my last small change. This was what I was working on when I made it. You will notice I deleted the StartStopTest. I did that because with this simplification it was not testing anything anymore that was not tested by other tests.

This change does change the behavior in one way. That is that calling stop is actually just the same as calling pause for now. I plan on changing this in the future and removing the start/stop interfaces in favor of just the pause/unpause interfaces. That will make it much simpler for users. If it is useful that it start paused, that behavior could be accomplished without the start and stop that was deleting and re-creating a bunch of the objects and internal state.

Checklist

@tylerjw
tylerjw requested a review from AndyZe October 27, 2021 15:31
@tylerjw tylerjw self-assigned this Oct 27, 2021
@tylerjw tylerjw mentioned this pull request Oct 27, 2021
3 tasks done
@codecov

codecov Bot commented Oct 27, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #761 (82b2cc7) into main (2391195) will decrease coverage by 0.04%.
The diff coverage is 77.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #761      +/-   ##
==========================================
- Coverage   54.54%   54.51%   -0.03%     
==========================================
  Files         195      196       +1     
  Lines       21359    21340      -19     
==========================================
- Hits        11649    11631      -18     
+ Misses       9710     9709       -1     
Impacted Files Coverage Δ
moveit_ros/moveit_servo/src/servo.cpp 72.42% <66.67%> (-1.11%) ⬇️
moveit_ros/moveit_servo/src/servo_node.cpp 68.89% <78.27%> (-8.16%) ⬇️
...ros/moveit_servo/include/moveit_servo/servo_node.h 100.00% <100.00%> (ø)
moveit_ros/moveit_servo/src/servo_node_main.cpp 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2391195...82b2cc7. Read the comment docs.

@henningkayser henningkayser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is some really good cleanup. Interesting, that get_node_base_interface() is really the only thing that is required, but this somewhat makes sense. Unrelated to your changes, do we really want to stick to a SingleThreadedExecutor? The collision check is running in a separate thread, but if it's blocking the executor thread (since PSM callbacks are locked) this could also interfere with in and outputs for the ServoCalcs thread. Haven't we at some point experienced weird synchronization issues were the output controls were limited to a lower frequency without an apparent reason?

@tylerjw
tylerjw merged commit 7e3fdcf into moveit:main Oct 29, 2021
@AndyZe

AndyZe commented Oct 29, 2021

Copy link
Copy Markdown
Member

@tylerjw Please make an issue to track the multiple concerns raised in the description:

The major advantage of that is that initialization is more straightforward as it happens in the constructor. You may ask why I didn't get rid of the start and stop interfaces then. The reason I didn't is that when I do it reveals a race condition. This has something to do with the static transform publisher needed for the virtual_joint.

I'm sorry for the lack of description for my last small change. This was what I was working on when I made it. You will notice I deleted the StartStopTest. I did that because with this simplification it was not testing anything anymore that was not tested by other tests.

This change does change the behavior in one way. That is that calling stop is actually just the same as calling pause for now. I plan on changing this in the future and removing the start/stop interfaces in favor of just the pause/unpause interfaces. That will make it much simpler for users. If it is useful that it start paused, that behavior could be accomplished without the start and stop that was deleting and re-creating a bunch of the objects and internal state.

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.

3 participants