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
0a1a6495
Commit
0a1a6495
authored
6 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Added cmd line options for length and mass scaling
parent
62f78013
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
VirtualRobot/examples/Simox2Mjcf/main.cpp
+40
-7
40 additions, 7 deletions
VirtualRobot/examples/Simox2Mjcf/main.cpp
with
40 additions
and
7 deletions
VirtualRobot/examples/Simox2Mjcf/main.cpp
+
40
−
7
View file @
0a1a6495
...
...
@@ -15,12 +15,14 @@ namespace fs = boost::filesystem;
void
printUsage
(
const
char
*
argv0
)
{
std
::
cout
<<
"Usage: "
<<
argv0
<<
" --robot <simox robot file> "
<<
"[--outdir <output directory>] "
<<
"[--meshRelDir <relative mesh directory>] "
<<
"[--actuator {motor|position|velocity}] "
<<
"[--mocap {y|n}] "
<<
"[--verbose {y|n}]"
<<
" --robot <simox robot file>"
<<
" [--outdir <output directory>]"
<<
" [--meshRelDir <relative mesh directory>]"
<<
" [--actuator {motor|position|velocity}]"
<<
" [--mocap {y|n}]"
<<
" [--length_scaling <length scaling (to m)>]"
<<
" [--mass_scaling <mass scaling (to kg)>]"
<<
" [--verbose {y|n}]"
<<
std
::
endl
;
}
...
...
@@ -36,6 +38,8 @@ int main(int argc, char* argv[])
RuntimeEnvironment
::
considerKey
(
"meshRelDir"
);
RuntimeEnvironment
::
considerKey
(
"actuator"
);
RuntimeEnvironment
::
considerKey
(
"mocap"
);
RuntimeEnvironment
::
considerKey
(
"scale_length"
);
RuntimeEnvironment
::
considerKey
(
"scale_mass"
);
RuntimeEnvironment
::
considerKey
(
"verbose"
);
RuntimeEnvironment
::
processCommandLine
(
argc
,
argv
);
...
...
@@ -84,6 +88,33 @@ int main(int argc, char* argv[])
const
bool
mocap
=
RuntimeEnvironment
::
checkParameter
(
"mocap"
,
"n"
)
==
"y"
;
const
bool
verbose
=
RuntimeEnvironment
::
checkParameter
(
"verbose"
,
"n"
)
==
"y"
;
auto
parseFloatParameter
=
[](
const
std
::
string
&
key
,
const
std
::
string
&
default_
)
{
const
std
::
string
string
=
RuntimeEnvironment
::
checkParameter
(
key
,
default_
);
try
{
return
std
::
stof
(
string
);
}
catch
(
const
std
::
invalid_argument
&
e
)
{
std
::
cerr
<<
"Could not parse value of argument "
<<
key
<<
": '"
<<
string
<<
"'
\n
"
<<
"Reason: "
<<
e
.
what
()
<<
std
::
endl
;
throw
e
;
}
};
float
lengthScaling
;
float
massScaling
;
try
{
lengthScaling
=
parseFloatParameter
(
"scale_length"
,
"0.001"
);
massScaling
=
parseFloatParameter
(
"scale_mass"
,
"0.001"
);
}
catch
(
const
std
::
invalid_argument
&
)
{
return
-
1
;
}
std
::
cout
<<
"Input file: "
<<
inputFilename
<<
std
::
endl
;
std
::
cout
<<
"Output dir: "
<<
outputDir
<<
std
::
endl
;
...
...
@@ -104,7 +135,7 @@ int main(int argc, char* argv[])
throw
;
// rethrow
}
if
(
false
)
if
(
/* DISABLES CODE */
(
false
)
)
{
// using RobotIO
RobotIO
::
saveMJCF
(
robot
,
inputFilename
.
filename
().
string
(),
outputDir
.
string
(),
meshRelDir
);
...
...
@@ -115,6 +146,8 @@ int main(int argc, char* argv[])
mujoco
::
MujocoIO
mujocoIO
(
robot
);
mujocoIO
.
setActuatorType
(
actuatorType
);
mujocoIO
.
setWithMocapBody
(
mocap
);
mujocoIO
.
setLengthScaling
(
lengthScaling
);
mujocoIO
.
setMassScaling
(
massScaling
);
mujocoIO
.
setVerbose
(
verbose
);
mujocoIO
.
saveMJCF
(
inputFilename
.
filename
().
string
(),
outputDir
.
string
(),
meshRelDir
);
}
...
...
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