Skip to content
Snippets Groups Projects
Commit 6ad08b8a authored by Mirko Wächter's avatar Mirko Wächter
Browse files

working MMMPlayer version

parent 42b5213a
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,8 @@
#include <Core/core/exceptions/local/ExpressionException.h>
#include <Core/core/system/ArmarXDataPath.h>
using namespace armarx;
using namespace MMM;
......@@ -43,7 +45,9 @@ void MMMPlayer::onConnectComponent()
ScopedLock lock(playerMutex);
currentFrame = 0;
MotionReaderXML reader;
motion = reader.loadMotion(getProperty<std::string>("MMMFile").getValue());
auto motionPath = getProperty<std::string>("MMMFile").getValue();
ArmarXDataPath::getAbsolutePath(motionPath, motionPath);
motion = reader.loadMotion(motionPath);
if(!motion)
{
terminate();
......@@ -53,7 +57,7 @@ void MMMPlayer::onConnectComponent()
}
kin = getProxy<KinematicUnitInterfacePrx>(getProperty<std::string>("KinematicUnitName").getValue());
float fps = getProperty<float>("FPS").getValue();
task = new PeriodicTask<MMMPlayer>(this, &MMMPlayer::run, fps, true, "MMMPlayerTask");
task = new PeriodicTask<MMMPlayer>(this, &MMMPlayer::run, 1000.0f/fps, true, "MMMPlayerTask");
task->start();
}
......@@ -62,14 +66,21 @@ void MMMPlayer::onConnectComponent()
void MMMPlayer::run()
{
ScopedLock lock(playerMutex);
if(currentFrame >= motion->getNumFrames())
{
currentFrame = 0;
}
auto frame = motion->getMotionFrame(currentFrame);
NameValueMap targetValues;
NameControlModeMap modes;
ARMARX_CHECK_EXPRESSION((int)jointNames.size() == frame->joint.rows());
for (size_t i = 0; i < jointNames.size(); ++i) {
targetValues[jointNames.at(i)] = frame->joint[i];
modes[jointNames.at(i)] = ePositionControl;
}
kin->switchControlMode(modes);
kin->setJointAngles(targetValues);
ARMARX_VERBOSE << deactivateSpam(3) << "Playing frame " << currentFrame;
currentFrame++;
}
......
......@@ -104,7 +104,7 @@ namespace armarx
KinematicUnitInterfacePrx kin;
PeriodicTask<MMMPlayer>::pointer_type task;
StringList jointNames;
int currentFrame;
size_t currentFrame;
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment