joint-binary-visitor.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019 INRIA
3 //
4 
5 #ifndef __pinocchio_multibody_visitor_joint_binary_visitor_hpp__
6 #define __pinocchio_multibody_visitor_joint_binary_visitor_hpp__
7 
8 #include <boost/variant.hpp>
9 
12 
13 namespace pinocchio
14 {
15  namespace fusion
16  {
17  namespace bf = boost::fusion;
18 
19  typedef boost::blank NoArg;
20 
26  template<typename JointVisitorDerived, typename ReturnType = void>
28  {
29 
30  template<typename JointModelDerived1, typename JointModelDerived2, typename ArgsTmp>
31  static ReturnType run(
32  const JointModelBase<JointModelDerived1> & jmodel1,
33  const JointModelBase<JointModelDerived2> & jmodel2,
36  ArgsTmp args)
37  {
38  InternalVisitorModelAndData<JointModelDerived1, JointModelDerived2, ArgsTmp> visitor(
39  jdata1, jdata2, args);
40  return visitor(jmodel1.derived(), jmodel2.derived());
41  }
42 
43  template<
44  typename Scalar,
45  int Options,
46  template<typename, int> class JointCollectionTpl,
47  typename ArgsTmp>
48  static ReturnType run(
53  ArgsTmp args)
54  {
56  InternalVisitorModelAndData<JointModel, JointModel, ArgsTmp> visitor(jdata1, jdata2, args);
57  return boost::apply_visitor(visitor, jmodel1, jmodel2);
58  }
59 
60  template<typename JointModelDerived1, typename JointModelDerived2>
61  static ReturnType run(
62  const JointModelBase<JointModelDerived1> & jmodel1,
63  const JointModelBase<JointModelDerived2> & jmodel2,
66  {
67  InternalVisitorModelAndData<JointModelDerived1, JointModelDerived2, NoArg> visitor(
68  jdata1, jdata2);
69  return visitor(jmodel1.derived(), jmodel2.derived());
70  }
71 
72  template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
73  static ReturnType run(
78  {
80  InternalVisitorModelAndData<JointModel, JointModel, NoArg> visitor(jdata1, jdata2);
81  return boost::apply_visitor(visitor, jmodel1, jmodel2);
82  }
83 
84  template<typename JointModelDerived1, typename JointModelDerived2, typename ArgsTmp>
85  static ReturnType run(
86  const JointModelBase<JointModelDerived1> & jmodel1,
87  const JointModelBase<JointModelDerived2> & jmodel2,
88  ArgsTmp args)
89  {
90  InternalVisitorModel<ArgsTmp> visitor(args);
91  return visitor(jmodel1.derived(), jmodel2.derived());
92  }
93 
94  template<
95  typename Scalar,
96  int Options,
97  template<typename, int> class JointCollectionTpl,
98  typename ArgsTmp>
99  static ReturnType run(
102  ArgsTmp args)
103  {
104  InternalVisitorModel<ArgsTmp> visitor(args);
105  return boost::apply_visitor(visitor, jmodel1, jmodel2);
106  }
107 
108  template<typename JointModelDerived1, typename JointModelDerived2>
109  static ReturnType run(
110  const JointModelBase<JointModelDerived1> & jmodel1,
111  const JointModelBase<JointModelDerived2> & jmodel2)
112  {
113  InternalVisitorModel<NoArg> visitor;
114  return visitor(jmodel1.derived(), jmodel2.derived());
115  }
116 
117  template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
118  static ReturnType run(
121  {
122  InternalVisitorModel<NoArg> visitor;
123  return boost::apply_visitor(visitor, jmodel1, jmodel2);
124  }
125 
126  private:
127  template<typename JointModel1, typename JointModel2, typename ArgType>
128  struct InternalVisitorModelAndData : public boost::static_visitor<ReturnType>
129  {
130  typedef typename JointModel1::JointDataDerived JointData1;
131  typedef typename JointModel2::JointDataDerived JointData2;
132 
134  : jdata1(jdata1)
135  , jdata2(jdata2)
136  , args(args)
137  {
138  }
139 
140  template<typename JointModelDerived1, typename JointModelDerived2>
141  ReturnType operator()(
142  const JointModelBase<JointModelDerived1> & jmodel1,
143  const JointModelBase<JointModelDerived2> & jmodel2) const
144  {
145  return bf::invoke(
146  &JointVisitorDerived::template algo<JointModelDerived1, JointModelDerived2>,
147  bf::append(
148  boost::ref(jmodel1.derived()), boost::ref(jmodel2.derived()),
149  boost::ref(
151  boost::ref(
153  args));
154  }
155 
158 
159  ArgType args;
160  };
161 
162  template<typename JointModel1, typename JointModel2>
163  struct InternalVisitorModelAndData<JointModel1, JointModel2, NoArg>
164  : public boost::static_visitor<ReturnType>
165  {
166  typedef typename JointModel1::JointDataDerived JointData1;
167  typedef typename JointModel2::JointDataDerived JointData2;
168 
170  : jdata1(jdata1)
171  , jdata2(jdata2)
172  {
173  }
174 
175  template<typename JointModelDerived1, typename JointModelDerived2>
176  ReturnType operator()(
177  const JointModelBase<JointModelDerived1> & jmodel1,
178  const JointModelBase<JointModelDerived2> & jmodel2) const
179  {
180  return bf::invoke(
181  &JointVisitorDerived::template algo<JointModelDerived1, JointModelDerived2>,
182  bf::make_vector(
183  boost::ref(jmodel1.derived()), boost::ref(jmodel2.derived()),
184  boost::ref(
186  boost::ref(boost::get<typename JointModelBase<JointModelDerived2>::JointDataDerived>(
187  jdata2))));
188  }
189 
192  };
193 
194  template<typename ArgType, typename Dummy = void>
195  struct InternalVisitorModel : public boost::static_visitor<ReturnType>
196  {
198  : args(args)
199  {
200  }
201 
202  template<typename JointModel1, typename JointModel2>
203  ReturnType operator()(
204  const JointModelBase<JointModel1> & jmodel1,
205  const JointModelBase<JointModel2> & jmodel2) const
206  {
207  return bf::invoke(
208  &JointVisitorDerived::template algo<JointModel1, JointModel2>,
209  bf::append(boost::ref(jmodel1.derived()), boost::ref(jmodel2.derived()), args));
210  }
211 
212  ArgType args;
213  };
214 
215  template<typename Dummy>
216  struct InternalVisitorModel<NoArg, Dummy> : public boost::static_visitor<ReturnType>
217  {
219  {
220  }
221 
222  template<typename JointModel1, typename JointModel2>
223  ReturnType operator()(
224  const JointModelBase<JointModel1> & jmodel1,
225  const JointModelBase<JointModel2> & jmodel2) const
226  {
227  return JointVisitorDerived::template algo<JointModel1, JointModel2>(
228  jmodel1.derived(), jmodel2.derived());
229  }
230  };
231 
232  }; // struct JointBinaryVisitorBase
233 
234  } // namespace fusion
235 } // namespace pinocchio
236 
237 #endif // ifndef __pinocchio_multibody_visitor_joint_binary_visitor_hpp__
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData::jdata1
JointData1 & jdata1
Definition: joint-binary-visitor.hpp:156
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData::InternalVisitorModelAndData
InternalVisitorModelAndData(JointData1 &jdata1, JointData2 &jdata2, ArgType args)
Definition: joint-binary-visitor.hpp:133
pinocchio::fusion::JointBinaryVisitorBase::run
static ReturnType run(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2)
Definition: joint-binary-visitor.hpp:109
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModel< NoArg, Dummy >::InternalVisitorModel
InternalVisitorModel()
Definition: joint-binary-visitor.hpp:218
pinocchio::JointModelBase
Definition: joint-model-base.hpp:75
pinocchio::Options
Options
Definition: joint-configuration.hpp:1082
pinocchio::fusion::JointBinaryVisitorBase::run
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel1, const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel2)
Definition: joint-binary-visitor.hpp:118
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData< JointModel1, JointModel2, NoArg >::JointData1
JointModel1::JointDataDerived JointData1
Definition: joint-binary-visitor.hpp:166
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData< JointModel1, JointModel2, NoArg >::JointData2
JointModel2::JointDataDerived JointData2
Definition: joint-binary-visitor.hpp:167
pinocchio::fusion::JointBinaryVisitorBase::run
static ReturnType run(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2, typename JointModelBase< JointModelDerived1 >::JointDataDerived &jdata1, typename JointModelBase< JointModelDerived2 >::JointDataDerived &jdata2, ArgsTmp args)
Definition: joint-binary-visitor.hpp:31
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::JointDataTpl
Definition: multibody/joint/fwd.hpp:162
pinocchio::fusion::JointBinaryVisitorBase
Base structure for Binary visitation of two JointModels. This structure provides runners to call the ...
Definition: joint-binary-visitor.hpp:27
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModel::operator()
ReturnType operator()(const JointModelBase< JointModel1 > &jmodel1, const JointModelBase< JointModel2 > &jmodel2) const
Definition: joint-binary-visitor.hpp:203
Dummy
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData
Definition: joint-binary-visitor.hpp:128
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModel::InternalVisitorModel
InternalVisitorModel(ArgType args)
Definition: joint-binary-visitor.hpp:197
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModel::args
ArgType args
Definition: joint-binary-visitor.hpp:212
args
args
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModel< NoArg, Dummy >::operator()
ReturnType operator()(const JointModelBase< JointModel1 > &jmodel1, const JointModelBase< JointModel2 > &jmodel2) const
Definition: joint-binary-visitor.hpp:223
pinocchio::JointModelTpl
Definition: multibody/joint/fwd.hpp:155
joint-base.hpp
pinocchio::fusion::JointBinaryVisitorBase::run
static ReturnType run(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2, ArgsTmp args)
Definition: joint-binary-visitor.hpp:85
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData::args
ArgType args
Definition: joint-binary-visitor.hpp:159
pinocchio::fusion::JointBinaryVisitorBase::run
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel1, const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel2, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata1, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata2)
Definition: joint-binary-visitor.hpp:73
pinocchio::JointModel
JointModelTpl< context::Scalar > JointModel
Definition: multibody/joint/fwd.hpp:155
fusion.hpp
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData::jdata2
JointData2 & jdata2
Definition: joint-binary-visitor.hpp:157
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData::JointData2
JointModel2::JointDataDerived JointData2
Definition: joint-binary-visitor.hpp:131
pinocchio::fusion::JointBinaryVisitorBase::run
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel1, const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel2, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata1, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata2, ArgsTmp args)
Definition: joint-binary-visitor.hpp:48
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData::operator()
ReturnType operator()(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2) const
Definition: joint-binary-visitor.hpp:141
pinocchio::fusion::JointBinaryVisitorBase::run
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel1, const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel2, ArgsTmp args)
Definition: joint-binary-visitor.hpp:99
boost::fusion
Definition: fusion.hpp:27
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::JointBinaryVisitorBase::InternalVisitorModelAndData< JointModel1, JointModel2, NoArg >::jdata2
JointData2 & jdata2
Definition: joint-binary-visitor.hpp:191
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData< JointModel1, JointModel2, NoArg >::InternalVisitorModelAndData
InternalVisitorModelAndData(JointData1 &jdata1, JointData2 &jdata2)
Definition: joint-binary-visitor.hpp:169
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData< JointModel1, JointModel2, NoArg >::jdata1
JointData1 & jdata1
Definition: joint-binary-visitor.hpp:190
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModel
Definition: joint-binary-visitor.hpp:195
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData::JointData1
JointModel1::JointDataDerived JointData1
Definition: joint-binary-visitor.hpp:130
pinocchio::fusion::JointBinaryVisitorBase::run
static ReturnType run(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2, typename JointModelBase< JointModelDerived1 >::JointDataDerived &jdata1, typename JointModelBase< JointModelDerived2 >::JointDataDerived &jdata2)
Definition: joint-binary-visitor.hpp:61
pinocchio::fusion::JointBinaryVisitorBase::InternalVisitorModelAndData< JointModel1, JointModel2, NoArg >::operator()
ReturnType operator()(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2) const
Definition: joint-binary-visitor.hpp:176
pinocchio::JointModelBase::derived
JointModelDerived & derived()
Definition: joint-model-base.hpp:82
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


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