sot-torque-control  1.6.4
Collection of dynamic-graph entities aimed at implementing torque control on different robots.
 
Loading...
Searching...
No Matches
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) \
14 Eigen::const_SigVectorXd name(signal.data(), signal.size())
15#define EIGEN_VECTOR_FROM_STD_VECTOR(name, signal) \
16 Eigen::SigVectorXd name(signal.data(), signal.size())
17
18/********************* VECTOR COPY ******************************/
19// c arrays define only the [] operator
20// mal vectors define only the () operator
21// std vectors define only the [] operator
22// Eigen vectors define both the [] and () operators
23
24#define COPY_ARRAY_TO_ARRAY(src, dest, size) \
25 for (unsigned int i = 0; i < size; i++) dest[i] = src[i]
26
27#define COPY_ARRAY_TO_VECTOR(src, dest) \
28 for (unsigned int i = 0; i < dest.size(); i++) dest(i) = src[i]
29
30#define COPY_VECTOR_TO_ARRAY(src, dest) \
31 for (unsigned int i = 0; i < src.size(); i++) dest[i] = src(i)
32
33#define COPY_SHIFTED_VECTOR_TO_VECTOR(src, dest, offset) \
34 for (unsigned int i = 0; i < dest.size(); i++) dest(i) = src(i + offset)
35
36#define COPY_SHIFTED_VECTOR_TO_ARRAY(src, dest, offset) \
37 for (unsigned int i = 0; i < dest.size(); i++) dest[i] = src(i + offset)
38
39#define COPY_VECTOR_TO_SHIFTED_VECTOR(src, dest, offset) \
40 for (unsigned int i = 0; i < src.size(); i++) dest(i + offset) = src(i)
41
42#define COPY_ARRAY_TO_SHIFTED_VECTOR(src, dest, offset) \
43 for (unsigned int i = 0; i < src.size(); i++) dest(i + offset) = src[i]
44
45#endif // __sot_torque_control_vector_conversion_H__