27#include <VirtualRobot/LinkedCoordinate.h>
46 using namespace Eigen;
51 VirtualRobot::LinkedCoordinate actualPose(robot);
55 actualPose.changeFrame(robot->getRootNode());
56 Vector3f actualPosition = actualPose.getPosition();
57 Quaternionf actualOrientation(actualPose.getPose().block<3, 3>(0, 0));
60 VirtualRobot::LinkedCoordinate targetPose =
64 targetPose.changeFrame(robot->getRootNode());
65 Vector3f targetPosition = targetPose.getPosition();
66 Quaternionf targetOrientation(targetPose.getPose().block<3, 3>(0, 0));
68 float cartesianDistance =
69 sqrtf(((targetPosition - actualPosition).
dot(targetPosition - actualPosition)));
70 float orientationDistance = actualOrientation.angularDistance(targetOrientation);
72 setOutput(
"TCPDistanceToTarget", cartesianDistance);
73 setOutput(
"TCPOrientationDistanceToTarget", orientationDistance);
76 if (cartesianDistance <=
getInput<float>(
"targetPositionDistanceTolerance") &&
77 (!withOri || orientationDistance <=
getInput<float>(
"targetOrientationDistanceTolerance")))
84 <<
"Target pose has not been reached with the desired accuracy. Cartesian distance: "
85 << cartesianDistance <<
", orientation distance: " << orientationDistance <<
" ";
86 ARMARX_INFO <<
"Actual pose: " << actualPose.getPose();
87 ARMARX_INFO <<
"Target pose: " << targetPose.getPose();
98 return "ValidateTcpPose";
ValidateTcpPose(XMLStateConstructorParams stateData)
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
static std::string GetName()
static SubClassRegistry Registry
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
static VirtualRobot::LinkedCoordinate createLinkedCoordinate(const VirtualRobot::RobotPtr &virtualRobot, const FramedPositionPtr &position, const FramedOrientationPtr &orientation)
Mimics the behaviour of the VirtualRobot::Robot class while redirecting everything to an Ice proxy.
RobotStateComponentInterfacePrx robotStateComponent
Prx for the RobotState.
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.
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.
#define ARMARX_VERBOSE
The logging level for verbose information.
Quaternion< float, 0 > Quaternionf
std::shared_ptr< class Robot > RobotPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
double dot(const Point &x, const Point &y)