38 #ifndef MOVEIT_CORE_ROBOT_STATE_ 39 #define MOVEIT_CORE_ROBOT_STATE_ 43 #include <sensor_msgs/JointState.h> 44 #include <visualization_msgs/MarkerArray.h> 45 #include <std_msgs/ColorRGBA.h> 46 #include <geometry_msgs/Twist.h> 49 #include <boost/assert.hpp> 61 typedef boost::function<bool(RobotState*
robot_state,
const JointModelGroup* joint_group,
62 const double* joint_group_variable_values)>
87 revolute = jt_revolute;
88 prismatic = jt_prismatic;
99 MaxEEFStep(
double translation,
double rotation) : translation(translation), rotation(rotation)
103 MaxEEFStep(
double step_size) : translation(step_size), rotation(3.5 * step_size)
151 return robot_model_->getVariableCount();
157 return robot_model_->getVariableNames();
163 return robot_model_->getLinkModel(link);
169 return robot_model_->getJointModel(joint);
175 return robot_model_->getJointModelGroup(group);
201 void setVariablePositions(
const double* position);
208 assert(robot_model_->getVariableCount() <= position.size());
209 setVariablePositions(&position[0]);
214 void setVariablePositions(
const std::map<std::string, double>& variable_map);
218 void setVariablePositions(
const std::map<std::string, double>& variable_map,
219 std::vector<std::string>& missing_variables);
223 void setVariablePositions(
const std::vector<std::string>& variable_names,
224 const std::vector<double>& variable_position);
229 setVariablePosition(robot_model_->getVariableIndex(variable), value);
236 position_[index] = value;
237 const JointModel* jm = robot_model_->getJointOfVariable(index);
240 markDirtyJointTransforms(jm);
241 updateMimicJoint(jm);
248 return position_[robot_model_->getVariableIndex(variable)];
256 return position_[index];
270 return has_velocity_;
289 void zeroVelocities();
294 has_velocity_ =
true;
296 memcpy(velocity_, velocity, robot_model_->getVariableCount() *
sizeof(double));
302 assert(robot_model_->getVariableCount() <= velocity.size());
303 setVariableVelocities(&velocity[0]);
308 void setVariableVelocities(
const std::map<std::string, double>& variable_map);
312 void setVariableVelocities(
const std::map<std::string, double>& variable_map,
313 std::vector<std::string>& missing_variables);
317 void setVariableVelocities(
const std::vector<std::string>& variable_names,
318 const std::vector<double>& variable_velocity);
323 setVariableVelocity(robot_model_->getVariableIndex(variable), value);
331 velocity_[index] = value;
337 return velocity_[robot_model_->getVariableIndex(variable)];
345 return velocity_[index];
349 void dropVelocities();
363 return has_acceleration_;
372 return acceleration_;
379 return acceleration_;
383 void zeroAccelerations();
389 has_acceleration_ =
true;
393 memcpy(acceleration_, acceleration, robot_model_->getVariableCount() *
sizeof(double));
400 assert(robot_model_->getVariableCount() <= acceleration.size());
401 setVariableAccelerations(&acceleration[0]);
406 void setVariableAccelerations(
const std::map<std::string, double>& variable_map);
411 void setVariableAccelerations(
const std::map<std::string, double>& variable_map,
412 std::vector<std::string>& missing_variables);
416 void setVariableAccelerations(
const std::vector<std::string>& variable_names,
417 const std::vector<double>& variable_acceleration);
422 setVariableAcceleration(robot_model_->getVariableIndex(variable), value);
430 acceleration_[index] = value;
436 return acceleration_[robot_model_->getVariableIndex(variable)];
444 return acceleration_[index];
448 void dropAccelerations();
487 has_acceleration_ =
false;
489 memcpy(effort_, effort, robot_model_->getVariableCount() *
sizeof(double));
495 assert(robot_model_->getVariableCount() <= effort.size());
496 setVariableEffort(&effort[0]);
500 void setVariableEffort(
const std::map<std::string, double>& variable_map);
504 void setVariableEffort(
const std::map<std::string, double>& variable_map, std::vector<std::string>& missing_variables);
507 void setVariableEffort(
const std::vector<std::string>& variable_names,
508 const std::vector<double>& variable_acceleration);
513 setVariableEffort(robot_model_->getVariableIndex(variable), value);
521 effort_[index] = value;
527 return effort_[robot_model_->getVariableIndex(variable)];
535 return effort_[index];
545 void invertVelocity();
556 setJointPositions(robot_model_->getJointModel(joint_name), position);
561 setJointPositions(robot_model_->getJointModel(joint_name), &position[0]);
566 setJointPositions(joint, &position[0]);
572 markDirtyJointTransforms(joint);
573 updateMimicJoint(joint);
578 setJointPositions(robot_model_->getJointModel(joint_name), transform);
584 markDirtyJointTransforms(joint);
585 updateMimicJoint(joint);
590 has_velocity_ =
true;
594 void setJointEfforts(
const JointModel* joint,
const double* effort);
598 return getJointPositions(robot_model_->getJointModel(joint_name));
608 return getJointVelocities(robot_model_->getJointModel(joint_name));
618 return getJointAccelerations(robot_model_->getJointModel(joint_name));
628 return getJointEffort(robot_model_->getJointModel(joint_name));
647 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
649 setJointGroupPositions(jmg, gstate);
657 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
661 setJointGroupPositions(jmg, &gstate[0]);
671 setJointGroupPositions(group, &gstate[0]);
677 void setJointGroupPositions(
const JointModelGroup* group,
const double* gstate);
684 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
688 setJointGroupPositions(jmg, values);
700 void setJointGroupActivePositions(
const JointModelGroup* group,
const std::vector<double>& gstate);
707 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
711 setJointGroupActivePositions(jmg, gstate);
718 void setJointGroupActivePositions(
const JointModelGroup* group,
const Eigen::VectorXd& values);
725 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
729 setJointGroupActivePositions(jmg, values);
738 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
742 copyJointGroupPositions(jmg, &gstate[0]);
751 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
753 copyJointGroupPositions(jmg, gstate);
762 copyJointGroupPositions(group, &gstate[0]);
768 void copyJointGroupPositions(
const JointModelGroup* group,
double* gstate)
const;
775 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
777 copyJointGroupPositions(jmg, values);
783 void copyJointGroupPositions(
const JointModelGroup* group, Eigen::VectorXd& values)
const;
796 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
798 setJointGroupVelocities(jmg, gstate);
806 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
808 setJointGroupVelocities(jmg, &gstate[0]);
816 setJointGroupVelocities(group, &gstate[0]);
822 void setJointGroupVelocities(
const JointModelGroup* group,
const double* gstate);
829 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
831 setJointGroupVelocities(jmg, values);
837 void setJointGroupVelocities(
const JointModelGroup* group,
const Eigen::VectorXd& values);
844 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
848 copyJointGroupVelocities(jmg, &gstate[0]);
857 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
859 copyJointGroupVelocities(jmg, gstate);
868 copyJointGroupVelocities(group, &gstate[0]);
874 void copyJointGroupVelocities(
const JointModelGroup* group,
double* gstate)
const;
881 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
883 copyJointGroupVelocities(jmg, values);
889 void copyJointGroupVelocities(
const JointModelGroup* group, Eigen::VectorXd& values)
const;
902 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
904 setJointGroupAccelerations(jmg, gstate);
912 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
914 setJointGroupAccelerations(jmg, &gstate[0]);
922 setJointGroupAccelerations(group, &gstate[0]);
928 void setJointGroupAccelerations(
const JointModelGroup* group,
const double* gstate);
935 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
937 setJointGroupAccelerations(jmg, values);
943 void setJointGroupAccelerations(
const JointModelGroup* group,
const Eigen::VectorXd& values);
950 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
954 copyJointGroupAccelerations(jmg, &gstate[0]);
963 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
965 copyJointGroupAccelerations(jmg, gstate);
974 copyJointGroupAccelerations(group, &gstate[0]);
980 void copyJointGroupAccelerations(
const JointModelGroup* group,
double* gstate)
const;
987 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
989 copyJointGroupAccelerations(jmg, values);
995 void copyJointGroupAccelerations(
const JointModelGroup* group, Eigen::VectorXd& values)
const;
1009 bool setFromIK(
const JointModelGroup* group,
const geometry_msgs::Pose& pose,
double timeout = 0.0,
1012 [[deprecated(
"The attempts argument is not supported anymore.")]]
bool 1017 return setFromIK(group, pose, timeout, constraint,
options);
1027 bool setFromIK(
const JointModelGroup* group,
const geometry_msgs::Pose& pose,
const std::string& tip,
1030 [[deprecated(
"The attempts argument is not supported anymore.")]]
bool 1032 unsigned int ,
double timeout = 0.0,
1036 return setFromIK(group, pose, tip, timeout, constraint,
options);
1045 bool setFromIK(
const JointModelGroup* group,
const Eigen::Isometry3d& pose,
double timeout = 0.0,
1048 [[deprecated(
"The attempts argument is not supported anymore.")]]
bool 1053 return setFromIK(group, pose, timeout, constraint,
options);
1062 bool setFromIK(
const JointModelGroup* group,
const Eigen::Isometry3d& pose,
const std::string& tip,
1065 [[deprecated(
"The attempts argument is not supported anymore.")]]
bool 1067 unsigned int ,
double timeout = 0.0,
1071 return setFromIK(group, pose, tip, timeout, constraint,
options);
1082 bool setFromIK(
const JointModelGroup* group,
const Eigen::Isometry3d& pose,
const std::string& tip,
1083 const std::vector<double>& consistency_limits,
double timeout = 0.0,
1086 [[deprecated(
"The attempts argument is not supported anymore.")]]
bool 1088 const std::vector<double>& consistency_limits,
unsigned int ,
double timeout = 0.0,
1092 return setFromIK(group, pose, tip, consistency_limits, timeout, constraint,
options);
1105 const std::vector<std::string>& tips,
double timeout = 0.0,
1108 [[deprecated(
"The attempts argument is not supported anymore.")]]
bool 1110 const std::vector<std::string>& tips,
unsigned int ,
double timeout = 0.0,
1114 return setFromIK(group, poses, tips, timeout, constraint,
options);
1128 const std::vector<std::string>& tips,
const std::vector<std::vector<double> >& consistency_limits,
1131 [[deprecated(
"The attempts argument is not supported anymore.")]]
bool 1133 const std::vector<std::string>& tips,
const std::vector<std::vector<double> >& consistency_limits,
1134 unsigned int ,
double timeout = 0.0,
1138 return setFromIK(group, poses, tips, consistency_limits, timeout, constraint,
options);
1150 const std::vector<std::string>& tips,
1151 const std::vector<std::vector<double> >& consistency_limits,
double timeout = 0.0,
1154 [[deprecated(
"The attempts argument is not supported anymore.")]]
bool 1156 const std::vector<std::string>& tips,
const std::vector<std::vector<double> >& consistency_limits,
1157 unsigned int ,
double timeout = 0.0,
1161 return setFromIKSubgroups(group, poses, tips, consistency_limits, timeout, constraint,
options);
1171 bool setFromDiffIK(
const JointModelGroup* group,
const Eigen::VectorXd& twist,
const std::string& tip,
double dt,
1181 bool setFromDiffIK(
const JointModelGroup* group,
const geometry_msgs::Twist& twist,
const std::string& tip,
double dt,
1221 const Eigen::Vector3d& direction,
bool global_reference_frame,
double distance,
1222 double max_step,
double jump_threshold_factor,
1226 return computeCartesianPath(group, traj, link, direction, global_reference_frame, distance,
1238 const Eigen::Isometry3d& target,
bool global_reference_frame,
const MaxEEFStep& max_step,
1244 const Eigen::Isometry3d& target,
bool global_reference_frame,
double max_step,
1245 double jump_threshold_factor,
1249 return computeCartesianPath(group, traj, link, target, global_reference_frame,
MaxEEFStep(max_step),
1267 double max_step,
double jump_threshold_factor,
1271 return computeCartesianPath(group, traj, link, waypoints, global_reference_frame,
MaxEEFStep(max_step),
1290 static double testJointSpaceJump(
const JointModelGroup* group, std::vector<RobotStatePtr>& traj,
1303 static double testRelativeJointSpaceJump(
const JointModelGroup* group, std::vector<RobotStatePtr>& traj,
1304 double jump_threshold_factor);
1318 static double testAbsoluteJointSpaceJump(
const JointModelGroup* group, std::vector<RobotStatePtr>& traj,
1319 double revolute_jump_threshold,
double prismatic_jump_threshold);
1331 Eigen::MatrixXd& jacobian,
bool use_quaternion_representation =
false)
const;
1343 Eigen::MatrixXd& jacobian,
bool use_quaternion_representation =
false)
1345 updateLinkTransforms();
1346 return static_cast<const RobotState*
>(
this)->getJacobian(group, link, reference_point_position, jacobian,
1347 use_quaternion_representation);
1368 updateLinkTransforms();
1369 return static_cast<const RobotState*
>(
this)->getJacobian(group, reference_point_position);
1374 void computeVariableVelocity(
const JointModelGroup* jmg, Eigen::VectorXd& qdot,
const Eigen::VectorXd& twist,
1382 updateLinkTransforms();
1383 static_cast<const RobotState*
>(
this)->computeVariableVelocity(jmg, qdot, twist, tip);
1389 bool integrateVariableVelocity(
const JointModelGroup* jmg,
const Eigen::VectorXd& qdot,
double dt,
1400 if (!msg.position.empty())
1401 setVariablePositions(msg.name, msg.position);
1402 if (!msg.velocity.empty())
1403 setVariableVelocities(msg.name, msg.velocity);
1409 void setToDefaultValues();
1412 bool setToDefaultValues(
const JointModelGroup* group,
const std::string& name);
1415 void setToRandomPositions();
1439 const std::vector<double>& distances);
1449 void updateCollisionBodyTransforms();
1453 void updateLinkTransforms();
1456 void update(
bool force =
false);
1468 updateStateWithLinkAt(robot_model_->getLinkModel(link_name), transform, backward);
1472 void updateStateWithLinkAt(
const LinkModel* link,
const Eigen::Isometry3d& transform,
bool backward =
false);
1476 return getGlobalLinkTransform(robot_model_->getLinkModel(link_name));
1481 updateLinkTransforms();
1487 return getCollisionBodyTransform(robot_model_->getLinkModel(link_name), index);
1492 updateCollisionBodyTransforms();
1498 return getJointTransform(robot_model_->getJointModel(joint_name));
1504 unsigned char& dirty = dirty_joint_transforms_[idx];
1510 return variable_joint_transforms_[idx];
1515 return getGlobalLinkTransform(robot_model_->getLinkModel(link_name));
1520 BOOST_VERIFY(checkLinkTransforms());
1526 return getCollisionBodyTransform(robot_model_->getLinkModel(link_name), index);
1531 BOOST_VERIFY(checkCollisionTransforms());
1537 return getJointTransform(robot_model_->getJointModel(joint_name));
1542 BOOST_VERIFY(checkJointTransforms(joint));
1553 return dirty_link_transforms_;
1558 return dirty_link_transforms_ || dirty_collision_body_transforms_;
1564 return dirtyCollisionBodyTransforms();
1627 void enforceBounds();
1631 enforcePositionBounds(joint);
1633 enforceVelocityBounds(joint);
1639 markDirtyJointTransforms(joint);
1640 updateMimicJoint(joint);
1645 void harmonizePositions();
1651 updateMimicJoint(joint);
1659 bool satisfiesBounds(
double margin = 0.0)
const;
1660 bool satisfiesBounds(
const JointModelGroup* joint_group,
double margin = 0.0)
const;
1663 return satisfiesPositionBounds(joint, margin) && (!has_velocity_ || satisfiesVelocityBounds(joint, margin));
1676 std::pair<double, const JointModel*> getMinDistanceToPositionBounds()
const;
1680 std::pair<double, const JointModel*> getMinDistanceToPositionBounds(
const JointModelGroup* group)
const;
1684 std::pair<double, const JointModel*>
1685 getMinDistanceToPositionBounds(
const std::vector<const JointModel*>& joints)
const;
1736 void attachBody(
const std::string&
id,
const std::vector<shapes::ShapeConstPtr>&
shapes,
1738 const std::string& link_name,
1739 const trajectory_msgs::JointTrajectory& detach_posture = trajectory_msgs::JointTrajectory());
1755 void attachBody(
const std::string&
id,
const std::vector<shapes::ShapeConstPtr>& shapes,
1757 const std::string& link_name,
1758 const trajectory_msgs::JointTrajectory& detach_posture = trajectory_msgs::JointTrajectory())
1760 std::set<std::string> touch_links_set(touch_links.begin(), touch_links.end());
1761 attachBody(
id, shapes, attach_trans, touch_links_set, link_name, detach_posture);
1765 void getAttachedBodies(std::vector<const AttachedBody*>& attached_bodies)
const;
1768 void getAttachedBodies(std::vector<const AttachedBody*>& attached_bodies,
const JointModelGroup* lm)
const;
1771 void getAttachedBodies(std::vector<const AttachedBody*>& attached_bodies,
const LinkModel* lm)
const;
1775 bool clearAttachedBody(
const std::string&
id);
1778 void clearAttachedBodies(
const LinkModel* link);
1784 void clearAttachedBodies();
1787 const AttachedBody* getAttachedBody(
const std::string& name)
const;
1790 bool hasAttachedBody(
const std::string&
id)
const;
1797 void computeAABB(std::vector<double>& aabb)
const;
1803 updateLinkTransforms();
1804 static_cast<const RobotState*
>(
this)->computeAABB(aabb);
1816 const Eigen::Isometry3d& getFrameTransform(
const std::string& frame_id);
1819 const Eigen::Isometry3d& getFrameTransform(
const std::string& frame_id)
const;
1822 bool knowsFrameTransform(
const std::string& frame_id)
const;
1831 void getRobotMarkers(visualization_msgs::MarkerArray& arr,
const std::vector<std::string>& link_names,
1832 const std_msgs::ColorRGBA& color,
const std::string& ns,
const ros::Duration& dur,
1833 bool include_attached =
false)
const;
1842 void getRobotMarkers(visualization_msgs::MarkerArray& arr,
const std::vector<std::string>& link_names,
1843 const std_msgs::ColorRGBA& color,
const std::string& ns,
const ros::Duration& dur,
1844 bool include_attached =
false)
1846 updateCollisionBodyTransforms();
1847 static_cast<const RobotState*
>(
this)->getRobotMarkers(arr, link_names, color, ns, dur, include_attached);
1854 void getRobotMarkers(visualization_msgs::MarkerArray& arr,
const std::vector<std::string>& link_names,
1855 bool include_attached =
false)
const;
1861 void getRobotMarkers(visualization_msgs::MarkerArray& arr,
const std::vector<std::string>& link_names,
1862 bool include_attached =
false)
1864 updateCollisionBodyTransforms();
1865 static_cast<const RobotState*
>(
this)->getRobotMarkers(arr, link_names, include_attached);
1868 void printStatePositions(std::ostream& out = std::cout)
const;
1873 void printStateInfo(std::ostream& out = std::cout)
const;
1875 void printTransforms(std::ostream& out = std::cout)
const;
1877 void printTransform(
const Eigen::Isometry3d& transform, std::ostream& out = std::cout)
const;
1879 void printDirtyInfo(std::ostream& out = std::cout)
const;
1881 std::string getStateTreeString(
const std::string& prefix =
"")
const;
1889 bool setToIKSolverFrame(Eigen::Isometry3d& pose,
const kinematics::KinematicsBaseConstPtr& solver);
1897 bool setToIKSolverFrame(Eigen::Isometry3d& pose,
const std::string& ik_frame);
1901 void initTransforms();
1907 dirty_link_transforms_ =
1908 dirty_link_transforms_ ==
nullptr ? joint : robot_model_->getCommonRoot(dirty_link_transforms_, joint);
1914 for (std::size_t i = 0; i < jm.size(); ++i)
1915 dirty_joint_transforms_[jm[i]->getJointIndex()] = 1;
1916 dirty_link_transforms_ = dirty_link_transforms_ ==
nullptr ?
1918 robot_model_->getCommonRoot(dirty_link_transforms_, group->
getCommonRoot());
1921 void markVelocity();
1922 void markAcceleration();
1929 for (std::size_t i = 0; i < mim.size(); ++i)
1931 position_[mim[i]->getFirstVariableIndex()] = mim[i]->getMimicFactor() * v + mim[i]->getMimicOffset();
1932 markDirtyJointTransforms(mim[i]);
1940 for (std::size_t i = 0; i < mim.size(); ++i)
1942 const int fvi = mim[i]->getFirstVariableIndex();
1944 mim[i]->getMimicFactor() * position_[mim[i]->getMimic()->getFirstVariableIndex()] + mim[i]->getMimicOffset();
1948 dirty_joint_transforms_[mim[i]->getJointIndex()] = 1;
1957 const int fvi = jm->getFirstVariableIndex();
1958 position_[fvi] = jm->getMimicFactor() * position_[jm->getMimic()->getFirstVariableIndex()] + jm->getMimicOffset();
1959 markDirtyJointTransforms(jm);
1961 markDirtyJointTransforms(group);
1966 void getMissingKeys(
const std::map<std::string, double>& variable_map,
1967 std::vector<std::string>& missing_variables)
const;
1968 void getStateTreeJointString(std::ostream& ss,
const JointModel* jm,
const std::string& pfx0,
bool last)
const;
1971 bool checkJointTransforms(
const JointModel* joint)
const;
1974 bool checkLinkTransforms()
const;
1977 bool checkCollisionTransforms()
const;
void setJointPositions(const std::string &joint_name, const double *position)
const Eigen::Isometry3d & getCollisionBodyTransform(const std::string &link_name, std::size_t index)
double getVariableVelocity(const std::string &variable) const
Get the velocity of a particular variable. An exception is thrown if the variable is not known...
random_numbers::RandomNumberGenerator & getRandomNumberGenerator()
Return the instance of a random number generator.
JumpThreshold(double jt_factor)
A set of options for the kinematics solver.
Eigen::Isometry3d * variable_joint_transforms_
void computeAABB(std::vector< double > &aabb)
Compute an axis-aligned bounding box that contains the current state. The format for aabb is (minx...
void updateMimicJoint(const JointModel *joint)
const double * getJointEffort(const JointModel *joint) const
Core components of MoveIt!
void copyJointGroupVelocities(const JointModelGroup *group, std::vector< double > &gstate) const
For a given group, copy the velocity values of the variables that make up the group into another loca...
void copyJointGroupAccelerations(const std::string &joint_group_name, double *gstate) const
For a given group, copy the acceleration values of the variables that make up the group into another ...
void getRobotMarkers(visualization_msgs::MarkerArray &arr, const std::vector< std::string > &link_names, bool include_attached=false)
Get a MarkerArray that fully describes the robot markers for a given robot. Update the state first...
void setJointGroupPositions(const std::string &joint_group_name, const std::vector< double > &gstate)
Given positions for the variables that make up a group, in the order found in the group (including va...
void setJointGroupAccelerations(const std::string &joint_group_name, const double *gstate)
Given accelerations for the variables that make up a group, in the order found in the group (includin...
double getVariablePosition(const std::string &variable) const
Get the position of a particular variable. An exception is thrown if the variable is not known...
const double * getVariableVelocities() const
Get const access to the velocities of the variables that make up this state. The values are in the sa...
void harmonizePosition(const JointModel *joint)
const double * getJointVelocities(const std::string &joint_name) const
void attachBody(const std::string &id, const std::vector< shapes::ShapeConstPtr > &shapes, const EigenSTL::vector_Isometry3d &attach_trans, const std::vector< std::string > &touch_links, const std::string &link_name, const trajectory_msgs::JointTrajectory &detach_posture=trajectory_msgs::JointTrajectory())
Add an attached body to a link.
Vec3fX< details::Vec3Data< double > > Vector3d
const std::vector< const JointModel * > & getMimicRequests() const
The joint models whose values would be modified if the value of this joint changed.
void updateMimicJoints(const JointModelGroup *group)
Update all mimic joints within group.
double * getVariableEffort()
Get raw access to the effort of the variables that make up this state. The values are in the same ord...
bool hasVelocities() const
By default, if velocities are never set or initialized, the state remembers that there are no velocit...
const double * getJointVelocities(const JointModel *joint) const
std::vector< double > values
bool dirtyJointTransform(const JointModel *joint) const
void enforcePositionBounds(const JointModel *joint)
const double * getJointAccelerations(const JointModel *joint) const
void copyJointGroupVelocities(const std::string &joint_group_name, Eigen::VectorXd &values) const
For a given group, copy the velocity values of the variables that make up the group into another loca...
double computeCartesianPath(const JointModelGroup *group, std::vector< RobotStatePtr > &traj, const LinkModel *link, const EigenSTL::vector_Isometry3d &waypoints, bool global_reference_frame, double max_step, double jump_threshold_factor, const GroupStateValidityCallbackFn &validCallback=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
int getJointIndex() const
Get the index of this joint within the robot model.
bool setFromIK(const JointModelGroup *group, const Eigen::Isometry3d &pose, unsigned int, double timeout=0.0, const GroupStateValidityCallbackFn &constraint=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
int getLinkIndex() const
The index of this joint when traversing the kinematic tree in depth first fashion.
void setVariableVelocities(const double *velocity)
Given an array with velocity values for all variables, set those values as the velocities in this sta...
const JointModel * dirty_collision_body_transforms_
MaxEEFStep(double translation, double rotation)
bool setFromIK(const JointModelGroup *group, const geometry_msgs::Pose &pose, const std::string &tip, unsigned int, double timeout=0.0, const GroupStateValidityCallbackFn &constraint=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
const Eigen::Isometry3d & getJointTransform(const std::string &joint_name)
void enforceVelocityBounds(const JointModel *joint)
void setVariablePositions(const std::vector< double > &position)
It is assumed positions is an array containing the new positions for all variables in this state...
virtual bool harmonizePosition(double *values, const Bounds &other_bounds) const
virtual void computeTransform(const double *joint_values, Eigen::Isometry3d &transf) const =0
Given the joint values for a joint, compute the corresponding transform.
const Eigen::Isometry3d & getCollisionBodyTransform(const LinkModel *link, std::size_t index)
bool setFromIK(const JointModelGroup *group, const Eigen::Isometry3d &pose, const std::string &tip, unsigned int, double timeout=0.0, const GroupStateValidityCallbackFn &constraint=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
void setJointPositions(const JointModel *joint, const double *position)
void copyJointGroupAccelerations(const std::string &joint_group_name, std::vector< double > &gstate) const
For a given group, copy the acceleration values of the variables that make up the group into another ...
Eigen::Isometry3d * global_link_transforms_
bool satisfiesPositionBounds(const double *values, double margin=0.0) const
Check if the set of values for the variables of this joint are within bounds.
void setJointGroupVelocities(const std::string &joint_group_name, const double *gstate)
Given velocities for the variables that make up a group, in the order found in the group (including v...
const Eigen::Isometry3d & getGlobalLinkTransform(const std::string &link_name) const
void interpolate(const RobotState &to, double t, RobotState &state, const JointModel *joint) const
double * getVariablePositions()
Get a raw pointer to the positions of the variables stored in this state. Use carefully. If you change these values externally you need to make sure you trigger a forced update for the state by calling update(true).
void setVariableAcceleration(int index, double value)
Set the acceleration of a single variable. The variable is specified by its index (a value associated...
bool setFromIK(const JointModelGroup *group, const EigenSTL::vector_Isometry3d &poses, const std::vector< std::string > &tips, const std::vector< std::vector< double > > &consistency_limits, unsigned int, double timeout=0.0, const GroupStateValidityCallbackFn &constraint=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
geometry_msgs::TransformStamped t
void markDirtyJointTransforms(const JointModel *joint)
void setVariableEffort(int index, double value)
Set the effort of a single variable. The variable is specified by its index (a value associated by th...
void setJointGroupPositions(const JointModelGroup *group, const std::vector< double > &gstate)
Given positions for the variables that make up a group, in the order found in the group (including va...
bool dirtyLinkTransforms() const
void setJointPositions(const std::string &joint_name, const std::vector< double > &position)
virtual void interpolate(const double *from, const double *to, const double t, double *state) const =0
Computes the state that lies at time t in [0, 1] on the segment that connects from state to to state...
const JointModel * getCommonRoot() const
Get the common root of all joint roots; not necessarily part of this group.
const JointModelGroup * getJointModelGroup(const std::string &group) const
Get the model of a particular joint group.
Eigen::MatrixXd getJacobian(const JointModelGroup *group, const Eigen::Vector3d &reference_point_position=Eigen::Vector3d(0.0, 0.0, 0.0))
Compute the Jacobian with reference to the last link of a specified group. If the group is not a chai...
const Eigen::Isometry3d & getGlobalLinkTransform(const LinkModel *link) const
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
double getVariableAcceleration(const std::string &variable) const
Get the acceleration of a particular variable. An exception is thrown if the variable is not known...
void copyJointGroupVelocities(const std::string &joint_group_name, std::vector< double > &gstate) const
For a given group, copy the velocity values of the variables that make up the group into another loca...
void setJointGroupVelocities(const JointModelGroup *group, const std::vector< double > &gstate)
Given velocities for the variables that make up a group, in the order found in the group (including v...
void setVariableEffort(const std::string &variable, double value)
Set the effort of a variable. If an unknown variable name is specified, an exception is thrown...
const double * getJointEffort(const std::string &joint_name) const
const Eigen::Isometry3d & getCollisionBodyTransform(const std::string &link_name, std::size_t index) const
void setJointGroupVelocities(const std::string &joint_group_name, const std::vector< double > &gstate)
Given velocities for the variables that make up a group, in the order found in the group (including v...
const double * getJointAccelerations(const std::string &joint_name) const
bool satisfiesPositionBounds(const JointModel *joint, double margin=0.0) const
void setJointGroupAccelerations(const std::string &joint_group_name, const std::vector< double > &gstate)
Given accelerations for the variables that make up a group, in the order found in the group (includin...
void setVariableEffort(const std::vector< double > &effort)
Given an array with effort values for all variables, set those values as the effort in this state...
void enforceBounds(const JointModel *joint)
const Eigen::Isometry3d & getJointTransform(const JointModel *joint)
const Eigen::Isometry3d & getCollisionBodyTransform(const LinkModel *link, std::size_t index) const
bool setFromIK(const JointModelGroup *group, const geometry_msgs::Pose &pose, unsigned int, double timeout=0.0, const GroupStateValidityCallbackFn &constraint=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
Struct for containing jump_threshold.
virtual double distance(const double *value1, const double *value2) const =0
Compute the distance between two joint states of the same model (represented by the variable values) ...
void copyJointGroupPositions(const std::string &joint_group_name, Eigen::VectorXd &values) const
For a given group, copy the position values of the variables that make up the group into another loca...
void setJointGroupActivePositions(const std::string &joint_group_name, const std::vector< double > &gstate)
Given positions for the variables of active joints that make up a group, in the order found in the gr...
MOVEIT_CLASS_FORWARD(RobotModel)
void setJointPositions(const JointModel *joint, const std::vector< double > &position)
void copyJointGroupVelocities(const std::string &joint_group_name, double *gstate) const
For a given group, copy the velocity values of the variables that make up the group into another loca...
boost::function< void(AttachedBody *body, bool attached)> AttachedBodyCallback
bool satisfiesVelocityBounds(const double *values, double margin=0.0) const
Check if the set of velocities for the variables of this joint are within bounds. ...
void setVariableAccelerations(const std::vector< double > &acceleration)
Given an array with acceleration values for all variables, set those values as the accelerations in t...
void setJointGroupVelocities(const std::string &joint_group_name, const Eigen::VectorXd &values)
Given velocities for the variables that make up a group, in the order found in the group (including v...
bool hasAccelerations() const
By default, if accelerations are never set or initialized, the state remembers that there are no acce...
bool getJacobian(const JointModelGroup *group, const LinkModel *link, const Eigen::Vector3d &reference_point_position, Eigen::MatrixXd &jacobian, bool use_quaternion_representation=false)
Compute the Jacobian with reference to a particular point on a given link, for a specified group...
bool enforcePositionBounds(double *values) const
Force the specified values to be inside bounds and normalized. Quaternions are normalized, continuous joints are made between -Pi and Pi. Returns true if changes were made.
const std::vector< const JointModel * > & getMimicJointModels() const
Get the mimic joints that are part of this group.
unsigned char * dirty_joint_transforms_
virtual void computeVariablePositions(const Eigen::Isometry3d &transform, double *joint_values) const =0
Given the transform generated by joint, compute the corresponding joint values.
std::size_t getVariableCount() const
Get the number of variables that describe this joint.
bool dirty() const
Returns true if anything in this state is dirty.
const Eigen::Isometry3d & getJointTransform(const std::string &joint_name) const
AttachedBodyCallback attached_body_update_callback_
This event is called when there is a change in the attached bodies for this state; The event specifie...
void setJointGroupAccelerations(const std::string &joint_group_name, const Eigen::VectorXd &values)
Given accelerations for the variables that make up a group, in the order found in the group (includin...
const RobotModelConstPtr & getRobotModel() const
Get the robot model this state is constructed for.
Struct for containing max_step for computeCartesianPath.
double computeCartesianPath(const JointModelGroup *group, std::vector< RobotStatePtr > &traj, const LinkModel *link, const Eigen::Isometry3d &target, bool global_reference_frame, double max_step, double jump_threshold_factor, const GroupStateValidityCallbackFn &validCallback=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
double getVariableVelocity(int index) const
Get the velocity of a particular variable. The variable is specified by its index. No checks are performed for the validity of the index passed.
const double * getVariableEffort() const
Get const raw access to the effort of the variables that make up this state. The values are in the sa...
void setJointGroupPositions(const std::string &joint_group_name, const Eigen::VectorXd &values)
Given positions for the variables that make up a group, in the order found in the group (including va...
A joint from the robot. Models the transform that this joint applies in the kinematic chain...
void getRobotMarkers(visualization_msgs::MarkerArray &arr, const std::vector< std::string > &link_names, const std_msgs::ColorRGBA &color, const std::string &ns, const ros::Duration &dur, bool include_attached=false)
Get a MarkerArray that fully describes the robot markers for a given robot. Update the state first...
void copyJointGroupPositions(const std::string &joint_group_name, double *gstate) const
For a given group, copy the position values of the variables that make up the group into another loca...
void updateStateWithLinkAt(const std::string &link_name, const Eigen::Isometry3d &transform, bool backward=false)
Update the state after setting a particular link to the input global transform pose.
const std::vector< const JointModel * > & getActiveJointModels() const
Get the active joints in this group (that have controllable DOF). This does not include mimic joints...
void copyJointGroupPositions(const std::string &joint_group_name, std::vector< double > &gstate) const
For a given group, copy the position values of the variables that make up the group into another loca...
bool setFromIKSubgroups(const JointModelGroup *group, const EigenSTL::vector_Isometry3d &poses, const std::vector< std::string > &tips, const std::vector< std::vector< double > > &consistency_limits, unsigned int, double timeout=0.0, const GroupStateValidityCallbackFn &constraint=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
bool enforceVelocityBounds(double *values) const
Force the specified velocities to be within bounds. Return true if changes were made.
void markDirtyJointTransforms(const JointModelGroup *group)
int getFirstCollisionBodyTransformIndex() const
double * getVariableVelocities()
Get raw access to the velocities of the variables that make up this state. The values are in the same...
bool dirtyCollisionBodyTransforms() const
void setJointPositions(const std::string &joint_name, const Eigen::Isometry3d &transform)
void copyJointGroupAccelerations(const std::string &joint_group_name, Eigen::VectorXd &values) const
For a given group, copy the acceleration values of the variables that make up the group into another ...
bool setFromIK(const JointModelGroup *group, const Eigen::Isometry3d &pose, const std::string &tip, const std::vector< double > &consistency_limits, unsigned int, double timeout=0.0, const GroupStateValidityCallbackFn &constraint=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
void setVariableVelocity(int index, double value)
Set the velocity of a single variable. The variable is specified by its index (a value associated by ...
const LinkModel * getLinkModel(const std::string &link) const
Get the model of a particular link.
void computeVariableVelocity(const JointModelGroup *jmg, Eigen::VectorXd &qdot, const Eigen::VectorXd &twist, const LinkModel *tip)
Given a twist for a particular link (tip), compute the corresponding velocity for every variable and ...
JumpThreshold(double jt_revolute, double jt_prismatic)
double getVariableEffort(const std::string &variable) const
Get the effort of a particular variable. An exception is thrown if the variable is not known...
unsigned int getActiveVariableCount() const
Get the number of variables that describe the active joints in this joint group. This excludes variab...
const JointModel * dirty_link_transforms_
std::size_t getVariableCount() const
Get the number of variables that make up this state.
void setJointGroupActivePositions(const std::string &joint_group_name, const Eigen::VectorXd &values)
Given positions for the variables of active joints that make up a group, in the order found in the gr...
double * getVariableAccelerations()
Get raw access to the accelerations of the variables that make up this state. The values are in the s...
void copyJointGroupAccelerations(const JointModelGroup *group, std::vector< double > &gstate) const
For a given group, copy the acceleration values of the variables that make up the group into another ...
const Eigen::Isometry3d & getGlobalLinkTransform(const std::string &link_name)
void setJointGroupPositions(const std::string &joint_group_name, const double *gstate)
Given positions for the variables that make up a group, in the order found in the group (including va...
random_numbers::RandomNumberGenerator * rng_
For certain operations a state needs a random number generator. However, it may be slightly expensive...
const double * getVariablePositions() const
Get a raw pointer to the positions of the variables stored in this state.
RobotModelConstPtr robot_model_
void setVariableValues(const sensor_msgs::JointState &msg)
void setVariableAccelerations(const double *acceleration)
Given an array with acceleration values for all variables, set those values as the accelerations in t...
Eigen::Isometry3d * global_collision_body_transforms_
double getVariableEffort(int index) const
Get the effort of a particular variable. The variable is specified by its index. No checks are perfor...
Representation of a robot's state. This includes position, velocity, acceleration and effort...
void setVariableAcceleration(const std::string &variable, double value)
Set the acceleration of a variable. If an unknown variable name is specified, an exception is thrown...
bool satisfiesVelocityBounds(const JointModel *joint, double margin=0.0) const
A link from the robot. Contains the constant transform applied to the link and its geometry...
std::vector< Eigen::Isometry3d, Eigen::aligned_allocator< Eigen::Isometry3d > > vector_Isometry3d
void setVariableEffort(const double *effort)
Given an array with effort values for all variables, set those values as the effort in this state...
bool hasEffort() const
By default, if effort is never set or initialized, the state remembers that there is no effort set...
unsigned int getVariableCount() const
Get the number of variables that describe this joint group. This includes variables necessary for mim...
bool satisfiesBounds(const JointModel *joint, double margin=0.0) const
int getFirstVariableIndex() const
Get the index of this joint's first variable within the full robot state.
void setJointGroupAccelerations(const JointModelGroup *group, const std::vector< double > &gstate)
Given accelerations for the variables that make up a group, in the order found in the group (includin...
void setVariablePosition(const std::string &variable, double value)
Set the position of a single variable. An exception is thrown if the variable name is not known...
Main namespace for MoveIt!
double distance(const RobotState &other, const JointModel *joint) const
Return the sum of joint distances to "other" state. Only considers active joints. ...
double getVariablePosition(int index) const
Get the position of a particular variable. The variable is specified by its index. No checks are performed for the validity of the index passed.
double getVariableAcceleration(int index) const
Get the acceleration of a particular variable. The variable is specified by its index. No checks are performed for the validity of the index passed.
const JointModel * getJointModel(const std::string &joint) const
Get the model of a particular joint.
const Eigen::Isometry3d & getJointTransform(const JointModel *joint) const
Object defining bodies that can be attached to robot links. This is useful when handling objects pick...
bool setFromIK(const JointModelGroup *group, const EigenSTL::vector_Isometry3d &poses, const std::vector< std::string > &tips, unsigned int, double timeout=0.0, const GroupStateValidityCallbackFn &constraint=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
std::ostream & operator<<(std::ostream &out, const VariableBounds &b)
Operator overload for printing variable bounds to a stream.
const std::vector< std::string > & getVariableNames() const
Get the names of the variables that make up this state, in the order they are stored in memory...
void setVariablePosition(int index, double value)
Set the position of a single variable. The variable is specified by its index (a value associated by ...
double distance(const RobotState &other) const
Return the sum of joint distances to "other" state. Only considers active joints. ...
void setVariableVelocities(const std::vector< double > &velocity)
Given an array with velocity values for all variables, set those values as the velocities in this sta...
void setVariableVelocity(const std::string &variable, double value)
Set the velocity of a variable. If an unknown variable name is specified, an exception is thrown...
double distance(const urdf::Pose &transform)
boost::function< bool(RobotState *robot_state, const JointModelGroup *joint_group, const double *joint_group_variable_values)> GroupStateValidityCallbackFn
Signature for functions that can verify that if the group joint_group in robot_state is set to joint_...
void setJointPositions(const JointModel *joint, const Eigen::Isometry3d &transform)
void copyJointGroupPositions(const JointModelGroup *group, std::vector< double > &gstate) const
For a given group, copy the position values of the variables that make up the group into another loca...
double computeCartesianPath(const JointModelGroup *group, std::vector< RobotStatePtr > &traj, const LinkModel *link, const Eigen::Vector3d &direction, bool global_reference_frame, double distance, double max_step, double jump_threshold_factor, const GroupStateValidityCallbackFn &validCallback=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
const double * getJointPositions(const std::string &joint_name) const
std::map< std::string, AttachedBody * > attached_body_map_
All attached bodies that are part of this state, indexed by their name.
const double * getJointPositions(const JointModel *joint) const
MaxEEFStep(double step_size)
const Eigen::Isometry3d & getGlobalLinkTransform(const LinkModel *link)
const double * getVariableAccelerations() const
Get const raw access to the accelerations of the variables that make up this state. The values are in the same order as reported by getVariableNames()
void setJointVelocities(const JointModel *joint, const double *velocity)
void updateMimicJoint(const std::vector< const JointModel *> &mim)
Update a set of joints that are certain to be mimicking other joints.