cheshirekow  v0.1.0
solver.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_SOLVER_HPP_
27 #define MPBLOCKS_DUBINS_CURVES_EIGEN_SOLVER_HPP_
28 
29 namespace mpblocks {
30 namespace dubins {
31 namespace curves_eigen {
32 
33 template <SolutionId idx, typename Format_t>
38 
39  static Result_t solve(const Eigen::Matrix<Format_t, 3, 1>& q0,
40  const Eigen::Matrix<Format_t, 3, 1>& q1,
41  const Format_t r) {
42  Result_t thisResult = Solver_t::solve(q0, q1, r);
43  return bestOf(thisResult, Next_t::solve(q0, q1, r), r);
44  }
45 
46  static Result_t solve_specific(int solnId,
47  const Eigen::Matrix<Format_t, 3, 1>& q0,
48  const Eigen::Matrix<Format_t, 3, 1>& q1,
49  const Format_t r) {
50  if (solnId == idx)
51  return Solver_t::solve(q0, q1, r);
52  else
53  return Next_t::solve_specific(solnId, q0, q1, r);
54  }
55 };
56 
57 template <typename Format_t>
58 struct SolverIterator<INVALID, Format_t> {
60 
61  static Result_t solve(const Eigen::Matrix<Format_t, 3, 1>& q0,
62  const Eigen::Matrix<Format_t, 3, 1>& q1,
63  const Format_t r) {
64  return Result_t();
65  }
66 
67  static Result_t solve_specific(int solnId,
68  const Eigen::Matrix<Format_t, 3, 1>& q0,
69  const Eigen::Matrix<Format_t, 3, 1>& q1,
70  const Format_t r) {
71  return Result_t();
72  }
73 };
74 
75 template <typename Format_t>
76 Path<Format_t> solve(const Eigen::Matrix<Format_t, 3, 1>& q0,
77  const Eigen::Matrix<Format_t, 3, 1>& q1,
78  const Format_t r) {
80 }
81 
82 template <typename Format_t>
84  const Eigen::Matrix<Format_t, 3, 1>& q0,
85  const Eigen::Matrix<Format_t, 3, 1>& q1,
86  const Format_t r) {
88  solnId, q0, q1, r);
89 }
90 
91 } // curves_eigen
92 } // dubins
93 } // mpblocks
94 
95 #endif // MPBLOCKS_DUBINS_CURVES_EIGEN_SOLVER_HPP_
static Result_t solve_specific(int solnId, const Eigen::Matrix< Format_t, 3, 1 > &q0, const Eigen::Matrix< Format_t, 3, 1 > &q1, const Format_t r)
Definition: solver.hpp:67
static Result_t solve_specific(int solnId, const Eigen::Matrix< Format_t, 3, 1 > &q0, const Eigen::Matrix< Format_t, 3, 1 > &q1, const Format_t r)
Definition: solver.hpp:46
static Result_t solve(const Vector3d_t &q0, const Vector3d_t &q1, const Format_t r)
Path< Format_t > solve_specific(int solver, const Eigen::Matrix< Format_t, 3, 1 > &q0, const Eigen::Matrix< Format_t, 3, 1 > &q1, const Format_t r)
Definition: solver.hpp:83
static Result_t solve(const Eigen::Matrix< Format_t, 3, 1 > &q0, const Eigen::Matrix< Format_t, 3, 1 > &q1, const Format_t r)
Definition: solver.hpp:61
interface for different solutions, this is specialized for each Id in the SolutionId enum ...
Definition: solver.h:39
Path< Format_t > solve(const Eigen::Matrix< Format_t, 3, 1 > &q0, const Eigen::Matrix< Format_t, 3, 1 > &q1, const Format_t r)
Definition: solver.hpp:76
Encodes a dubins path primitive, which is three connected arc segments.
Definition: path.h:42
static Result_t solve(const Eigen::Matrix< Format_t, 3, 1 > &q0, const Eigen::Matrix< Format_t, 3, 1 > &q1, const Format_t r)
Definition: solver.hpp:39
Path< Format_t > bestOf(const Path< Format_t > &r0, const Path< Format_t > &r1, const Format_t r)
Definition: path.h:96
SolverIterator<(SolutionId)(idx+1), Format_t > Next_t
Definition: solver.hpp:37