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
c57051fe
Commit
c57051fe
authored
1 year ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Auto format (pure)
parent
6a8b8441
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/Nodes/RobotNodeHemisphere.cpp
+153
-114
153 additions, 114 deletions
VirtualRobot/Nodes/RobotNodeHemisphere.cpp
VirtualRobot/Nodes/RobotNodeHemisphere.h
+45
-68
45 additions, 68 deletions
VirtualRobot/Nodes/RobotNodeHemisphere.h
with
198 additions
and
182 deletions
VirtualRobot/Nodes/RobotNodeHemisphere.cpp
+
153
−
114
View file @
c57051fe
#include
"RobotNodeHemisphere.h"
#include
"RobotNodeHemisphere.h"
#include
"Nodes/Sensor.h"
#include
"Robot.h"
#include
"VirtualRobotException.h"
#include
<algorithm>
#include
<algorithm>
#include
<cmath>
#include
<cmath>
#include
<Eigen/Geometry>
#include
<Eigen/Geometry>
#include
<SimoxUtility/meta/enum/EnumNames.hpp>
#include
<SimoxUtility/math/pose/pose.h>
#include
<SimoxUtility/math/convert/rad_to_deg.h>
#include
<SimoxUtility/math/convert/rad_to_deg.h>
#include
<SimoxUtility/math/pose/pose.h>
#include
<SimoxUtility/meta/enum/EnumNames.hpp>
#include
"Nodes/Sensor.h"
#include
"Robot.h"
#include
"VirtualRobotException.h"
namespace
VirtualRobot
namespace
VirtualRobot
{
{
static
const
float
initialLimit
=
1.0
;
static
const
float
initialLimit
=
1.0
;
extern
const
simox
::
meta
::
EnumNames
<
RobotNodeHemisphere
::
Role
>
RoleNames
=
extern
const
simox
::
meta
::
EnumNames
<
RobotNodeHemisphere
::
Role
>
RoleNames
=
{
{
{
RobotNodeHemisphere
::
Role
::
FIRST
,
"first"
},
{
RobotNodeHemisphere
::
Role
::
FIRST
,
"first"
},
{
RobotNodeHemisphere
::
Role
::
SECOND
,
"second"
},
{
RobotNodeHemisphere
::
Role
::
SECOND
,
"second"
},
};
};
VirtualRobot
::
RobotNodeHemisphere
::
RobotNodeHemisphere
()
VirtualRobot
::
RobotNodeHemisphere
::
RobotNodeHemisphere
()
{
{
}
}
RobotNodeHemisphere
::
Role
RobotNodeHemisphere
::
RoleFromString
(
const
std
::
string
&
string
)
RobotNodeHemisphere
::
Role
RobotNodeHemisphere
::
RoleFromString
(
const
std
::
string
&
string
)
{
{
return
RoleNames
.
from_name
(
string
);
return
RoleNames
.
from_name
(
string
);
}
}
RobotNodeHemisphere
::
RobotNodeHemisphere
(
RobotNodeHemisphere
::
RobotNodeHemisphere
(
RobotWeakPtr
rob
,
RobotWeakPtr
rob
,
const
std
::
string
&
name
,
const
std
::
string
&
name
,
const
Eigen
::
Matrix4f
&
preJointTransform
,
const
Eigen
::
Matrix4f
&
preJointTransform
,
VisualizationNodePtr
visualization
,
VisualizationNodePtr
visualization
,
CollisionModelPtr
collisionModel
,
CollisionModelPtr
collisionModel
,
float
jointValueOffset
,
float
jointValueOffset
,
const
SceneObject
::
Physics
&
physics
,
const
SceneObject
::
Physics
&
physics
,
CollisionCheckerPtr
colChecker
,
CollisionCheckerPtr
colChecker
,
RobotNodeType
type
)
:
RobotNodeType
type
RobotNode
(
rob
,
)
:
name
,
RobotNode
(
rob
,
name
,
-
initialLimit
,
initialLimit
,
visualization
,
collisionModel
,
-
initialLimit
,
jointValueOffset
,
physics
,
colChecker
,
type
)
initialLimit
,
visualization
,
collisionModel
,
jointValueOffset
,
physics
,
colChecker
,
type
)
{
{
initialized
=
false
;
initialized
=
false
;
optionalDHParameter
.
isSet
=
false
;
optionalDHParameter
.
isSet
=
false
;
...
@@ -53,20 +59,28 @@ namespace VirtualRobot
...
@@ -53,20 +59,28 @@ namespace VirtualRobot
checkValidRobotNodeType
();
checkValidRobotNodeType
();
}
}
RobotNodeHemisphere
::
RobotNodeHemisphere
(
RobotWeakPtr
rob
,
RobotNodeHemisphere
::
RobotNodeHemisphere
(
const
std
::
string
&
name
,
RobotWeakPtr
rob
,
float
a
,
const
std
::
string
&
name
,
float
d
,
float
a
,
float
d
,
float
alpha
,
float
theta
,
float
alpha
,
VisualizationNodePtr
visualization
,
float
theta
,
CollisionModelPtr
collisionModel
,
VisualizationNodePtr
visualization
,
float
jointValueOffset
,
CollisionModelPtr
collisionModel
,
const
SceneObject
::
Physics
&
physics
,
float
jointValueOffset
,
CollisionCheckerPtr
colChecker
,
const
SceneObject
::
Physics
&
physics
,
RobotNodeType
type
CollisionCheckerPtr
colChecker
,
)
:
RobotNodeType
type
)
:
RobotNode
(
rob
,
name
,
-
initialLimit
,
initialLimit
,
visualization
,
collisionModel
,
RobotNode
(
rob
,
jointValueOffset
,
physics
,
colChecker
,
type
)
name
,
-
initialLimit
,
initialLimit
,
visualization
,
collisionModel
,
jointValueOffset
,
physics
,
colChecker
,
type
)
{
{
initialized
=
false
;
initialized
=
false
;
optionalDHParameter
.
isSet
=
true
;
optionalDHParameter
.
isSet
=
true
;
...
@@ -95,34 +109,32 @@ namespace VirtualRobot
...
@@ -95,34 +109,32 @@ namespace VirtualRobot
checkValidRobotNodeType
();
checkValidRobotNodeType
();
}
}
RobotNodeHemisphere
::~
RobotNodeHemisphere
()
=
default
;
RobotNodeHemisphere
::~
RobotNodeHemisphere
()
void
=
default
;
RobotNodeHemisphere
::
setXmlInfo
(
const
XmlInfo
&
info
)
void
RobotNodeHemisphere
::
setXmlInfo
(
const
XmlInfo
&
info
)
{
{
VR_ASSERT
(
secondData
.
has_value
());
VR_ASSERT
(
secondData
.
has_value
());
switch
(
info
.
role
)
switch
(
info
.
role
)
{
{
case
Role
::
FIRST
:
case
Role
::
FIRST
:
firstData
.
emplace
(
FirstData
{});
firstData
.
emplace
(
FirstData
{});
firstData
->
maths
.
maths
.
setConstants
(
info
.
lever
,
info
.
theta0Rad
);
firstData
->
maths
.
maths
.
setConstants
(
info
.
lever
,
info
.
theta0Rad
);
break
;
break
;
case
Role
::
SECOND
:
case
Role
::
SECOND
:
secondData
.
emplace
(
SecondData
{});
secondData
.
emplace
(
SecondData
{});
break
;
break
;
}
}
}
}
bool
bool
RobotNodeHemisphere
::
initialize
(
RobotNodeHemisphere
::
initialize
(
SceneObjectPtr
parent
,
SceneObjectPtr
parent
,
const
std
::
vector
<
SceneObjectPtr
>&
children
)
const
std
::
vector
<
SceneObjectPtr
>&
children
)
{
{
VR_ASSERT_MESSAGE
(
firstData
.
has_value
()
xor
secondData
.
has_value
(),
VR_ASSERT_MESSAGE
(
firstData
.
has_value
()
xor
secondData
.
has_value
(),
std
::
stringstream
()
<<
firstData
.
has_value
()
<<
" / "
<<
secondData
.
has_value
());
std
::
stringstream
()
<<
firstData
.
has_value
()
<<
" / "
<<
secondData
.
has_value
());
// The second node needs to store a reference to the first node.
// The second node needs to store a reference to the first node.
if
(
secondData
)
if
(
secondData
)
...
@@ -132,11 +144,13 @@ namespace VirtualRobot
...
@@ -132,11 +144,13 @@ namespace VirtualRobot
RobotNodeHemisphere
*
firstNode
=
dynamic_cast
<
RobotNodeHemisphere
*>
(
parent
.
get
());
RobotNodeHemisphere
*
firstNode
=
dynamic_cast
<
RobotNodeHemisphere
*>
(
parent
.
get
());
RobotNodeHemisphere
*
secondNode
=
this
;
RobotNodeHemisphere
*
secondNode
=
this
;
if
(
not
(
firstNode
and
firstNode
->
firstData
))
if
(
not
(
firstNode
and
firstNode
->
firstData
))
{
{
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
"The parent of a hemisphere joint with role '"
<<
RoleNames
.
to_name
(
Role
::
SECOND
)
<<
"' "
ss
<<
"The parent of a hemisphere joint with role '"
<<
"must be a hemisphere joint with role '"
<<
RoleNames
.
to_name
(
Role
::
FIRST
)
<<
"' "
;
<<
RoleNames
.
to_name
(
Role
::
SECOND
)
<<
"' "
<<
"must be a hemisphere joint with role '"
<<
RoleNames
.
to_name
(
Role
::
FIRST
)
<<
"' "
;
THROW_VR_EXCEPTION
(
ss
.
str
());
THROW_VR_EXCEPTION
(
ss
.
str
());
}
}
...
@@ -159,11 +173,12 @@ namespace VirtualRobot
...
@@ -159,11 +173,12 @@ namespace VirtualRobot
return
RobotNode
::
initialize
(
parent
,
children
);
return
RobotNode
::
initialize
(
parent
,
children
);
}
}
void
void
RobotNodeHemisphere
::
updateTransformationMatrices
(
RobotNodeHemisphere
::
updateTransformationMatrices
(
const
Eigen
::
Matrix4f
&
parentPose
)
const
Eigen
::
Matrix4f
&
parentPose
)
{
{
VR_ASSERT_MESSAGE
(
firstData
.
has_value
()
xor
secondData
.
has_value
(),
std
::
stringstream
()
<<
firstData
.
has_value
()
<<
" / "
<<
secondData
.
has_value
());
VR_ASSERT_MESSAGE
(
firstData
.
has_value
()
xor
secondData
.
has_value
(),
std
::
stringstream
()
<<
firstData
.
has_value
()
<<
" / "
<<
secondData
.
has_value
());
if
(
firstData
)
if
(
firstData
)
{
{
...
@@ -174,7 +189,8 @@ namespace VirtualRobot
...
@@ -174,7 +189,8 @@ namespace VirtualRobot
VR_ASSERT_MESSAGE
(
secondData
->
firstNode
,
"First node must be known to second node."
);
VR_ASSERT_MESSAGE
(
secondData
->
firstNode
,
"First node must be known to second node."
);
hemisphere
::
CachedMaths
&
maths
=
secondData
->
maths
();
hemisphere
::
CachedMaths
&
maths
=
secondData
->
maths
();
Eigen
::
Vector2f
actuators
(
secondData
->
firstNode
->
getJointValue
(),
this
->
getJointValue
());
Eigen
::
Vector2f
actuators
(
secondData
->
firstNode
->
getJointValue
(),
this
->
getJointValue
());
maths
.
update
(
actuators
);
maths
.
update
(
actuators
);
...
@@ -189,25 +205,28 @@ namespace VirtualRobot
...
@@ -189,25 +205,28 @@ namespace VirtualRobot
if
(
verbose
)
if
(
verbose
)
{
{
Eigen
::
IOFormat
iof
(
5
,
0
,
" "
,
"
\n
"
,
" ["
,
"]"
);
Eigen
::
IOFormat
iof
(
5
,
0
,
" "
,
"
\n
"
,
" ["
,
"]"
);
std
::
cout
<<
__FUNCTION__
<<
"() of second actuator with "
std
::
cout
<<
"
\n
lever = "
<<
maths
.
maths
.
lever
<<
__FUNCTION__
<<
"() of second actuator with "
<<
"
\n
theta0 = "
<<
maths
.
maths
.
theta0Rad
<<
"
\n
lever = "
<<
maths
.
maths
.
lever
<<
"
\n
radius = "
<<
maths
.
maths
.
radius
<<
"
\n
theta0 = "
<<
maths
.
maths
.
theta0Rad
<<
"
\n
joint value = "
<<
jointValue
<<
"
\n
radius = "
<<
maths
.
maths
.
radius
<<
"
\n
joint value = "
<<
jointValue
<<
"
\n
actuator (angle) =
\n
"
<<
actuators
.
transpose
().
format
(
iof
)
<<
"
\n
actuator (angle) =
\n
"
<<
"
\n
actuator (pos) =
\n
"
<<
maths
.
maths
.
angleToPosition
(
actuators
.
cast
<
double
>
()).
transpose
().
format
(
iof
)
<<
actuators
.
transpose
().
format
(
iof
)
<<
"
\n
actuator (pos) =
\n
"
<<
"
\n
local transform =
\n
"
<<
localTransformation
.
format
(
iof
)
<<
maths
.
maths
.
angleToPosition
(
actuators
.
cast
<
double
>
()).
transpose
().
format
(
iof
)
<<
"
\n
joint transform =
\n
"
<<
transform
.
format
(
iof
)
<<
"
\n
local transform =
\n
"
<<
std
::
endl
;
<<
localTransformation
.
format
(
iof
)
<<
"
\n
joint transform =
\n
"
<<
transform
.
format
(
iof
)
<<
std
::
endl
;
}
}
}
}
}
}
void
void
RobotNodeHemisphere
::
print
(
bool
printChildren
,
bool
printDecoration
)
const
RobotNodeHemisphere
::
print
(
bool
printChildren
,
bool
printDecoration
)
const
{
{
ReadLockPtr
lock
=
getRobot
()
->
getReadLock
();
ReadLockPtr
lock
=
getRobot
()
->
getReadLock
();
VR_ASSERT_MESSAGE
(
firstData
.
has_value
()
xor
secondData
.
has_value
(),
std
::
stringstream
()
<<
firstData
.
has_value
()
<<
" / "
<<
secondData
.
has_value
());
VR_ASSERT_MESSAGE
(
firstData
.
has_value
()
xor
secondData
.
has_value
(),
std
::
stringstream
()
<<
firstData
.
has_value
()
<<
" / "
<<
secondData
.
has_value
());
if
(
printDecoration
)
if
(
printDecoration
)
{
{
...
@@ -223,7 +242,8 @@ namespace VirtualRobot
...
@@ -223,7 +242,8 @@ namespace VirtualRobot
else
if
(
secondData
)
else
if
(
secondData
)
{
{
std
::
cout
<<
"* Hemisphere joint second node"
;
std
::
cout
<<
"* Hemisphere joint second node"
;
std
::
cout
<<
"* Transform:
\n
"
<<
secondData
->
maths
().
maths
.
getEndEffectorTransform
()
<<
std
::
endl
;
std
::
cout
<<
"* Transform:
\n
"
<<
secondData
->
maths
().
maths
.
getEndEffectorTransform
()
<<
std
::
endl
;
}
}
if
(
printDecoration
)
if
(
printDecoration
)
...
@@ -240,13 +260,12 @@ namespace VirtualRobot
...
@@ -240,13 +260,12 @@ namespace VirtualRobot
}
}
}
}
RobotNodePtr
RobotNodePtr
RobotNodeHemisphere
::
_clone
(
RobotNodeHemisphere
::
_clone
(
const
RobotPtr
newRobot
,
const
RobotPtr
newRobot
,
const
VisualizationNodePtr
visualizationModel
,
const
VisualizationNodePtr
visualizationModel
,
const
CollisionModelPtr
collisionModel
,
const
CollisionModelPtr
collisionModel
,
CollisionCheckerPtr
colChecker
,
CollisionCheckerPtr
colChecker
,
float
scaling
)
float
scaling
)
{
{
ReadLockPtr
lock
=
getRobot
()
->
getReadLock
();
ReadLockPtr
lock
=
getRobot
()
->
getReadLock
();
Physics
physics
=
this
->
physics
.
scale
(
scaling
);
Physics
physics
=
this
->
physics
.
scale
(
scaling
);
...
@@ -254,24 +273,32 @@ namespace VirtualRobot
...
@@ -254,24 +273,32 @@ namespace VirtualRobot
RobotNodeHemispherePtr
cloned
;
RobotNodeHemispherePtr
cloned
;
if
(
optionalDHParameter
.
isSet
)
if
(
optionalDHParameter
.
isSet
)
{
{
cloned
.
reset
(
new
RobotNodeHemisphere
(
cloned
.
reset
(
new
RobotNodeHemisphere
(
newRobot
,
newRobot
,
name
,
name
,
optionalDHParameter
.
aMM
()
*
scaling
,
optionalDHParameter
.
aMM
()
*
scaling
,
optionalDHParameter
.
dMM
()
*
scaling
,
optionalDHParameter
.
dMM
()
*
scaling
,
optionalDHParameter
.
alphaRadian
(),
optionalDHParameter
.
alphaRadian
(),
optionalDHParameter
.
thetaRadian
(),
optionalDHParameter
.
thetaRadian
(),
visualizationModel
,
collisionModel
,
visualizationModel
,
jointValueOffset
,
collisionModel
,
physics
,
colChecker
,
nodeType
));
jointValueOffset
,
physics
,
colChecker
,
nodeType
));
}
}
else
else
{
{
Eigen
::
Matrix4f
localTransform
=
getLocalTransformation
();
Eigen
::
Matrix4f
localTransform
=
getLocalTransformation
();
simox
::
math
::
position
(
localTransform
)
*=
scaling
;
simox
::
math
::
position
(
localTransform
)
*=
scaling
;
cloned
.
reset
(
new
RobotNodeHemisphere
(
cloned
.
reset
(
new
RobotNodeHemisphere
(
newRobot
,
newRobot
,
name
,
localTransform
,
name
,
visualizationModel
,
collisionModel
,
localTransform
,
jointValueOffset
,
physics
,
colChecker
,
nodeType
));
visualizationModel
,
collisionModel
,
jointValueOffset
,
physics
,
colChecker
,
nodeType
));
}
}
if
(
this
->
firstData
)
if
(
this
->
firstData
)
...
@@ -288,45 +315,52 @@ namespace VirtualRobot
...
@@ -288,45 +315,52 @@ namespace VirtualRobot
return
cloned
;
return
cloned
;
}
}
bool
bool
RobotNodeHemisphere
::
isHemisphereJoint
()
const
RobotNodeHemisphere
::
isHemisphereJoint
()
const
{
{
return
true
;
return
true
;
}
}
bool
RobotNodeHemisphere
::
isFirstHemisphereJointNode
()
const
bool
RobotNodeHemisphere
::
isFirstHemisphereJointNode
()
const
{
{
return
firstData
.
has_value
();
return
firstData
.
has_value
();
}
}
bool
RobotNodeHemisphere
::
isSecondHemisphereJointNode
()
const
bool
RobotNodeHemisphere
::
isSecondHemisphereJointNode
()
const
{
{
return
secondData
.
has_value
();
return
secondData
.
has_value
();
}
}
const
RobotNodeHemisphere
::
SecondData
&
RobotNodeHemisphere
::
getSecondData
()
const
const
RobotNodeHemisphere
::
SecondData
&
RobotNodeHemisphere
::
getSecondData
()
const
{
{
VR_ASSERT
(
secondData
.
has_value
());
VR_ASSERT
(
secondData
.
has_value
());
return
secondData
.
value
();
return
secondData
.
value
();
}
}
RobotNodeHemisphere
::
SecondData
&
RobotNodeHemisphere
::
getSecondData
()
RobotNodeHemisphere
::
SecondData
&
RobotNodeHemisphere
::
getSecondData
()
{
{
VR_ASSERT
(
secondData
.
has_value
());
VR_ASSERT
(
secondData
.
has_value
());
return
secondData
.
value
();
return
secondData
.
value
();
}
}
void
RobotNodeHemisphere
::
checkValidRobotNodeType
()
void
RobotNodeHemisphere
::
checkValidRobotNodeType
()
{
{
RobotNode
::
checkValidRobotNodeType
();
RobotNode
::
checkValidRobotNodeType
();
THROW_VR_EXCEPTION_IF
(
nodeType
==
Body
||
nodeType
==
Transform
,
"RobotNodeHemisphere must be a JointNode or a GenericNode"
);
THROW_VR_EXCEPTION_IF
(
nodeType
==
Body
||
nodeType
==
Transform
,
"RobotNodeHemisphere must be a JointNode or a GenericNode"
);
}
}
std
::
string
std
::
string
RobotNodeHemisphere
::
_toXML
(
const
std
::
string
&
/*modelPath*/
)
RobotNodeHemisphere
::
_toXML
(
const
std
::
string
&
/*modelPath*/
)
{
{
VR_ASSERT_MESSAGE
(
firstData
.
has_value
()
xor
secondData
.
has_value
(),
VR_ASSERT_MESSAGE
(
firstData
.
has_value
()
xor
secondData
.
has_value
(),
std
::
stringstream
()
<<
firstData
.
has_value
()
<<
" / "
<<
secondData
.
has_value
());
std
::
stringstream
()
<<
firstData
.
has_value
()
<<
" / "
<<
secondData
.
has_value
());
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
"
\t\t
<Joint type='Hemisphere'>"
<<
std
::
endl
;
ss
<<
"
\t\t
<Joint type='Hemisphere'>"
<<
std
::
endl
;
...
@@ -349,26 +383,31 @@ namespace VirtualRobot
...
@@ -349,26 +383,31 @@ namespace VirtualRobot
ss
<<
"
\t\t\t
<MaxVelocity value='"
<<
maxVelocity
<<
"'/>"
<<
std
::
endl
;
ss
<<
"
\t\t\t
<MaxVelocity value='"
<<
maxVelocity
<<
"'/>"
<<
std
::
endl
;
ss
<<
"
\t\t\t
<MaxTorque value='"
<<
maxTorque
<<
"'/>"
<<
std
::
endl
;
ss
<<
"
\t\t\t
<MaxTorque value='"
<<
maxTorque
<<
"'/>"
<<
std
::
endl
;
for
(
auto
propIt
=
propagatedJointValues
.
begin
();
propIt
!=
propagatedJointValues
.
end
();
++
propIt
)
for
(
auto
propIt
=
propagatedJointValues
.
begin
();
propIt
!=
propagatedJointValues
.
end
();
++
propIt
)
{
{
ss
<<
"
\t\t\t
<PropagateJointValue name='"
<<
propIt
->
first
<<
"' factor='"
<<
propIt
->
second
<<
"'/>"
<<
std
::
endl
;
ss
<<
"
\t\t\t
<PropagateJointValue name='"
<<
propIt
->
first
<<
"' factor='"
<<
propIt
->
second
<<
"'/>"
<<
std
::
endl
;
}
}
ss
<<
"
\t\t
</Joint>"
<<
std
::
endl
;
ss
<<
"
\t\t
</Joint>"
<<
std
::
endl
;
return
ss
.
str
();
return
ss
.
str
();
}
}
hemisphere
::
CachedMaths
&
RobotNodeHemisphere
::
SecondData
::
maths
()
hemisphere
::
CachedMaths
&
RobotNodeHemisphere
::
SecondData
::
maths
()
{
{
return
firstNode
->
firstData
->
maths
;
return
firstNode
->
firstData
->
maths
;
}
}
const
hemisphere
::
CachedMaths
&
RobotNodeHemisphere
::
SecondData
::
maths
()
const
const
hemisphere
::
CachedMaths
&
RobotNodeHemisphere
::
SecondData
::
maths
()
const
{
{
return
firstNode
->
firstData
->
maths
;
return
firstNode
->
firstData
->
maths
;
}
}
hemisphere
::
Maths
::
Jacobian
RobotNodeHemisphere
::
SecondData
::
getJacobian
()
hemisphere
::
Maths
::
Jacobian
RobotNodeHemisphere
::
SecondData
::
getJacobian
()
{
{
VR_ASSERT
(
firstNode
);
VR_ASSERT
(
firstNode
);
VR_ASSERT
(
secondNode
);
VR_ASSERT
(
secondNode
);
...
@@ -382,4 +421,4 @@ namespace VirtualRobot
...
@@ -382,4 +421,4 @@ namespace VirtualRobot
return
jacobian
;
return
jacobian
;
}
}
}
}
// namespace VirtualRobot
This diff is collapsed.
Click to expand it.
VirtualRobot/Nodes/RobotNodeHemisphere.h
+
45
−
68
View file @
c57051fe
...
@@ -21,18 +21,16 @@
...
@@ -21,18 +21,16 @@
*/
*/
#pragma once
#pragma once
#include
<VirtualRobot/VirtualRobot.h>
#include
<optional>
#include
<VirtualRobot/Nodes/RobotNode.h>
#include
<VirtualRobot/Nodes/HemisphereJoint/CachedMaths.h>
#include
<VirtualRobot/Nodes/HemisphereJoint/Maths.h>
#include
<Eigen/Core>
#include
<string>
#include
<string>
#include
<vector>
#include
<vector>
#include
<optional>
#include
<Eigen/Core>
#include
<VirtualRobot/Nodes/HemisphereJoint/CachedMaths.h>
#include
<VirtualRobot/Nodes/HemisphereJoint/Maths.h>
#include
<VirtualRobot/Nodes/RobotNode.h>
#include
<VirtualRobot/VirtualRobot.h>
namespace
VirtualRobot
namespace
VirtualRobot
{
{
...
@@ -53,7 +51,6 @@ namespace VirtualRobot
...
@@ -53,7 +51,6 @@ namespace VirtualRobot
class
VIRTUAL_ROBOT_IMPORT_EXPORT
RobotNodeHemisphere
:
public
RobotNode
class
VIRTUAL_ROBOT_IMPORT_EXPORT
RobotNodeHemisphere
:
public
RobotNode
{
{
public:
public:
enum
class
Role
enum
class
Role
{
{
/// The first DoF in the kinematic chain.
/// The first DoF in the kinematic chain.
...
@@ -73,7 +70,6 @@ namespace VirtualRobot
...
@@ -73,7 +70,6 @@ namespace VirtualRobot
double
lever
=
-
1
;
double
lever
=
-
1
;
};
};
/// Data held by the first joint.
/// Data held by the first joint.
struct
FirstData
struct
FirstData
{
{
...
@@ -97,60 +93,53 @@ namespace VirtualRobot
...
@@ -97,60 +93,53 @@ namespace VirtualRobot
public
:
public
:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
RobotNodeHemisphere
(
RobotNodeHemisphere
(
RobotWeakPtr
rob
,
///< The robot
RobotWeakPtr
rob
,
///< The robot
const
std
::
string
&
name
,
///< The name
const
std
::
string
&
name
,
///< The name
const
Eigen
::
Matrix4f
&
preJointTransform
,
///< This transformation is applied before the translation of the joint is done
const
Eigen
::
Matrix4f
&
VisualizationNodePtr
visualization
=
nullptr
,
///< A visualization model
preJointTransform
,
///< This transformation is applied before the translation of the joint is done
CollisionModelPtr
collisionModel
=
nullptr
,
///< A collision model
VisualizationNodePtr
visualization
=
nullptr
,
///< A visualization model
float
jointValueOffset
=
0.0
f
,
///< An offset that is internally added to the joint value
CollisionModelPtr
collisionModel
=
nullptr
,
///< A collision model
const
SceneObject
::
Physics
&
p
=
{},
///< physics information
float
jointValueOffset
=
CollisionCheckerPtr
colChecker
=
nullptr
,
///< A collision checker instance (if not set, the global col checker is used)
0.0
f
,
///< An offset that is internally added to the joint value
RobotNodeType
type
=
Generic
const
SceneObject
::
Physics
&
p
=
{},
///< physics information
);
CollisionCheckerPtr
colChecker
=
nullptr
,
///< A collision checker instance (if not set, the global col checker is used)
RobotNodeType
type
=
Generic
);
// The DH-based constructor is not tested so far for Hemisphere joints.
// The DH-based constructor is not tested so far for Hemisphere joints.
RobotNodeHemisphere
(
RobotNodeHemisphere
(
RobotWeakPtr
rob
,
///< The robot
RobotWeakPtr
rob
,
///< The robot
const
std
::
string
&
name
,
///< The name
const
std
::
string
&
name
,
///< The name
float
a
,
///< dh paramters
float
a
,
///< dh paramters
float
d
,
///< dh paramters
float
d
,
///< dh paramters
float
alpha
,
///< dh paramters
float
alpha
,
///< dh paramters
float
theta
,
///< dh paramters
float
theta
,
///< dh paramters
VisualizationNodePtr
visualization
=
nullptr
,
///< A visualization model
VisualizationNodePtr
visualization
=
nullptr
,
///< A visualization model
CollisionModelPtr
collisionModel
=
nullptr
,
///< A collision model
CollisionModelPtr
collisionModel
=
nullptr
,
///< A collision model
float
jointValueOffset
=
0.0
f
,
///< An offset that is internally added to the joint value
float
jointValueOffset
=
const
SceneObject
::
Physics
&
p
=
{},
///< physics information
0.0
f
,
///< An offset that is internally added to the joint value
CollisionCheckerPtr
colChecker
=
{},
///< A collision checker instance (if not set, the global col checker is used)
const
SceneObject
::
Physics
&
p
=
{},
///< physics information
RobotNodeType
type
=
Generic
CollisionCheckerPtr
colChecker
=
);
{},
///< A collision checker instance (if not set, the global col checker is used)
RobotNodeType
type
=
Generic
);
public
:
public
:
~
RobotNodeHemisphere
()
override
;
~
RobotNodeHemisphere
()
override
;
void
setXmlInfo
(
const
XmlInfo
&
info
);
void
setXmlInfo
(
const
XmlInfo
&
info
);
bool
bool
initialize
(
SceneObjectPtr
parent
=
nullptr
,
initialize
(
const
std
::
vector
<
SceneObjectPtr
>&
children
=
{})
override
;
SceneObjectPtr
parent
=
nullptr
,
const
std
::
vector
<
SceneObjectPtr
>&
children
=
{}
)
override
;
/// Print status information.
/// Print status information.
void
void
print
(
bool
printChildren
=
false
,
bool
printDecoration
=
true
)
const
override
;
print
(
bool
printChildren
=
false
,
bool
printDecoration
=
true
)
const
override
;
bool
bool
isHemisphereJoint
()
const
override
;
isHemisphereJoint
()
const
override
;
bool
isFirstHemisphereJointNode
()
const
;
bool
isFirstHemisphereJointNode
()
const
;
bool
isSecondHemisphereJointNode
()
const
;
bool
isSecondHemisphereJointNode
()
const
;
...
@@ -163,39 +152,27 @@ namespace VirtualRobot
...
@@ -163,39 +152,27 @@ namespace VirtualRobot
const
SecondData
&
getSecondData
()
const
;
const
SecondData
&
getSecondData
()
const
;
protected
:
protected
:
RobotNodeHemisphere
();
RobotNodeHemisphere
();
/// Derived classes add custom XML tags here
/// Derived classes add custom XML tags here
std
::
string
std
::
string
_toXML
(
const
std
::
string
&
modelPath
)
override
;
_toXML
(
const
std
::
string
&
modelPath
)
override
;
/// Checks if nodeType constraints are fulfilled. Otherwise an exception is thrown.
/// Checks if nodeType constraints are fulfilled. Otherwise an exception is thrown.
/// Called on initialization.
/// Called on initialization.
void
void
checkValidRobotNodeType
()
override
;
checkValidRobotNodeType
()
override
;
void
void
updateTransformationMatrices
(
const
Eigen
::
Matrix4f
&
parentPose
)
override
;
updateTransformationMatrices
(
const
Eigen
::
Matrix4f
&
parentPose
)
override
;
RobotNodePtr
RobotNodePtr
_clone
(
const
RobotPtr
newRobot
,
_clone
(
const
RobotPtr
newRobot
,
const
VisualizationNodePtr
visualizationModel
,
const
VisualizationNodePtr
visualizationModel
,
const
CollisionModelPtr
collisionModel
,
const
CollisionModelPtr
collisionModel
,
CollisionCheckerPtr
colChecker
,
CollisionCheckerPtr
colChecker
,
float
scaling
)
override
;
float
scaling
)
override
;
private
:
private
:
std
::
optional
<
FirstData
>
firstData
;
std
::
optional
<
FirstData
>
firstData
;
std
::
optional
<
SecondData
>
secondData
;
std
::
optional
<
SecondData
>
secondData
;
};
};
}
// namespace VirtualRobot
}
// namespace VirtualRobot
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