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
7b392a4c
Commit
7b392a4c
authored
5 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Refactor body.addGeom,
parent
094339f4
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
VirtualRobot/MJCF/elements/types/body.cpp
+15
-8
15 additions, 8 deletions
VirtualRobot/MJCF/elements/types/body.cpp
VirtualRobot/MJCF/elements/types/body.h
+12
-2
12 additions, 2 deletions
VirtualRobot/MJCF/elements/types/body.h
with
27 additions
and
10 deletions
VirtualRobot/MJCF/elements/types/body.cpp
+
15
−
8
View file @
7b392a4c
...
...
@@ -118,6 +118,13 @@ Geom Body::addGeom(const std::string& type)
return
geom
;
}
Geom
Body
::
addGeom
(
const
std
::
string
&
type
,
const
Eigen
::
Vector3f
&
size
)
{
Geom
geom
=
addGeom
(
type
);
geom
.
size
=
size
;
return
geom
;
}
Geom
Body
::
addGeomMesh
(
const
std
::
string
&
meshName
,
const
std
::
string
&
materialName
)
{
Geom
geom
=
addGeom
(
"mesh"
);
...
...
@@ -134,15 +141,15 @@ Geom Body::addGeomMesh(const std::string& meshName, const std::string& materialN
Body
Worldbody
::
addMocapBody
(
const
std
::
string
&
name
,
float
geomSize
)
{
Body
mocap
=
addChild
<
Body
>
();
mocap
.
name
=
name
;
Body
mocap
=
addBody
(
name
);
mocap
.
mocap
=
true
;
// add geom for visualization
Geom
geom
=
mocap
.
addChild
<
Geom
>
();
geom
.
type
=
"box"
;
geom
.
size
=
geomSize
*
Eigen
::
Vector3f
::
Ones
();
if
(
geomSize
>
0
)
{
// Add geom for visualization.
Geom
geom
=
mocap
.
addGeom
(
"box"
,
Eigen
::
Vector3f
::
Constant
(
geomSize
));
}
return
mocap
;
}
...
...
This diff is collapsed.
Click to expand it.
VirtualRobot/MJCF/elements/types/body.h
+
12
−
2
View file @
7b392a4c
...
...
@@ -109,6 +109,7 @@ struct Geom : public Element<Geom>
mjcf_FloatAttributeDef
(
Geom
,
fitscale
,
1
);
};
struct
Site
:
public
Element
<
Site
>
{
static
const
std
::
string
tag
;
...
...
@@ -130,6 +131,7 @@ struct Site : public Element<Site>
mjcf_PoseAttributes
(
Site
);
};
struct
Camera
:
public
Element
<
Camera
>
{
static
const
std
::
string
tag
;
...
...
@@ -151,6 +153,7 @@ struct Camera : public Element<Camera>
mjcf_PoseAttributes
(
Camera
);
};
struct
Light
:
public
Element
<
Light
>
{
static
const
std
::
string
tag
;
...
...
@@ -179,6 +182,7 @@ struct Light : public Element<Light>
mjcf_Vector3fAttributeDef
(
Light
,
specular
,
Eigen
::
Vector3f
::
Constant
(
0.3
f
));
};
struct
Body
:
public
Element
<
Body
>
{
static
const
std
::
string
tag
;
...
...
@@ -202,8 +206,10 @@ struct Body : public Element<Body>
/// Add a free joint element to a body.
FreeJoint
addFreeJoint
();
/// Add a geom
to a body, referencing a mesh
.
/// Add a geom
element with the given type
.
Geom
addGeom
(
const
std
::
string
&
type
);
/// Add a geom element with type and size.
Geom
addGeom
(
const
std
::
string
&
type
,
const
Eigen
::
Vector3f
&
size
);
/// Add a mesh geom with optional material (for texture).
Geom
addGeomMesh
(
const
std
::
string
&
meshName
,
const
std
::
string
&
materialName
=
""
);
...
...
@@ -216,6 +222,7 @@ struct Body : public Element<Body>
mjcf_PoseAttributes
(
Body
);
};
struct
Worldbody
:
public
Element
<
Worldbody
>
{
static
const
std
::
string
tag
;
...
...
@@ -224,7 +231,10 @@ struct Worldbody : public Element<Worldbody>
/// Add a body element.
Body
addBody
(
const
std
::
string
&
name
=
""
,
const
std
::
string
&
childClass
=
""
);
/// Add a mocap body with the given name to the worldbody.
/**
* @brief Add a mocap body with the given name to the worldbody.
* @param geomSize If positive, a box geom is added for visualization and interaction.
*/
Body
addMocapBody
(
const
std
::
string
&
name
,
float
geomSize
);
};
...
...
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