33MoveJointsVelControl::SubClassRegistry
57 if (jointNames->getSize() != targetJointValues->getSize())
59 throw LocalException(
"Sizes of joint name list and joint value list do not match!");
66 Eigen::VectorXf errorJoint(jointNames->getSize());
67 Eigen::VectorXf currentJoint(jointNames->getSize());
68 ARMARX_VERBOSE <<
"number of joints that will be set: " << jointNames->getSize()
69 <<
", maxVel:" << maxVel <<
flush;
71 for (
int i = 0; i < jointNames->getSize(); i++)
74 robot->getRobotNode(jointNames->getVariant(i)->getString())->getJointValue();
75 errorJoint(i) = targetJointValues->getVariant(i)->getFloat() - currentJoint(i);
110 float VEL_GAIN = 1.0f;
111 float VEL_MAX_COEFF = 0.02f;
114 float maxV = fabs(errorJoint.maxCoeff());
116 if (maxV > VEL_MAX_COEFF)
118 errorJoint = errorJoint / maxV * VEL_MAX_COEFF * VEL_GAIN;
124 NameValueMap targetVelocities;
125 NameValueMap targetAngles;
126 NameControlModeMap controlModes;
129 for (
int i = 0; i < jointNames->getSize(); i++)
131 std::string jName = jointNames->getVariant(i)->getString();
132 targetVelocities[jName] = errorJoint(i) * VEL_GAIN;
133 targetAngles[jName] = currentJoint(i) + errorJoint(i);
134 controlModes[jName] = ePositionVelocityControl;
204 if (!robot->hasRobotNodeSet(kinChainName))
206 ARMARX_WARNING <<
"Robot does not know kinematic chain with name " << kinChainName <<
flush;
210 VirtualRobot::RobotNodeSetPtr rns = robot->getRobotNodeSet(kinChainName);
213 NameValueMap targetJointVelocities;
215 for (
unsigned int i = 0; i < rns->getSize(); i++)
217 targetJointVelocities[rns->getNode(i)->getName()] = 0;
227 return "MoveJointsVelControl";
void onBreak() override
Virtual function, in which the behaviour of state is defined, when it is abnormally exited....
static SubClassRegistry Registry
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
static std::string GetName()
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
MoveJointsVelControl(XMLStateConstructorParams stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Mimics the behaviour of the VirtualRobot::Robot class while redirecting everything to an Ice proxy.
VirtualRobot::RobotPtr createLocalClone()
Clones the structure of this remote robot to a local instance.
RobotStateComponentInterfacePrx robotStateComponent
Prx for the RobotState.
KinematicUnitInterfacePrx kinematicUnitPrx
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...
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.
bool isInputParameterSet(const std::string &key) const
Checks whether a given input parameter is set or not.
XMLStateTemplate(const XMLStateConstructorParams ¶ms)
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#define ARMARX_VERBOSE
The logging level for verbose information.
std::shared_ptr< class Robot > RobotPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< SingleTypeVariantList > SingleTypeVariantListPtr
const LogSender::manipulator flush
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr