Commit Graph

1005 Commits

Author SHA1 Message Date
v4hn
f63d5b6892 Make transform in cost::Clearance configurable
In theory this can be done with a PassThrough with a modifying transform,
but this specific mapping is intrinsic to the definition of Clearance as a cost.
2020-09-21 22:52:19 +02:00
v4hn
cdc7cb04fc refactor Forward -> PassThrough
based on review feedback
2020-09-21 22:52:19 +02:00
v4hn
64e2440c53 simplify LinkMotion computation
review feedback
2020-09-21 22:52:19 +02:00
v4hn
05932ad5f1 enable implicit construction of CostTerm from lambdas
without the need for explicit casts to the correct signature.
2020-09-21 22:52:19 +02:00
v4hn
034a155315 provide CostTerm class for all CostTerms
This pattern allows cost::Constant to override the hierarchical cost computation
for the SerialContainer and avoid traversing the graph.

I implemented the CostTerm::supports() pattern over a full double visitor pattern
with overloads for each SolutionBase specialization, because the SerialContainer
needs to know whether cost aggregation of the subsolutions should take place or whether
the SolutionSequence should be forwarded to the CostTerm.
This would not be possible with a `virtual double operator()(const SolutionSequence&)`
callback in CostTerm.

Alternatively, implementing the hierarchical aggregation in the default implementation
of this operator would be possible as well, but breaks intuition:
- the corresponding methods to handle `SubTrajectory` and `WrappedSolution` *have to*
  default to not touching the solution's cost at all so it is inappropriate to have
  the default implementation for the Sequence do something else
- The SerialContainer also aggregates costs outside the `computeCost()` interface
  (in multiple places in `onNewSolution()` to aggregate costs along partial paths)
  and thus moving the hierarchical aggregation to the CostTerm methods requires
  the aggregator to be shared between the Container and the CostTerm,

The only shortcoming of the implemented approach, by contrast, is that user implementations
that want to handle WrappedSolution or SolutionSequence differently have to ensure
the supports_ flags are set correctly. Notice that most custom CostTerms will only
ever access SubTrajectories and this case is simplified with the provided CostTerm constructors.
2020-09-21 22:50:51 +02:00
v4hn
8ae1060b4d add CostAggregator for SerialContainer
It can be useful to change the default addition to other operators.

The simplest example is applying a Constant cost term to a container.
As the tests show, the visitor-based cost computation ends up adding
cost::Constant *for each subtrajectory*.
2020-09-21 22:50:51 +02:00
v4hn
28b98e989c improve cost term tests
- add tests for nested containers
- add descriptions to checks
- refactor helper to support different containers
2020-09-21 22:50:45 +02:00
v4hn
dcee7c408f add basic tests for using cost terms 2020-09-21 22:31:52 +02:00
v4hn
1689f6cd95 introduce new trivial stage Forward
This can be used together with a custom CostTerm to modify costs of a solution.
2020-09-21 22:31:52 +02:00
v4hn
0e38730fd4 compute cost in liftSolution as well 2020-09-21 22:31:52 +02:00
v4hn
939f0b7256 setCostTermShort(nullptr) must not set a valid function 2020-09-21 22:31:52 +02:00
v4hn
a0975e3afc avoid ambiguity of setCostTerm(nullptr) 2020-09-21 22:31:52 +02:00
v4hn
d68ab383b6 allow setCostTerm for containers
implement visitor pattern for cost computation on solutions

- compute cost terms for solution subtrees instead of only for SubTrajectory

- allows users to set cost terms for containers
2020-09-21 22:31:24 +02:00
v4hn
039b0a2c27 move more overhead to computeCost 2020-09-21 22:31:23 +02:00
v4hn
e53d943b75 remove CostTransform
If required, this can hopefully be implemented through Wrapper stages soon.
2020-09-21 22:31:23 +02:00
v4hn
53c0964618 cost computation: provide valid interface states for Solution
The CostTerm's should get only a single solution that is well-setup
with its InterfaceStates. That's impossible though because these
states are stored in different places depending on the cost.

To avoid this, set stub states for cost computation
and change them to the real states later on.

This is motivated by the Clearance cost which can act on an InterfaceState only.
2020-09-21 22:31:23 +02:00
v4hn
bbf7d415f6 make cost operators const 2020-09-21 22:28:36 +02:00
v4hn
1f8feaaf0a refactor addCost->computeCost 2020-09-21 22:26:25 +02:00
v4hn
d2bd0a0037 generalize Clearance cost
- can now be used to estimate cost for either interface state or the trajectory
- Introduced Interface::Direction NONE as a way of pointing to the trajectory in contrast to START or END
2020-09-21 22:26:25 +02:00
v4hn
7a00ac646e add missing license 2020-09-21 22:24:44 +02:00
v4hn
14c885621f remove Cost suffix for elements in mtc::cost:: 2020-09-21 22:24:44 +02:00
v4hn
9a96a7e4f6 implement LinkMotionCost 2020-09-21 22:24:44 +02:00
v4hn
6dbc742f20 implement correct PathLengthCost
The previous implementation depends on the dynamics limits of the robot,
which might be interesting in some cases, but shouldn't be a default anywhere.
2020-09-21 22:24:44 +02:00
v4hn
a92753dafc add cumulative distance to ClearanceCost 2020-09-21 22:24:44 +02:00
v4hn
18ed51d7f3 turn Clearance cost into parameterized struct
There is a lot of variations for how to compute clearance.
2020-09-21 22:24:44 +02:00
v4hn
cf0e4e3b01 establish struct cost pattern
for costs with multiple parameters, this option-style is more useful
than verbose getter/setter. There is nothing to hide here.
2020-09-21 22:24:07 +02:00
v4hn
f9ba302728 enable costs to (optionally) return a comment
With more complicated costs (such as the ClearanceCost), it's useful to get comments.
2020-09-21 22:22:37 +02:00
v4hn
a15204b40b allow wrappers to use CostTerm 2020-09-21 22:22:37 +02:00
v4hn
56268cb6cc first attempts on ClearanceCost 2020-09-21 22:22:37 +02:00
v4hn
9060404037 improve comments 2020-09-21 22:22:37 +02:00
v4hn
f3fec26f5a add CostTransform
CostTerms only apply to primitive solutions and generalizing them
to Containers would make them quite unintuitive (and adds overhead).

Instead CostTransform can be used in any container to scale, crop, square
the cost of the solutions.

I initially thought about adding scaling factors, but then again,
other transforms are of interest just as well.
2020-09-21 22:22:37 +02:00
v4hn
f79625d1bd fully restrict CostTerms to primitive solutions
simplify implementations.
2020-09-21 22:22:37 +02:00
v4hn
ffc62c2d11 add explicit default CostTerms to most basic stages
Simplifies code and makes the costs of each stage explicit.
2020-09-21 22:22:37 +02:00
v4hn
9eae554d89 provide Constant and PathLength cost terms 2020-09-21 22:22:37 +02:00
Robert Haschke
dd9ce974ce
tf2 compatibility for Noetic (#206) 2020-09-21 21:43:34 +02:00
v4hn
9337743de2 add CostTerm interface
basic stages can now be configured with arbitrary cost terms.
2020-09-21 18:02:49 +02:00
v4hn
1a2eafa256 fix stage test mock
base class init needs to be called although this didn't pose problems
until now.
2020-09-17 23:00:12 +02:00
Robert Haschke
b0b4db4bc5
Fix pick-place-demo: Correctly set hand group (#205) 2020-09-07 15:14:08 +02:00
v4hn
c510c6b5b6 WrappedSolution: expose child solution
SolutionSequence allows to access children already,
but WrappedSolution blocked access to the full hierarchy.
2020-08-21 14:41:22 +02:00
v4hn
4a6c389aee expose WrappedSolution together with other Solution types
Moved out of private header.

Users can access these objects, so they should know about the type.
2020-08-21 14:41:22 +02:00
v4hn
7609f0b1e2 Solution: export public creator
It's a public interface, returning private pointer is not neat.
2020-08-21 14:41:22 +02:00
v4hn
3aa0cfc1a2 InterfaceState: provide constructor with initial Priority
most useful to prepare a valid InterfaceState in tests
2020-08-21 14:41:22 +02:00
v4hn
6e0e323a58 PredicateFilter: actually use declared property 2020-08-20 15:29:45 +02:00
v4hn
310ca3ef15 MoveTo: support map<string,double> joint target
There was a corresponding setGoal method already, but no implementation...
2020-08-20 15:20:29 +02:00
Michael Görner
ee6c50ad31
Apply clang-format-10 (#199) 2020-08-20 11:56:53 +02:00
Michael Görner
47f052b93d
adapt tests to new moveit_resources layout (#200) 2020-08-20 11:04:18 +02:00
v4hn
62813f33f7 fix c&p error in documentation 2020-08-11 20:43:34 +02:00
v4hn
62d894199f expose Stage API to get the matching introspection ID
This was implicitly requested in #192 .
2020-08-11 20:43:34 +02:00
v4hn
6bebe3f3ed do not mix pimpl() and impl for no reason 2020-08-11 20:43:34 +02:00
v4hn
03c7f55fcc fix unused-parameter warning 2020-08-11 20:43:34 +02:00