-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
distance_and_interpolation_provider.h
89 lines (68 loc) · 3.75 KB
/
distance_and_interpolation_provider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include <Eigen/Core>
#include "drake/common/drake_copyable.h"
namespace drake {
namespace planning {
/** This class represents the base interface for performing configuration
distance and interpolation operations, used by CollisionChecker. See
LinearDistanceAndInterpolationProvider for an implementation covering common
"linear" distance and interpolation behavior.
Configuration distance and interpolation are necessary for a CollisionChecker to
perform edge collision checks, and an essential part of many motion planning
problems. The C-spaces for many planning problems combine joints with widely
differing effects (e.g. for a given angular change, the shoulder joint of a
robot arm results in much more significant motion than the same change on a
finger joint) or units (e.g. a mobile robot with translation in meters and yaw
in radians). As a result, it is often necessary to weight elements of the
configuration differently when computing configuration distance.
Likewise, in more complex C-spaces, it may be necessary to perform more complex
interpolation behavior (e.g. when planning for a mobile robot whose motion is
modelled via Dubbins or Reeds-Shepp paths).
Configuration distance takes two configurations of the robot, from and to, both
as Eigen::VectorXd, and returns (potentially weighted) C-space distance as a
double. The returned distance will be strictly non-negative.
To be valid, distance must satisfy the following condition:
- ComputeConfigurationDistance(q, q) ≡ 0
for values of q that are valid for the C-space in use.
Configuration interpolation takes two configurations of the robot, from and to,
both as Eigen::VectorXd, plus a ratio in [0, 1] and returns the interpolated
configuration.
To be valid, interpolation must satisfy the following conditions:
- InterpolateBetweenConfigurations(from, to, 0) ≡ from
- InterpolateBetweenConfigurations(from, to, 1) ≡ to
- InterpolateBetweenConfigurations(q, q, ratio) ≡ q, for all ratio in [0, 1]
for values of q, from, and to that are valid for the C-space in use.*/
class DistanceAndInterpolationProvider {
public:
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(DistanceAndInterpolationProvider);
virtual ~DistanceAndInterpolationProvider();
/** Computes the configuration distance from the provided configuration `from`
to the provided configuration `to`. The returned distance will be strictly
non-negative.
@pre from.size() == to.size() */
double ComputeConfigurationDistance(const Eigen::VectorXd& from,
const Eigen::VectorXd& to) const;
/** Returns the interpolated configuration between `from` and `to` at `ratio`.
@pre from.size() == to.size()
@pre ratio in [0, 1] */
Eigen::VectorXd InterpolateBetweenConfigurations(const Eigen::VectorXd& from,
const Eigen::VectorXd& to,
double ratio) const;
protected:
DistanceAndInterpolationProvider();
/** Derived distance and interpolation providers must implement distance
computation. The returned distance must be non-negative.
DistanceAndInterpolationProvider ensures that `from` and `to` are the same
size. */
virtual double DoComputeConfigurationDistance(
const Eigen::VectorXd& from, const Eigen::VectorXd& to) const = 0;
/** Derived distance and interpolation providers must implement interpolation.
The returned configuration must be the same size as `from` and `to`.
DistanceAndInterpolationProvider ensures that `from` and `to` are the same
size and that `ratio` is in [0, 1]. */
virtual Eigen::VectorXd DoInterpolateBetweenConfigurations(
const Eigen::VectorXd& from, const Eigen::VectorXd& to,
double ratio) const = 0;
};
} // namespace planning
} // namespace drake