forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
point.h
105 lines (78 loc) · 3.53 KB
/
point.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#pragma once
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "drake/geometry/optimization/convex_set.h"
namespace drake {
namespace geometry {
namespace optimization {
/** A convex set that contains exactly one element. Also known as a
singleton or unit set.
This set is always nonempty, even in the zero-dimensional case.
@ingroup geometry_optimization */
class Point final : public ConvexSet {
public:
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Point);
/** Constructs a default (zero-dimensional, nonempty) set. */
Point();
/** Constructs a Point. */
explicit Point(const Eigen::Ref<const Eigen::VectorXd>& x);
/** Constructs a Point from a SceneGraph geometry and pose in the
`reference_frame` frame, obtained via the QueryObject. If `reference_frame`
frame is std::nullopt, then it will be expressed in the world frame.
@throws std::exception if geometry_id does not correspond to a Sphere or if
the Sphere has radius greater than `maximum_allowable_radius`. */
Point(const QueryObject<double>& query_object, GeometryId geometry_id,
std::optional<FrameId> reference_frame = std::nullopt,
double maximum_allowable_radius = 0.0);
~Point() final;
/** Returns true if the point is within `tol` of x(), under the L∞-norm. */
using ConvexSet::PointInSet;
/** Retrieves the point. */
const Eigen::VectorXd& x() const { return x_; }
/** Changes the element `x` describing the set.
@pre x must be of size ambient_dimension(). */
void set_x(const Eigen::Ref<const Eigen::VectorXd>& x);
/** Every Point is bounded by construction.
@param parallelism Ignored -- no parallelization is used.
@note See @ref ConvexSet::IsBounded "parent class's documentation" for more
details. */
using ConvexSet::IsBounded;
private:
std::unique_ptr<ConvexSet> DoClone() const final;
std::optional<bool> DoIsBoundedShortcut() const final;
/** A Point is always nonempty, even in the zero-dimensional case. */
bool DoIsEmpty() const final;
std::optional<Eigen::VectorXd> DoMaybeGetPoint() const final;
std::optional<bool> DoPointInSetShortcut(
const Eigen::Ref<const Eigen::VectorXd>& x, double tol) const final;
std::pair<VectorX<symbolic::Variable>,
std::vector<solvers::Binding<solvers::Constraint>>>
DoAddPointInSetConstraints(
solvers::MathematicalProgram*,
const Eigen::Ref<const solvers::VectorXDecisionVariable>&) const final;
std::vector<solvers::Binding<solvers::Constraint>>
DoAddPointInNonnegativeScalingConstraints(
solvers::MathematicalProgram* prog,
const Eigen::Ref<const solvers::VectorXDecisionVariable>& x,
const symbolic::Variable& t) const final;
std::vector<solvers::Binding<solvers::Constraint>>
DoAddPointInNonnegativeScalingConstraints(
solvers::MathematicalProgram* prog,
const Eigen::Ref<const Eigen::MatrixXd>& A,
const Eigen::Ref<const Eigen::VectorXd>& b,
const Eigen::Ref<const Eigen::VectorXd>& c, double d,
const Eigen::Ref<const solvers::VectorXDecisionVariable>& x,
const Eigen::Ref<const solvers::VectorXDecisionVariable>& t) const final;
std::pair<std::unique_ptr<Shape>, math::RigidTransformd> DoToShapeWithPose()
const final;
double DoCalcVolume() const final { return 0.0; }
std::vector<std::optional<double>> DoProjectionShortcut(
const Eigen::Ref<const Eigen::MatrixXd>& points,
EigenPtr<Eigen::MatrixXd> projected_points) const final;
Eigen::VectorXd x_;
};
} // namespace optimization
} // namespace geometry
} // namespace drake