cheshirekow  v0.1.0
SolutionLSL.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
26 #ifndef MPBLOCKS_DUBINS_CURVES_EIGEN_SOLUTION_LSL_HPP_
27 #define MPBLOCKS_DUBINS_CURVES_EIGEN_SOLUTION_LSL_HPP_
28 
32 
33 namespace mpblocks {
34 namespace dubins {
35 namespace curves_eigen {
36 
38 template <typename Scalar>
39 struct Solver<LSL, Scalar> {
40  typedef Eigen::Matrix<Scalar, 3, 1> Vector3d;
41  typedef Eigen::Matrix<Scalar, 2, 1> Vector2d;
42 
43  static Path<Scalar> solve(const Vector3d& q0, const Vector3d& q1,
44  const Scalar r) {
45  Path<Scalar> out(LSL);
46  Vector2d c[2];
47  Vector3d s;
48 
49  // calculate the center of the circle to which q1 is tangent
50  c[0] = leftCenter(q0, r);
51 
52  // calculate the center of the circle to which q2 is tangent
53  c[1] = leftCenter(q1, r);
54 
55  // find the vector between the two
56  Vector2d v = c[1] - c[0];
57 
58  // the length of the straight segment is the length of this vector
59  s[1] = v.norm();
60 
61  // the angle of that vector is the target angle of the vehicle
62  Scalar t0 = q0[2];
63  Scalar t1 = std::atan2(v[1], v[0]);
64  Scalar t2 = q1[2];
65  s[0] = ccwArc(t0, t1);
66  s[2] = ccwArc(t1, t2);
67 
68  out = s;
69  return out;
70  }
71 };
72 
73 } // curves_eigen
74 } // dubins
75 } // mpblocks
76 
77 #endif // MPBLOCKS_DUBINS_CURVES_EIGEN_SOLUTION_LSL_HPP_
static Path< Scalar > solve(const Vector3d &q0, const Vector3d &q1, const Scalar r)
Definition: SolutionLSL.hpp:43
__host__ __device__ Format_t ccwArc(Format_t a, Format_t b)
returns the counter clockwise (left) distance from a to b
Definition: funcs.hpp:51
interface for different solutions, this is specialized for each Id in the SolutionId enum ...
Definition: solver.h:39
Encodes a dubins path primitive, which is three connected arc segments.
Definition: path.h:42
Eigen::Matrix< Scalar, 2, 1 > leftCenter(const Eigen::Matrix< Scalar, 3, 1 > &q, Scalar r)
return the center of a counter clockwise (left) circle coincident to q with radius r ...
Definition: funcs.hpp:54