sot-torque-control  1.6.1
Collection of dynamic-graph entities aimed at implementing torque control on different robots.
vector-conversions.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2014, Andrea Del Prete, LAAS-CNRS
3  *
4  */
5 
6 #ifndef __sot_torque_control_vector_conversion_H__
7 #define __sot_torque_control_vector_conversion_H__
8 
9 #include <Eigen/Dense>
10 #include <fstream>
11 #include <sstream>
12 
13 #define EIGEN_CONST_VECTOR_FROM_STD_VECTOR(name, signal) Eigen::const_SigVectorXd name(signal.data(), signal.size())
14 #define EIGEN_VECTOR_FROM_STD_VECTOR(name, signal) Eigen::SigVectorXd name(signal.data(), signal.size())
15 
16 /********************* VECTOR COPY ******************************/
17 // c arrays define only the [] operator
18 // mal vectors define only the () operator
19 // std vectors define only the [] operator
20 // Eigen vectors define both the [] and () operators
21 
22 #define COPY_ARRAY_TO_ARRAY(src, dest, size) \
23  for (unsigned int i = 0; i < size; i++) dest[i] = src[i]
24 
25 #define COPY_ARRAY_TO_VECTOR(src, dest) \
26  for (unsigned int i = 0; i < dest.size(); i++) dest(i) = src[i]
27 
28 #define COPY_VECTOR_TO_ARRAY(src, dest) \
29  for (unsigned int i = 0; i < src.size(); i++) dest[i] = src(i)
30 
31 #define COPY_SHIFTED_VECTOR_TO_VECTOR(src, dest, offset) \
32  for (unsigned int i = 0; i < dest.size(); i++) dest(i) = src(i + offset)
33 
34 #define COPY_SHIFTED_VECTOR_TO_ARRAY(src, dest, offset) \
35  for (unsigned int i = 0; i < dest.size(); i++) dest[i] = src(i + offset)
36 
37 #define COPY_VECTOR_TO_SHIFTED_VECTOR(src, dest, offset) \
38  for (unsigned int i = 0; i < src.size(); i++) dest(i + offset) = src(i)
39 
40 #define COPY_ARRAY_TO_SHIFTED_VECTOR(src, dest, offset) \
41  for (unsigned int i = 0; i < src.size(); i++) dest(i + offset) = src[i]
42 
43 #endif // __sot_torque_control_vector_conversion_H__