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
9c2dc45a
Commit
9c2dc45a
authored
9 years ago
by
Peter Kaiser
Browse files
Options
Downloads
Patches
Plain Diff
ConstrainedIK: Experimental implementation of robot reduction
parent
6694a9ba
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/IK/ConstrainedIK.cpp
+72
-2
72 additions, 2 deletions
VirtualRobot/IK/ConstrainedIK.cpp
VirtualRobot/IK/ConstrainedIK.h
+6
-1
6 additions, 1 deletion
VirtualRobot/IK/ConstrainedIK.h
with
78 additions
and
3 deletions
VirtualRobot/IK/ConstrainedIK.cpp
+
72
−
2
View file @
9c2dc45a
...
...
@@ -2,8 +2,8 @@
using
namespace
VirtualRobot
;
ConstrainedIK
::
ConstrainedIK
(
RobotPtr
&
robot
,
const
RobotNodeSetPtr
&
nodeSet
,
int
maxIterations
,
float
stall_epsilon
,
float
raise_epsilon
)
:
r
obot
(
robot
),
ConstrainedIK
::
ConstrainedIK
(
RobotPtr
&
robot
,
const
RobotNodeSetPtr
&
nodeSet
,
int
maxIterations
,
float
stall_epsilon
,
float
raise_epsilon
,
bool
reduceRobot
)
:
originalR
obot
(
robot
),
nodeSet
(
nodeSet
),
maxIterations
(
maxIterations
),
currentIteration
(
0
),
...
...
@@ -12,6 +12,18 @@ ConstrainedIK::ConstrainedIK(RobotPtr& robot, const RobotNodeSetPtr& nodeSet, in
raiseEpsilon
(
raise_epsilon
)
{
addSeed
(
eSeedInitial
);
// Reduce the provided robot to only those nodes requested for the IK. This has the advantage that
// joints not necessary for the IK (e.g. finger joints) are not updated
if
(
reduceRobot
)
{
VR_WARNING
<<
"Robot reduction is EXPERIMENTAL"
<<
std
::
endl
;
this
->
robot
=
buildReducedRobot
(
originalRobot
);
}
else
{
this
->
robot
=
originalRobot
;
}
}
void
ConstrainedIK
::
addConstraint
(
const
ConstraintPtr
&
constraint
,
int
priority
,
bool
hard_constraint
)
...
...
@@ -146,3 +158,61 @@ int ConstrainedIK::getCurrentIteration()
return
currentIteration
;
}
void
ConstrainedIK
::
getUnitableNodes
(
const
RobotNodePtr
&
robotNode
,
const
RobotNodeSetPtr
&
nodeSet
,
std
::
vector
<
std
::
string
>
&
unitable
)
{
std
::
vector
<
RobotNodePtr
>
descendants
;
robotNode
->
collectAllRobotNodes
(
descendants
);
for
(
std
::
vector
<
RobotNodePtr
>::
const_iterator
i
=
descendants
.
begin
();
i
!=
descendants
.
end
();
i
++
)
{
// Skip current robot node
if
(
*
i
==
robotNode
)
{
continue
;
}
if
(
nodeSet
->
hasRobotNode
(
*
i
)
||
*
i
==
nodeSet
->
getTCP
())
{
// Actuated joint in subtree -> recursive descent
std
::
vector
<
SceneObjectPtr
>
children
=
robotNode
->
getChildren
();
for
(
auto
&
child
:
children
)
{
RobotNodePtr
childRobotNode
=
boost
::
dynamic_pointer_cast
<
RobotNode
>
(
child
);
if
(
childRobotNode
)
{
getUnitableNodes
(
childRobotNode
,
nodeSet
,
unitable
);
}
}
return
;
}
}
// No actuated joint in subtree
if
(
!
robotNode
->
getChildren
().
empty
())
{
unitable
.
push_back
(
robotNode
->
getName
());
}
}
RobotPtr
ConstrainedIK
::
buildReducedRobot
(
const
RobotPtr
&
original
)
{
std
::
vector
<
std
::
string
>
names
;
for
(
int
i
=
0
;
i
<
nodeSet
->
getSize
();
i
++
)
{
names
.
push_back
(
nodeSet
->
getNode
(
i
)
->
getName
());
}
std
::
vector
<
std
::
string
>
unitable
;
getUnitableNodes
(
original
->
getRootNode
(),
nodeSet
,
unitable
);
VR_INFO
<<
"Reducing robot model by uniting "
<<
unitable
.
size
()
<<
" nodes:"
<<
std
::
endl
;
for
(
auto
&
node
:
unitable
)
{
VR_INFO
<<
" "
<<
node
<<
std
::
endl
;
}
return
RobotFactory
::
cloneUniteSubsets
(
original
,
"ConstrainedIK_Reduced_Robot"
,
unitable
);
}
This diff is collapsed.
Click to expand it.
VirtualRobot/IK/ConstrainedIK.h
+
6
−
1
View file @
9c2dc45a
...
...
@@ -48,7 +48,7 @@ namespace VirtualRobot
};
public
:
ConstrainedIK
(
RobotPtr
&
robot
,
const
RobotNodeSetPtr
&
nodeSet
,
int
maxIterations
=
1000
,
float
stall_epsilon
=
0.0001
,
float
raise_epsilon
=
0.8
);
ConstrainedIK
(
RobotPtr
&
robot
,
const
RobotNodeSetPtr
&
nodeSet
,
int
maxIterations
=
1000
,
float
stall_epsilon
=
0.0001
,
float
raise_epsilon
=
0.8
,
bool
reduceRobot
=
false
);
void
addConstraint
(
const
ConstraintPtr
&
constraint
,
int
priority
=
0
,
bool
hard_constraint
=
true
);
void
removeConstraint
(
const
ConstraintPtr
&
constraint
);
...
...
@@ -68,11 +68,16 @@ namespace VirtualRobot
bool
getRunning
();
int
getCurrentIteration
();
protected
:
void
getUnitableNodes
(
const
RobotNodePtr
&
robotNode
,
const
RobotNodeSetPtr
&
nodeSet
,
std
::
vector
<
std
::
string
>
&
unitable
);
RobotPtr
buildReducedRobot
(
const
RobotPtr
&
original
);
protected
:
std
::
vector
<
ConstraintPtr
>
constraints
;
std
::
map
<
ConstraintPtr
,
int
>
priorities
;
std
::
map
<
ConstraintPtr
,
bool
>
hardConstraints
;
RobotPtr
originalRobot
;
RobotPtr
robot
;
RobotNodeSetPtr
nodeSet
;
Eigen
::
VectorXf
initialConfig
;
...
...
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