joint-unary-visitor.hpp
Go to the documentation of this file.
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 
13 
14 namespace 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  {
38  InternalVisitorModelAndData<JointModelTpl<Scalar, Options, JointCollectionTpl>, ArgsTmp>
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  {
48  InternalVisitorModelAndData<JointModelTpl<Scalar, Options, JointCollectionTpl>, NoArg>
49  visitor(jdata);
50  return boost::apply_visitor(visitor, jmodel);
51  }
52 
53  template<typename JointModelDerived, typename ArgsTmp>
54  static ReturnType run(
55  const JointModelBase<JointModelDerived> & jmodel,
57  ArgsTmp args)
58  {
59  InternalVisitorModelAndData<JointModelDerived, ArgsTmp> visitor(jdata, args);
60  return visitor(jmodel.derived());
61  }
62 
63  template<typename JointModelDerived>
64  static ReturnType run(
65  const JointModelBase<JointModelDerived> & jmodel,
67  {
68  InternalVisitorModelAndData<JointModelDerived, NoArg> visitor(jdata);
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  {
80  InternalVisitorModel<ArgsTmp> visitor(args);
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  {
92  InternalVisitorModel<ArgsTmp> visitor(args);
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  {
99  InternalVisitorModel<NoArg> visitor;
100  return boost::apply_visitor(visitor, jmodel);
101  }
102 
103  template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
105  {
106  InternalVisitorModel<NoArg> visitor;
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  {
113  InternalVisitorModel<ArgsTmp> visitor(args);
114  return visitor(jmodel.derived());
115  }
116 
117  template<typename JointDataDerived, typename ArgsTmp>
118  static ReturnType run(const JointDataBase<JointDataDerived> & jdata, ArgsTmp args)
119  {
120  InternalVisitorModel<ArgsTmp> visitor(args);
121  return visitor(jdata.derived());
122  }
123 
124  template<typename JointModelDerived>
125  static ReturnType run(const JointModelBase<JointModelDerived> & jmodel)
126  {
127  InternalVisitorModel<NoArg> visitor;
128  return visitor(jmodel.derived());
129  }
130 
131  template<typename JointDataDerived>
132  static ReturnType run(const JointDataBase<JointDataDerived> & jdata)
133  {
134  InternalVisitorModel<NoArg> visitor;
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 
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(
159  args));
160  }
161 
162  ReturnType operator()(const JointModelVoid)
163  {
164  return;
165  }
166 
168  ArgType args;
169  };
170 
171  template<typename JointModel>
173  : public boost::static_visitor<ReturnType>
174  {
175  typedef typename JointModel::JointDataDerived JointData;
176 
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(
191  }
192 
194  };
195 
196  template<typename ArgType, typename Dummy = void>
197  struct InternalVisitorModel : public boost::static_visitor<ReturnType>
198  {
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  {
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__
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel::operator()
ReturnType operator()(const JointModelBase< JointModelDerived > &jmodel) const
Definition: joint-unary-visitor.hpp:205
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData::InternalVisitorModelAndData
InternalVisitorModelAndData(JointData &jdata, ArgType args)
Definition: joint-unary-visitor.hpp:144
pinocchio::JointModelBase
Definition: joint-model-base.hpp:75
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, ArgsTmp args)
Definition: joint-unary-visitor.hpp:78
pinocchio::Options
Options
Definition: joint-configuration.hpp:1082
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel
Definition: joint-unary-visitor.hpp:197
pinocchio::JointDataBase
Definition: joint-data-base.hpp:161
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel< NoArg, Dummy >::operator()
ReturnType operator()(const JointModelBase< JointModelDerived > &jmodel) const
Definition: joint-unary-visitor.hpp:236
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Definition: joint-unary-visitor.hpp:44
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData::args
ArgType args
Definition: joint-unary-visitor.hpp:168
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::JointDataTpl
Definition: multibody/joint/fwd.hpp:162
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointDataBase< JointDataDerived > &jdata, ArgsTmp args)
Definition: joint-unary-visitor.hpp:118
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel::operator()
ReturnType operator()(const JointModelVoid)
Definition: joint-unary-visitor.hpp:220
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel< NoArg, Dummy >::operator()
ReturnType operator()(const JointDataBase< JointDataDerived > &jdata) const
Definition: joint-unary-visitor.hpp:242
pinocchio::JointDataBase::derived
Derived & derived()
Definition: joint-data-base.hpp:168
pinocchio::fusion::JointUnaryVisitorBase
Base structure for Unary visitation of a JointModel. This structure provides runners to call the righ...
Definition: joint-unary-visitor.hpp:25
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData::operator()
ReturnType operator()(const JointModelBase< JointModelDerived > &jmodel) const
Definition: joint-unary-visitor.hpp:151
Dummy
args
args
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, ArgsTmp args)
Definition: joint-unary-visitor.hpp:33
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointModelBase< JointModelDerived > &jmodel, ArgsTmp args)
Definition: joint-unary-visitor.hpp:111
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData< JointModel, NoArg >::operator()
ReturnType operator()(const JointModelBase< JointModelDerived > &jmodel) const
Definition: joint-unary-visitor.hpp:183
pinocchio::JointModelVoid
Definition: multibody/joint/fwd.hpp:25
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel::operator()
ReturnType operator()(const JointDataBase< JointDataDerived > &jdata) const
Definition: joint-unary-visitor.hpp:213
pinocchio::JointModelTpl
Definition: multibody/joint/fwd.hpp:155
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointDataBase< JointDataDerived > &jdata)
Definition: joint-unary-visitor.hpp:132
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Definition: joint-unary-visitor.hpp:97
joint-base.hpp
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointModelBase< JointModelDerived > &jmodel)
Definition: joint-unary-visitor.hpp:125
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, ArgsTmp args)
Definition: joint-unary-visitor.hpp:90
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData::jdata
JointData & jdata
Definition: joint-unary-visitor.hpp:167
fusion.hpp
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel::InternalVisitorModel
InternalVisitorModel(ArgType args)
Definition: joint-unary-visitor.hpp:199
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointModelBase< JointModelDerived > &jmodel, typename JointModelBase< JointModelDerived >::JointDataDerived &jdata)
Definition: joint-unary-visitor.hpp:64
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Definition: joint-unary-visitor.hpp:104
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData::operator()
ReturnType operator()(const JointModelVoid)
Definition: joint-unary-visitor.hpp:162
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData
Definition: joint-unary-visitor.hpp:140
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel::args
ArgType args
Definition: joint-unary-visitor.hpp:225
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData< JointModel, NoArg >::InternalVisitorModelAndData
InternalVisitorModelAndData(JointData &jdata)
Definition: joint-unary-visitor.hpp:177
boost::fusion::append
result_of::push_front< V const, T >::type append(T const &t, V const &v)
Append the element T at the front of boost fusion vector V.
Definition: fusion.hpp:32
pinocchio::fusion::NoArg
boost::blank NoArg
Definition: fusion.hpp:20
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModel< NoArg, Dummy >::InternalVisitorModel
InternalVisitorModel()
Definition: joint-unary-visitor.hpp:231
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData::JointData
JointModel::JointDataDerived JointData
Definition: joint-unary-visitor.hpp:142
pinocchio::fusion::JointUnaryVisitorBase::run
static ReturnType run(const JointModelBase< JointModelDerived > &jmodel, typename JointModelBase< JointModelDerived >::JointDataDerived &jdata, ArgsTmp args)
Definition: joint-unary-visitor.hpp:54
pinocchio::JointModelBase::derived
JointModelDerived & derived()
Definition: joint-model-base.hpp:82
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData< JointModel, NoArg >::jdata
JointData & jdata
Definition: joint-unary-visitor.hpp:193
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::fusion::JointUnaryVisitorBase::InternalVisitorModelAndData< JointModel, NoArg >::JointData
JointModel::JointDataDerived JointData
Definition: joint-unary-visitor.hpp:175


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:31