GCC Code Coverage Report


Directory: ./
File: src/feature/feature-1d.cpp
Date: 2024-10-13 12:22:59
Exec Total Coverage
Lines: 0 32 0.0%
Branches: 0 48 0.0%

Line Branch Exec Source
1 /*
2 * Copyright 2010,
3 * François Bleibel,
4 * Olivier Stasse,
5 *
6 * CNRS/AIST
7 *
8 */
9
10 /* --------------------------------------------------------------------- */
11 /* --- INCLUDE --------------------------------------------------------- */
12 /* --------------------------------------------------------------------- */
13
14 /* --- SOT --- */
15 #include <sot/core/debug.hh>
16 #include <sot/core/exception-feature.hh>
17 #include <sot/core/feature-1d.hh>
18 using namespace std;
19
20 #include <sot/core/factory.hh>
21
22 using namespace dynamicgraph::sot;
23 using namespace dynamicgraph;
24 DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Feature1D, "Feature1D");
25
26 /* --------------------------------------------------------------------- */
27 /* --- CLASS ----------------------------------------------------------- */
28 /* --------------------------------------------------------------------- */
29
30 Feature1D::Feature1D(const string &pointName)
31 : FeatureAbstract(pointName),
32 errorSIN(NULL, "sotFeature1D(" + name + ")::input(vector)::errorIN"),
33 jacobianSIN(NULL,
34 "sotFeature1D(" + name + ")::input(matrix)::jacobianIN") {
35 jacobianSOUT.addDependency(jacobianSIN);
36 errorSOUT.addDependency(errorSIN);
37
38 signalRegistration(errorSIN << jacobianSIN);
39 }
40
41 /* --------------------------------------------------------------------- */
42 /* --------------------------------------------------------------------- */
43 /* --------------------------------------------------------------------- */
44
45 void Feature1D::addDependenciesFromReference(void) {}
46 void Feature1D::removeDependenciesFromReference(void) {}
47
48 /* --------------------------------------------------------------------- */
49 /* --------------------------------------------------------------------- */
50 /* --------------------------------------------------------------------- */
51
52 unsigned int &Feature1D::getDimension(unsigned int &dim, int /*time*/) {
53 sotDEBUG(25) << "# In {" << endl;
54
55 dim = 1;
56
57 sotDEBUG(25) << "# Out }" << endl;
58 return dim;
59 }
60
61 dynamicgraph::Vector &Feature1D::computeError(dynamicgraph::Vector &res,
62 int time) {
63 const dynamicgraph::Vector &err = errorSIN.access(time);
64 res.resize(1);
65 res(0) = err.dot(err) * .5;
66
67 return res;
68 }
69
70 dynamicgraph::Matrix &Feature1D::computeJacobian(dynamicgraph::Matrix &res,
71 int time) {
72 sotDEBUGIN(15);
73
74 const dynamicgraph::Matrix &Jac = jacobianSIN.access(time);
75 const dynamicgraph::Vector &err = errorSIN.access(time);
76
77 res.resize(1, Jac.cols());
78 res.fill(0);
79 for (int j = 0; j < Jac.cols(); ++j)
80 for (int i = 0; i < Jac.rows(); ++i) res(0, j) += err(i) * Jac(i, j);
81
82 sotDEBUGOUT(15);
83 return res;
84 }
85
86 /* --------------------------------------------------------------------- */
87 /* --------------------------------------------------------------------- */
88 /* --------------------------------------------------------------------- */
89
90 void Feature1D::display(std::ostream &os) const {
91 os << "1D <" << name << ">: " << std::endl;
92
93 try {
94 os << " error= " << errorSIN.accessCopy() << endl
95 << " J = " << jacobianSIN.accessCopy() << endl;
96 } catch (ExceptionAbstract e) {
97 os << " All SIN not set.";
98 }
99 }
100