Drake
multilane_brute_force_integral.h
Go to the documentation of this file.
1 #pragma once
2
3 #include <tuple>
4
5
6
7 namespace drake {
8 namespace maliput {
9 namespace multilane {
10 namespace test {
11
12 // Approximates a path length lower bound for the given @p road_curve
13 // from @p p_0 to @p p_1, for constant @p r and @p h offsets, by
14 // computing the same integral for a 2^@p k_order linear approximation.
15 //
17 // @param p_0 The lower integration bound for the p coordinate.
18 // @param p_1 The upper integration bound for the p coordinate.
19 // @param r The r coordinate offset.
20 // @param h The h coordinate offset.
21 // @param k_order Order k of the linear approximation, i.e. 2^k segments
22 // are used in the approximation.
23 // @param maximum_step A mutable reference that, if given (can be nullptr), is
24 // set to the maximum step length used in the computation.
25 // @pre Given upper integration bound @p p_1 is less than or equal to 1.
26 // @pre Given upper integration bound @p p_1 is greater than or equal to
27 // the given lower integration bound @p p_0.
28 // @pre Given lower integration bound @p p_0 is greater than or equal to 0.
29 // @pre Given @p k_order for the linear approximation is a non-negative number.
30 // @throw std::runtime_error if preconditions are not met.
32  double p_0, double p_1, double r,
33  double h, int k_order,
34  double* maximum_step);
35
36 // Approximates the path length of a given @p road_curve from @p p_0 to @p p_1,
37 // for constant @p r and @p h offsets, to within specified @p tolerance.
38 //
39 // To ensure the error falls within @p tolerance, a path length lower bound
40 // is used (see BruteForcePathLengthIntegral()). If the curve is split in pieces
41 // no longer than the scale length of the curve, assuming the curve is well
42 // behaved, each one of the pieces can roughly be approximated as a constant
43 // curvature arc of radius R, subtending an angle θ. Then, let E(k) be the kth
44 // order approximation computed as the length of the chord that connects the arc
45 // endpoints, E(k+1) be the (k+1)th order approximation computed as the sum
46 // of the lengths of the resulting chords after an arc bisection and E(∞) be the
47 // true path length. It can be shown that: E(∞) - E(k+1) <= E(k+1) - E(k).
48 //
49 // TODO(hidmic): Compute a path length upper bound to ensure the approximation
50 // is within tolerance.
51 //
53 // @param p_0 The lower integration bound for the p coordinate.
54 // @param p_1 The upper integration bound for the p coordinate.
55 // @param r The r coordinate offset.
56 // @param h The h coordinate offset.
57 // @param tolerance The tolerance for the approximation, in the absolute error
58 // sense.
59 // @param k_order_hint A mutable reference to the order k of the linear
60 // approximation that, if given (can be nullptr) it's used
61 // as hint on call and it's updated to the actually required
62 // order necessary to achieve the specified tolerance on
63 // return.
64 // @pre Given upper integration bound @p p_1 is less than or equal to 1.
65 // @pre Given upper integration bound @p p_1 is greater than or equal to
66 // the given lower integration bound @p p_0.
67 // @pre Given lower integration bound @p p_0 is greater than or equal to 0.
68 // @pre Given tolerance is a positive real number.
69 // @pre If given, the order suggested by @p k_order_hint is a non-negative
70 // number.
71 // @throw std::runtime_error if preconditions are not met.
73  const RoadCurve& rc, double p_0, double p_1,
74  double r, double h, double tolerance,
75  int* k_order_hint);
76
77 } // namespace test
78 } // namespace multilane
79 } // namespace maliput
80 } // namespace drake
Definition: automotive_demo.cc:105