Commit Graph

578 Commits

Author SHA1 Message Date
Robert Haschke
8433e460e4 Merge branch 'master' into wip-python-api 2020-11-26 12:05:03 +01:00
cpetersmeier
012a10be25 StagesWrapper: Python Function Bindings
Add python bindings for

    - SimpleGrasp::setIKFrame
    - Pick::setApproachMotion
    - Pick::setLiftMotion
2020-11-26 11:47:20 +01:00
Robert Haschke
bfa2a6070d MoveTo: Publish failed planning attempts 2020-10-30 00:44:51 +01:00
Robert Haschke
ae843a784e Merge PR #214 (fix various issues) and #215 (rework rviz introspection) 2020-10-24 04:45:53 +02:00
Robert Haschke
cf5031e89d Create task-specific ServiceClients to fetch solutions
This finally allows to have multiple tasks publishing in the same namespace.
2020-10-24 04:43:30 +02:00
Robert Haschke
b91d87c6eb IntroSpection: indicateReset() on disable 2020-10-24 04:43:30 +02:00
Robert Haschke
8b1c66c4b7 Allow naming a Task
which just names the top-level container
2020-10-24 04:43:30 +02:00
Robert Haschke
c471879b08 Rename process_id -> task_id 2020-10-24 04:43:30 +02:00
Robert Haschke
b071a059f9 Rename TaskPrivate::id -> TaskPrivate::ns
TaskPrivate's id_ actually served as a namespace parameter.
2020-10-24 04:43:30 +02:00
Robert Haschke
3a7a4eb953 Connect: Fix segfault when accessing solutions from multiple plan() calls
Connect::init() was resetting its dynamically created JMG merged_jmg_,
thus invalidating all previous solutions. Only reset the JMG in reset().
2020-10-24 03:23:19 +02:00
Robert Haschke
cb0f20cad7 Improve task unittests 2020-10-24 03:22:46 +02:00
Jafar Abdi
be270cb574
Task: Add ability to set timeout (#213)
Task::setTimeout will allow setting an overall timeout.
2020-10-24 03:22:05 +02:00
cpetersmeier
ede5fe396f StagesWrapper: Add std::map setGoal overload.
Adding a further overload of the `setGoal()` function that is exposed to
the python api. This should provide an interface for passing in dicts as
joint name and -angle configurations.
2020-10-21 16:45:05 +02:00
Robert Haschke
d3b878a31c Fix issues with Merger stage 2020-09-23 08:00:42 +02:00
Robert Haschke
88c217e9a6 Report exceptions (e.g. config issues) 2020-09-23 07:59:39 +02:00
Robert Haschke
7499f7b297 Report merge failures 2020-09-23 07:59:39 +02:00
Robert Haschke
14fc3d2586 Reject failures early 2020-09-23 07:59:39 +02:00
Robert Haschke
49b2ff8ce5 Test Merger 2020-09-22 11:06:34 +02:00
Robert Haschke
745d6739bd fix typo 2020-09-22 11:06:01 +02:00
Robert Haschke
8152994e52 Fix interface resolution 2020-09-22 10:57:49 +02:00
Robert Haschke
4089d5eefa Container::remove(): return removed Stage 2020-09-22 10:56:11 +02:00
Robert Haschke
198f8f5389 clearer naming of cost variables 2020-09-21 22:52:19 +02:00
v4hn
04a8afb16c melodic compatibility 2020-09-21 22:52:19 +02:00
v4hn
5d0fd57754 initialize default CostTerm in constructor
It seems to be too fragile to rely on `init` being called.
On the other hand we should really enforce this anyway. -.-
2020-09-21 22:52:19 +02:00
Robert Haschke
687fcb6a6d Update comments to solution's computeCost() methods 2020-09-21 22:52:19 +02:00
v4hn
62586c2688 rework CostTerm's from support flags to vtable
requested in review.

Without support for custom aggregators, which we dropped again
after finding more flaws with it, I agree that this is the nicer solution.

On the downside, it converts the interfaces from copyable objects
to another round of shared_ptrs.

I added shortcuts for lambda costs to keep support for
`stage->setCostTerm([](auto&& s){ return 42; })`
without the additional
`stage->setCostTerm(LambdaCostTerm{ [](auto&& s){ return 42; } } )`
2020-09-21 22:52:19 +02:00
v4hn
45e6cdb47d Revert "add CostAggregator for SerialContainer"
This reverts commit dc7ce9bdfac97eb468f5a850adcb27cc118b5fd7.

It turns out multiple places in SerialContainer's cost inference
expect 0.0 as the neutral element (which is why std::min and multiply did not work).
While these additional issues can be fixed, it would make the interface much less elegant.

We should consider adding it back if an actual use-case is there to discuss.
2020-09-21 22:52:19 +02:00
v4hn
cce7380f9d Clearance: provide better interface for different modes
Interface::Direction should always designate a valid direction.
2020-09-21 22:52:19 +02:00
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