Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
4d386da3
Commit
4d386da3
authored
5 years ago
by
Adrian Knobloch
Browse files
Options
Downloads
Patches
Plain Diff
Fix FrameTracking component
parent
261aa76c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!48
Frame tracking component
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/components/FrameTracking/FrameTracking.cpp
+19
-8
19 additions, 8 deletions
source/RobotAPI/components/FrameTracking/FrameTracking.cpp
with
19 additions
and
8 deletions
source/RobotAPI/components/FrameTracking/FrameTracking.cpp
+
19
−
8
View file @
4d386da3
...
...
@@ -169,22 +169,33 @@ void FrameTracking::_lookAtFrame(const std::string& frameName)
syncronizeLocalClone
();
auto
frame
=
localRobot
->
getRobotNode
(
frameName
);
auto
posInRobotFrame
=
localRobot
->
toLocalCoordinateSystemVec
(
frame
->
getGlobalPosition
());
// do nothing if the robot works above his head
// he should already look upwards because if this component runs continously
if
(
std
::
sqrt
(
posInRobotFrame
.
x
()
*
posInRobotFrame
.
x
()
+
posInRobotFrame
.
y
()
*
posInRobotFrame
.
y
())
<
300.
f
)
{
return
;
}
_lookAtPoint
(
posInRobotFrame
);
}
void
FrameTracking
::
_lookAtPoint
(
const
Eigen
::
Vector3f
&
point
)
{
float
yaw
=
std
::
acos
(
point
.
x
()
/
point
.
block
<
2
,
1
>
(
0
,
0
).
norm
())
-
static_cast
<
float
>
(
M_PI
)
/
2.
f
;
float
yaw
=
-
std
::
atan2
(
point
.
x
(),
point
.
y
());
// make shure the joint value satisfies the joint limits
yaw
=
std
::
max
(
headYawJoint
->
getJointLimitLo
(),
yaw
);
yaw
=
std
::
min
(
headYawJoint
->
getJointLimitHi
(),
yaw
);
// we dont want the robot to move from one limit to the other in one step
float
currentYaw
=
headYawJoint
->
getJointValue
();
if
(
!
headYawJoint
->
isLimitless
()
&&
std
::
abs
(
currentYaw
-
yaw
)
>
headYawJoint
->
getJointLimitHi
()
-
headYawJoint
->
getJointLimitLo
()
-
static_cast
<
float
>
(
M_PI
)
/
8
)
{
yaw
=
currentYaw
;
}
//
auto pointInPitchJointFrame = headPitchJoint->toLocalCoordinateSystemVec(localRobot->toGlobalCoordinateSystemVec(point));
//
Eigen::Vector2f pj{pointInPitchJointFrame.y(), pointInPitchJointFrame.z()
+ 10
};
auto
pointInPitchJointFrame
=
headPitchJoint
->
toLocalCoordinateSystemVec
(
localRobot
->
toGlobalCoordinateSystemVec
(
point
));
Eigen
::
Vector2f
pj
{
pointInPitchJointFrame
.
y
(),
pointInPitchJointFrame
.
z
()};
float
headHeightRealativeToPitchJoint
=
headPitchJoint
->
toLocalCoordinateSystemVec
(
cameraNode
->
getGlobalPosition
()).
z
();
// float pitch = static_cast<float>(M_PI) / 2.f - std::asin(pj.x() / pj.norm());// - std::asin(headHeightRealativeToPitchJoint / pj.norm());
auto
pointInCameraFrame
=
cameraNode
->
toLocalCoordinateSystemVec
(
localRobot
->
toGlobalCoordinateSystemVec
(
point
));
Eigen
::
Vector2f
pj
{
pointInCameraFrame
.
y
(),
pointInCameraFrame
.
z
()
+
headHeightRealativeToPitchJoint
};
float
pitch
=
std
::
asin
(
pj
.
x
()
/
pj
.
norm
());
float
pitch
=
headPitchJoint
->
getJointValue
()
-
std
::
asin
(
pj
.
x
()
/
pj
.
norm
())
+
std
::
asin
(
headHeightRealativeToPitchJoint
/
pj
.
norm
());
// make shure the joint value satisfies the joint limits
pitch
=
std
::
max
(
headPitchJoint
->
getJointLimitLo
(),
pitch
);
pitch
=
std
::
min
(
headPitchJoint
->
getJointLimitHi
(),
pitch
);
...
...
@@ -192,7 +203,7 @@ void FrameTracking::_lookAtPoint(const Eigen::Vector3f& point)
auto
controlModes
=
kinematicUnitInterfacePrx
->
getControlModes
();
kinematicUnitInterfacePrx
->
switchControlMode
({{
headYawJoint
->
getName
(),
ControlMode
::
ePositionControl
},
{
headPitchJoint
->
getName
(),
ControlMode
::
ePositionControl
}});
kinematicUnitInterfacePrx
->
setJointAngles
({{
headYawJoint
->
getName
(),
yaw
},
{
headPitchJoint
->
getName
(),
pitch
}});
//
kinematicUnitInterfacePrx->switchControlMode({{headYawJoint->getName(), controlModes[headYawJoint->getName()]}, {headPitchJoint->getName(), controlModes[headPitchJoint->getName()]}});
kinematicUnitInterfacePrx
->
switchControlMode
({{
headYawJoint
->
getName
(),
controlModes
[
headYawJoint
->
getName
()]},
{
headPitchJoint
->
getName
(),
controlModes
[
headPitchJoint
->
getName
()]}});
}
void
FrameTracking
::
_enableTracking
(
bool
enable
)
...
...
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