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
b36be07b
Commit
b36be07b
authored
6 years ago
by
Rohan Budhiraja
Browse files
Options
Downloads
Patches
Plain Diff
[srdf][referenceConfig] loadReferenceConfigurations
parent
fe12706b
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/parsers/srdf.hpp
+9
-0
9 additions, 0 deletions
src/parsers/srdf.hpp
src/parsers/srdf.hxx
+57
-33
57 additions, 33 deletions
src/parsers/srdf.hxx
with
66 additions
and
33 deletions
src/parsers/srdf.hpp
+
9
−
0
View file @
b36be07b
...
...
@@ -81,6 +81,7 @@ namespace pinocchio
/// \return The neutral configuration as an eigen vector
///
template
<
typename
Scalar
,
int
Options
,
template
<
typename
,
int
>
class
JointCollectionTpl
>
PINOCCHIO_DEPRECATED
typename
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>::
ConfigVectorType
getNeutralConfiguration
(
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>
&
model
,
const
std
::
string
&
filename
,
...
...
@@ -94,6 +95,14 @@ namespace pinocchio
const
std
::
string
&
filename
,
const
bool
verbose
=
false
)
throw
(
std
::
invalid_argument
)
{
return
getNeutralConfiguration
(
model
,
filename
,
verbose
);
}
template
<
typename
Scalar
,
int
Options
,
template
<
typename
,
int
>
class
JointCollectionTpl
>
void
loadReferenceConfigurations
(
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>
&
model
,
const
std
::
string
&
filename
,
const
bool
verbose
)
throw
(
std
::
invalid_argument
);
///
/// \brief Load the rotor params of a given model associated to a SRDF file.
...
...
This diff is collapsed.
Click to expand it.
src/parsers/srdf.hxx
+
57
−
33
View file @
b36be07b
...
...
@@ -200,12 +200,35 @@ namespace pinocchio
assert
(
false
&&
"no rotor params found in the srdf file"
);
return
false
;
// warning : uninitialized vector is returned
}
template
<
typename
Scalar
,
int
Options
,
template
<
typename
,
int
>
class
JointCollectionTpl
>
typename
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>::
ConfigVectorType
getNeutralConfiguration
(
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>
&
model
,
const
std
::
string
&
filename
,
const
bool
verbose
)
throw
(
std
::
invalid_argument
)
{
typedef
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>
Model
;
loadReferenceConfigurations
(
model
,
filename
,
verbose
);
typename
Model
::
ConfigVectorMap
::
iterator
it
=
model
.
referenceConfigurations
.
find
(
"half_sitting"
);
if
(
it
==
model
.
referenceConfigurations
.
end
()
)
{
// not found
assert
(
false
&&
"no half_sitting configuration found in the srdf file"
);
// Should we throw something here ?
return
Model
::
ConfigVectorType
::
Constant
(
model
.
nq
,(
Scalar
)
NAN
);
// warning : uninitialized vector is returned
}
else
{
return
it
->
second
;
}
}
template
<
typename
Scalar
,
int
Options
,
template
<
typename
,
int
>
class
JointCollectionTpl
>
void
loadReferenceConfigurations
(
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>
&
model
,
const
std
::
string
&
filename
,
const
bool
verbose
)
throw
(
std
::
invalid_argument
)
{
typedef
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>
Model
;
typedef
typename
Model
::
JointModel
JointModel
;
...
...
@@ -238,47 +261,48 @@ namespace pinocchio
if
(
v
.
first
==
"group_state"
)
{
const
std
::
string
name
=
v
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.name"
);
// Ensure that it is the half_sitting tag
if
(
name
==
"half_sitting"
)
if
(
!
model
.
referenceConfigurations
.
insert
(
std
::
make_pair
(
name
,
Model
::
ConfigVectorType
::
Zero
(
model
.
nq
))).
second
)
{
// Element already present...
if
(
verbose
)
std
::
cout
<<
"The reference configuration "
<<
name
<<
" has been defined multiple times. "
<<
"Only the last instance of "
<<
name
<<
" is being used."
<<
std
::
endl
;
}
typename
Model
::
ConfigVectorType
&
ref_config
=
model
.
referenceConfigurations
.
find
(
name
)
->
second
;
// Iterate over all the joint tags
BOOST_FOREACH
(
const
ptree
::
value_type
&
joint_tag
,
v
.
second
)
{
// Iterate over all the joint tags
BOOST_FOREACH
(
const
ptree
::
value_type
&
joint_tag
,
v
.
second
)
if
(
joint_tag
.
first
==
"joint"
)
{
if
(
joint_tag
.
first
==
"joint"
)
{
std
::
string
joint_name
=
joint_tag
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.name"
);
typename
Model
::
JointIndex
joint_id
=
model
.
getJointId
(
joint_name
);
std
::
string
joint_name
=
joint_tag
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.name"
);
typename
Model
::
JointIndex
joint_id
=
model
.
getJointId
(
joint_name
);
// Search in model the joint and its config id
if
(
joint_id
!=
model
.
joints
.
size
())
// != model.njoints
{
const
JointModel
&
joint
=
model
.
joints
[
joint_id
];
typename
Model
::
ConfigVectorType
joint_config
(
joint
.
nq
());
const
std
::
string
joint_val
=
joint_tag
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.value"
);
std
::
istringstream
config_string
(
joint_val
);
std
::
vector
<
double
>
config_vec
((
std
::
istream_iterator
<
double
>
(
config_string
)),
std
::
istream_iterator
<
double
>
());
joint_config
=
Eigen
::
Map
<
typename
Model
::
ConfigVectorType
>
(
config_vec
.
data
(),
config_vec
.
size
());
model
.
neutralConfiguration
.
segment
(
joint
.
idx_q
(),
joint
.
nq
())
=
joint_config
;
if
(
verbose
)
{
std
::
cout
<<
"("
<<
joint_name
<<
" , "
<<
joint_config
.
transpose
()
<<
")"
<<
std
::
endl
;
}
}
else
// Search in model the joint and its config id
if
(
joint_id
!=
model
.
joints
.
size
())
// != model.njoints
{
const
JointModel
&
joint
=
model
.
joints
[
joint_id
];
typename
Model
::
ConfigVectorType
joint_config
(
joint
.
nq
());
const
std
::
string
joint_val
=
joint_tag
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.value"
);
std
::
istringstream
config_string
(
joint_val
);
std
::
vector
<
double
>
config_vec
((
std
::
istream_iterator
<
double
>
(
config_string
)),
std
::
istream_iterator
<
double
>
());
joint_config
=
Eigen
::
Map
<
typename
Model
::
ConfigVectorType
>
(
config_vec
.
data
(),
config_vec
.
size
());
ref_config
.
segment
(
joint
.
idx_q
(),
joint
.
nq
())
=
joint_config
;
if
(
verbose
)
{
if
(
verbose
)
std
::
cout
<<
"
The Joint
"
<<
joint_name
<<
"
was not found in model
"
<<
std
::
endl
;
std
::
cout
<<
"
(
"
<<
joint_name
<<
"
, "
<<
joint_config
.
transpose
()
<<
")
"
<<
std
::
endl
;
}
}
else
{
if
(
verbose
)
std
::
cout
<<
"The Joint "
<<
joint_name
<<
" was not found in model"
<<
std
::
endl
;
}
}
return
model
.
neutralConfiguration
;
}
}
}
}
// BOOST_FOREACH
assert
(
false
&&
"no half_sitting configuration found in the srdf file"
);
// Should we throw something here ?
return
ModelTpl
<
Scalar
,
Options
,
JointCollectionTpl
>::
ConfigVectorType
::
Constant
(
model
.
nq
,(
Scalar
)
NAN
);
// warning : uninitialized vector is returned
}
}
}
// namespace pinocchio
...
...
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