Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Tools/Actorics/JointDataSequencer.cpp

Go to the documentation of this file.
00001 /** 
00002 * @file JointDataSequencer.cpp
00003 *
00004 * Implementation of JointDataSequencer class.
00005 *
00006 * @author Max Risler
00007 */
00008 
00009 #include "JointDataSequencer.h"
00010 
00011 JointDataSequencer::JointDataSequencer()
00012 {
00013   running = false;
00014 }
00015 
00016 JointDataSequencer& JointDataSequencer::operator=(const JointDataSequence& other)
00017 {
00018   numOfEntries = other.numOfEntries;
00019   loop = other.loop;
00020   for (int i = 0; i < numOfEntries; i++)
00021   {
00022     entry[i] = other.entry[i];
00023     interpolate[i] = other.interpolate[i];
00024     repeats[i] = other.repeats[i];
00025   }
00026 
00027   running = false;
00028 
00029   return *this;
00030 }
00031 
00032 bool JointDataSequencer::isRunning()
00033 {
00034   return running;
00035 }
00036 
00037 void JointDataSequencer::start()
00038 {
00039   running = (numOfEntries>0);
00040   sequencePos = 0;
00041   repetitionCounter = 0;
00042 }
00043 
00044 void JointDataSequencer::stop()
00045 {
00046   running = false;
00047 }
00048 
00049 void JointDataSequencer::nextSequenceData(JointData& jointData)
00050 {
00051   if (!running) return;
00052 
00053   //set next data
00054   if (interpolate[sequencePos] && sequencePos > 0)
00055     interpolateJointData(jointData,entry[sequencePos-1],entry[sequencePos],repetitionCounter,repeats[sequencePos]);
00056   else if (interpolate[sequencePos] && sequencePos == 0 && loop)
00057   interpolateJointData(jointData,entry[numOfEntries - 1],entry[0],repetitionCounter,repeats[sequencePos]);
00058   else
00059     jointData = entry[sequencePos];
00060 
00061   //increase position in sequence
00062   repetitionCounter++;
00063   if (repetitionCounter >= repeats[sequencePos])
00064   {
00065     //finished repeating current line
00066     repetitionCounter = 0;
00067     sequencePos++;
00068     if (sequencePos >= numOfEntries)
00069     {
00070       //finished sequence
00071       if (loop) 
00072         //repeat
00073         sequencePos = 0;
00074       else
00075         //finished
00076         running = false;
00077     }
00078   } 
00079 }
00080 
00081 void JointDataSequencer::interpolateJointData(
00082     JointData& jointData,
00083     const JointData& from, const JointData& to, int step, int len
00084     )
00085 {
00086   for (int i = 0; i < JointData::numOfJoint; i++)
00087     if (from.data[i] == jointDataInvalidValue || to.data[i] == jointDataInvalidValue)
00088       jointData.data[i] = jointDataInvalidValue;
00089     else
00090       jointData.data[i] = 
00091         from.data[i] + 
00092         (to.data[i] - from.data[i]) * step / len;
00093 }
00094 
00095 /*
00096  * Change log :
00097  * 
00098  * $Log: JointDataSequencer.cpp,v $
00099  * Revision 1.1.1.1  2004/05/22 17:35:56  cvsadm
00100  * created new repository GT2004_WM
00101  *
00102  * Revision 1.1  2003/10/07 10:13:21  cvsadm
00103  * Created GT2004 (M.J.)
00104  *
00105  * Revision 1.1  2003/09/26 11:40:40  juengel
00106  * - sorted tools
00107  * - clean-up in DataTypes
00108  *
00109  * Revision 1.1.1.1  2003/07/02 09:40:28  cvsadm
00110  * created new repository for the competitions in Padova from the 
00111  * tamara CVS (Tuesday 2:00 pm)
00112  *
00113  * removed unused solutions
00114  *
00115  * Revision 1.1  2002/09/10 15:53:58  cvsadm
00116  * Created new project GT2003 (M.L.)
00117  * - Cleaned up the /Src/DataTypes directory
00118  * - Removed challenge related source code
00119  * - Removed processing of incoming audio data
00120  * - Renamed AcousticMessage to SoundRequest
00121  *
00122  * Revision 1.2  2002/06/10 20:38:16  risler
00123  * removed bug in loop with interpolating sequences
00124  *
00125  * Revision 1.1.1.1  2002/05/10 12:40:32  cvsadm
00126  * Moved GT2002 Project from ute to tamara.
00127  *
00128  * Revision 1.3  2002/02/23 14:50:42  risler
00129  * start on empty sequence sets running flag correctly
00130  *
00131  * Revision 1.2  2002/02/21 18:02:51  risler
00132  * added assignment operator
00133  *
00134  * Revision 1.1  2002/02/21 16:29:21  risler
00135  * added JointDataSequencer
00136  *
00137  *
00138  */

Generated on Thu Sep 23 19:57:37 2004 for GT2004 by doxygen 1.3.6