Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hpp-manipulation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Humanoid Path Planner
hpp-manipulation
Commits
9e29620f
Commit
9e29620f
authored
7 years ago
by
Joseph Mirabel
Committed by
Joseph Mirabel
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Class Handle takes a mask as input.
parent
8b23a94a
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
include/hpp/manipulation/handle.hh
+11
-0
11 additions, 0 deletions
include/hpp/manipulation/handle.hh
src/handle.cc
+68
-17
68 additions, 17 deletions
src/handle.cc
with
79 additions
and
17 deletions
include/hpp/manipulation/handle.hh
+
11
−
0
View file @
9e29620f
...
@@ -84,6 +84,14 @@ namespace hpp {
...
@@ -84,6 +84,14 @@ namespace hpp {
return
localPosition_
;
return
localPosition_
;
}
}
/// Set constraint mask
void
mask
(
const
std
::
vector
<
bool
>&
mask
);
/// Get constraint mask
/// See mask(const std::vector<bool>&)
const
std
::
vector
<
bool
>&
mask
()
const
{
return
mask_
;
}
/// Create constraint corresponding to a gripper grasping this object
/// Create constraint corresponding to a gripper grasping this object
/// \param gripper object containing the gripper information
/// \param gripper object containing the gripper information
/// \return the constraint of relative transformation between the handle and
/// \return the constraint of relative transformation between the handle and
...
@@ -143,6 +151,7 @@ namespace hpp {
...
@@ -143,6 +151,7 @@ namespace hpp {
const
JointPtr_t
&
joint
)
:
name_
(
name
),
const
JointPtr_t
&
joint
)
:
name_
(
name
),
localPosition_
(
localPosition
),
localPosition_
(
localPosition
),
joint_
(
joint
),
clearance_
(
0
),
joint_
(
joint
),
clearance_
(
0
),
mask_
(
6
,
true
),
weakPtr_
()
weakPtr_
()
{
{
}
}
...
@@ -161,6 +170,8 @@ namespace hpp {
...
@@ -161,6 +170,8 @@ namespace hpp {
JointPtr_t
joint_
;
JointPtr_t
joint_
;
/// Clearance
/// Clearance
value_type
clearance_
;
value_type
clearance_
;
/// Mask
std
::
vector
<
bool
>
mask_
;
/// Weak pointer to itself
/// Weak pointer to itself
HandleWkPtr_t
weakPtr_
;
HandleWkPtr_t
weakPtr_
;
...
...
This diff is collapsed.
Click to expand it.
src/handle.cc
+
68
−
17
View file @
9e29620f
...
@@ -67,62 +67,112 @@ namespace hpp {
...
@@ -67,62 +67,112 @@ namespace hpp {
return
false
;
return
false
;
}
}
inline
bool
is6Dmask
(
const
std
::
vector
<
bool
>&
mask
)
{
for
(
std
::
size_t
i
=
0
;
i
<
6
;
++
i
)
if
(
!
mask
[
i
])
return
false
;
return
true
;
}
inline
std
::
vector
<
bool
>
complementMask
(
const
std
::
vector
<
bool
>&
mask
)
{
std
::
vector
<
bool
>
m
(
6
);
for
(
std
::
size_t
i
=
0
;
i
<
6
;
++
i
)
m
[
i
]
=
!
mask
[
i
];
return
m
;
}
inline
std
::
string
maskToStr
(
const
std
::
vector
<
bool
>&
mask
)
{
std
::
stringstream
ss
;
ss
<<
"("
;
for
(
std
::
size_t
i
=
0
;
i
<
5
;
++
i
)
ss
<<
mask
[
i
]
<<
","
;
ss
<<
mask
[
5
]
<<
")"
;
return
ss
.
str
();
}
void
Handle
::
mask
(
const
std
::
vector
<
bool
>&
mask
)
{
assert
(
mask
.
size
()
==
6
);
std
::
size_t
nRotFree
=
3
;
for
(
std
::
size_t
i
=
3
;
i
<
6
;
++
i
)
if
(
mask
[
i
])
nRotFree
--
;
switch
(
nRotFree
)
{
case
1
:
// TODO we should check the axis are properly aligned.
break
;
case
2
:
// This does not make sense.
throw
std
::
logic_error
(
"It is not allowed to constrain only one rotation"
);
break
;
}
mask_
=
mask
;
}
NumericalConstraintPtr_t
Handle
::
createGrasp
NumericalConstraintPtr_t
Handle
::
createGrasp
(
const
GripperPtr_t
&
gripper
)
const
(
const
GripperPtr_t
&
gripper
)
const
{
{
using
boost
::
assign
::
list_of
;
using
core
::
ExplicitRelativeTransformation
;
using
core
::
ExplicitRelativeTransformation
;
// If handle is on a freeflying object, create an explicit constraint
// If handle is on a freeflying object, create an explicit constraint
if
(
isHandleOnR3SO3
(
*
this
))
{
if
(
is6Dmask
(
mask_
)
&&
isHandleOnR3SO3
(
*
this
))
{
return
ExplicitRelativeTransformation
::
create
return
ExplicitRelativeTransformation
::
create
(
"Explicit_relative_transform_"
+
name
()
+
"_"
+
gripper
->
name
(),
(
"Explicit_relative_transform_"
+
name
()
+
"_"
+
gripper
->
name
(),
gripper
->
joint
()
->
robot
(),
gripper
->
joint
(),
joint
(),
gripper
->
joint
()
->
robot
(),
gripper
->
joint
(),
joint
(),
gripper
->
objectPositionInJoint
(),
localPosition
());
gripper
->
objectPositionInJoint
(),
localPosition
());
}
}
std
::
vector
<
bool
>
mask
=
list_of
(
true
)(
true
)(
true
)(
true
)(
true
)(
true
);
return
NumericalConstraintPtr_t
return
NumericalConstraintPtr_t
(
NumericalConstraint
::
create
(
RelativeTransformation
::
create
(
NumericalConstraint
::
create
(
RelativeTransformation
::
create
(
"Grasp_
(1,1,1,1,1,1)
_"
+
name
()
(
"Grasp_
"
+
maskToStr
(
mask_
)
+
"
_"
+
name
()
+
"_"
+
gripper
->
name
(),
+
"_"
+
gripper
->
name
(),
gripper
->
joint
()
->
robot
(),
gripper
->
joint
()
->
robot
(),
gripper
->
joint
(),
joint
(),
gripper
->
joint
(),
joint
(),
gripper
->
objectPositionInJoint
(),
gripper
->
objectPositionInJoint
(),
localPosition
(),
mask
)));
localPosition
(),
mask
_
)));
}
}
NumericalConstraintPtr_t
Handle
::
createGraspComplement
NumericalConstraintPtr_t
Handle
::
createGraspComplement
(
const
GripperPtr_t
&
gripper
)
const
(
const
GripperPtr_t
&
gripper
)
const
{
{
core
::
DevicePtr_t
robot
=
gripper
->
joint
()
->
robot
();
core
::
DevicePtr_t
robot
=
gripper
->
joint
()
->
robot
();
return
NumericalConstraint
::
create
(
if
(
is6Dmask
(
mask_
))
{
boost
::
shared_ptr
<
ZeroDiffFunc
>
(
new
ZeroDiffFunc
(
return
NumericalConstraint
::
create
(
robot
->
configSize
(),
robot
->
numberDof
(),
boost
::
shared_ptr
<
ZeroDiffFunc
>
(
new
ZeroDiffFunc
(
"GraspComp_(0,0,0,0,0,0)_"
+
name
()
+
"_"
+
gripper
->
name
()
robot
->
configSize
(),
robot
->
numberDof
(),
))
"GraspComp_(0,0,0,0,0,0)_"
+
name
()
+
"_"
+
gripper
->
name
()
);
))
);
}
else
{
// TODO handle cases where rotations or translation are allowed.
std
::
vector
<
bool
>
Cmask
=
complementMask
(
mask_
);
return
NumericalConstraintPtr_t
(
NumericalConstraint
::
create
(
RelativeTransformation
::
create
(
"Transformation_"
+
maskToStr
(
Cmask
)
+
"_"
+
name
()
+
"_"
+
gripper
->
name
(),
gripper
->
joint
()
->
robot
(),
gripper
->
joint
(),
joint
(),
gripper
->
objectPositionInJoint
(),
localPosition
(),
Cmask
),
core
::
Equality
::
create
()));
}
}
}
NumericalConstraintPtr_t
Handle
::
createPreGrasp
NumericalConstraintPtr_t
Handle
::
createPreGrasp
(
const
GripperPtr_t
&
gripper
,
const
value_type
&
shift
)
const
(
const
GripperPtr_t
&
gripper
,
const
value_type
&
shift
)
const
{
{
using
boost
::
assign
::
list_of
;
using
boost
::
assign
::
list_of
;
std
::
vector
<
bool
>
mask
=
list_of
(
true
)(
true
)(
true
)(
true
)(
true
)(
true
);
Transform3f
transform
=
gripper
->
objectPositionInJoint
()
Transform3f
transform
=
gripper
->
objectPositionInJoint
()
*
Transform3f
(
I3
,
vector3_t
(
shift
,
0
,
0
));
*
Transform3f
(
I3
,
vector3_t
(
shift
,
0
,
0
));
return
NumericalConstraintPtr_t
return
NumericalConstraintPtr_t
(
NumericalConstraint
::
create
(
RelativeTransformation
::
create
(
NumericalConstraint
::
create
(
RelativeTransformation
::
create
(
"Pregrasp_
(1,1,1,1,1,1)
_"
+
name
()
(
"Pregrasp_
"
+
maskToStr
(
mask_
)
+
"
_"
+
name
()
+
"_"
+
gripper
->
name
(),
+
"_"
+
gripper
->
name
(),
gripper
->
joint
()
->
robot
(),
gripper
->
joint
()
->
robot
(),
gripper
->
joint
(),
joint
(),
gripper
->
joint
(),
joint
(),
transform
,
localPosition
(),
mask
)));
transform
,
localPosition
(),
mask
_
)));
}
}
HandlePtr_t
Handle
::
clone
()
const
HandlePtr_t
Handle
::
clone
()
const
{
{
HandlePtr_t
self
=
weakPtr_
.
lock
();
HandlePtr_t
other
=
Handle
::
create
(
name
(),
localPosition
(),
joint
());
return
Handle
::
create
(
self
->
name
(),
self
->
localPosition
(),
other
->
mask
(
mask_
);
self
->
joint
());
other
->
clearance
(
clearance_
);
return
other
;
}
}
std
::
ostream
&
Handle
::
print
(
std
::
ostream
&
os
)
const
std
::
ostream
&
Handle
::
print
(
std
::
ostream
&
os
)
const
...
@@ -130,6 +180,7 @@ namespace hpp {
...
@@ -130,6 +180,7 @@ namespace hpp {
os
<<
"name :"
<<
name
()
<<
std
::
endl
;
os
<<
"name :"
<<
name
()
<<
std
::
endl
;
os
<<
"local position :"
<<
localPosition
()
<<
std
::
endl
;
os
<<
"local position :"
<<
localPosition
()
<<
std
::
endl
;
os
<<
"joint :"
<<
joint
()
->
name
()
<<
std
::
endl
;
os
<<
"joint :"
<<
joint
()
->
name
()
<<
std
::
endl
;
os
<<
"mask :"
<<
maskToStr
(
mask
())
<<
std
::
endl
;
return
os
;
return
os
;
}
}
...
...
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