Commit 6f9305f3 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

Add Oscillator

parent 1ce872a1
Pipeline #10884 failed with stage
in 3 minutes and 22 seconds
//
// Copyright (C) 2012 LAAS-CNRS
//
// Author: Florent Lamiraux,
// Mehdi Benallegue <mehdi@benallegue.com>
//
#ifndef SOT_TOOLS_OSCILLATOR_HH
#define SOT_TOOLS_OSCILLATOR_HH
#include <limits>
#include <dynamic-graph/command.h>
#include <dynamic-graph/command-bind.h>
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/command-direct-setter.h>
#include <dynamic-graph/command-direct-getter.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/factory.h>
#include <dynamic-graph/entity.h>
namespace dynamicgraph {
namespace sot {
namespace tools {
class Oscillator : public Entity {
DYNAMIC_GRAPH_ENTITY_DECL();
public:
Oscillator(const std::string name);
protected:
double& computeSignal(double& sout, const int& t);
dynamicgraph::Vector& computeVectorSignal(dynamicgraph::Vector& vsout, const int& t);
double value(double dt, double time, double omega, double phase, double amplitude, double bias);
SignalPtr<double, int> angularFrequencySIN_;
SignalPtr<double, int> magnitudeSIN_;
SignalPtr<double, int> phaseSIN_;
SignalPtr<double, int> biasSIN_;
SignalTimeDependent<double, int> soutSOUT_;
SignalTimeDependent<dynamicgraph::Vector, int> vectorSoutSOUT_;
double epsilon_;
bool started_;
bool continuous_;
double dt_;
double lastValue_;
}; // class Oscillator
} // namespace tools
} // namespace sot
} // namespace dynamicgraph
#endif // SOT_TOOLS_CUBIC_INTERPOLATION_SE3_HH
...@@ -4,19 +4,9 @@ ...@@ -4,19 +4,9 @@
// Author: Florent Lamiraux, // Author: Florent Lamiraux,
// Mehdi Benallegue <mehdi@benallegue.com> // Mehdi Benallegue <mehdi@benallegue.com>
// //
//
#include <limits> #include "sot/tools/oscillator.hh"
#include <dynamic-graph/command.h>
#include <dynamic-graph/command-bind.h>
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/command-direct-setter.h>
#include <dynamic-graph/command-direct-getter.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/factory.h>
#include <dynamic-graph/entity.h>
namespace dynamicgraph { namespace dynamicgraph {
namespace sot { namespace sot {
...@@ -26,31 +16,6 @@ using command::makeDirectGetter; ...@@ -26,31 +16,6 @@ using command::makeDirectGetter;
using command::makeDirectSetter; using command::makeDirectSetter;
namespace tools { namespace tools {
class Oscillator : public Entity {
DYNAMIC_GRAPH_ENTITY_DECL();
public:
Oscillator(const std::string name);
protected:
double& computeSignal(double& sout, const int& t);
dynamicgraph::Vector& computeVectorSignal(dynamicgraph::Vector& vsout, const int& t);
double value(double dt, double time, double omega, double phase, double amplitude, double bias);
SignalPtr<double, int> angularFrequencySIN_;
SignalPtr<double, int> magnitudeSIN_;
SignalPtr<double, int> phaseSIN_;
SignalPtr<double, int> biasSIN_;
SignalTimeDependent<double, int> soutSOUT_;
SignalTimeDependent<dynamicgraph::Vector, int> vectorSoutSOUT_;
double epsilon_;
bool started_;
bool continuous_;
double dt_;
double lastValue_;
}; // class Oscillator
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Oscillator, "Oscillator"); DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Oscillator, "Oscillator");
Oscillator::Oscillator(const std::string name) Oscillator::Oscillator(const std::string name)
......
...@@ -3,13 +3,10 @@ ...@@ -3,13 +3,10 @@
#include <sot/tools/kinematic-planner.hh> #include <sot/tools/kinematic-planner.hh>
#include <sot/tools/seqplay.hh> #include <sot/tools/seqplay.hh>
#include <sot/tools/simpleseqplay.hh> #include <sot/tools/simpleseqplay.hh>
#include <sot/tools/oscillator.hh>
namespace dgst = dynamicgraph::sot::tools; namespace dgst = dynamicgraph::sot::tools;
typedef boost::mpl::vector< typedef boost::mpl::vector<dgst::CubicInterpolation, dgst::CubicInterpolationSE3, dgst::Seqplay, dgst::SimpleSeqPlay,
dgst::CubicInterpolation dgst::Oscillator>
, dgst::CubicInterpolationSE3 entities_t;
, dgst::KinematicPlanner
, dgst::Seqplay
, dgst::SimpleSeqPlay
> entities_t;
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
ADD_UNIT_TEST(test_simpleseqplay test_simpleseqplay.cc) ADD_UNIT_TEST(test_simpleseqplay test_simpleseqplay.cc)
TARGET_LINK_LIBRARIES(test_simpleseqplay ${PROJECT_NAME} ${Boost_LIBRARIES}) TARGET_LINK_LIBRARIES(test_simpleseqplay PRIVATE ${PROJECT_NAME} Boost::unit_test_framework)
IF(BUILD_PYTHON_INTERFACE) IF(BUILD_PYTHON_INTERFACE)
ADD_SUBDIRECTORY(python) ADD_SUBDIRECTORY(python)
......
import unittest import unittest
from random import random from random import random
from dynamic_graph.sot.tools.oscillator import Oscillator from dynamic_graph.sot.tools import Oscillator
class OscillatorTest(unittest.TestCase): class OscillatorTest(unittest.TestCase):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment