25#include <VirtualRobot/VirtualRobot.h>
32#include <armarx/control/common/FTSensor.h>
34#include <armarx/control/njoint_mp_controller/task_space/ControllerInterface.h>
36#include <mplib/core/SampledTrajectory.h>
37#include <mplib/factories/AbstractMPFactory.h>
38#include <mplib/factories/MPFactoryCreator.h>
39#include <mplib/factories/VMPFactory.h>
40#include <mplib/representation/vmp/PrincipalComponentVMP.h>
44 namespace common = armarx::control::common;
45 namespace law = armarx::control::common::control_law;
60 law::TaskspaceKeypointsAdmittanceController::Config>,
61 public KeypointMPControllerInterface
65 using VMPPtr = std::shared_ptr<mplib::representation::vmp::PrincipalComponentVMP>;
69 const NJointControllerConfigPtr& config,
71 std::string
getClassName(
const Ice::Current&)
const override;
72 void rtRun(
const IceUtil::Time& sensorValuesTimestamp,
73 const IceUtil::Time& timeSinceLastIteration)
override;
82 void setKeypoints(
const Eigen::VectorXf&,
const Ice::Current&)
override;
84 const float keypoint_stiffness,
86 const Eigen::VectorXf& ctrl_mask,
87 const Eigen::VectorXf& init_keypoints_position,
88 const Ice::Current&)
override;
93 void setTCPPose(
const Eigen::Matrix4f&,
const Ice::Current&)
override;
98 const Eigen::VectorXf&,
99 const Ice::Current&)
override;
101 const Eigen::Vector3f&,
102 const Ice::Current&)
override;
106 void setTCPMass(Ice::Float,
const Ice::Current&)
override;
112 std::string
getNames(
const Ice::Current&)
override;
113 void start(
const Ice::DoubleSeq&,
const Ice::Current&)
override;
114 void startWithTime(
const Ice::DoubleSeq&, Ice::Double,
const Ice::Current&)
override;
117 void stop(
const Ice::Current&)
override;
118 void pause(
const Ice::Current&)
override;
119 void resume(
const Ice::Current&)
override;
120 void reset(
const Ice::Current&)
override;
121 bool isFinished(
const Ice::Current&)
override;
122 void learnFromCSV(
const Ice::StringSeq&,
const Ice::Current&)
override;
123 void setGoal(
const Ice::DoubleSeq&,
const Ice::Current&)
override;
125 setStartAndGoal(
const Ice::DoubleSeq&,
const Ice::DoubleSeq&,
const Ice::Current&)
override;
126 void setViaPoint(Ice::Double,
const Ice::DoubleSeq&,
const Ice::Current&)
override;
128 std::string
serialize(
const Ice::Current&)
override;
129 Ice::DoubleSeq
deserialize(
const std::string& mpAsString,
const Ice::Current&)
override;
130 Ice::Double
getCanVal(
const Ice::Current&)
override;
132 void toggleMP(
const bool enableMP,
const Ice::Current&)
override;
141 const std::string& name,
142 const Eigen::Matrix4f& pose);
144 const std::string& name,
147 const std::string& name,
152 std::vector<const SensorValue1DoFActuatorTorque*> torqueSensors;
153 std::vector<const SensorValue1DoFActuatorVelocity*> velocitySensors;
154 std::vector<const SensorValue1DoFActuatorPosition*> positionSensors;
155 std::vector<ControlTarget1DoFActuatorTorque*> targets;
160 StringFloatDictionary desired_torques;
169 mplib::core::DVec2d currentState;
176 std::string kinematicChainName;
177 std::vector<std::string> jointNames;
178 law::TaskspaceKeypointsAdmittanceController
controller;
179 common::FTSensor ftsensor;
181 std::atomic_bool rtFirstRun =
true;
182 std::atomic_bool rtReady =
false;
186 Eigen::VectorXf initialStateEigen;
187 mplib::core::DVec2d initialState;
188 mplib::core::DVec2d currentState;
189 mplib::core::DVec targetPosition;
190 mplib::core::DVec goal;
194 double timeDuration = 0.0;
195 std::atomic_bool mpRunning =
false;
196 std::atomic_bool mpFinished =
false;
198 std::atomic_bool mpEnabled{
false};
NJointControllerWithTripleBuffer(const law::TaskspaceKeypointsAdmittanceController::Config &initialCommands=law::TaskspaceKeypointsAdmittanceController::Config())
A simple triple buffer for lockfree comunication between a single writer and a single reader.
void resume(const Ice::Current &) override
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
void setGoal(const Ice::DoubleSeq &, const Ice::Current &) override
void onInitNJointController() override
Ice::Double getCanVal(const Ice::Current &) override
void stop(const Ice::Current &) override
void reconfigureController(const std::string &, const Ice::Current &) override
std::string getNames(const Ice::Current &) override
void start(const Ice::DoubleSeq &, const Ice::Current &) override
bool isFinished(const Ice::Current &) override
void learnFromCSV(const Ice::StringSeq &, const Ice::Current &) override
KeypointMPController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void resetKeypoints(const int n_points, const float keypoint_stiffness, const bool is_rigid, const Eigen::VectorXf &ctrl_mask, const Eigen::VectorXf &init_keypoints_position, const Ice::Current &) override
void setKeypoints(const Eigen::VectorXf &, const Ice::Current &) override
KeypointMPControllerConfigPtr ConfigPtrT
void pause(const Ice::Current &) override
void removeAllViaPoint(const Ice::Current &) override
void startAsTraj(const Ice::Current &) override
std::shared_ptr< mplib::representation::vmp::PrincipalComponentVMP > VMPPtr
void toggleMP(const bool enableMP, const Ice::Current &) override
void setStartAndGoal(const Ice::DoubleSeq &, const Ice::DoubleSeq &, const Ice::Current &) override
void setForceTorqueBaseline(const Eigen::Vector3f &, const Eigen::Vector3f &, const Ice::Current &) override
bool getMPEnabled(const Ice::Current &) override
Ice::DoubleSeq deserialize(const std::string &mpAsString, const Ice::Current &) override
std::string getKinematicChainName(const Ice::Current &) override
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
void setTCPCoMInFTFrame(const Eigen::Vector3f &, const Ice::Current &) override
void publishPose(StringVariantBaseMap &datafields, const std::string &name, const Eigen::Matrix4f &pose)
std::string serialize(const Ice::Current &) override
void setViaPoint(Ice::Double, const Ice::DoubleSeq &, const Ice::Current &) override
void setTCPMass(Ice::Float, const Ice::Current &) override
void startAsTrajWithTime(Ice::Double, const Ice::Current &) override
void calibrateFTSensor(const Ice::Current &) override
void setTCPPose(const Eigen::Matrix4f &, const Ice::Current &) override
void startWithTime(const Ice::DoubleSeq &, Ice::Double, const Ice::Current &) override
void publishVec6f(StringVariantBaseMap &datafields, const std::string &name, const Eigen::Vector6f &vec)
void setControlParameters(const std::string &, const Eigen::VectorXf &, const Ice::Current &) override
set control parameter
std::string getClassName(const Ice::Current &) const override
void publishVecXf(StringVariantBaseMap &datafields, const std::string &name, const Eigen::Vector6f &vec)
void rtPreActivateController() override
This function is called before the controller is activated.
void toggleGravityCompensation(const bool toggle, const Ice::Current &) override
ft sensor
Matrix< float, 6, 1 > Vector6f
std::shared_ptr< class Robot > RobotPtr
This file is part of ArmarX.
This file is part of ArmarX.
This file is part of ArmarX.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceUtil::Handle< class RobotUnit > RobotUnitPtr
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl