cheshirekow  v0.1.0
types.h
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  */
27 #ifndef MPBLOCKS_DUBINS_CURVES_TYPES_H_
28 #define MPBLOCKS_DUBINS_CURVES_TYPES_H_
29 
30 namespace mpblocks {
31 namespace dubins {
32 
34 struct L{};
35 
37 struct R{};
38 
40 struct S{};
41 
43 struct a{};
44 
46 struct b{};
47 
50 {
55  LSL,
56  RSR,
57  LSR,
58  RSL,
60 };
61 
63 template <class P1, class P2, class P3, class V=a>
64 struct TypeToId{ static const SolutionId ID = INVALID; };
65 
66 // these types have a variant
67 template <> struct TypeToId<L,R,L,a>{ static const SolutionId ID = LRLa; };
68 template <> struct TypeToId<L,R,L,b>{ static const SolutionId ID = LRLb; };
69 template <> struct TypeToId<R,L,R,a>{ static const SolutionId ID = RLRa; };
70 template <> struct TypeToId<R,L,R,b>{ static const SolutionId ID = RLRb; };
71 
72 // these types dont have a variant
73 template <class V> struct TypeToId<L,S,L,V>{ static const SolutionId ID = LSL; };
74 template <class V> struct TypeToId<R,S,R,V>{ static const SolutionId ID = RSR; };
75 template <class V> struct TypeToId<L,S,R,V>{ static const SolutionId ID = LSR; };
76 template <class V> struct TypeToId<R,S,L,V>{ static const SolutionId ID = RSL; };
77 
79 template <SolutionId ID, int i>
80 struct IdToType{ typedef void Result; };
81 
82 template <> struct IdToType<LRLa,0>{ typedef L Result; };
83 template <> struct IdToType<LRLa,1>{ typedef R Result; };
84 template <> struct IdToType<LRLa,2>{ typedef L Result; };
85 template <> struct IdToType<LRLb,0>{ typedef L Result; };
86 template <> struct IdToType<LRLb,1>{ typedef R Result; };
87 template <> struct IdToType<LRLb,2>{ typedef L Result; };
88 
89 template <> struct IdToType<RLRa,0>{ typedef R Result; };
90 template <> struct IdToType<RLRa,1>{ typedef L Result; };
91 template <> struct IdToType<RLRa,2>{ typedef R Result; };
92 template <> struct IdToType<RLRb,0>{ typedef R Result; };
93 template <> struct IdToType<RLRb,1>{ typedef L Result; };
94 template <> struct IdToType<RLRb,2>{ typedef R Result; };
95 
96 template <> struct IdToType<LSL,0>{ typedef L Result; };
97 template <> struct IdToType<LSL,1>{ typedef S Result; };
98 template <> struct IdToType<LSL,2>{ typedef L Result; };
99 template <> struct IdToType<LSR,0>{ typedef L Result; };
100 template <> struct IdToType<LSR,1>{ typedef S Result; };
101 template <> struct IdToType<LSR,2>{ typedef R Result; };
102 
103 template <> struct IdToType<RSR,0>{ typedef R Result; };
104 template <> struct IdToType<RSR,1>{ typedef S Result; };
105 template <> struct IdToType<RSR,2>{ typedef R Result; };
106 template <> struct IdToType<RSL,0>{ typedef R Result; };
107 template <> struct IdToType<RSL,1>{ typedef S Result; };
108 template <> struct IdToType<RSL,2>{ typedef L Result; };
109 
110 } // dubins
111 } // mpblocks
112 
113 #endif // MPBLOCKS_DUBINS_CURVES_TYPES_H_
converts a SolutionID and index 0,1,2 into a type
Definition: types.h:80
empty struct used to template "variant" of three arc primitives
Definition: types.h:46
empty struct used to template "variant" of three arc primitives
Definition: types.h:43
empty struct used to template "right turn" primitive
Definition: types.h:37
empty struct used to template "straight" primitive
Definition: types.h:40
empty struct used to template "left turn" primitive
Definition: types.h:34
static const SolutionId ID
Definition: types.h:64
SolutionId
enumerates solution types
Definition: types.h:49
converts template paramters to SolutionID
Definition: types.h:64