Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pinocchio
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
pinocchio
Commits
6bdd9e52
Commit
6bdd9e52
authored
9 years ago
by
jcarpent
Browse files
Options
Downloads
Patches
Plain Diff
[C++] Add computation of potential energy
parent
0322cf27
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/algorithm/energy.hpp
+36
-0
36 additions, 0 deletions
src/algorithm/energy.hpp
src/multibody/model.hpp
+1
-0
1 addition, 0 deletions
src/multibody/model.hpp
with
37 additions
and
0 deletions
src/algorithm/energy.hpp
+
36
−
0
View file @
6bdd9e52
...
...
@@ -40,8 +40,26 @@ namespace se3 {
const
Eigen
::
VectorXd
&
q
,
const
Eigen
::
VectorXd
&
v
,
const
bool
update_kinematics
=
true
);
///
/// \brief Computes the potential energy of the system, i.e. the potential energy linked to the gravity field.
/// The result is accessible throw data.potential_energy.
///
/// \param[in] model The model structure of the rigid body system.
/// \param[in] data The data structure of the rigid body system.
/// \param[in] q The joint configuration vector (dim model.nq).
///
/// \return The potential energy of the system in [J].
///
inline
double
potentialEnergy
(
const
Model
&
model
,
Data
&
data
,
const
Eigen
::
VectorXd
&
q
,
const
bool
update_kinematics
=
true
);
}
/* --- Details -------------------------------------------------------------------- */
/* --- Details -------------------------------------------------------------------- */
/* --- Details -------------------------------------------------------------------- */
namespace
se3
{
...
...
@@ -64,5 +82,23 @@ namespace se3
data
.
kinetic_energy
*=
.5
;
return
data
.
kinetic_energy
;
}
inline
double
potentialEnergy
(
const
Model
&
model
,
Data
&
data
,
const
Eigen
::
VectorXd
&
q
,
const
bool
update_kinematics
)
{
data
.
potential_energy
=
0.
;
const
Motion
::
ConstLinear_t
&
g
=
model
.
gravity
.
linear
();
if
(
update_kinematics
)
geometry
(
model
,
data
,
q
);
for
(
Model
::
Index
i
=
1
;
i
<
(
Model
::
Index
)(
model
.
nbody
);
++
i
)
data
.
potential_energy
+=
model
.
inertias
[
i
].
mass
()
*
data
.
oMi
[
i
].
translation
().
dot
(
g
);
return
data
.
potential_energy
;
}
}
#endif // __se3_energy_hpp__
This diff is collapsed.
Click to expand it.
src/multibody/model.hpp
+
1
−
0
View file @
6bdd9e52
...
...
@@ -155,6 +155,7 @@ namespace se3
Eigen
::
VectorXd
upperPositionLimit
;
// limit for joint upper position
double
kinetic_energy
;
// kinetic energy of the model
double
potential_energy
;
// potential energy of the model
Data
(
const
Model
&
ref
);
...
...
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