pinocchio  3.3.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
copy.hpp
1 //
2 // Copyright (c) 2016-2020 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_copy_hpp__
6 #define __pinocchio_copy_hpp__
7 
8 #include "pinocchio/multibody/model.hpp"
9 #include "pinocchio/multibody/data.hpp"
10 #include "pinocchio/algorithm/check.hpp"
11 
12 namespace pinocchio
13 {
26  template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
27  inline void copy(
28  const ModelTpl<Scalar, Options, JointCollectionTpl> & model,
29  const DataTpl<Scalar, Options, JointCollectionTpl> & origin,
30  DataTpl<Scalar, Options, JointCollectionTpl> & dest,
31  KinematicLevel kinematic_level);
32 
33 } // namespace pinocchio
34 
35 /* --- Details -------------------------------------------------------------------- */
36 // #include "pinocchio/algorithm/copy.hxx"
37 
39 namespace pinocchio
40 {
41  template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl>
42  inline void copy(
46  KinematicLevel kinematic_level)
47  {
49  typedef typename Model::JointIndex JointIndex;
50 
51  PINOCCHIO_CHECK_INPUT_ARGUMENT(kinematic_level >= POSITION);
52 
53  for (JointIndex jid = 1; jid < (JointIndex)model.njoints; ++jid)
54  {
55  dest.oMi[jid] = origin.oMi[jid];
56  if (kinematic_level >= VELOCITY)
57  {
58  dest.v[jid] = origin.v[jid];
59  }
60  if (kinematic_level >= ACCELERATION)
61  {
62  dest.a[jid] = origin.a[jid];
63  dest.a_gf[jid] = origin.a_gf[jid];
64  dest.f[jid] = origin.f[jid];
65  }
66  }
67  }
68 
69 } // namespace pinocchio
71 
72 #endif // ifndef __pinocchio_copy_hpp__
KinematicLevel
List of Kinematics Level supported by Pinocchio.
Definition: fwd.hpp:60
@ VELOCITY
Definition: fwd.hpp:63
@ ACCELERATION
Definition: fwd.hpp:65
@ POSITION
Definition: fwd.hpp:61
Main pinocchio namespace.
Definition: treeview.dox:11
void copy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &origin, DataTpl< Scalar, Options, JointCollectionTpl > &dest, KinematicLevel kinematic_level)
Copy part of the data from origin to dest. Template parameter can be used to select at which differen...
Definition: copy.hpp:42