Newer
Older
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* Copyright 2011,
* Nicolas Mansard
* LAAS-CNRS
*
* This file is part of sot-dyninv.
* sot-dyninv is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* sot-dyninv is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with sot-dyninv. If not, see <http://www.gnu.org/licenses/>.
*/
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* --- SOT --- */
//#define VP_DEBUG
//#define VP_DEBUG_MODE 45
#include <sot-dyninv/feature-projected-line.h>
#include <dynamic-graph/command.h>
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/command-getter.h>
#include <dynamic-graph/command-bind.h>
#include <sot/core/debug.hh>
#include <sot/core/exception-feature.hh>
#include <sot/core/matrix-homogeneous.hh>
#include <sot/core/matrix-rotation.hh>
#include <sot/core/vector-utheta.hh>
#include <sot/core/factory.hh>
namespace dynamicgraph
{
namespace sot
{
namespace dyninv
{
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeatureProjectedLine,"FeatureProjectedLine");
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
FeatureProjectedLine::
FeatureProjectedLine( const std::string& pointName )
: FeatureAbstract( pointName )
,CONSTRUCT_SIGNAL_IN(xa,MatrixHomogeneous)
,CONSTRUCT_SIGNAL_IN(xb,MatrixHomogeneous)
,CONSTRUCT_SIGNAL_IN(Ja,ml::Matrix)
,CONSTRUCT_SIGNAL_IN(Jb,ml::Matrix)
,CONSTRUCT_SIGNAL_IN(xc,ml::Vector)
{
jacobianSOUT.addDependency( xaSIN );
jacobianSOUT.addDependency( xbSIN );
jacobianSOUT.addDependency( xcSIN );
jacobianSOUT.addDependency( JaSIN );
jacobianSOUT.addDependency( JbSIN );
errorSOUT.addDependency( xaSIN );
errorSOUT.addDependency( xbSIN );
errorSOUT.addDependency( xcSIN );
signalRegistration( xaSIN << xbSIN << xcSIN << JaSIN << JbSIN );
}
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
unsigned int& FeatureProjectedLine::
getDimension( unsigned int & dim, int )
{
dim = 2;
return dim;
}
/** Compute the interaction matrix from a subset of
* the possible features.
*/
ml::Matrix& FeatureProjectedLine::
computeJacobian( ml::Matrix& J,int time )
{
sotDEBUGIN(15);
const MatrixHomogeneous & A = xaSIN(time), & B = xbSIN(time);
const ml::Vector & C = xcSIN(time);
const double
xa=A(0,3),xb=B(0,3),xc=C(0),
ya=A(1,3),yb=B(1,3),yc=C(1);
const ml::Matrix & JA = JaSIN(time), & JB = JbSIN(time);
const int nq=JA.nbCols();
assert((int)JB.nbCols()==nq);
J.resize(1,nq);
for( int i=0;i<nq;++i )
{
const double
& dxa=JA(0,i),& dxb=JB(0,i),
& dya=JA(1,i),& dyb=JB(1,i);
J(0,i) = dxa*(yb-yc) - dxb*(ya-yc) - dya*(xb-xc) + dyb*(xa-xc);
}
sotDEBUGOUT(15);
return J;
}
/** Compute the error between two visual features from a subset
* a the possible features.
*/
ml::Vector&
FeatureProjectedLine::computeError( ml::Vector& error,int time )
{
sotDEBUGIN(15);
const MatrixHomogeneous & A = xaSIN(time),& B = xbSIN(time);
const ml::Vector & C = xcSIN(time);
const double
xa=A(0,3),xb=B(0,3),xc=C(0),
ya=A(1,3),yb=B(1,3),yc=C(1);
error.resize(1);
error(0) = (xb-xa)*(yc-ya)-(yb-ya)*(xc-xa);
sotDEBUGOUT(15);
return error ;
}
void FeatureProjectedLine::
display( std::ostream& os ) const
{
os <<"ProjectedLine <"<<name<<">" ;
}
} // namespace dyninv
} // namespace sot
} // namespace dynamicgraph
/*
* Local variables:
* c-basic-offset: 2
* End:
*/