MPPool.h
Go to the documentation of this file.
1 /**
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @author Jianfeng Gao ( jianfeng dot gao at kit dot edu )
17  * @date 2022
18  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19  * GNU General Public License
20  */
21 
22 
23 #pragma once
24 
25 #include <mplib/representation/vmp/PrincipalComponentVMP.h>
26 
27 #include <armarx/control/common/mp/MPPoolInterface.h>
28 #include "MP.h"
29 
30 
32 {
33  BETTER_ENUM(mpClass, int, JSMP, JSVelMP, TSMP, TSVelMP, KeypointsMP)
34 
36  {
40  };
41  using MPInputOutputPtr = std::shared_ptr<MPInputOutput>;
42 
43 
44 
45  class MPPool:
46  public virtual MPPoolInterface
47  {
48  public:
49  MPPool(){};
50  ~MPPool(){};
51 
52  void runMPs();
53  void createMPs(const MP::MPListConfig& mpListConfig);
54  void reconfigureMPs(const MP::MPListConfig& mpListConfig);
55 
56  public:
57  /// Interface functions
58  std::string getNames(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
59  /// control
60  void start(const std::string& mpName = "all",
61  const Ice::DoubleSeq& startVec = std::vector<double>(),
62  const Ice::DoubleSeq& goalVec = std::vector<double>(),
63  Ice::Double timeDuration = -1.0,
64  const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
65 
66  void stop(const std::string &mpName = "all", const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
67  void pause(const std::string &mpName = "all", const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
68  void resume(const std::string &mpName = "all", const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
69  void reset(const std::string &mpName = "all", const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
70  bool isFinished(const std::string &mpName = "all", const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
71 
72  /// setting
73  void learnFromCSV(const Ice::StringSeq& fileNames = std::vector<std::string>(), const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
74 
75  void setGoal(const Ice::DoubleSeq& goals, const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
76  void setStartAndGoal(const Ice::DoubleSeq& starts, const Ice::DoubleSeq& goals, const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
77  void setViaPoint(Ice::Double u, const Ice::DoubleSeq& viapoint, const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
78  void removeAllViaPoint(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
79 
80  /// serialze
81  // void setWeight(const Ice::DoubleSeqSeq& weights, const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
82  // Ice::DoubleSeqSeq getWeight(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
83  std::string serialize(const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
84  Ice::DoubleSeq deserialize(const std::string&, const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
85 
86  ///
87  Ice::Double getCanVal(const std::string& mpName, const Ice::Current& iceCurrent = Ice::emptyCurrent) override;
88  bool getMPEnabled(const Ice::Current &) override;
89 
90  protected:
91  std::map<std::string, MPInputOutput> mps;
92  };
93 
94  using MPPoolPtr = std::shared_ptr<MPPool>;
95 } /// namespace armarx::control::common::mp
armarx::control::common::mp::MPInputOutput::output
MPOutputPtr output
Definition: MPPool.h:39
armarx::control::common::mp::MPPool::getCanVal
Ice::Double getCanVal(const std::string &mpName, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:287
armarx::MPPoolInterface::getNames
string getNames()
armarx::control::common::mp::MPPool::deserialize
Ice::DoubleSeq deserialize(const std::string &, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:281
armarx::control::common::mp::MPPoolPtr
std::shared_ptr< MPPool > MPPoolPtr
Definition: MPPool.h:94
armarx::MPPoolInterface::getMPEnabled
bool getMPEnabled()
armarx::control::common::mp::MPInputOutput::mp
MPPtr mp
Definition: MPPool.h:37
armarx::control::common::mp::MPPool::stop
void stop(const std::string &mpName="all", const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:118
armarx::MPPoolInterface
Definition: MPPoolInterface.ice:32
armarx::control::common::mp::MPPool::reset
void reset(const std::string &mpName="all", const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:187
armarx::control::common::mp::MPInputOutput
Definition: MPPool.h:35
armarx::control::common::mp::MPPool::runMPs
void runMPs()
Definition: MPPool.cpp:68
armarx::control::common::mp
namespace armarx::control::common::control_law
Definition: aron_conversions.cpp:135
armarx::control::common::mp::MPPool::setGoal
void setGoal(const Ice::DoubleSeq &goals, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:248
armarx::control::common::mp::MPPool::createMPs
void createMPs(const MP::MPListConfig &mpListConfig)
Definition: MPPool.cpp:15
armarx::control::common::mp::MPPool::MPPool
MPPool()
Definition: MPPool.h:49
MP.h
armarx::VariantType::Double
const VariantTypeId Double
Definition: Variant.h:919
armarx::control::common::mp::MPPtr
std::shared_ptr< MP > MPPtr
Definition: MP.h:182
armarx::control::common::mp::MPPool::resume
void resume(const std::string &mpName="all", const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:164
armarx::control::common::mp::MPInputOutput::input
MPInputPtr input
Definition: MPPool.h:38
armarx::MPPoolInterface::removeAllViaPoint
void removeAllViaPoint()
armarx::control::common::mp::MPInputPtr
std::shared_ptr< MPInput > MPInputPtr
Definition: MP.h:45
armarx::control::common::mp::MPPool::pause
void pause(const std::string &mpName="all", const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:141
armarx::control::common::mp::MPPool::setViaPoint
void setViaPoint(Ice::Double u, const Ice::DoubleSeq &viapoint, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:261
armarx::control::common::mp::MPPool::reconfigureMPs
void reconfigureMPs(const MP::MPListConfig &mpListConfig)
Definition: MPPool.cpp:62
armarx::control::common::mp::MPPool::learnFromCSV
void learnFromCSV(const Ice::StringSeq &fileNames=std::vector< std::string >(), const Ice::Current &iceCurrent=Ice::emptyCurrent) override
setting
Definition: MPPool.cpp:238
armarx::control::common::mp::MPPool::setStartAndGoal
void setStartAndGoal(const Ice::DoubleSeq &starts, const Ice::DoubleSeq &goals, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:253
armarx::control::common::mp::MP::MPListConfig
Definition: MP.h:102
armarx::control::common::mp::MPOutputPtr
std::shared_ptr< MPOutput > MPOutputPtr
Definition: MP.h:46
armarx::control::common::mp::MPPool::start
void start(const std::string &mpName="all", const Ice::DoubleSeq &startVec=std::vector< double >(), const Ice::DoubleSeq &goalVec=std::vector< double >(), Ice::Double timeDuration=-1.0, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
control
Definition: MPPool.cpp:86
armarx::control::common::mp::MPPool::~MPPool
~MPPool()
Definition: MPPool.h:50
armarx::control::common::mp::MPPool
Definition: MPPool.h:45
armarx::control::common::mp::MPInputOutputPtr
std::shared_ptr< MPInputOutput > MPInputOutputPtr
Definition: MPPool.h:41
armarx::control::common::mp::MPPool::mps
std::map< std::string, MPInputOutput > mps
Definition: MPPool.h:91
armarx::MPPoolInterface::serialize
string serialize()
serialze
armarx::control::common::mp::MPPool::isFinished
bool isFinished(const std::string &mpName="all", const Ice::Current &iceCurrent=Ice::emptyCurrent) override
Definition: MPPool.cpp:210