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
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
Lennard Hofmann
RobotAPI
Commits
39d31734
Commit
39d31734
authored
10 years ago
by
Mirko Wächter
Committed by
Ali Paikan
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
MMM Player set joint modes only once
parent
b883274e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/components/MMMPlayer/MMMPlayer.cpp
+31
-20
31 additions, 20 deletions
source/RobotAPI/components/MMMPlayer/MMMPlayer.cpp
with
31 additions
and
20 deletions
source/RobotAPI/components/MMMPlayer/MMMPlayer.cpp
+
31
−
20
View file @
39d31734
...
...
@@ -69,24 +69,41 @@ void MMMPlayer::onConnectComponent()
float
frameDuration
=
motion
->
getMotionFrame
(
1
)
->
timestep
-
motion
->
getMotionFrame
(
0
)
->
timestep
;
ARMARX_CHECK_EXPRESSION
(
frameDuration
!=
0
);
ARMARX_CHECK_EXPRESSION
(
frameDuration
>
0
)
motionFPS
=
1.0
f
/
frameDuration
;
motionFPS
=
1.0
f
/
frameDuration
;
ARMARX_VERBOSE
<<
VAROUT
(
motionFPS
);
}
}
kin
=
getProxy
<
KinematicUnitInterfacePrx
>
(
getProperty
<
std
::
string
>
(
"KinematicUnitName"
).
getValue
());
debugObserver
=
getProxy
<
DebugObserverInterfacePrx
>
(
"DebugObserver"
);
desiredFPS
=
getProperty
<
float
>
(
"FPS"
).
getValue
();
start
=
0.3
;
end
=
1.26
;
direction
=
1
;
jointOffets
[
"Right Arm Shoulder2"
]
=
15.0
/
180.0
*
M_PI
;
jointOffets
[
"Left Arm Shoulder2"
]
=
15.0
/
180.0
*
M_PI
;
kin
=
getProxy
<
KinematicUnitInterfacePrx
>
(
getProperty
<
std
::
string
>
(
"KinematicUnitName"
).
getValue
());
debugObserver
=
getProxy
<
DebugObserverInterfacePrx
>
(
"DebugObserver"
);
desiredFPS
=
getProperty
<
float
>
(
"FPS"
).
getValue
();
start
=
0.3
;
end
=
1.26
;
direction
=
1
;
jointOffets
[
"Right Arm Shoulder2"
]
=
15.0
/
180.0
*
M_PI
;
jointOffets
[
"Left Arm Shoulder2"
]
=
15.0
/
180.0
*
M_PI
;
NameControlModeMap
modes
;
for
(
size_t
i
=
0
;
i
<
jointNames
.
size
();
++
i
)
{
const
auto
&
jointName
=
jointNames
.
at
(
i
);
if
(
usePIDController
)
{
modes
[
jointName
]
=
eVelocityControl
;
}
else
{
modes
[
jointName
]
=
ePositionControl
;
}
}
kin
->
switchControlMode
(
modes
);
}
task
=
new
PeriodicTask
<
MMMPlayer
>
(
this
,
&
MMMPlayer
::
run
,
1000.0
f
/
desiredFPS
,
true
,
"MMMPlayerTask"
);
task
->
start
();
}
...
...
@@ -94,7 +111,7 @@ void MMMPlayer::run()
{
ScopedLock
lock
(
playerMutex
);
NameValueMap
targetVelocities
;
NameControlModeMap
modes
;
// targetPositionValues.clear();
//// if(currentFrame % 2 == 0)
// targetPositionValues["Right Arm Elbow1"] = start + (end - start) * 0.01 * currentFrame;
...
...
@@ -111,7 +128,7 @@ void MMMPlayer::run()
// return;
if
(
currentFrame
>=
motion
->
getNumFrames
()
||
currentFrame
<
0
)
if
(
currentFrame
>=
(
int
)
motion
->
getNumFrames
()
||
currentFrame
<
0
)
{
if
(
getProperty
<
bool
>
(
"LoopPlayback"
).
getValue
())
{
...
...
@@ -125,7 +142,7 @@ void MMMPlayer::run()
}
auto
frame
=
motion
->
getMotionFrame
(
currentFrame
);
MMM
::
MotionFramePtr
nextFrame
;
if
(
currentFrame
+
1
<
motion
->
getNumFrames
())
if
(
currentFrame
+
1
<
(
int
)
motion
->
getNumFrames
())
nextFrame
=
motion
->
getMotionFrame
(
currentFrame
+
1
);
targetPositionValues
.
clear
();
// NameValueMap targetVelocities;
...
...
@@ -168,15 +185,9 @@ void MMMPlayer::run()
// debugObserver->setDebugDatafield(jointName, "i", new Variant(pid->second->integral* pid->second->Ki));
// debugObserver->setDebugDatafield(jointName, "d", new Variant(pid->second->derivative * pid->second->Kd));
// debugObserver->setDebugDatafield(jointName, "velocity", new Variant(targetVelocities[jointName]));
modes
[
jointName
]
=
eVelocityControl
;
}
else
{
modes
[
jointName
]
=
ePositionControl
;
}
}
debugObserver
->
setDebugChannel
(
"targetJointAngles"
,
debugTargetValues
);
kin
->
switchControlMode
(
modes
);
kin
->
setJointVelocities
(
targetVelocities
);
if
(
!
usePIDController
)
kin
->
setJointAngles
(
targetPositionValues
);
...
...
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