ExecuteTrajectory.cpp
Go to the documentation of this file.
1 #include "ExecuteTrajectory.h"
2 
4 
6 //#include <armarx/control/common/mp/MP.h>
7 //#include <armarx/control/common/mp/aron/MPConfig.aron.generated.h>
8 //#include <armarx/control/common/utils.h>
9 
10 #include <SimoxUtility/json/json.hpp>
11 
12 //#include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
14 //#include <armarx/control/njoint_mp_controller/task_space/MixedImpedanceVelocityController.h>
15 //#include <armarx/control/skills/constants/constants.h>
17 
19 {
20 
22  ::armarx::skills::SimpleSpecializedSkill<ParamType>(GetSkillDescription()), srv_(srv)
23  {
24  }
25 
27  ExecuteTrajectory::exit(const SpecializedExitInput& in)
28  {
29 
30  return {::armarx::skills::TerminatedSkillStatus::Succeeded};
31  }
32 
34  ExecuteTrajectory::main(const SpecializedMainInput& in)
35  {
36  ARMARX_INFO << "in main of execute trajectory";
38 
39  // create controller
40  std::string controllerNamePrefix = "executeTrajectory";
41  auto builder =
43  // ->createControllerBuilder<armarx::control::common::ControllerType::TSMPVel>();
44  //->createControllerBuilder<armarx::control::common::ControllerType::TSMPImpCol>();
45  //->createControllerBuilder<armarx::control::common::ControllerType::TSMPMixImpVel>();
48 
49  auto ctrl = builder.createGetTSComplianceMPCtrl(controllerNamePrefix,
50  in.parameters.mpConfigList.toAronDTO(),
51  nullptr,
52  in.parameters.controllerConfigPath);
53  // std::string mainCanValName;
54  // std::string nodeSetName;
55  // for (auto& mpCfg : in.parameters.mpConfigList.mpList)
56  // {
57  // if (mpCfg.role == "taskspace")
58  // {
59  // mainCanValName = mpCfg.name;
60  // nodeSetName = mpCfg.nodeSetName;
61  // break;
62  // }
63  // }
66  auto start = IceUtil::Time::now().toSecondsDouble();
67  while (!ctrl->isFinishedAll() and not shouldSkillTerminate())
68  {
69  // auto canVal = ctrl->getCanVal(mainCanValName);
70  // if (not ctrl->isSafeForceTorque(nodeSetName))
71  // {
72  // ARMARX_IMPORTANT << "!!!! Force Torque Guard Triggered Stopping !!! at " << canVal;
73  // ctrl->pauseAll();
74  // break;
75  // }
77  }
78  auto duration = IceUtil::Time::now().toSecondsDouble() - start;
79  ARMARX_INFO << VAROUT(duration);
81  {
82  ctrl->stopAll();
83  }
85 
86  // while (ctrl->isControllerActive())
87  // {
88  // ctrl->deactivateController();
89  // usleep(10000);
90  // }
91  // ctrl->deleteController();
92 
93  return MakeSucceededResult();
94  }
95 
96 
97 } // namespace armarx::control::skills::skills
skills
This file is part of ArmarX.
armarx::skills::SimpleSpecializedSkill< arondto::ExecuteTrajectoryParams >::ParamType
arondto::ExecuteTrajectoryParams ParamType
Definition: SimpleSpecializedSkill.h:14
Trajectory.h
armarx::core::time::Clock::WaitFor
static void WaitFor(const Duration &duration)
Wait for a certain duration on the virtual clock.
Definition: Clock.cpp:99
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
aron_conversions.h
armarx::control::skills::skills::ExecuteTrajectory::ExecuteTrajectory
ExecuteTrajectory(const Services &)
Definition: ExecuteTrajectory.cpp:21
ExecuteTrajectory.h
armarx::skills::SimpleSpecializedSkill< arondto::ExecuteTrajectoryParams >::exit
Skill::ExitResult exit() final
Definition: SimpleSpecializedSkill.h:81
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
armarx::core::time::Duration::Seconds
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
Definition: Duration.cpp:72
armarx::control::common::ControllerType::TSMPMixImpVelCol
@ TSMPMixImpVelCol
armarx::control::skills::skills::ExecuteTrajectory::Services
Definition: ExecuteTrajectory.h:28
armarx::control::client::ComponentPlugin::createControllerBuilder
auto createControllerBuilder(Args... args)
Definition: ComponentPlugin.h:81
ShapeHand.h
armarx::skills::Skill::MakeSucceededResult
static MainResult MakeSucceededResult(aron::data::DictPtr data=nullptr)
Definition: Skill.cpp:329
armarx::skills::Skill::MainResult
A result struct for th main method of a skill.
Definition: Skill.h:39
controller_descriptions.h
armarx::skills::Skill::ExitResult
A result struct for skill exit function.
Definition: Skill.h:46
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::skills::SimpleSpecializedSkill< arondto::ExecuteTrajectoryParams >::main
Skill::MainResult main() final
Definition: SimpleSpecializedSkill.h:71
VAROUT
#define VAROUT(x)
Definition: StringHelpers.h:198
armarx::control::skills::skills
Definition: ExecuteTrajectory.cpp:18
armarx::skills::Skill::shouldSkillTerminate
bool shouldSkillTerminate() const
Returns whether the skill should terminate as soon as possible.
Definition: Skill.cpp:385
armarx::skills::Skill::throwIfSkillShouldTerminate
void throwIfSkillShouldTerminate(const std::string &abortedMessage="")
Definition: Skill.cpp:305
armarx::control::skills::skills::ExecuteTrajectory::Services::controlComponentPluginUser
::armarx::control::client::ComponentPlugin * controlComponentPluginUser
Definition: ExecuteTrajectory.h:30
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::core::time::Duration::MilliSeconds
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
Definition: Duration.cpp:48