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 @@
// Author: Florent Lamiraux,
// Mehdi Benallegue <mehdi@benallegue.com>
//
//
#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>
#include "sot/tools/oscillator.hh"
namespace dynamicgraph {
namespace sot {
......@@ -26,31 +16,6 @@ using command::makeDirectGetter;
using command::makeDirectSetter;
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");
Oscillator::Oscillator(const std::string name)
......
......@@ -3,13 +3,10 @@
#include <sot/tools/kinematic-planner.hh>
#include <sot/tools/seqplay.hh>
#include <sot/tools/simpleseqplay.hh>
#include <sot/tools/oscillator.hh>
namespace dgst = dynamicgraph::sot::tools;
typedef boost::mpl::vector<
dgst::CubicInterpolation
, dgst::CubicInterpolationSE3
, dgst::KinematicPlanner
, dgst::Seqplay
, dgst::SimpleSeqPlay
> entities_t;
typedef boost::mpl::vector<dgst::CubicInterpolation, dgst::CubicInterpolationSE3, dgst::Seqplay, dgst::SimpleSeqPlay,
dgst::Oscillator>
entities_t;
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
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)
ADD_SUBDIRECTORY(python)
......
import unittest
from random import random
from dynamic_graph.sot.tools.oscillator import Oscillator
from dynamic_graph.sot.tools import Oscillator
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