control/test_control_pd.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019,
3  * Olivier Stasse,
4  *
5  * CNRS/AIST
6  *
7  */
8 
9 #include <iostream>
10 #include <sot/core/debug.hh>
11 
12 #ifndef WIN32
13 #include <unistd.h>
14 #endif
15 
16 using namespace std;
17 
18 #include <dynamic-graph/entity.h>
19 #include <dynamic-graph/factory.h>
20 
21 #include <sot/core/control-pd.hh>
22 #include <sstream>
23 
24 using namespace dynamicgraph;
25 using namespace dynamicgraph::sot;
26 
27 #define BOOST_TEST_MODULE debug - control - pd
28 
29 #include <boost/test/tools/output_test_stream.hpp>
30 #include <boost/test/unit_test.hpp>
31 
32 BOOST_AUTO_TEST_CASE(control_pd) {
33  sot::ControlPD *aControlPD = new ControlPD("acontrol_pd");
34  aControlPD->init(0.001);
35  std::istringstream Kpiss("[5](10.0,20.0,30.0,40.0,50.0)");
36  std::istringstream Kdiss("[5](0.10,0.20,0.30,0.40,0.50)");
37  aControlPD->KpSIN.set(Kpiss);
38  aControlPD->KdSIN.set(Kdiss);
39  std::istringstream posiss("[5](1.0,1.0,1.0,1.0,1.0)");
40  aControlPD->positionSIN.set(posiss);
41  std::istringstream dposiss("[5](3.0,3.1,3.2,3.3,3.4)");
42  aControlPD->desiredpositionSIN.set(dposiss);
43  std::istringstream veliss("[5](0.0,0.0,0.0,0.0,0.0)");
44  aControlPD->velocitySIN.set(veliss);
45  std::istringstream dveliss("[5](1.5,1.4,1.3,1.2,1.1)");
46  aControlPD->desiredvelocitySIN.set(dveliss);
47 
48  aControlPD->controlSOUT.recompute(0);
49  aControlPD->positionErrorSOUT.recompute(0);
50  aControlPD->velocityErrorSOUT.recompute(0);
51  {
52  boost::test_tools::output_test_stream output;
53  aControlPD->controlSOUT.get(output);
54  BOOST_CHECK(output.is_equal("20.15 42.28 66.39 92.48 120.55"));
55  }
56  {
57  boost::test_tools::output_test_stream output;
58  aControlPD->positionErrorSOUT.get(output);
59  BOOST_CHECK(output.is_equal("2 2.1 2.2 2.3 2.4"));
60  }
61  {
62  boost::test_tools::output_test_stream output;
63  aControlPD->velocityErrorSOUT.get(output);
64  BOOST_CHECK(output.is_equal("1.5 1.4 1.3 1.2 1.1"));
65  }
66 }
control-pd.hh
dynamicgraph::sot::ControlPD::positionSIN
SignalPtr< dynamicgraph::Vector, sigtime_t > positionSIN
Definition: control-pd.hh:70
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(control_pd)
Definition: control/test_control_pd.cpp:32
dynamicgraph::sot::ControlPD::velocitySIN
SignalPtr< dynamicgraph::Vector, sigtime_t > velocitySIN
Definition: control-pd.hh:72
dynamicgraph::sot::ControlPD::KdSIN
SignalPtr< dynamicgraph::Vector, sigtime_t > KdSIN
Definition: control-pd.hh:69
dynamicgraph
dynamicgraph::sot::ControlPD::controlSOUT
SignalTimeDependent< dynamicgraph::Vector, sigtime_t > controlSOUT
Definition: control-pd.hh:74
dynamicgraph::sot::ControlPD::desiredpositionSIN
SignalPtr< dynamicgraph::Vector, sigtime_t > desiredpositionSIN
Definition: control-pd.hh:71
debug.hh
dynamicgraph::sot::ControlPD::init
void init(const double &step)
Definition: control-pd.cpp:61
dynamicgraph::sot::ControlPD::velocityErrorSOUT
SignalTimeDependent< dynamicgraph::Vector, sigtime_t > velocityErrorSOUT
Definition: control-pd.hh:76
dynamicgraph::sot::ControlPD
Definition: control-pd.hh:46
dynamicgraph::sot::ControlPD::desiredvelocitySIN
SignalPtr< dynamicgraph::Vector, sigtime_t > desiredvelocitySIN
Definition: control-pd.hh:73
dynamicgraph::sot
dynamicgraph::sot::ControlPD::KpSIN
SignalPtr< dynamicgraph::Vector, sigtime_t > KpSIN
Definition: control-pd.hh:68
dynamicgraph::sot::ControlPD::positionErrorSOUT
SignalTimeDependent< dynamicgraph::Vector, sigtime_t > positionErrorSOUT
Definition: control-pd.hh:75


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:32