pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
joint-unary-visitor.hpp
1//
2// Copyright (c) 2015-2023 CNRS INRIA
3//
4
5#ifndef __pinocchio_multibody_visitor_joint_unary_visitor_hpp__
6#define __pinocchio_multibody_visitor_joint_unary_visitor_hpp__
7
8#include <boost/variant/apply_visitor.hpp>
9#include <boost/variant/get.hpp>
10
11#include "pinocchio/multibody/visitor/fusion.hpp"
12#include "pinocchio/multibody/joint/joint-base.hpp"
13
14namespace pinocchio
15{
16 namespace fusion
17 {
18
24 template<typename JointVisitorDerived, typename ReturnType = void>
26 {
27
28 template<
29 typename Scalar,
30 int Options,
31 template<typename, int> class JointCollectionTpl,
32 typename ArgsTmp>
33 static ReturnType run(
36 ArgsTmp args)
37 {
39 visitor(jdata, args);
40 return boost::apply_visitor(visitor, jmodel);
41 }
42
43 template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
44 static ReturnType run(
47 {
49 visitor(jdata);
50 return boost::apply_visitor(visitor, jmodel);
51 }
52
53 template<typename JointModelDerived, typename ArgsTmp>
54 static ReturnType run(
57 ArgsTmp args)
58 {
60 return visitor(jmodel.derived());
61 }
62
63 template<typename JointModelDerived>
64 static ReturnType run(
67 {
69 return visitor(jmodel.derived());
70 }
71
72 template<
73 typename Scalar,
74 int Options,
75 template<typename, int> class JointCollectionTpl,
76 typename ArgsTmp>
77 static ReturnType
79 {
81 return boost::apply_visitor(visitor, jmodel);
82 }
83
84 template<
85 typename Scalar,
86 int Options,
87 template<typename, int> class JointCollectionTpl,
88 typename ArgsTmp>
89 static ReturnType
91 {
93 return boost::apply_visitor(visitor, jdata);
94 }
95
96 template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
97 static ReturnType run(const JointModelTpl<Scalar, Options, JointCollectionTpl> & jmodel)
98 {
100 return boost::apply_visitor(visitor, jmodel);
101 }
102
103 template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
104 static ReturnType run(const JointDataTpl<Scalar, Options, JointCollectionTpl> & jdata)
105 {
107 return boost::apply_visitor(visitor, jdata);
108 }
109
110 template<typename JointModelDerived, typename ArgsTmp>
111 static ReturnType run(const JointModelBase<JointModelDerived> & jmodel, ArgsTmp args)
112 {
114 return visitor(jmodel.derived());
115 }
116
117 template<typename JointDataDerived, typename ArgsTmp>
118 static ReturnType run(const JointDataBase<JointDataDerived> & jdata, ArgsTmp args)
119 {
121 return visitor(jdata.derived());
122 }
123
124 template<typename JointModelDerived>
125 static ReturnType run(const JointModelBase<JointModelDerived> & jmodel)
126 {
128 return visitor(jmodel.derived());
129 }
130
131 template<typename JointDataDerived>
132 static ReturnType run(const JointDataBase<JointDataDerived> & jdata)
133 {
135 return visitor(jdata.derived());
136 }
137
138 private:
139 template<typename JointModel, typename ArgType>
140 struct InternalVisitorModelAndData : public boost::static_visitor<ReturnType>
141 {
142 typedef typename JointModel::JointDataDerived JointData;
143
144 InternalVisitorModelAndData(JointData & jdata, ArgType args)
145 : jdata(jdata)
146 , args(args)
147 {
148 }
149
150 template<typename JointModelDerived>
151 ReturnType operator()(const JointModelBase<JointModelDerived> & jmodel) const
152 {
153 return bf::invoke(
154 &JointVisitorDerived::template algo<JointModelDerived>,
155 bf::append(
156 boost::ref(jmodel.derived()),
157 boost::ref(
158 boost::get<typename JointModelBase<JointModelDerived>::JointDataDerived>(jdata)),
159 args));
160 }
161
162 ReturnType operator()(const JointModelVoid)
163 {
164 return;
165 }
166
167 JointData & jdata;
168 ArgType args;
169 };
170
171 template<typename JointModel>
172 struct InternalVisitorModelAndData<JointModel, NoArg>
173 : public boost::static_visitor<ReturnType>
174 {
175 typedef typename JointModel::JointDataDerived JointData;
176
177 InternalVisitorModelAndData(JointData & jdata)
178 : jdata(jdata)
179 {
180 }
181
182 template<typename JointModelDerived>
183 ReturnType operator()(const JointModelBase<JointModelDerived> & jmodel) const
184 {
185 return bf::invoke(
186 &JointVisitorDerived::template algo<JointModelDerived>,
187 bf::make_vector(
188 boost::ref(jmodel.derived()),
189 boost::ref(
190 boost::get<typename JointModelBase<JointModelDerived>::JointDataDerived>(jdata))));
191 }
192
193 JointData & jdata;
194 };
195
196 template<typename ArgType, typename Dummy = void>
197 struct InternalVisitorModel : public boost::static_visitor<ReturnType>
198 {
199 InternalVisitorModel(ArgType args)
200 : args(args)
201 {
202 }
203
204 template<typename JointModelDerived>
205 ReturnType operator()(const JointModelBase<JointModelDerived> & jmodel) const
206 {
207 return bf::invoke(
208 &JointVisitorDerived::template algo<JointModelDerived>,
209 bf::append(boost::ref(jmodel.derived()), args));
210 }
211
212 template<typename JointDataDerived>
213 ReturnType operator()(const JointDataBase<JointDataDerived> & jdata) const
214 {
215 return bf::invoke(
216 &JointVisitorDerived::template algo<JointDataDerived>,
217 bf::append(boost::ref(jdata.derived()), args));
218 }
219
220 ReturnType operator()(const JointModelVoid)
221 {
222 return;
223 }
224
225 ArgType args;
226 };
227
228 template<typename Dummy>
229 struct InternalVisitorModel<NoArg, Dummy> : public boost::static_visitor<ReturnType>
230 {
231 InternalVisitorModel()
232 {
233 }
234
235 template<typename JointModelDerived>
236 ReturnType operator()(const JointModelBase<JointModelDerived> & jmodel) const
237 {
238 return JointVisitorDerived::template algo<JointModelDerived>(jmodel.derived());
239 }
240
241 template<typename JointDataDerived>
242 ReturnType operator()(const JointDataBase<JointDataDerived> & jdata) const
243 {
244 return JointVisitorDerived::template algo<JointDataDerived>(jdata.derived());
245 }
246 };
247 }; // struct JointUnaryVisitorBase
248
249 } // namespace fusion
250} // namespace pinocchio
251
252#endif // ifndef __pinocchio_multibody_visitor_joint_unary_visitor_hpp__
Main pinocchio namespace.
Definition treeview.dox:11
Base structure for Unary visitation of a JointModel. This structure provides runners to call the righ...