3 #include <SimoxUtility/json.h>
17 ARMARX_INFO <<
"----------------------------------- creating MPs -------------------------------------------------";
22 auto className = mpClass::_from_string_nocase(
c.className.c_str());
30 mps.insert({
c.name, {jsmp, in, out}});
33 case mpClass::JSVelMP:
40 mps.insert({
c.name, {tsmp, in, out}});
43 case mpClass::KeypointsMP:
48 mps.insert({
c.name, {tsmp, in, out}});
51 case mpClass::TSVelMP:
54 ARMARX_WARNING <<
"unsupported MP class: " <<
c.className <<
"\nsupported names include: "
55 "JSMP, JSVelMP, TSMP, TSVelMP, KeypointsMP";
59 ARMARX_INFO <<
"---------------------------------- All MPs created -----------------------------------------------";
72 mp.second.mp->run(mp.second.input, mp.second.output);
78 std::string allMPs =
"";
81 allMPs = allMPs + mp.second.mp->getMPName() +
", ";
86 void MPPool::start(
const std::string& mpName,
const Ice::DoubleSeq& startVec,
const Ice::DoubleSeq& goalVec,
Ice::Double timeDuration,
const Ice::Current &iceCurrent)
90 ARMARX_IMPORTANT <<
"to start all MPs at once, it's up to the user to configure the start, goal and timeduration properly before this call.";
93 mp.second.mp->start();
98 auto search =
mps.find(mpName);
99 if (search !=
mps.end())
101 if (timeDuration < 0.0)
103 search->second.mp->start(goalVec, startVec);
107 search->second.mp->start(goalVec, startVec, timeDuration);
112 ARMARX_ERROR << mpName <<
" is not in the MP pool. Please check your configuration file";
124 mp.second.mp->stop();
129 auto search =
mps.find(mpName);
130 if (search !=
mps.end())
132 search->second.mp->stop();
136 ARMARX_ERROR << mpName <<
" is not in the MP pool. Please check your configuration file";
147 mp.second.mp->pause();
152 auto search =
mps.find(mpName);
153 if (search !=
mps.end())
155 search->second.mp->pause();
159 ARMARX_ERROR << mpName <<
" is not in the MP pool. Please check your configuration file";
170 mp.second.mp->resume();
175 auto search =
mps.find(mpName);
176 if (search !=
mps.end())
178 search->second.mp->resume();
182 ARMARX_ERROR << mpName <<
" is not in the MP pool. Please check your configuration file";
193 mp.second.mp->reset();
198 auto search =
mps.find(mpName);
199 if (search !=
mps.end())
201 search->second.mp->reset();
205 ARMARX_ERROR << mpName <<
" is not in the MP pool. Please check your configuration file";
216 if (!mp.second.mp->isFinished())
225 auto search =
mps.find(mpName);
226 if (search !=
mps.end())
228 return search->second.mp->isFinished();
232 ARMARX_ERROR << mpName <<
" is not in the MP pool. Please check your configuration file";
240 ARMARX_INFO <<
"--------------------------------------- Train MPs ----------------------------------------------------";
243 mp.second.mp->learnFromCSV();
245 ARMARX_INFO <<
"--------------------------------------- done ----------------------------------------------------";
257 mp.second.mp->setStartAndGoal(starts, goals);
283 std::vector<double> test {0.1, 0.1};
289 auto search =
mps.find(mpName);
290 if (search !=
mps.end())
292 return search->second.mp->getCanonicalValue();
296 ARMARX_ERROR << mpName <<
" is not in the MP pool. Please check your configuration file";