joint-binary-visitor.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019 INRIA
3 //
4 
5 #ifndef __pinocchio_multibody_visitior_joint_binary_visitor_hpp__
6 #define __pinocchio_multibody_visitior_joint_binary_visitor_hpp__
7 
8 #include <boost/variant.hpp>
9 
10 #include "pinocchio/multibody/joint/joint-base.hpp"
11 #include "pinocchio/multibody/visitor/fusion.hpp"
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(const JointModelBase<JointModelDerived1> & jmodel1,
32  const JointModelBase<JointModelDerived2> & jmodel2,
35  ArgsTmp args)
36  {
37  InternalVisitorModelAndData<JointModelDerived1,JointModelDerived2,ArgsTmp> visitor(jdata1,jdata2,args);
38  return visitor(jmodel1.derived(),jmodel2.derived());
39  }
40 
41  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ArgsTmp>
42  static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel1,
46  ArgsTmp args)
47  {
49  InternalVisitorModelAndData<JointModel,JointModel,ArgsTmp> visitor(jdata1,jdata2,args);
50  return boost::apply_visitor(visitor,jmodel1,jmodel2);
51  }
52 
53  template<typename JointModelDerived1, typename JointModelDerived2>
54  static ReturnType run(const JointModelBase<JointModelDerived1> & jmodel1,
55  const JointModelBase<JointModelDerived2> & jmodel2,
58  {
59  InternalVisitorModelAndData<JointModelDerived1,JointModelDerived2,NoArg> visitor(jdata1,jdata2);
60  return visitor(jmodel1.derived(),jmodel2.derived());
61  }
62 
63  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
64  static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel1,
68  {
70  InternalVisitorModelAndData<JointModel,JointModel,NoArg> visitor(jdata1,jdata2);
71  return boost::apply_visitor(visitor,jmodel1,jmodel2);
72  }
73 
74  template<typename JointModelDerived1, typename JointModelDerived2, typename ArgsTmp>
75  static ReturnType run(const JointModelBase<JointModelDerived1> & jmodel1,
76  const JointModelBase<JointModelDerived2> & jmodel2,
77  ArgsTmp args)
78  {
79  InternalVisitorModel<ArgsTmp> visitor(args);
80  return visitor(jmodel1.derived(),jmodel2.derived());
81  }
82 
83  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl, typename ArgsTmp>
84  static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel1,
86  ArgsTmp args)
87  {
88  InternalVisitorModel<ArgsTmp> visitor(args);
89  return boost::apply_visitor(visitor,jmodel1,jmodel2);
90  }
91 
92  template<typename JointModelDerived1, typename JointModelDerived2>
93  static ReturnType run(const JointModelBase<JointModelDerived1> & jmodel1,
94  const JointModelBase<JointModelDerived2> & jmodel2)
95  {
96  InternalVisitorModel<NoArg> visitor;
97  return visitor(jmodel1.derived(),jmodel2.derived());
98  }
99 
100  template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
101  static ReturnType run(const JointModelTpl<Scalar,Options,JointCollectionTpl> & jmodel1,
103  {
104  InternalVisitorModel<NoArg> visitor;
105  return boost::apply_visitor(visitor,jmodel1,jmodel2);
106  }
107 
108  private:
109 
110  template<typename JointModel1, typename JointModel2, typename ArgType>
112  : public boost::static_visitor<ReturnType>
113  {
114  typedef typename JointModel1::JointDataDerived JointData1;
115  typedef typename JointModel2::JointDataDerived JointData2;
116 
118  JointData2 & jdata2,
119  ArgType args)
120  : jdata1(jdata1)
121  , jdata2(jdata2)
122  , args(args)
123  {}
124 
125  template<typename JointModelDerived1, typename JointModelDerived2>
126  ReturnType operator()(const JointModelBase<JointModelDerived1> & jmodel1,
127  const JointModelBase<JointModelDerived2> & jmodel2) const
128  {
129  return bf::invoke(&JointVisitorDerived::template algo<JointModelDerived1,JointModelDerived2>,
130  bf::append(boost::ref(jmodel1.derived()),
131  boost::ref(jmodel2.derived()),
132  boost::ref(boost::get<typename JointModelBase<JointModelDerived1>::JointDataDerived >(jdata1)),
133  boost::ref(boost::get<typename JointModelBase<JointModelDerived2>::JointDataDerived >(jdata2)),
134  args));
135  }
136 
137  JointData1 & jdata1;
138  JointData2 & jdata2;
139 
140  ArgType args;
141  };
142 
143  template<typename JointModel1, typename JointModel2>
144  struct InternalVisitorModelAndData<JointModel1,JointModel2,NoArg>
145  : public boost::static_visitor<ReturnType>
146  {
147  typedef typename JointModel1::JointDataDerived JointData1;
148  typedef typename JointModel2::JointDataDerived JointData2;
149 
150  InternalVisitorModelAndData(JointData1 & jdata1, JointData2 & jdata2)
151  : jdata1(jdata1)
152  , jdata2(jdata2)
153  {}
154 
155  template<typename JointModelDerived1, typename JointModelDerived2>
156  ReturnType operator()(const JointModelBase<JointModelDerived1> & jmodel1,
157  const JointModelBase<JointModelDerived2> & jmodel2) const
158  {
159  return bf::invoke(&JointVisitorDerived::template algo<JointModelDerived1,JointModelDerived2>,
160  bf::make_vector(boost::ref(jmodel1.derived()),
161  boost::ref(jmodel2.derived()),
162  boost::ref(boost::get<typename JointModelBase<JointModelDerived1>::JointDataDerived >(jdata1)),
163  boost::ref(boost::get<typename JointModelBase<JointModelDerived2>::JointDataDerived >(jdata2))));
164  }
165 
166  JointData1 & jdata1;
167  JointData2 & jdata2;
168  };
169 
170  template<typename ArgType, typename Dummy = void>
172  : public boost::static_visitor<ReturnType>
173  {
175  : args(args)
176  {}
177 
178  template<typename JointModel1, typename JointModel2>
179  ReturnType operator()(const JointModelBase<JointModel1> & jmodel1,
180  const JointModelBase<JointModel2> & jmodel2) const
181  {
182  return bf::invoke(&JointVisitorDerived::template algo<JointModel1,JointModel2>,
183  bf::append(boost::ref(jmodel1.derived()),
184  boost::ref(jmodel2.derived()),
185  args));
186  }
187 
188  ArgType args;
189  };
190 
191  template<typename Dummy>
192  struct InternalVisitorModel<NoArg,Dummy>
193  : public boost::static_visitor<ReturnType>
194  {
196 
197  template<typename JointModel1, typename JointModel2>
198  ReturnType operator()(const JointModelBase<JointModel1> & jmodel1,
199  const JointModelBase<JointModel2> & jmodel2) const
200  {
201  return JointVisitorDerived::
202  template algo<JointModel1,JointModel2>(jmodel1.derived(),
203  jmodel2.derived());
204  }
205  };
206 
207  }; // struct JointBinaryVisitorBase
208 
209  } // namespace fusion
210 } // namespace pinocchio
211 
212 #endif // ifndef __pinocchio_multibody_visitior_joint_binary_visitor_hpp__
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:24
static ReturnType run(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2, ArgsTmp args)
Base structure for Binary visitation of two JointModels. This structure provides runners to call the ...
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)
static ReturnType run(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2, typename JointModelBase< JointModelDerived1 >::JointDataDerived &jdata1, typename JointModelBase< JointModelDerived2 >::JointDataDerived &jdata2)
ReturnType operator()(const JointModelBase< JointModel1 > &jmodel1, const JointModelBase< JointModel2 > &jmodel2) const
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)
static ReturnType run(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2)
static ReturnType run(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2, typename JointModelBase< JointModelDerived1 >::JointDataDerived &jdata1, typename JointModelBase< JointModelDerived2 >::JointDataDerived &jdata2, ArgsTmp args)
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel1, const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel2)
JointModelDerived & derived()
InternalVisitorModelAndData(JointData1 &jdata1, JointData2 &jdata2, ArgType args)
ReturnType operator()(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2) const
Main pinocchio namespace.
Definition: timings.cpp:30
ReturnType operator()(const JointModelBase< JointModelDerived1 > &jmodel1, const JointModelBase< JointModelDerived2 > &jmodel2) const
JointModelTpl< double > JointModel
ReturnType operator()(const JointModelBase< JointModel1 > &jmodel1, const JointModelBase< JointModel2 > &jmodel2) const
static ReturnType run(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel1, const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel2, ArgsTmp args)


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:03