Go to the documentation of this file.
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>
49 defineRequiredProperty<std::string>(
"KinematicUnitName",
50 "Name of the KinematicUnit Proxy");
51 defineOptionalProperty<std::string>(
52 "RobotStateTopicName",
"RobotState",
"Name of the RobotComponent State topic.");
53 defineOptionalProperty<float>(
54 "MaxJointVelocity", 30.f / 180 * 3.141,
"Maximal joint velocity in rad/sec");
55 defineOptionalProperty<int>(
"CycleTime", 30,
"Cycle time of the tcp control in ms");
57 defineOptionalProperty<std::string>(
60 "comma seperated list of nodesets' endeffectors, which poses and velocities that "
61 "should be reported. * for all, empty for none");
62 defineOptionalProperty<std::string>(
63 "RobotStateComponentName",
64 "RobotStateComponent",
65 "Name of the RobotStateComponent that should be used");
67 defineOptionalProperty<float>(
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,
203 Eigen::VectorXf applyMaxJointVelocity(
const Eigen::VectorXf& jointVelocity,
204 float maxJointVelocity);
206 float maxJointVelocity;
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;
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);
317 VirtualRobot::RobotNodePtr tcp,
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;
334 void applyTCPWeights(VirtualRobot::RobotNodePtr tcp, Eigen::MatrixXf& partJacobian);
339 bool solveIK(
float stepSize = 1,
340 float minChange = 0.01f,
342 bool useAlternativeOnFail =
false);
348 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
MatrixXX< 4, 4, float > Matrix4f
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
::std::map<::std::string, ::armarx::FramedPoseBasePtr > FramedPoseBaseMap
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.
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
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