Skip to content

Commit

Permalink
Merge pull request #7 from proyan/master
Browse files Browse the repository at this point in the history
Update sequence player
  • Loading branch information
Olivier Stasse committed Feb 3, 2017
2 parents 944ccb5 + fda55c8 commit e06fb82
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.1
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ SET (LIBRARY_NAME ${PROJECT_NAME})
ADD_LIBRARY (${LIBRARY_NAME} SHARED
cubic-interpolation.cc
cubic-interpolation.hh
kinematic-planner.cc
kinematic-planner.hh
#kinematic-planner.cc
#kinematic-planner.hh
cubic-interpolation-se3.cc
cubic-interpolation-se3.hh
oscillator.cc
Expand Down
22 changes: 10 additions & 12 deletions src/simpleseqplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ namespace dynamicgraph

SimpleSeqPlay::SimpleSeqPlay (const std::string& name) :
Entity (name),
postureSOUT_ ("SimpleSeqPlay(" + name + ")::output(vector)::posture"),
firstSINTERN( NULL,
sotNOSIGNAL,"SimpleSeqPlay("+name+")::intern(dummy)::init" ),
postureSOUT_(boost::bind (&SimpleSeqPlay::computePosture,this, _1, _2),
firstSINTERN,
"SimpleSeqPlay(" + name + ")::output(vector)::posture"),
state_ (0), startTime_ (0), posture_ ()
{
firstSINTERN.setConstant(0);
signalRegistration (postureSOUT_ );
postureSOUT_.setFunction (boost::bind (&SimpleSeqPlay::computePosture,
this, _1, _2));
cd

std::string docstring =
"Load files describing a whole-body motion as reference feature "
"trajectories\n"
Expand Down Expand Up @@ -74,9 +75,7 @@ cd
std::ifstream file;
unsigned int lineNumber = 0;
int postureSize = -2;

fn= filename + ".posture";

// Open file
file.open (fn.c_str ());
if (!file.is_open ())
Expand All @@ -85,15 +84,14 @@ cd
fn);
}


posture_.clear ();

// Read posture
while (file.good ())
{
std::getline (file, line);
++lineNumber;
tokenizer_t tok (line, escaped_list_separator<char>('\\', '\t', '\"'));
tokenizer_t tok (line, escaped_list_separator<char>('\\', ' ', '\"' ));
std::vector <double> components;
for(tokenizer_t::iterator it=tok.begin(); it!=tok.end(); ++it)
{
Expand All @@ -118,7 +116,7 @@ cd
throw std::runtime_error (oss.str ());
}
}
Vector config (static_cast<unsigned> (components.size () - 1));
dg::Vector config (static_cast<unsigned> (components.size () - 1));
for (unsigned i = 1; i < components.size (); ++i)
{
config (i - 1) = components[i];
Expand All @@ -140,7 +138,7 @@ cd
}
}

Vector& SimpleSeqPlay::computePosture (Vector& pos, const int& t)
dg::Vector& SimpleSeqPlay::computePosture (dg::Vector& pos, int t)
{
if (posture_.size () == 0)
{
Expand Down Expand Up @@ -183,7 +181,7 @@ cd
" Warning: pluging signals before loading trajectories will fail.\n";
}

DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (SimpleSeqPlay, "SimpleSeqplay");
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (SimpleSeqPlay, "SimpleSeqPlay");
} // namespace tools
} //namespace sot
} // namespace dynamicgraph
Expand Down
24 changes: 11 additions & 13 deletions src/simpleseqplay.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,41 @@
# include <dynamic-graph/entity.h>
# include <dynamic-graph/factory.h>
# include <dynamic-graph/linear-algebra.h>
# include <dynamic-graph/signal.h>
# include <sot/core/matrix-homogeneous.hh>
# include <sot/core/matrix-rotation.hh>
# include <dynamic-graph/signal-time-dependent.h>
# include <sot/core/matrix-geometry.hh>

namespace dynamicgraph {
namespace sot {
namespace tools {
using dynamicgraph::Entity;
using dynamicgraph::Vector;
using dynamicgraph::Signal;
using dynamicgraph::sot::MatrixHomogeneous;
namespace dg = dynamicgraph;

class Seqplay : public Entity
class SimpleSeqPlay : public dg::Entity
{
Signal <Vector, int> postureSOUT_;
typedef int Dummy;
dg::SignalTimeDependent<Dummy,int> firstSINTERN;
dg::SignalTimeDependent<dg::Vector,int> postureSOUT_;

DYNAMIC_GRAPH_ENTITY_DECL();
Seqplay (const std::string& name);
SimpleSeqPlay (const std::string& name);

void load (const std::string& filename);
void start ();
virtual std::string getDocString () const;

private:
Vector& computePosture (Vector& pos, const int& t);
dg::Vector& computePosture (dg::Vector& pos, int t);
// 0: motion not started, 1: motion in progress, 2: motion finished
unsigned int state_;
unsigned int configId_;
int startTime_;

std::vector <Vector> posture_;
std::vector <dg::Vector> posture_;

bool facultativeFound_[7];

std::vector <double> time_;

}; // class Seqplay
}; // class SimpleSeqPlay
} // namespace tools
} //namespace sot
} // namespace dynamicgraph
Expand Down

0 comments on commit e06fb82

Please sign in to comment.