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

support modifying wrappers in user stages #253

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

v4hn
Copy link
Contributor

@v4hn v4hn commented Apr 7, 2021

Possible features that require this interface might be

  • trajectory reparameterization,
  • trajectory optimization as post-processing (like MoveIt's CHOMP adapter),
  • multi-trajectory blending (similar to Pilz' sequence planner)

Here is an example illustrating how difficult it is to do the same without the interface.

Fixes #208

@codecov
Copy link

codecov bot commented Apr 7, 2021

Codecov Report

Merging #253 (07d8acb) into master (06b3df9) will increase coverage by 0.33%.
The diff coverage is 82.54%.

❗ Current head 07d8acb differs from pull request most recent head 1ef46e2. Consider uploading reports for the commit 1ef46e2 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #253      +/-   ##
==========================================
+ Coverage   51.63%   51.95%   +0.33%     
==========================================
  Files         101      101              
  Lines        6590     6580      -10     
==========================================
+ Hits         3402     3418      +16     
+ Misses       3188     3162      -26     
Impacted Files Coverage Δ
core/include/moveit/task_constructor/container.h 91.67% <ø> (ø)
core/include/moveit/task_constructor/container_p.h 95.66% <ø> (ø)
core/src/stages/compute_ik.cpp 79.73% <64.71%> (ø)
core/src/container.cpp 70.26% <86.49%> (-0.08%) ⬇️
core/include/moveit/task_constructor/stage_p.h 96.08% <100.00%> (+3.93%) ⬆️
core/src/stage.cpp 80.90% <100.00%> (+2.11%) ⬆️
core/include/moveit/task_constructor/cost_terms.h 81.82% <0.00%> (-1.51%) ⬇️
core/src/storage.cpp 83.79% <0.00%> (ø)
core/src/solvers/cartesian_path.cpp 85.30% <0.00%> (ø)
... and 11 more

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 06b3df9...1ef46e2. Read the comment docs.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

I think I can approve. Please have a look at the questions.

core/include/moveit/task_constructor/container.h Outdated Show resolved Hide resolved
core/include/moveit/task_constructor/container.h Outdated Show resolved Hide resolved
@v4hn v4hn self-assigned this Apr 7, 2021
@v4hn v4hn force-pushed the modifying-wrapper branch 3 times, most recently from f454c22 to 1ec5fec Compare April 13, 2021 13:02
@v4hn
Copy link
Contributor Author

v4hn commented Apr 13, 2021

I just pushed a set of commits that work for me now. Please have a look @rhaschke.
That took me way longer already than it should. -.-"

I didn't touch the Merger because I don't use it and we don't have any tests for it.
It doesn't rely on the removed sendForward/... methods anyway because you implemented another version of them in there.

@rhaschke
Copy link
Contributor

I won't have time before Thursday...

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

This was hard to review and needs more discussion. Let's have a phone call on Thursday?

core/src/container.cpp Outdated Show resolved Hide resolved
core/src/stages/compute_ik.cpp Outdated Show resolved Hide resolved
core/src/container.cpp Outdated Show resolved Hide resolved
core/src/container.cpp Show resolved Hide resolved
core/src/container.cpp Outdated Show resolved Hide resolved
Comment on lines 212 to 213
const InterfaceState* external_from{ create_from ? new_from : internalToExternalMap().at(internal_from) };
const InterfaceState* external_to{ create_to ? new_to : internalToExternalMap().at(internal_to) };
Copy link
Contributor

Choose a reason for hiding this comment

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

I think, here you assume that internalToExternalMap() is only used to link external and internal states for reading interfaces.
If the interface is writing, i.e. create_* is true, but new_* is a nullptr (like in liftSolution() calls from SerialContainer) the resulting external_* state will be a nullptr as well. Further below, you will pass these null pointers to storeSolution, which passes them on to ContainerBasePrivate::onNewFailure.

core/src/container.cpp Show resolved Hide resolved
Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

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

Just to add a motivation to avoid state bloat in interfaces:
We want to keep the number of states small to avoid extra planning steps in neighbouring states (propagators, connects). For each new interface state, they will trigger a new computation. Thus if the states don't differ (which is now the case for all states lifted from a serial container), we should reuse an existing state.

@v4hn
Copy link
Contributor Author

v4hn commented May 10, 2021

Sorry, I was on sick leave last week and am working through my backlog today.
I will hopefully be available for the rest of this week, so if you want we can have a call about this after I addressed everything else you pointed out here.

@v4hn v4hn force-pushed the modifying-wrapper branch 3 times, most recently from 07d8acb to 6299110 Compare June 8, 2021 12:51
@v4hn
Copy link
Contributor Author

v4hn commented Jun 15, 2021

I somewhat got stuck on a seemingly minor change I don't like to make.
The current internal/external state design dictates that whereas 1 external state can map to n internal ones (to support parallel containers), each internal state can correspond to only one external state - and I thought that's fine.
However, this is not actually true w.r.t. containers. Prominently ComputeIK can spawn more than one external state for the same internal (obviously once you think about it).

The options are either to modify the bimap to allow for 1:n relationships in either direction, or to split up start and end maps, because the direction of the actual 1:n relationship depends on the read/write direction. So I believe if we know whether the interface reads/writes, a single map for each interface could suffice.

analogous to storeSolution
Possible features that require this interface might be
- trajectory reparameterization,
- trajectory optimization as post-processing (like MoveIt's CHOMP adapter),
- multi-trajectory blending (similar to Pilz' sequence planner)

Also remove invalid interfaces.
Parallel containers must always forward solutions of their child stages,
so simple spawning is not allowed without a child solution.
Doesn't make a difference in single-threaded planning, but still better.

Also move to storeState helper.
Required to lift a SolutionSequence, and modify its states (e.g., to add properties).
It's just a nicer interface than calling
`liftModifiedSolution(sol, InterfaceState{s}, InterfaceState{s}, child)` everywhere.
to simplify debugging.
Essential for SerialContainer that spawns multiple solutions
with the same end state.
clang-tidy rightfully complained that moving rvalues doesn't make
sense when the underlying method accepts const refs.

The rvalue parameter interface, as it is used with spawn/etc. indicates
that the solution is submitted to the system. But with the shared_ptr interface
we need for `liftModifiedSolution` it does not make any sense, especially because
we can't even move the passed pointer to the internal datastructures but have to copy...
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.

Missing Interfaces for Modifying Wrapper
2 participants