Go to the documentation of this file.
25 #include <RobotAPI/interface/units/TCPControlUnit.h>
30 #include <VirtualRobot/IK/DifferentialIK.h>
32 #include <ArmarXCore/interface/observers/ObserverInterface.h>
49 defineRequiredProperty<std::string>(
"KinematicUnitName",
"Name of the KinematicUnit Proxy");
50 defineOptionalProperty<std::string>(
"RobotStateTopicName",
"RobotState",
"Name of the RobotComponent State topic.");
51 defineOptionalProperty<float>(
"MaxJointVelocity", 30.f / 180 * 3.141,
"Maximal joint velocity in rad/sec");
52 defineOptionalProperty<int>(
"CycleTime", 30,
"Cycle time of the tcp control in ms");
54 defineOptionalProperty<std::string>(
"TCPsToReport",
"",
"comma seperated list of nodesets' endeffectors, which poses and velocities that should be reported. * for all, empty for none");
55 defineOptionalProperty<std::string>(
"RobotStateComponentName",
"RobotStateComponent",
"Name of the RobotStateComponent that should be used");
57 defineOptionalProperty<float>(
"LambdaDampedSVD", 0.1f,
"Parameter used for smoothing the differential IK near singularities.");
86 virtual public TCPControlUnitInterface
115 void setTCPVelocity(
const std::string& nodeSetName,
const std::string& tcpName, const::armarx::FramedDirectionBasePtr& translationVelocity, const::armarx::FramedDirectionBasePtr& orientationVelocityRPY,
const Ice::Current&
c = Ice::emptyCurrent)
override;
122 void init(
const Ice::Current&
c = Ice::emptyCurrent)
override;
127 void start(
const Ice::Current&
c = Ice::emptyCurrent)
override;
132 void stop(
const Ice::Current&
c = Ice::emptyCurrent)
override;
133 UnitExecutionState
getExecutionState(
const Ice::Current&
c = Ice::emptyCurrent)
override;
140 void request(
const Ice::Current&
c = Ice::emptyCurrent)
override;
148 void release(
const Ice::Current&
c = Ice::emptyCurrent)
override;
150 bool isRequested(
const Ice::Current&
c = Ice::emptyCurrent)
override;
160 return "TCPControlUnit";
166 static Eigen::VectorXf
CalcNullspaceJointDeltas(
const Eigen::VectorXf& desiredJointDeltas,
const Eigen::MatrixXf& jacobian,
const Eigen::MatrixXf& jacobianInverse);
167 static Eigen::VectorXf
CalcJointLimitAvoidanceDeltas(VirtualRobot::RobotNodeSetPtr robotNodeSet,
const Eigen::MatrixXf& jacobian,
const Eigen::MatrixXf& jacobianInverse, Eigen::VectorXf desiredJointValues = Eigen::VectorXf());
170 static void ContinuousAngles(
const Eigen::AngleAxisf& oldAngle, Eigen::AngleAxisf& newAngle,
double& offset);
172 void periodicReport();
174 Eigen::VectorXf applyMaxJointVelocity(
const Eigen::VectorXf& jointVelocity,
float maxJointVelocity);
176 float maxJointVelocity;
180 struct TCPVelocityData
184 std::string nodeSetName;
188 using TCPVelocityDataMap = std::map<std::string, TCPVelocityData>;
189 TCPVelocityDataMap tcpVelocitiesMap, localTcpVelocitiesMap;
191 using DIKMap = std::map<std::string, VirtualRobot::DifferentialIKPtr>;
192 DIKMap dIKMap, localDIKMap;
197 std::string robotName;
199 KinematicUnitInterfacePrx kinematicUnitPrx;
204 TCPControlUnitListenerPrx listener;
209 std::map<std::string, double> oriOffsets;
211 std::vector<VirtualRobot::RobotNodePtr > nodesToReport;
215 std::mutex dataMutex;
216 std::mutex taskMutex;
217 std::mutex reportMutex;
218 bool calculationRunning;
219 double syncTimeDelta;
221 std::string topicName;
243 EDifferentialIK(VirtualRobot::RobotNodeSetPtr rns, VirtualRobot:: RobotNodePtr coordSystem = VirtualRobot::RobotNodePtr(), VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod = eSVD);
257 void setRefFrame(VirtualRobot::RobotNodePtr coordSystem);
263 bool computeSteps(
float stepSize = 1.f,
float mininumChange = 0.01f,
int maxNStep = 50)
override;
264 bool computeSteps(Eigen::VectorXf& resultJointDelta,
float stepSize = 1.f,
float mininumChange = 0.01f,
int maxNStep = 50,
ComputeFunction computeFunction = &DifferentialIK::computeStep);
265 Eigen::VectorXf
computeStep(
float stepSize)
override;
267 void applyTCPWeights(VirtualRobot::RobotNodePtr tcp, Eigen::MatrixXf& partJacobian);
272 bool solveIK(
float stepSize = 1,
float minChange = 0.01f,
int maxSteps = 50,
bool useAlternativeOnFail =
false);
277 std::map<VirtualRobot:: SceneObjectPtr, Eigen::VectorXf>
tcpWeights;
std::string getDefaultName() const override
Retrieve default name of component.
PropertyDefinitionsPtr createPropertyDefinitions() override
void onInitComponent() override
Pure virtual hook for the subclass.
Eigen::VectorXf computeStep(float stepSize) override
void onConnectComponent() override
Pure virtual hook for the subclass.
bool computeSteps(float stepSize=1.f, float mininumChange=0.01f, int maxNStep=50) override
void setDOFWeights(Eigen::VectorXf dofWeights)
UnitExecutionState getExecutionState(const Ice::Current &c=Ice::emptyCurrent) override
void init(const Ice::Current &c=Ice::emptyCurrent) override
Does not do anything at the moment.
void start(const Ice::Current &c=Ice::emptyCurrent) override
Does not do anything at the moment.
static Eigen::VectorXf CalcNullspaceJointDeltas(const Eigen::VectorXf &desiredJointDeltas, const Eigen::MatrixXf &jacobian, const Eigen::MatrixXf &jacobianInverse)
void applyTCPWeights(VirtualRobot::RobotNodePtr tcp, Eigen::MatrixXf &partJacobian)
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
bool isRequested(const Ice::Current &c=Ice::emptyCurrent) override
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
void request(const Ice::Current &c=Ice::emptyCurrent) override
Triggers the calculation loop for using cartesian velocity.
void reportJointCurrents(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &) override
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
void reportJointVelocities(const NameValueMap &jointVel, Ice::Long timestamp, bool, const Ice::Current &) override
void setCycleTime(Ice::Int milliseconds, const Ice::Current &c=Ice::emptyCurrent) override
Sets the cycle time with which the joint velocities are recalculated.
void reportJointStatuses(const NameStatusMap &, Ice::Long timestamp, bool, const Ice::Current &) override
void setRefFrame(VirtualRobot::RobotNodePtr coordSystem)
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
void stop(const Ice::Current &c=Ice::emptyCurrent) override
Does not do anything at the moment.
::std::map< ::std::string, ::armarx::FramedPoseBasePtr > FramedPoseBaseMap
TCPControlUnitPropertyDefinitions(std::string prefix)
void applyDOFWeightsToJacobian(Eigen::MatrixXf &Jacobian)
void setGoal(const Eigen::Matrix4f &goal, VirtualRobot::RobotNodePtr tcp, VirtualRobot::IKSolver::CartesianSelection mode, float tolerancePosition, float toleranceRotation, Eigen::VectorXf tcpWeight)
bool adjustDOFWeightsToJointLimits(const Eigen::VectorXf &plannedJointDeltas)
Eigen::VectorXf dofWeights
std::map< VirtualRobot::SceneObjectPtr, Eigen::VectorXf > tcpWeights
static Eigen::VectorXf CalcJointLimitAvoidanceDeltas(VirtualRobot::RobotNodeSetPtr robotNodeSet, const Eigen::MatrixXf &jacobian, const Eigen::MatrixXf &jacobianInverse, Eigen::VectorXf desiredJointValues=Eigen::VectorXf())
bool solveIK(float stepSize=1, float minChange=0.01f, int maxSteps=50, bool useAlternativeOnFail=false)
void reportJointTorques(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &) override
armarx::core::time::DateTime Time
Eigen::VectorXf computeStepIndependently(float stepSize)
void calcAndSetVelocities()
Eigen::VectorXf(EDifferentialIK::* ComputeFunction)(float)
void onExitComponent() override
Hook for subclass.
float getWeightedErrorPosition(VirtualRobot::SceneObjectPtr tcp)
Baseclass for all ArmarX ManagedIceObjects requiring properties.
std::shared_ptr< EDifferentialIK > EDifferentialIKPtr
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
void reportJointAngles(const NameValueMap &jointAngles, Ice::Long timestamp, bool, const Ice::Current &) override
MatrixXX< 4, 4, float > Matrix4f
Base Class for all Logging classes.
Default component property definition container.
void release(const Ice::Current &c=Ice::emptyCurrent) override
Releases and stops the recalculation and updating of joint velocities.
VirtualRobot::RobotNodePtr getRefFrame()
void reportJointMotorTemperatures(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &) override
boost::intrusive_ptr< SceneObject > SceneObjectPtr
void onDisconnectComponent() override
Hook for subclass.
Eigen::VectorXf tcpWeightVec
Eigen::MatrixXf calcFullJacobian()
EDifferentialIK(VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr coordSystem=VirtualRobot::RobotNodePtr(), VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod=eSVD)
The TCPControlUnit class.
void reportJointAccelerations(const NameValueMap &jointAccelerations, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c) override
void reportControlModeChanged(const NameControlModeMap &, Ice::Long timestamp, bool, const Ice::Current &) override
This file offers overloads of toIce() and fromIce() functions for STL container types.
void setTCPVelocity(const std::string &nodeSetName, const std::string &tcpName, const ::armarx::FramedDirectionBasePtr &translationVelocity, const ::armarx::FramedDirectionBasePtr &orientationVelocityRPY, const Ice::Current &c=Ice::emptyCurrent) override
Sets the cartesian velocity of a node in a nodeset for translation and/or orientation.
std::shared_ptr< class Robot > RobotPtr