Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
292a9ef3
Commit
292a9ef3
authored
6 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Fixed some attribute parsing errors
parent
8ce6134e
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
VirtualRobot/MJCF/elements/core/mjcf_utils.cpp
+11
-13
11 additions, 13 deletions
VirtualRobot/MJCF/elements/core/mjcf_utils.cpp
VirtualRobot/MJCF/elements/core/mjcf_utils.h
+10
-13
10 additions, 13 deletions
VirtualRobot/MJCF/elements/core/mjcf_utils.h
with
21 additions
and
26 deletions
VirtualRobot/MJCF/elements/core/mjcf_utils.cpp
+
11
−
13
View file @
292a9ef3
...
...
@@ -7,18 +7,6 @@
namespace
mjcf
{
ActuatorType
toActuatorType
(
std
::
string
str
)
{
static
const
std
::
map
<
std
::
string
,
ActuatorType
>
map
{
{
"motor"
,
ActuatorType
::
MOTOR
},
{
"position"
,
ActuatorType
::
POSITION
},
{
"velocity"
,
ActuatorType
::
VELOCITY
}
};
std
::
transform
(
str
.
begin
(),
str
.
end
(),
str
.
begin
(),
::
tolower
);
return
map
.
at
(
str
);
}
std
::
size_t
commonPrefixLength
(
const
std
::
string
&
a
,
const
std
::
string
&
b
)
{
const
std
::
string
*
smaller
=
&
a
;
...
...
@@ -40,6 +28,16 @@ namespace mjcf
return
strings
[
int
(
b
)];
}
void
fromAttr
(
const
std
::
string
&
valueStr
,
bool
&
value
)
{
static
const
std
::
map
<
std
::
string
,
bool
>
map
=
{
{
"true"
,
true
},
{
"false"
,
false
},
{
"1"
,
true
},
{
"0"
,
false
},
};
value
=
map
.
at
(
valueStr
);
}
Eigen
::
Vector2f
strToVec2
(
const
char
*
string
)
{
...
...
@@ -68,7 +66,7 @@ namespace mjcf
{
return
strcmp
(
lhs
,
rhs
)
==
0
;
}
}
bool
std
::
operator
==
(
const
char
*
lhs
,
const
std
::
string
&
rhs
)
...
...
This diff is collapsed.
Click to expand it.
VirtualRobot/MJCF/elements/core/mjcf_utils.h
+
10
−
13
View file @
292a9ef3
...
...
@@ -41,13 +41,6 @@ namespace Eigen
namespace
mjcf
{
enum
class
ActuatorType
{
MOTOR
,
POSITION
,
VELOCITY
};
ActuatorType
toActuatorType
(
std
::
string
str
);
// Get lenght of common prefix of two strings (was used for mergin body names).
std
::
size_t
commonPrefixLength
(
const
std
::
string
&
a
,
const
std
::
string
&
b
);
...
...
@@ -78,6 +71,14 @@ namespace mjcf
/// Single values via boost::lexical cast. Only enabled for non-Eigen types.
template
<
typename
AttrT
,
typename
std
::
enable_if
<!
Eigen
::
is_eigen_expression
<
AttrT
>
::
value
,
AttrT
>::
type
*
=
nullptr
>
void
fromAttr
(
const
std
::
string
&
valueStr
,
AttrT
&
value
);
/// Bool
void
fromAttr
(
const
std
::
string
&
valueStr
,
bool
&
value
);
/// Eigen Matrix and vectors
template
<
typename
Derived
>
void
fromAttr
(
const
std
::
string
&
valueStr
,
Eigen
::
MatrixBase
<
Derived
>&
value
);
...
...
@@ -85,10 +86,6 @@ namespace mjcf
template
<
typename
Derived
>
void
fromAttr
(
const
std
::
string
&
valueStr
,
Eigen
::
QuaternionBase
<
Derived
>&
value
);
/// Single values via boost::lexical cast. Only enabled for non-Eigen types.
template
<
typename
AttrT
,
typename
std
::
enable_if
<!
Eigen
::
is_eigen_expression
<
AttrT
>
::
value
,
AttrT
>::
type
*
=
nullptr
>
void
fromAttr
(
const
std
::
string
&
valueStr
,
AttrT
&
value
);
template
<
typename
Scalar
>
...
...
@@ -109,9 +106,9 @@ namespace mjcf
template
<
typename
Derived
>
std
::
string
toAttr
(
const
Eigen
::
MatrixBase
<
Derived
>&
mat
)
{
static
const
Eigen
::
IOFormat
iof
static
const
Eigen
::
IOFormat
iof
{
7
,
0
,
""
,
" "
,
""
,
""
,
""
,
""
Eigen
::
FullPrecision
,
Eigen
::
DontAlignCols
,
"
"
,
" "
,
""
,
""
,
""
,
""
};
std
::
stringstream
ss
;
...
...
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