31#include <VirtualRobot/IK/GenericIKSolver.h>
32#include <VirtualRobot/LinkedCoordinate.h>
33#include <VirtualRobot/RobotNodeSet.h>
41CalculateJointAngleConfiguration::SubClassRegistry
66 float maxErrorRot =
getInput<float>(
"targetOrientationDistanceTolerance");
68 VirtualRobot::IKSolver::CartesianSelection ikType = VirtualRobot::IKSolver::All;
72 ikType = VirtualRobot::IKSolver::Position;
98 if (!robot->hasRobotNodeSet(kinChainName))
100 ARMARX_WARNING <<
"Robot does not know kinematic chain with name " << kinChainName <<
flush;
104 ARMARX_INFO <<
"Setting up ik solver for kin chain: " << kinChainName
105 <<
", max position error:" << maxError <<
", max orientation erorr " << maxErrorRot
107 VirtualRobot::GenericIKSolverPtr ikSolver(
new VirtualRobot::GenericIKSolver(
108 robot->getRobotNodeSet(kinChainName), VirtualRobot::JacobiProvider::eSVDDamped));
109 ikSolver->setVerbose(
true);
110 ikSolver->setMaximumError(maxError, maxErrorRot);
111 ikSolver->setupJacobian(0.6f, 10);
113 VirtualRobot::LinkedCoordinate target =
118 Eigen::Matrix4f goalInRoot = target.getInFrame(robot->getRootNode());
123 Eigen::Matrix4f goalGlobal = robot->getRootNode()->toGlobalCoordinateSystem(goalInRoot);
131 if (!ikSolver->solve(goalGlobal, ikType, 5))
141 VirtualRobot::RobotNodeSetPtr kinematicChain = robot->getRobotNodeSet(kinChainName);
143 for (
int i = 0; i < (
signed int)kinematicChain->getSize(); i++)
146 targetJointValues.
addVariant(
Variant(kinematicChain->getNode(i)->getJointValue()));
147 ARMARX_LOG <<
" joint: " << kinematicChain->getNode(i)->getName()
148 <<
" value: " << kinematicChain->getNode(i)->getJointValue() <<
flush;
155 setOutput(
"targetJointValues", targetJointValues);
164 return "CalculateJointAngleConfiguration";
static VirtualRobot::LinkedCoordinate createLinkedCoordinate(const VirtualRobot::RobotPtr &virtualRobot, const FramedPositionPtr &position, const FramedOrientationPtr &orientation)
static SubClassRegistry Registry
static std::string GetName()
void run() override
Virtual function, that can be reimplemented to calculate complex operations.
CalculateJointAngleConfiguration(XMLStateConstructorParams stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
VirtualRobot::RobotPtr createLocalClone()
Clones the structure of this remote robot to a local instance.
RobotStateComponentInterfacePrx robotStateComponent
Prx for the RobotState.
The SingleTypeVariantList class is a subclass of VariantContainer and is comparable to a std::vector<...
void addVariant(const Variant &variant)
int getSize(const Ice::Current &c=Ice::emptyCurrent) const override
ContextType * getContext() const
void sendEvent(const EventPtr event, StateBasePtr eventProcessor=nullptr)
Function to send an event to a specific state from an onEnter()-function. Must not be called anywhere...
void setOutput(std::string const &key, const Variant &value)
setOuput() sets an output parameter of this state.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getInput(const std::string &key) const
getInput can be used to access a specific input parameter.
The Variant class is described here: Variants.
XMLStateTemplate(const XMLStateConstructorParams ¶ms)
#define ARMARX_INFO
The normal logging level.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
std::shared_ptr< class Robot > RobotPtr
const VariantTypeId String
const VariantTypeId Float
This file offers overloads of toIce() and fromIce() functions for STL container types.
const LogSender::manipulator flush
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr