Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ublas_types.hpp « itasc « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bf9bdcc26f26085db7e13fb474b99da748879c8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * ublas_types.hpp
 *
 *  Created on: Jan 5, 2009
 *      Author: rubensmits
 */

#ifndef UBLAS_TYPES_HPP_
#define UBLAS_TYPES_HPP_

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>
#include "kdl/frames.hpp"
#include "kdl/tree.hpp"
#include "kdl/chain.hpp"
#include "kdl/jacobian.hpp"
#include "kdl/jntarray.hpp"


namespace iTaSC{

namespace ublas = boost::numeric::ublas;
using KDL::Twist;
using KDL::Frame;
using KDL::Joint;
using KDL::Inertia;
using KDL::SegmentMap;
using KDL::Tree;
using KDL::JntArray;
using KDL::Jacobian;
using KDL::Segment;
using KDL::Rotation;
using KDL::Vector;
using KDL::Chain;

#define u_scalar double
#define u_vector ublas::vector<u_scalar>
#define u_zero_vector ublas::zero_vector<u_scalar>
#define u_matrix ublas::matrix<u_scalar>
#define u_matrix6 ublas::matrix<u_scalar,6,6>
#define u_identity_matrix ublas::identity_matrix<u_scalar>
#define u_scalar_vector ublas::scalar_vector<u_scalar>
#define u_zero_matrix ublas::zero_matrix<u_scalar>
#define u_vector6 ublas::bounded_vector<u_scalar,6>

inline static int changeBase(const u_matrix& J_in, const Frame& T, u_matrix& J_out) {

    if (J_out.size1() != 6 || J_in.size1() != 6 || J_in.size2() != J_out.size2())
        return -1;
    for (unsigned int j = 0; j < J_in.size2(); ++j) {
        ublas::matrix_column<const u_matrix > Jj_in = column(J_in,j);
        ublas::matrix_column<u_matrix > Jj_out = column(J_out,j);
		Twist arg;
        for(unsigned int i=0;i<6;++i)
            arg(i)=Jj_in(i);
		Twist tmp(T*arg);
        for(unsigned int i=0;i<6;++i)
                    Jj_out(i)=tmp(i);
    }
    return 0;
}
inline static int changeBase(const ublas::matrix_range<u_matrix >& J_in, const Frame& T, ublas::matrix_range<u_matrix >& J_out) {

    if (J_out.size1() != 6 || J_in.size1() != 6 || J_in.size2() != J_out.size2())
        return -1;
    for (unsigned int j = 0; j < J_in.size2(); ++j) {
        ublas::matrix_column<const ublas::matrix_range<u_matrix > > Jj_in = column(J_in,j);
        ublas::matrix_column<ublas::matrix_range<u_matrix > > Jj_out = column(J_out,j);
		Twist arg;
        for(unsigned int i=0;i<6;++i)
            arg(i)=Jj_in(i);
		Twist tmp(T*arg);
        for(unsigned int i=0;i<6;++i)
                    Jj_out(i)=tmp(i);
    }
    return 0;
}

}
#endif /* UBLAS_TYPES_HPP_ */