Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sot-core
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
Show more breadcrumbs
Stack Of Tasks
sot-core
Commits
1620bc51
Commit
1620bc51
authored
11 years ago
by
Francesco Morsillo
Browse files
Options
Downloads
Patches
Plain Diff
Working second order integration on device.cpp
parent
af83a7f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/sot/core/device.hh
+4
-2
4 additions, 2 deletions
include/sot/core/device.hh
src/tools/device.cpp
+38
-28
38 additions, 28 deletions
src/tools/device.cpp
with
42 additions
and
30 deletions
include/sot/core/device.hh
+
4
−
2
View file @
1620bc51
...
...
@@ -61,7 +61,9 @@ namespace dynamicgraph {
protected
:
ml
::
Vector
state_
;
ml
::
Vector
statedot_
;
ml
::
Vector
velocity_
;
bool
vel_controlInit_
;
ml
::
Vector
vel_control_
;
bool
secondOrderIntegration_
;
bool
withForceSignals
[
4
];
PeriodicCall
periodicCallBefore_
;
...
...
@@ -92,7 +94,7 @@ namespace dynamicgraph {
dynamicgraph
::
SignalPtr
<
ml
::
Vector
,
int
>
zmpSIN
;
dynamicgraph
::
Signal
<
ml
::
Vector
,
int
>
stateSOUT
;
dynamicgraph
::
Signal
<
ml
::
Vector
,
int
>
statedot
SOUT
;
dynamicgraph
::
Signal
<
ml
::
Vector
,
int
>
velocity
SOUT
;
dynamicgraph
::
Signal
<
MatrixRotation
,
int
>
attitudeSOUT
;
dynamicgraph
::
Signal
<
ml
::
Vector
,
int
>*
forcesSOUT
[
4
];
...
...
This diff is collapsed.
Click to expand it.
src/tools/device.cpp
+
38
−
28
View file @
1620bc51
...
...
@@ -113,19 +113,20 @@ Device::
Device
::
Device
(
const
std
::
string
&
n
)
:
Entity
(
n
)
,
state_
(
6
)
,
secondOrderIntegration_
(
false
)
,
controlSIN
(
NULL
,
"Device("
+
n
+
")::input(double)::control"
)
//,attitudeSIN(NULL,"Device::input(matrixRot)::attitudeIN")
,
attitudeSIN
(
NULL
,
"Device::input(vector3)::attitudeIN"
)
,
zmpSIN
(
NULL
,
"Device::input(vector3)::zmp"
)
,
stateSOUT
(
"Device("
+
n
+
")::output(vector)::state"
)
,
statedotSOUT
(
"Device("
+
n
+
")::output(vector)::statedot"
)
,
attitudeSOUT
(
"Device("
+
n
+
")::output(matrixRot)::attitude"
)
,
pseudoTorqueSOUT
(
"Device::output(vector)::ptorque"
)
,
previousControlSOUT
(
"Device("
+
n
+
")::output(vector)::previousControl"
)
,
motorcontrolSOUT
(
"Device("
+
n
+
")::output(vector)::motorcontrol"
)
,
ZMPPreviousControllerSOUT
(
"Device("
+
n
+
")::output(vector)::zmppreviouscontroller"
),
ffPose_
(),
,
state_
(
6
)
,
secondOrderIntegration_
(
false
)
,
vel_controlInit_
(
false
)
,
controlSIN
(
NULL
,
"Device("
+
n
+
")::input(double)::control"
)
//,attitudeSIN(NULL,"Device::input(matrixRot)::attitudeIN")
,
attitudeSIN
(
NULL
,
"Device::input(vector3)::attitudeIN"
)
,
zmpSIN
(
NULL
,
"Device::input(vector3)::zmp"
)
,
stateSOUT
(
"Device("
+
n
+
")::output(vector)::state"
)
,
velocitySOUT
(
"Device("
+
n
+
")::output(vector)::velocity"
)
,
attitudeSOUT
(
"Device("
+
n
+
")::output(matrixRot)::attitude"
)
,
pseudoTorqueSOUT
(
"Device::output(vector)::ptorque"
)
,
previousControlSOUT
(
"Device("
+
n
+
")::output(vector)::previousControl"
)
,
motorcontrolSOUT
(
"Device("
+
n
+
")::output(vector)::motorcontrol"
)
,
ZMPPreviousControllerSOUT
(
"Device("
+
n
+
")::output(vector)::zmppreviouscontroller"
),
ffPose_
(),
forceZero6
(
6
)
{
forceZero6
.
fill
(
0
);
...
...
@@ -177,8 +178,8 @@ Device( const std::string& n )
/* Second Order Integration set. */
docstring
=
"
\n
"
" Set the position calculous starting from
acceleration
\n
"
" measure instead of velocity
\n
"
" Set the position calculous starting from
\n
"
"
acceleration
measure instead of velocity
\n
"
"
\n
"
;
addCommand
(
"setSecondOrderIntegration"
,
...
...
@@ -201,6 +202,10 @@ setStateSize( const unsigned int& size )
pseudoTorqueSOUT
.
setConstant
(
state_
);
motorcontrolSOUT
.
setConstant
(
state_
);
velocity_
.
resize
(
size
);
velocity_
.
fill
(
.0
);
velocitySOUT
.
setConstant
(
velocity_
);
ml
::
Vector
zmp
(
3
);
zmp
.
fill
(
.0
);
ZMPPreviousControllerSOUT
.
setConstant
(
zmp
);
}
...
...
@@ -209,8 +214,6 @@ void Device::
setState
(
const
ml
::
Vector
&
st
)
{
state_
=
st
;
statedot_
=
ml
::
Vector
(
state_
.
size
());
statedot_
.
setZero
();
stateSOUT
.
setConstant
(
state_
);
motorcontrolSOUT
.
setConstant
(
state_
);
}
...
...
@@ -235,7 +238,9 @@ void Device::
setSecondOrderIntegration
()
{
secondOrderIntegration_
=
true
;
signalRegistration
(
statedotSOUT
);
signalRegistration
(
velocitySOUT
);
velocity_
.
fill
(
.0
);
velocitySOUT
.
setConstant
(
velocity_
);
}
void
Device
::
...
...
@@ -248,8 +253,8 @@ increment( const double & dt )
stateSOUT
.
setConstant
(
state_
);
stateSOUT
.
setTime
(
time
+
1
);
if
(
secondOrderIntegration_
)
{
statedot
SOUT
.
setConstant
(
statedot
_
);
statedot
SOUT
.
setTime
(
time
+
1
);
velocity
SOUT
.
setConstant
(
velocity
_
);
velocity
SOUT
.
setTime
(
time
+
1
);
}
for
(
int
i
=
0
;
i
<
4
;
++
i
){
if
(
!
withForceSignals
[
i
]
)
forcesSOUT
[
i
]
->
setConstant
(
forceZero6
);
...
...
@@ -323,8 +328,13 @@ increment( const double & dt )
void
Device
::
integrate
(
const
double
&
dt
)
{
const
ml
::
Vector
&
control
=
controlSIN
.
accessCopy
();
ml
::
Vector
vel_control
=
ml
::
Vector
(
control
.
size
());
vel_control
.
setZero
();
if
(
!
vel_controlInit_
)
{
vel_control_
=
ml
::
Vector
(
control
.
size
());
vel_controlInit_
=
true
;
}
// If control size is state size - 6, integrate joint angles,
// if control and state are of same size, integrate 6 first degrees of
// freedom as a translation and roll pitch yaw.
...
...
@@ -333,21 +343,21 @@ void Device::integrate( const double & dt )
if
(
secondOrderIntegration_
)
for
(
unsigned
int
i
=
0
;
i
<
control
.
size
();
++
i
)
{
vel_control
(
i
)
=
statedot
_
(
i
)
+
control
(
i
)
*
dt
*
0.5
;
statedot_
(
i
)
=
statedot
_
(
i
)
+
control
(
i
)
*
dt
;
vel_control
_
(
i
)
=
velocity
_
(
i
)
+
control
(
i
)
*
dt
*
0.5
;
velocity_
(
i
)
=
velocity
_
(
i
)
+
control
(
i
)
*
dt
;
}
else
{
vel_control
=
control
;
vel_control
_
=
control
;
}
if
(
vel_control
.
size
()
==
state_
.
size
())
{
if
(
vel_control
_
.
size
()
==
state_
.
size
())
{
offset
=
0
;
integrateRollPitchYaw
(
state_
,
vel_control
,
dt
);
integrateRollPitchYaw
(
state_
,
vel_control
_
,
dt
);
}
for
(
unsigned
int
i
=
6
;
i
<
state_
.
size
();
++
i
)
{
state_
(
i
)
+=
(
vel_control
(
i
-
offset
)
*
dt
);
}
{
state_
(
i
)
+=
(
vel_control
_
(
i
-
offset
)
*
dt
);
}
}
/* --- DISPLAY ------------------------------------------------------------ */
...
...
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