27#include <VirtualRobot/IK/DifferentialIK.h>
28#include <VirtualRobot/VirtualRobot.h>
32#include <ArmarXCore/interface/observers/ObserverInterface.h>
34#include <RobotAPI/interface/units/TCPControlUnit.h>
50 "Name of the KinematicUnit Proxy");
52 "RobotStateTopicName",
"RobotState",
"Name of the RobotComponent State topic.");
54 "MaxJointVelocity", 30.f / 180 * 3.141,
"Maximal joint velocity in rad/sec");
60 "comma seperated list of nodesets' endeffectors, which poses and velocities that "
61 "should be reported. * for all, empty for none");
63 "RobotStateComponentName",
64 "RobotStateComponent",
65 "Name of the RobotStateComponent that should be used");
70 "Parameter used for smoothing the differential IK near singularities.");
110 const Ice::Current&
c = Ice::emptyCurrent)
override;
128 const std::string& tcpName,
129 const ::armarx::FramedDirectionBasePtr& translationVelocity,
130 const ::armarx::FramedDirectionBasePtr& orientationVelocityRPY,
131 const Ice::Current&
c = Ice::emptyCurrent)
override;
138 void init(
const Ice::Current&
c = Ice::emptyCurrent)
override;
143 void start(
const Ice::Current&
c = Ice::emptyCurrent)
override;
148 void stop(
const Ice::Current&
c = Ice::emptyCurrent)
override;
149 UnitExecutionState
getExecutionState(
const Ice::Current&
c = Ice::emptyCurrent)
override;
156 void request(
const Ice::Current&
c = Ice::emptyCurrent)
override;
164 void release(
const Ice::Current&
c = Ice::emptyCurrent)
override;
166 bool isRequested(
const Ice::Current&
c = Ice::emptyCurrent)
override;
177 return "TCPControlUnit";
184 const Eigen::MatrixXf& jacobian,
185 const Eigen::MatrixXf& jacobianInverse);
186 static Eigen::VectorXf
188 const Eigen::MatrixXf& jacobian,
189 const Eigen::MatrixXf& jacobianInverse,
190 Eigen::VectorXf desiredJointValues = Eigen::VectorXf());
194 static void ContinuousAngles(
const Eigen::AngleAxisf& oldAngle,
195 Eigen::AngleAxisf& newAngle,
198 void periodicReport();
199 Eigen::VectorXf calcJointVelocities(VirtualRobot::RobotNodeSetPtr robotNodeSet,
200 Eigen::VectorXf tcpDelta,
201 VirtualRobot::RobotNodePtr refFrame,
202 VirtualRobot::IKSolver::CartesianSelection mode);
203 Eigen::VectorXf applyMaxJointVelocity(
const Eigen::VectorXf& jointVelocity,
204 float maxJointVelocity);
206 float maxJointVelocity;
208 Eigen::Matrix4f lastTCPPose;
210 struct TCPVelocityData
214 std::string nodeSetName;
218 using TCPVelocityDataMap = std::map<std::string, TCPVelocityData>;
219 TCPVelocityDataMap tcpVelocitiesMap, localTcpVelocitiesMap;
221 using DIKMap = std::map<std::string, VirtualRobot::DifferentialIKPtr>;
222 DIKMap dIKMap, localDIKMap;
227 std::string robotName;
229 KinematicUnitInterfacePrx kinematicUnitPrx;
234 TCPControlUnitListenerPrx listener;
239 std::map<std::string, double> oriOffsets;
241 std::vector<VirtualRobot::RobotNodePtr> nodesToReport;
243 IceUtil::Time lastTopicReportTime;
245 std::mutex dataMutex;
246 std::mutex taskMutex;
247 std::mutex reportMutex;
248 bool calculationRunning;
249 double syncTimeDelta;
251 std::string topicName;
259 const Ice::Current&)
override;
263 const Ice::Current&)
override;
267 const Ice::Current&)
override;
271 const Ice::Current&)
override;
275 const Ice::Current&
c)
override;
279 const Ice::Current&)
override;
283 const Ice::Current&)
override;
287 const Ice::Current&)
override;
296 VirtualRobot::RobotNodePtr coordSystem = VirtualRobot::RobotNodePtr(),
297 VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod = eSVD);
299 VirtualRobot::RobotNodePtr
314 void setRefFrame(VirtualRobot::RobotNodePtr coordSystem);
316 void setGoal(
const Eigen::Matrix4f& goal,
317 VirtualRobot::RobotNodePtr tcp,
318 VirtualRobot::IKSolver::CartesianSelection mode,
319 float tolerancePosition,
320 float toleranceRotation,
321 Eigen::VectorXf tcpWeight);
326 computeSteps(
float stepSize = 1.f,
float mininumChange = 0.01f,
int maxNStep = 50)
override;
328 float stepSize = 1.f,
329 float mininumChange = 0.01f,
332 Eigen::VectorXf
computeStep(
float stepSize)
override;
339 bool solveIK(
float stepSize = 1,
340 float minChange = 0.01f,
342 bool useAlternativeOnFail =
false);
348 std::map<VirtualRobot::SceneObjectPtr, Eigen::VectorXf>
tcpWeights;
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Component()
Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
Eigen::VectorXf computeStep(float stepSize) override
bool computeSteps(Eigen::VectorXf &resultJointDelta, float stepSize=1.f, float mininumChange=0.01f, int maxNStep=50, ComputeFunction computeFunction=&DifferentialIK::computeStep)
std::map< VirtualRobot::SceneObjectPtr, Eigen::VectorXf > tcpWeights
void setGoal(const Eigen::Matrix4f &goal, VirtualRobot::RobotNodePtr tcp, VirtualRobot::IKSolver::CartesianSelection mode, float tolerancePosition, float toleranceRotation, Eigen::VectorXf tcpWeight)
void applyDOFWeightsToJacobian(Eigen::MatrixXf &Jacobian)
Eigen::VectorXf tcpWeightVec
bool solveIK(float stepSize=1, float minChange=0.01f, int maxSteps=50, bool useAlternativeOnFail=false)
Eigen::VectorXf(EDifferentialIK::* ComputeFunction)(float)
VirtualRobot::RobotNodePtr getRefFrame()
void applyTCPWeights(VirtualRobot::RobotNodePtr tcp, Eigen::MatrixXf &partJacobian)
bool adjustDOFWeightsToJointLimits(const Eigen::VectorXf &plannedJointDeltas)
Eigen::VectorXf computeStepIndependently(float stepSize)
float getWeightedErrorPosition(VirtualRobot::SceneObjectPtr tcp)
Eigen::MatrixXf calcFullJacobian()
void setRefFrame(VirtualRobot::RobotNodePtr coordSystem)
void applyTCPWeights(Eigen::MatrixXf &invJacobian)
EDifferentialIK(VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr coordSystem=VirtualRobot::RobotNodePtr(), VirtualRobot::JacobiProvider::InverseJacobiMethod invJacMethod=eSVD)
bool computeSteps(float stepSize=1.f, float mininumChange=0.01f, int maxNStep=50) override
Eigen::VectorXf dofWeights
void setDOFWeights(Eigen::VectorXf dofWeights)
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
TCPControlUnitPropertyDefinitions(std::string prefix)
void onInitComponent() override
Pure virtual hook for the subclass.
static Eigen::VectorXf CalcNullspaceJointDeltas(const Eigen::VectorXf &desiredJointDeltas, const Eigen::MatrixXf &jacobian, const Eigen::MatrixXf &jacobianInverse)
void start(const Ice::Current &c=Ice::emptyCurrent) override
Does not do anything at the moment.
void release(const Ice::Current &c=Ice::emptyCurrent) override
Releases and stops the recalculation and updating of joint velocities.
UnitExecutionState getExecutionState(const Ice::Current &c=Ice::emptyCurrent) override
void reportJointMotorTemperatures(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &) override
void reportControlModeChanged(const NameControlModeMap &, Ice::Long timestamp, bool, const Ice::Current &) override
void onDisconnectComponent() override
Hook for subclass.
static Eigen::VectorXf CalcJointLimitAvoidanceDeltas(VirtualRobot::RobotNodeSetPtr robotNodeSet, const Eigen::MatrixXf &jacobian, const Eigen::MatrixXf &jacobianInverse, Eigen::VectorXf desiredJointValues=Eigen::VectorXf())
void init(const Ice::Current &c=Ice::emptyCurrent) override
Does not do anything at the moment.
void setCycleTime(Ice::Int milliseconds, const Ice::Current &c=Ice::emptyCurrent) override
Sets the cycle time with which the joint velocities are recalculated.
void reportJointTorques(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &) override
void stop(const Ice::Current &c=Ice::emptyCurrent) override
Does not do anything at the moment.
void reportJointAngles(const NameValueMap &jointAngles, Ice::Long timestamp, bool, const Ice::Current &) override
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.
bool isRequested(const Ice::Current &c=Ice::emptyCurrent) override
void onConnectComponent() override
Pure virtual hook for the subclass.
void request(const Ice::Current &c=Ice::emptyCurrent) override
Triggers the calculation loop for using cartesian velocity.
void reportJointAccelerations(const NameValueMap &jointAccelerations, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c) override
PropertyDefinitionsPtr createPropertyDefinitions() override
void calcAndSetVelocities()
void onExitComponent() override
Hook for subclass.
void reportJointCurrents(const NameValueMap &, Ice::Long timestamp, bool, const Ice::Current &) override
std::string getDefaultName() const override
Retrieve default name of component.
void reportJointStatuses(const NameStatusMap &, Ice::Long timestamp, bool, const Ice::Current &) override
void reportJointVelocities(const NameValueMap &jointVel, Ice::Long timestamp, bool, const Ice::Current &) override
std::shared_ptr< class Robot > RobotPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceInternal::Handle< FramedDirection > FramedDirectionPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
std::shared_ptr< EDifferentialIK > EDifferentialIKPtr
::std::map<::std::string, ::armarx::FramedPoseBasePtr > FramedPoseBaseMap