Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sot-dyninv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Stack Of Tasks
sot-dyninv
Commits
d16b100c
Commit
d16b100c
authored
12 years ago
by
Nicolas Mansard
Browse files
Options
Downloads
Patches
Plain Diff
Added an operator into solver-kine.
parent
10a7e684
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/solver-kine.cpp
+130
-7
130 additions, 7 deletions
src/solver-kine.cpp
with
130 additions
and
7 deletions
src/solver-kine.cpp
+
130
−
7
View file @
d16b100c
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#ifdef VP_DEBUG
#ifdef VP_DEBUG
class
solver_op_space__INIT
class
solver_op_space__INIT
{
{
public:
solver_op_space__INIT
(
void
)
{
dynamicgraph
::
sot
::
DebugTrace
::
openFile
();
}
//
public:solver_op_space__INIT( void ) { dynamicgraph::sot::DebugTrace::openFile(); }
};
};
solver_op_space__INIT
solver_op_space_initiator
;
solver_op_space__INIT
solver_op_space_initiator
;
#endif //#ifdef VP_DEBUG
#endif //#ifdef VP_DEBUG
...
@@ -39,7 +39,45 @@ solver_op_space__INIT solver_op_space_initiator;
...
@@ -39,7 +39,45 @@ solver_op_space__INIT solver_op_space_initiator;
#include
<soth/Algebra.hpp>
#include
<soth/Algebra.hpp>
#include
<Eigen/QR>
#include
<Eigen/QR>
#include
<sot-dyninv/mal-to-eigen.h>
#include
<sot-dyninv/mal-to-eigen.h>
#include
<sys/time.h>
namespace
soth
{
Bound
&
operator
-=
(
Bound
&
xb
,
const
double
&
x
)
{
return
xb
;
}
const
Bound
operator
-
(
const
Bound
&
a
,
const
Bound
&
b
)
{
assert
(
b
.
getType
()
==
Bound
::
BOUND_TWIN
||
a
.
getType
()
==
b
.
getType
()
);
if
(
b
.
getType
()
==
Bound
::
BOUND_TWIN
)
{
switch
(
a
.
getType
()
)
{
case
Bound
::
BOUND_TWIN
:
case
Bound
::
BOUND_INF
:
case
Bound
::
BOUND_SUP
:
return
Bound
(
a
.
getBound
(
a
.
getType
())
-
b
.
getBound
(
Bound
::
BOUND_TWIN
),
a
.
getType
());
break
;
case
Bound
::
BOUND_DOUBLE
:
return
Bound
(
a
.
getBound
(
Bound
::
BOUND_INF
)
-
b
.
getBound
(
Bound
::
BOUND_TWIN
),
a
.
getBound
(
Bound
::
BOUND_SUP
)
-
b
.
getBound
(
Bound
::
BOUND_TWIN
));
break
;
}
}
else
{
// TODO
throw
"TODO"
;
}
return
a
;
}
}
namespace
dynamicgraph
namespace
dynamicgraph
{
{
...
@@ -52,7 +90,17 @@ namespace dynamicgraph
...
@@ -52,7 +90,17 @@ namespace dynamicgraph
using
namespace
dg
;
using
namespace
dg
;
using
dg
::
SignalBase
;
using
dg
::
SignalBase
;
/* --- DG FACTORY ------------------------------------------------------- */
static
bool
isLH
(
boost
::
shared_ptr
<
soth
::
Stage
>
s
)
{
return
s
->
name
==
"tasklh"
;
}
static
bool
isRH
(
boost
::
shared_ptr
<
soth
::
Stage
>
s
)
{
return
s
->
name
==
"taskrhorient"
;
}
/* --- DG FACTORY ------------------------------------------------------- */
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
SolverKine
,
"SolverKine"
);
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
SolverKine
,
"SolverKine"
);
/* --- CONSTRUCTION ----------------------------------------------------- */
/* --- CONSTRUCTION ----------------------------------------------------- */
...
@@ -74,6 +122,8 @@ namespace dynamicgraph
...
@@ -74,6 +122,8 @@ namespace dynamicgraph
,
Ctasks
(),
btasks
()
,
Ctasks
(),
btasks
()
,
solution
()
,
solution
()
,
activeSet
(),
relevantActiveSet
(
false
)
{
{
signalRegistration
(
controlSOUT
<<
velocitySOUT
signalRegistration
(
controlSOUT
<<
velocitySOUT
<<
dampingSIN
);
<<
dampingSIN
);
...
@@ -83,6 +133,14 @@ namespace dynamicgraph
...
@@ -83,6 +133,14 @@ namespace dynamicgraph
makeCommandVoid0
(
*
this
,
&
SolverKine
::
debugOnce
,
makeCommandVoid0
(
*
this
,
&
SolverKine
::
debugOnce
,
docCommandVoid0
(
"open trace-file for next iteration of the solver."
)));
docCommandVoid0
(
"open trace-file for next iteration of the solver."
)));
addCommand
(
"resetAset"
,
makeCommandVoid0
(
*
this
,
&
SolverKine
::
resetAset
,
docCommandVoid0
(
"Reset the active set."
)));
addCommand
(
"decompo"
,
makeCommandVoid1
(
*
this
,
&
SolverKine
::
getDecomposition
,
docCommandVoid1
(
"Return the decomposition of the given level."
,
"Stage level"
)));
addCommand
(
"setControlFreeFloating"
,
addCommand
(
"setControlFreeFloating"
,
makeDirectSetter
(
*
this
,
&
controlFreeFloating
,
makeDirectSetter
(
*
this
,
&
controlFreeFloating
,
docDirectSetter
(
"If true, the ouput control includes the ff (ie, size nbDof). Oterwise, size is nbDof-6. FF is supposed to be at the head."
,
"bool"
)));
docDirectSetter
(
"If true, the ouput control includes the ff (ie, size nbDof). Oterwise, size is nbDof-6. FF is supposed to be at the head."
,
"bool"
)));
...
@@ -120,6 +178,25 @@ namespace dynamicgraph
...
@@ -120,6 +178,25 @@ namespace dynamicgraph
controlSOUT
.
setReady
();
controlSOUT
.
setReady
();
}
}
/* --- NOTIFICATION HCOD ------------------------------------------------ */
struct
HCODUpdateCounter
{
void
operator
()
(
std
::
string
stage
,
soth
::
ConstraintRef
cst
,
std
::
string
event
)
{
if
(
!
onoff
)
return
;
//sotDEBUG(0)
//std::cout<< "At t="<<iter<<" [" << stage << "," << cst << "]: " << event << std::endl;
count
++
;
}
static
int
iter
;
static
int
count
;
static
bool
onoff
;
HCODUpdateCounter
()
{
count
=
0
;}
};
int
HCODUpdateCounter
::
count
=
0
;
int
HCODUpdateCounter
::
iter
=
0
;
bool
HCODUpdateCounter
::
onoff
=
true
;
/* --- INIT SOLVER ------------------------------------------------------ */
/* --- INIT SOLVER ------------------------------------------------------ */
/* --- INIT SOLVER ------------------------------------------------------ */
/* --- INIT SOLVER ------------------------------------------------------ */
...
@@ -144,8 +221,22 @@ namespace dynamicgraph
...
@@ -144,8 +221,22 @@ namespace dynamicgraph
resizeSolver
(
void
)
resizeSolver
(
void
)
{
{
hsolver
=
hcod_ptr_t
(
new
soth
::
HCOD
(
nbDofs
,
stack
.
size
()
));
hsolver
=
hcod_ptr_t
(
new
soth
::
HCOD
(
nbDofs
,
stack
.
size
()
));
debugOnce
();
Ctasks
.
resize
(
stack
.
size
());
Ctasks
.
resize
(
stack
.
size
());
btasks
.
resize
(
stack
.
size
());
btasks
.
resize
(
stack
.
size
());
relevantActiveSet
=
false
;
// std::cout << controlSOUT.getTime() << std::endl;
// if( controlSOUT.getTime() == 10)
// {
// std::cout <<"Exceptionaly keep the aset." << std::endl;
// relevantActiveSet = true;
// activeSet[5] = soth::cstref_vector_t();
// activeSet[6] = soth::cstref_vector_t();
// activeSet.push_back(soth::cstref_vector_t());
// activeSet.push_back(soth::cstref_vector_t());
// }
int
i
=
0
;
int
i
=
0
;
BOOST_FOREACH
(
TaskAbstract
*
task
,
stack
)
BOOST_FOREACH
(
TaskAbstract
*
task
,
stack
)
...
@@ -160,6 +251,7 @@ namespace dynamicgraph
...
@@ -160,6 +251,7 @@ namespace dynamicgraph
}
}
solution
.
resize
(
nbDofs
);
solution
.
resize
(
nbDofs
);
hsolver
->
notifiorRegistration
(
HCODUpdateCounter
());
}
}
/* Return true iff the solver sizes fit to the task set. */
/* Return true iff the solver sizes fit to the task set. */
...
@@ -188,15 +280,18 @@ namespace dynamicgraph
...
@@ -188,15 +280,18 @@ namespace dynamicgraph
return
!
toBeResized
;
return
!
toBeResized
;
}
}
/* --- SIGNALS ---------------------------------------------------------- */
/* --- SIGNALS ---------------------------------------------------------- */
/* --- SIGNALS ---------------------------------------------------------- */
/* --- SIGNALS ---------------------------------------------------------- */
/* --- SIGNALS ---------------------------------------------------------- */
/* --- SIGNALS ---------------------------------------------------------- */
std
::
ofstream
fup
(
"/tmp/up.dat"
);
ml
::
Vector
&
SolverKine
::
ml
::
Vector
&
SolverKine
::
controlSOUT_function
(
ml
::
Vector
&
mlcontrol
,
int
t
)
controlSOUT_function
(
ml
::
Vector
&
mlcontrol
,
int
t
)
{
{
sotDEBUG
(
15
)
<<
" # In time = "
<<
t
<<
std
::
endl
;
sotDEBUG
(
15
)
<<
" # In time = "
<<
t
<<
std
::
endl
;
HCODUpdateCounter
::
iter
=
t
;
refreshTaskTime
(
t
);
refreshTaskTime
(
t
);
if
(
!
checkSolverSize
()
)
resizeSolver
();
if
(
!
checkSolverSize
()
)
resizeSolver
();
...
@@ -229,9 +324,6 @@ namespace dynamicgraph
...
@@ -229,9 +324,6 @@ namespace dynamicgraph
const
dg
::
sot
::
VectorMultiBound
&
ddx
=
task
.
taskSOUT
(
t
);
const
dg
::
sot
::
VectorMultiBound
&
ddx
=
task
.
taskSOUT
(
t
);
const
int
nx
=
ddx
.
size
();
const
int
nx
=
ddx
.
size
();
sotDEBUG
(
5
)
<<
"ddx"
<<
i
<<
" = "
<<
ddx
<<
std
::
endl
;
sotDEBUG
(
25
)
<<
"J"
<<
i
<<
" = "
<<
J
<<
std
::
endl
;
assert
(
Ctask
.
rows
()
==
nx
&&
btask
.
size
()
==
nx
);
assert
(
Ctask
.
rows
()
==
nx
&&
btask
.
size
()
==
nx
);
assert
(
J
.
rows
()
==
nx
&&
J
.
cols
()
==
nbDofs
&&
(
int
)
ddx
.
size
()
==
nx
);
assert
(
J
.
rows
()
==
nx
&&
J
.
cols
()
==
nbDofs
&&
(
int
)
ddx
.
size
()
==
nx
);
...
@@ -243,13 +335,24 @@ namespace dynamicgraph
...
@@ -243,13 +335,24 @@ namespace dynamicgraph
/* --- */
/* --- */
sotDEBUG
(
1
)
<<
"Initial config."
<<
std
::
endl
;
sotDEBUG
(
1
)
<<
"Initial config."
<<
std
::
endl
;
double
time
=
0
;
hsolver
->
reset
();
hsolver
->
reset
();
hsolver
->
setInitialActiveSet
();
if
(
relevantActiveSet
)
hsolver
->
setInitialActiveSet
(
activeSet
);
else
hsolver
->
setInitialActiveSet
();
struct
timeval
t0
,
t1
;
gettimeofday
(
&
t0
,
NULL
);
sotDEBUG
(
1
)
<<
"Run for a solution."
<<
std
::
endl
;
sotDEBUG
(
1
)
<<
"Run for a solution."
<<
std
::
endl
;
hsolver
->
activeSearch
(
solution
);
hsolver
->
activeSearch
(
solution
);
sotDEBUG
(
1
)
<<
"solution = "
<<
(
MATLAB
)
solution
<<
std
::
endl
;
sotDEBUG
(
1
)
<<
"solution = "
<<
(
MATLAB
)
solution
<<
std
::
endl
;
gettimeofday
(
&
t1
,
NULL
);
time
=
((
t1
.
tv_sec
-
t0
.
tv_sec
)
+
(
t1
.
tv_usec
-
t0
.
tv_usec
)
/
1.0e6
);
activeSet
=
hsolver
->
getOptimalActiveSet
();
relevantActiveSet
=
true
;
if
(
controlFreeFloating
)
if
(
controlFreeFloating
)
{
{
...
@@ -262,6 +365,12 @@ namespace dynamicgraph
...
@@ -262,6 +365,12 @@ namespace dynamicgraph
control
=
solution
.
tail
(
nbDofs
-
6
);
control
=
solution
.
tail
(
nbDofs
-
6
);
}
}
fup
<<
t
<<
"
\t
"
<<
HCODUpdateCounter
::
count
<<
" "
<<
time
<<
" "
<<
hsolver
->
sizeA
();
fup
<<
std
::
endl
;
HCODUpdateCounter
::
count
=
0
;
sotDEBUG
(
1
)
<<
"control = "
<<
mlcontrol
<<
std
::
endl
;
sotDEBUG
(
1
)
<<
"control = "
<<
mlcontrol
<<
std
::
endl
;
return
mlcontrol
;
return
mlcontrol
;
}
}
...
@@ -274,8 +383,22 @@ namespace dynamicgraph
...
@@ -274,8 +383,22 @@ namespace dynamicgraph
void
SolverKine
::
void
SolverKine
::
debugOnce
(
void
)
debugOnce
(
void
)
{
{
std
::
cout
<<
"Open the trace"
<<
std
::
endl
;
dg
::
sot
::
DebugTrace
::
openFile
(
"/tmp/sot.txt"
);
dg
::
sot
::
DebugTrace
::
openFile
(
"/tmp/sot.txt"
);
hsolver
->
debugOnce
();
hsolver
->
debugOnce
(
"/tmp/soth.txt"
,
true
);
}
void
SolverKine
::
resetAset
(
void
)
{
relevantActiveSet
=
false
;
}
void
SolverKine
::
getDecomposition
(
const
int
&
i
)
{
using
namespace
soth
;
std
::
cout
<<
"M"
<<
i
<<
" = "
<<
(
MATLAB
)
hsolver
->
stage
(
i
).
getM
()
<<
std
::
endl
;
std
::
cout
<<
"L"
<<
i
<<
" = "
<<
(
MATLAB
)(
MatrixXd
)
(
hsolver
->
stage
(
i
).
getLtri
())
<<
std
::
endl
;
}
}
/* --- ENTITY ----------------------------------------------------------- */
/* --- ENTITY ----------------------------------------------------------- */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment