38 #ifndef MOVEIT_CORE_ROBOT_STATE_ 39 #define MOVEIT_CORE_ROBOT_STATE_ 44 #include <sensor_msgs/JointState.h> 45 #include <visualization_msgs/MarkerArray.h> 46 #include <std_msgs/ColorRGBA.h> 47 #include <geometry_msgs/Twist.h> 50 #include <boost/assert.hpp> 62 typedef boost::function<bool(RobotState*
robot_state,
const JointModelGroup* joint_group,
63 const double* joint_group_variable_values)>
88 revolute = jt_revolute;
89 prismatic = jt_prismatic;
98 MaxEEFStep(
double translation = 0.0,
double rotation = 0.0) : translation(translation), rotation(rotation)
146 return robot_model_->getVariableCount();
152 return robot_model_->getVariableNames();
158 return robot_model_->getLinkModel(link);
164 return robot_model_->getJointModel(joint);
170 return robot_model_->getJointModelGroup(group);
196 void setVariablePositions(
const double* position);
203 assert(robot_model_->getVariableCount() <= position.size());
204 setVariablePositions(&position[0]);
209 void setVariablePositions(
const std::map<std::string, double>& variable_map);
213 void setVariablePositions(
const std::map<std::string, double>& variable_map,
214 std::vector<std::string>& missing_variables);
218 void setVariablePositions(
const std::vector<std::string>& variable_names,
219 const std::vector<double>& variable_position);
224 setVariablePosition(robot_model_->getVariableIndex(variable), value);
231 position_[index] = value;
232 const JointModel* jm = robot_model_->getJointOfVariable(index);
235 markDirtyJointTransforms(jm);
236 updateMimicJoint(jm);
243 return position_[robot_model_->getVariableIndex(variable)];
251 return position_[index];
265 return has_velocity_;
286 has_velocity_ =
true;
288 memcpy(velocity_, velocity, robot_model_->getVariableCount() *
sizeof(double));
294 assert(robot_model_->getVariableCount() <= velocity.size());
295 setVariableVelocities(&velocity[0]);
300 void setVariableVelocities(
const std::map<std::string, double>& variable_map);
304 void setVariableVelocities(
const std::map<std::string, double>& variable_map,
305 std::vector<std::string>& missing_variables);
309 void setVariableVelocities(
const std::vector<std::string>& variable_names,
310 const std::vector<double>& variable_velocity);
315 setVariableVelocity(robot_model_->getVariableIndex(variable), value);
323 velocity_[index] = value;
329 return velocity_[robot_model_->getVariableIndex(variable)];
337 return velocity_[index];
352 return has_acceleration_;
361 return acceleration_;
368 return acceleration_;
375 has_acceleration_ =
true;
379 memcpy(acceleration_, acceleration, robot_model_->getVariableCount() *
sizeof(double));
386 assert(robot_model_->getVariableCount() <= acceleration.size());
387 setVariableAccelerations(&acceleration[0]);
392 void setVariableAccelerations(
const std::map<std::string, double>& variable_map);
397 void setVariableAccelerations(
const std::map<std::string, double>& variable_map,
398 std::vector<std::string>& missing_variables);
402 void setVariableAccelerations(
const std::vector<std::string>& variable_names,
403 const std::vector<double>& variable_acceleration);
408 setVariableAcceleration(robot_model_->getVariableIndex(variable), value);
416 acceleration_[index] = value;
422 return acceleration_[robot_model_->getVariableIndex(variable)];
430 return acceleration_[index];
467 has_acceleration_ =
false;
469 memcpy(effort_, effort, robot_model_->getVariableCount() *
sizeof(double));
475 assert(robot_model_->getVariableCount() <= effort.size());
476 setVariableEffort(&effort[0]);
480 void setVariableEffort(
const std::map<std::string, double>& variable_map);
484 void setVariableEffort(
const std::map<std::string, double>& variable_map,
485 std::vector<std::string>& missing_variables);
488 void setVariableEffort(
const std::vector<std::string>& variable_names,
489 const std::vector<double>& variable_acceleration);
494 setVariableEffort(robot_model_->getVariableIndex(variable), value);
502 effort_[index] = value;
508 return effort_[robot_model_->getVariableIndex(variable)];
516 return effort_[index];
520 void invertVelocity();
529 setJointPositions(robot_model_->getJointModel(joint_name), position);
534 setJointPositions(robot_model_->getJointModel(joint_name), &position[0]);
539 setJointPositions(joint, &position[0]);
545 markDirtyJointTransforms(joint);
546 updateMimicJoint(joint);
551 setJointPositions(robot_model_->getJointModel(joint_name), transform);
557 markDirtyJointTransforms(joint);
558 updateMimicJoint(joint);
563 has_velocity_ =
true;
567 void setJointEfforts(
const JointModel* joint,
const double* effort);
571 return getJointPositions(robot_model_->getJointModel(joint_name));
581 return getJointVelocities(robot_model_->getJointModel(joint_name));
591 return getJointAccelerations(robot_model_->getJointModel(joint_name));
601 return getJointEffort(robot_model_->getJointModel(joint_name));
620 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
622 setJointGroupPositions(jmg, gstate);
630 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
632 setJointGroupPositions(jmg, &gstate[0]);
640 setJointGroupPositions(group, &gstate[0]);
646 void setJointGroupPositions(
const JointModelGroup* group,
const double* gstate);
653 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
655 setJointGroupPositions(jmg, values);
661 void setJointGroupPositions(
const JointModelGroup* group,
const Eigen::VectorXd& values);
668 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
672 copyJointGroupPositions(jmg, &gstate[0]);
681 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
683 copyJointGroupPositions(jmg, gstate);
692 copyJointGroupPositions(group, &gstate[0]);
698 void copyJointGroupPositions(
const JointModelGroup* group,
double* gstate)
const;
705 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
707 copyJointGroupPositions(jmg, values);
713 void copyJointGroupPositions(
const JointModelGroup* group, Eigen::VectorXd& values)
const;
726 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
728 setJointGroupVelocities(jmg, gstate);
736 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
738 setJointGroupVelocities(jmg, &gstate[0]);
746 setJointGroupVelocities(group, &gstate[0]);
752 void setJointGroupVelocities(
const JointModelGroup* group,
const double* gstate);
759 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
761 setJointGroupVelocities(jmg, values);
767 void setJointGroupVelocities(
const JointModelGroup* group,
const Eigen::VectorXd& values);
774 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
778 copyJointGroupVelocities(jmg, &gstate[0]);
787 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
789 copyJointGroupVelocities(jmg, gstate);
798 copyJointGroupVelocities(group, &gstate[0]);
804 void copyJointGroupVelocities(
const JointModelGroup* group,
double* gstate)
const;
811 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
813 copyJointGroupVelocities(jmg, values);
819 void copyJointGroupVelocities(
const JointModelGroup* group, Eigen::VectorXd& values)
const;
832 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
834 setJointGroupAccelerations(jmg, gstate);
842 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
844 setJointGroupAccelerations(jmg, &gstate[0]);
852 setJointGroupAccelerations(group, &gstate[0]);
858 void setJointGroupAccelerations(
const JointModelGroup* group,
const double* gstate);
865 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
867 setJointGroupAccelerations(jmg, values);
873 void setJointGroupAccelerations(
const JointModelGroup* group,
const Eigen::VectorXd& values);
880 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
884 copyJointGroupAccelerations(jmg, &gstate[0]);
893 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
895 copyJointGroupAccelerations(jmg, gstate);
904 copyJointGroupAccelerations(group, &gstate[0]);
910 void copyJointGroupAccelerations(
const JointModelGroup* group,
double* gstate)
const;
917 const JointModelGroup* jmg = robot_model_->getJointModelGroup(joint_group_name);
919 copyJointGroupAccelerations(jmg, values);
925 void copyJointGroupAccelerations(
const JointModelGroup* group, Eigen::VectorXd& values)
const;
939 bool setToIKSolverFrame(Eigen::Affine3d& pose,
const kinematics::KinematicsBaseConstPtr& solver);
947 bool setToIKSolverFrame(Eigen::Affine3d& pose,
const std::string& ik_frame);
956 bool setFromIK(
const JointModelGroup* group,
const geometry_msgs::Pose& pose,
unsigned int attempts = 0,
968 bool setFromIK(
const JointModelGroup* group,
const geometry_msgs::Pose& pose,
const std::string& tip,
969 unsigned int attempts = 0,
double timeout = 0.0,
980 bool setFromIK(
const JointModelGroup* group,
const Eigen::Affine3d& pose,
unsigned int attempts = 0,
991 bool setFromIK(
const JointModelGroup* group,
const Eigen::Affine3d& pose,
const std::string& tip,
992 unsigned int attempts = 0,
double timeout = 0.0,
1005 bool setFromIK(
const JointModelGroup* group,
const Eigen::Affine3d& pose,
const std::string& tip,
1006 const std::vector<double>& consistency_limits,
unsigned int attempts = 0,
double timeout = 0.0,
1021 const std::vector<std::string>& tips,
unsigned int attempts = 0,
double timeout = 0.0,
1037 const std::vector<std::string>& tips,
const std::vector<std::vector<double> >& consistency_limits,
1038 unsigned int attempts = 0,
double timeout = 0.0,
1052 const std::vector<std::string>& tips,
1053 const std::vector<std::vector<double> >& consistency_limits,
unsigned int attempts = 0,
1054 double timeout = 0.0,
1065 bool setFromDiffIK(
const JointModelGroup* group,
const Eigen::VectorXd& twist,
const std::string& tip,
double dt,
1075 bool setFromDiffIK(
const JointModelGroup* group,
const geometry_msgs::Twist& twist,
const std::string& tip,
double dt,
1109 const Eigen::Vector3d& direction,
bool global_reference_frame,
double distance,
1115 const Eigen::Vector3d& direction,
bool global_reference_frame,
double distance,
1116 double max_step,
double jump_threshold_factor,
1120 return computeCartesianPath(group, traj, link, direction, global_reference_frame, distance,
1132 const Eigen::Affine3d& target,
bool global_reference_frame,
const MaxEEFStep& max_step,
1138 const Eigen::Affine3d& target,
bool global_reference_frame,
double max_step,
1139 double jump_threshold_factor,
1143 return computeCartesianPath(group, traj, link, target, global_reference_frame,
MaxEEFStep(max_step),
1144 JumpThreshold(jump_threshold_factor), validCallback, options);
1161 double jump_threshold_factor,
1165 return computeCartesianPath(group, traj, link, waypoints, global_reference_frame,
MaxEEFStep(max_step),
1166 JumpThreshold(jump_threshold_factor), validCallback, options);
1184 static double testJointSpaceJump(
const JointModelGroup* group, std::vector<RobotStatePtr>& traj,
1197 static double testRelativeJointSpaceJump(
const JointModelGroup* group, std::vector<RobotStatePtr>& traj,
1198 double jump_threshold_factor);
1212 static double testAbsoluteJointSpaceJump(
const JointModelGroup* group, std::vector<RobotStatePtr>& traj,
1213 double revolute_jump_threshold,
double prismatic_jump_threshold);
1224 bool getJacobian(
const JointModelGroup* group,
const LinkModel* link,
const Eigen::Vector3d& reference_point_position,
1225 Eigen::MatrixXd& jacobian,
bool use_quaternion_representation =
false)
const;
1237 Eigen::MatrixXd& jacobian,
bool use_quaternion_representation =
false)
1239 updateLinkTransforms();
1240 return static_cast<const RobotState*
>(
this)->getJacobian(group, link, reference_point_position, jacobian,
1241 use_quaternion_representation);
1251 const Eigen::Vector3d& reference_point_position = Eigen::Vector3d(0.0, 0.0, 0.0))
const;
1260 const Eigen::Vector3d& reference_point_position = Eigen::Vector3d(0.0, 0.0, 0.0))
1262 updateLinkTransforms();
1263 return static_cast<const RobotState*
>(
this)->getJacobian(group, reference_point_position);
1268 void computeVariableVelocity(
const JointModelGroup* jmg, Eigen::VectorXd& qdot,
const Eigen::VectorXd& twist,
1276 updateLinkTransforms();
1277 static_cast<const RobotState*
>(
this)->computeVariableVelocity(jmg, qdot, twist, tip);
1283 bool integrateVariableVelocity(
const JointModelGroup* jmg,
const Eigen::VectorXd& qdot,
double dt,
1294 if (!msg.position.empty())
1295 setVariablePositions(msg.name, msg.position);
1296 if (!msg.velocity.empty())
1297 setVariableVelocities(msg.name, msg.velocity);
1303 void setToDefaultValues();
1306 bool setToDefaultValues(
const JointModelGroup* group,
const std::string& name);
1309 void setToRandomPositions();
1333 const std::vector<double>& distances);
1343 void updateCollisionBodyTransforms();
1347 void updateLinkTransforms();
1350 void update(
bool force =
false);
1362 updateStateWithLinkAt(robot_model_->getLinkModel(link_name), transform, backward);
1366 void updateStateWithLinkAt(
const LinkModel* link,
const Eigen::Affine3d& transform,
bool backward =
false);
1370 return getGlobalLinkTransform(robot_model_->getLinkModel(link_name));
1375 updateLinkTransforms();
1381 return getCollisionBodyTransform(robot_model_->getLinkModel(link_name), index);
1386 updateCollisionBodyTransforms();
1392 return getJointTransform(robot_model_->getJointModel(joint_name));
1398 unsigned char& dirty = dirty_joint_transforms_[idx];
1404 return variable_joint_transforms_[idx];
1409 return getGlobalLinkTransform(robot_model_->getLinkModel(link_name));
1414 BOOST_VERIFY(checkLinkTransforms());
1420 return getCollisionBodyTransform(robot_model_->getLinkModel(link_name), index);
1425 BOOST_VERIFY(checkCollisionTransforms());
1431 return getJointTransform(robot_model_->getJointModel(joint_name));
1436 BOOST_VERIFY(checkJointTransforms(joint));
1447 return dirty_link_transforms_;
1452 return dirty_link_transforms_ || dirty_collision_body_transforms_;
1458 return dirtyCollisionBodyTransforms();
1501 void enforceBounds();
1505 enforcePositionBounds(joint);
1507 enforceVelocityBounds(joint);
1513 markDirtyJointTransforms(joint);
1514 updateMimicJoint(joint);
1522 bool satisfiesBounds(
double margin = 0.0)
const;
1523 bool satisfiesBounds(
const JointModelGroup* joint_group,
double margin = 0.0)
const;
1526 return satisfiesPositionBounds(joint, margin) && (!has_velocity_ || satisfiesVelocityBounds(joint, margin));
1539 std::pair<double, const JointModel*> getMinDistanceToPositionBounds()
const;
1543 std::pair<double, const JointModel*> getMinDistanceToPositionBounds(
const JointModelGroup* group)
const;
1547 std::pair<double, const JointModel*>
1548 getMinDistanceToPositionBounds(
const std::vector<const JointModel*>& joints)
const;
1599 void attachBody(
const std::string&
id,
const std::vector<shapes::ShapeConstPtr>&
shapes,
1601 const std::string& link_name,
1602 const trajectory_msgs::JointTrajectory& detach_posture = trajectory_msgs::JointTrajectory());
1618 void attachBody(
const std::string&
id,
const std::vector<shapes::ShapeConstPtr>& shapes,
1620 const std::string& link_name,
1621 const trajectory_msgs::JointTrajectory& detach_posture = trajectory_msgs::JointTrajectory())
1623 std::set<std::string> touch_links_set(touch_links.begin(), touch_links.end());
1624 attachBody(
id, shapes, attach_trans, touch_links_set, link_name, detach_posture);
1628 void getAttachedBodies(std::vector<const AttachedBody*>& attached_bodies)
const;
1631 void getAttachedBodies(std::vector<const AttachedBody*>& attached_bodies,
const JointModelGroup* lm)
const;
1634 void getAttachedBodies(std::vector<const AttachedBody*>& attached_bodies,
const LinkModel* lm)
const;
1638 bool clearAttachedBody(
const std::string&
id);
1641 void clearAttachedBodies(
const LinkModel* link);
1647 void clearAttachedBodies();
1650 const AttachedBody* getAttachedBody(
const std::string& name)
const;
1653 bool hasAttachedBody(
const std::string&
id)
const;
1660 void computeAABB(std::vector<double>& aabb)
const;
1666 updateLinkTransforms();
1667 static_cast<const RobotState*
>(
this)->computeAABB(aabb);
1679 const Eigen::Affine3d& getFrameTransform(
const std::string&
id);
1682 const Eigen::Affine3d& getFrameTransform(
const std::string&
id)
const;
1685 bool knowsFrameTransform(
const std::string&
id)
const;
1694 void getRobotMarkers(visualization_msgs::MarkerArray& arr,
const std::vector<std::string>& link_names,
1695 const std_msgs::ColorRGBA& color,
const std::string& ns,
const ros::Duration& dur,
1696 bool include_attached =
false)
const;
1705 void getRobotMarkers(visualization_msgs::MarkerArray& arr,
const std::vector<std::string>& link_names,
1706 const std_msgs::ColorRGBA& color,
const std::string& ns,
const ros::Duration& dur,
1707 bool include_attached =
false)
1709 updateCollisionBodyTransforms();
1710 static_cast<const RobotState*
>(
this)->getRobotMarkers(arr, link_names, color, ns, dur, include_attached);
1717 void getRobotMarkers(visualization_msgs::MarkerArray& arr,
const std::vector<std::string>& link_names,
1718 bool include_attached =
false)
const;
1724 void getRobotMarkers(visualization_msgs::MarkerArray& arr,
const std::vector<std::string>& link_names,
1725 bool include_attached =
false)
1727 updateCollisionBodyTransforms();
1728 static_cast<const RobotState*
>(
this)->getRobotMarkers(arr, link_names, include_attached);
1731 void printStatePositions(std::ostream& out = std::cout)
const;
1733 void printStateInfo(std::ostream& out = std::cout)
const;
1735 void printTransforms(std::ostream& out = std::cout)
const;
1737 void printTransform(
const Eigen::Affine3d& transform, std::ostream& out = std::cout)
const;
1739 void printDirtyInfo(std::ostream& out = std::cout)
const;
1741 std::string getStateTreeString(
const std::string& prefix =
"")
const;
1751 dirty_link_transforms_ =
1752 dirty_link_transforms_ == NULL ? joint : robot_model_->getCommonRoot(dirty_link_transforms_, joint);
1758 for (std::size_t i = 0; i < jm.size(); ++i)
1759 dirty_joint_transforms_[jm[i]->getJointIndex()] = 1;
1760 dirty_link_transforms_ = dirty_link_transforms_ == NULL ?
1762 robot_model_->getCommonRoot(dirty_link_transforms_, group->
getCommonRoot());
1765 void markVelocity();
1766 void markAcceleration();
1773 for (std::size_t i = 0; i < mim.size(); ++i)
1775 position_[mim[i]->getFirstVariableIndex()] = mim[i]->getMimicFactor() * v + mim[i]->getMimicOffset();
1776 markDirtyJointTransforms(mim[i]);
1784 for (std::size_t i = 0; i < mim.size(); ++i)
1786 const int fvi = mim[i]->getFirstVariableIndex();
1788 mim[i]->getMimicFactor() * position_[mim[i]->getMimic()->getFirstVariableIndex()] + mim[i]->getMimicOffset();
1792 dirty_joint_transforms_[mim[i]->getJointIndex()] = 1;
1801 const int fvi = jm->getFirstVariableIndex();
1802 position_[fvi] = jm->getMimicFactor() * position_[jm->getMimic()->getFirstVariableIndex()] + jm->getMimicOffset();
1803 markDirtyJointTransforms(jm);
1805 markDirtyJointTransforms(group);
1810 void getMissingKeys(
const std::map<std::string, double>& variable_map,
1811 std::vector<std::string>& missing_variables)
const;
1812 void getStateTreeJointString(std::ostream& ss,
const JointModel* jm,
const std::string& pfx0,
bool last)
const;
1815 bool checkJointTransforms(
const JointModel* joint)
const;
1818 bool checkLinkTransforms()
const;
1821 bool checkCollisionTransforms()
const;
void attachBody(const std::string &id, const std::vector< shapes::ShapeConstPtr > &shapes, const EigenSTL::vector_Affine3d &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.
void setJointPositions(const std::string &joint_name, const double *position)
bool hasAccelerations() const
By default, if accelerations are never set or initialized, the state remembers that there are no acce...
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 ...
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...
random_numbers::RandomNumberGenerator & getRandomNumberGenerator()
Return the instance of a random number generator.
JumpThreshold(double jt_factor)
A set of options for the kinematics solver.
std::size_t getVariableCount() const
Get the number of variables that describe this joint.
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)
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...
Core components of MoveIt!
const Eigen::Affine3d & getGlobalLinkTransform(const LinkModel *link) const
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...
Eigen::Affine3d * global_collision_body_transforms_
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...
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 ...
double distance(const RobotState &other) const
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 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::Affine3d & getJointTransform(const JointModel *joint)
std::vector< Eigen::Affine3d, Eigen::aligned_allocator< Eigen::Affine3d > > vector_Affine3d
double getVariableAcceleration(const std::string &variable) const
Get the acceleration of a particular variable. An exception is thrown if the variable is not known...
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.
void updateMimicJoints(const JointModelGroup *group)
Update all mimic joints within group.
const Eigen::Affine3d & getGlobalLinkTransform(const std::string &link_name) const
double * getVariableEffort()
Get raw access to the effort of the variables that make up this state. The values are in the same ord...
const Eigen::Affine3d & getGlobalLinkTransform(const std::string &link_name)
void enforcePositionBounds(const JointModel *joint)
const Eigen::Affine3d & getJointTransform(const std::string &joint_name) const
const std::vector< const JointModel * > & getMimicRequests() const
The joint models whose values would be modified if the value of this joint changed.
const Eigen::Affine3d & getCollisionBodyTransform(const LinkModel *link, std::size_t index) const
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 ...
const double * getJointVelocities(const std::string &joint_name) const
const JointModelGroup * getJointModelGroup(const std::string &group) const
Get the model of a particular joint group.
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_
const Eigen::Affine3d & getCollisionBodyTransform(const std::string &link_name, std::size_t index) const
#define MOVEIT_DEPRECATED
bool hasVelocities() const
By default, if velocities are never set or initialized, the state remembers that there are no velocit...
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 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...
double computeCartesianPath(const JointModelGroup *group, std::vector< RobotStatePtr > &traj, const LinkModel *link, const Eigen::Affine3d &target, bool global_reference_frame, double max_step, double jump_threshold_factor, const GroupStateValidityCallbackFn &validCallback=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
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.
const std::vector< const JointModel * > & getMimicJointModels() const
Get the mimic joints that are part of this group.
void setJointPositions(const JointModel *joint, const double *position)
Eigen::Affine3d * global_link_transforms_
const double * getJointEffort(const JointModel *joint) const
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...
bool enforceVelocityBounds(double *values) const
Force the specified velocities to be within bounds. Return true if changes were made.
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...
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 satisfiesBounds(const JointModel *joint, double margin=0.0) const
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.
double computeCartesianPath(const JointModelGroup *group, std::vector< RobotStatePtr > &traj, const LinkModel *link, const EigenSTL::vector_Affine3d &waypoints, bool global_reference_frame, double max_step, double jump_threshold_factor, const GroupStateValidityCallbackFn &validCallback=GroupStateValidityCallbackFn(), const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions())
void markDirtyJointTransforms(const JointModel *joint)
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...
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...
int getFirstCollisionBodyTransformIndex() const
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...
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...
bool satisfiesVelocityBounds(const JointModel *joint, double margin=0.0) const
bool satisfiesPositionBounds(const JointModel *joint, double margin=0.0) const
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...
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
unsigned int getVariableCount() const
Get the number of variables that describe this joint group. This includes variables necessary for mim...
const double * getJointEffort(const std::string &joint_name) const
const Eigen::Affine3d & getJointTransform(const JointModel *joint) const
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...
int getLinkIndex() const
The index of this joint when traversing the kinematic tree in depth first fashion.
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...
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...
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...
const Eigen::Affine3d & getCollisionBodyTransforms(const std::string &link_name, std::size_t index)
void enforceBounds(const JointModel *joint)
int getJointIndex() const
Get the index of this joint within the robot model.
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) ...
MOVEIT_CLASS_FORWARD(RobotModel)
MaxEEFStep(double translation=0.0, double rotation=0.0)
void setJointPositions(const JointModel *joint, const std::vector< double > &position)
boost::function< void(AttachedBody *body, bool attached)> AttachedBodyCallback
double distance(const RobotState &other, const JointModel *joint) const
void setVariableAccelerations(const std::vector< double > &acceleration)
Given an array with acceleration values for all variables, set those values as the accelerations in t...
const Eigen::Affine3d & getCollisionBodyTransform(const LinkModel *link, std::size_t index)
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 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...
unsigned char * dirty_joint_transforms_
bool dirtyLinkTransforms() const
void updateStateWithLinkAt(const std::string &link_name, const Eigen::Affine3d &transform, bool backward=false)
Update the state after setting a particular link to the input global transform pose.
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 double * getVariablePositions() const
Get a raw pointer to the positions of the variables stored in this state.
Struct for containing max_step for computeCartesianPath.
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...
const RobotModelConstPtr & getRobotModel() const
Get the robot model this state is constructed for.
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.
void markDirtyJointTransforms(const JointModelGroup *group)
double * getVariableVelocities()
Get raw access to the velocities of the variables that make up this state. The values are in the same...
const JointModel * getJointModel(const std::string &joint) const
Get the model of a particular joint.
const JointModel * getCommonRoot() const
Get the common root of all joint roots; not necessarily part of this group.
void setVariableVelocity(int index, double value)
Set the velocity of a single variable. The variable is specified by its index (a value associated by ...
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)
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...
virtual void computeTransform(const double *joint_values, Eigen::Affine3d &transf) const =0
Given the joint values for a joint, compute the corresponding transform.
const JointModel * dirty_link_transforms_
int getFirstVariableIndex() const
Get the index of this joint's first variable within the full robot state.
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.
double * getVariableAccelerations()
Get raw access to the accelerations of the variables that make up this state. The values are in the s...
const LinkModel * getLinkModel(const std::string &link) const
Get the model of a particular link.
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...
const double * getJointAccelerations(const JointModel *joint) const
random_numbers::RandomNumberGenerator * rng_
For certain operations a state needs a random number generator. However, it may be slightly expensive...
bool hasEffort() const
By default, if effort is never set or initialized, the state remembers that there is no effort set...
void setJointPositions(const JointModel *joint, const Eigen::Affine3d &transform)
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...
void interpolate(const RobotState &to, double t, RobotState &state, const JointModel *joint) const
Update state by interpolating form this state towards to, at time t in [0,1] but only for the joint j...
const double * getVariableVelocities() const
Get const access to the velocities of the variables that make up this state. The values are in the sa...
const double * getJointVelocities(const JointModel *joint) const
const Eigen::Affine3d & getJointTransform(const std::string &joint_name)
Representation of a robot's state. This includes position, velocity, acceleration and effort...
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 setVariableAcceleration(const std::string &variable, double value)
Set the acceleration of a variable. If an unknown variable name is specified, an exception is thrown...
double getVariablePosition(const std::string &variable) const
Get the position of a particular variable. An exception is thrown if the variable is not known...
A link from the robot. Contains the constant transform applied to the link and its geometry...
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 setVariableEffort(const double *effort)
Given an array with effort values for all variables, set those values as the effort in this state...
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()
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...
bool dirty() const
Returns true if anything in this state is dirty.
bool dirtyJointTransform(const JointModel *joint) const
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...
const double * getJointPositions(const std::string &joint_name) const
const double * getJointAccelerations(const std::string &joint_name) const
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!
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...
const Eigen::Affine3d & getGlobalLinkTransform(const LinkModel *link)
double getVariableEffort(int index) const
Get the effort of a particular variable. The variable is specified by its index. No checks are perfor...
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. ...
std::size_t getVariableCount() const
Get the number of variables that make up this state.
double getVariableVelocity(const std::string &variable) const
Get the velocity of a particular variable. An exception is thrown if the variable is not known...
Object defining bodies that can be attached to robot links. This is useful when handling objects pick...
Eigen::Affine3d * variable_joint_transforms_
std::ostream & operator<<(std::ostream &out, const VariableBounds &b)
Operator overload for printing variable bounds to a stream.
void setVariablePosition(int index, double value)
Set the position of a single variable. The variable is specified by its index (a value associated by ...
bool dirtyCollisionBodyTransforms() const
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...
virtual void computeVariablePositions(const Eigen::Affine3d &transform, double *joint_values) const =0
Given the transform generated by joint, compute the corresponding joint values.
double distance(const urdf::Pose &transform)
const double * getJointPositions(const JointModel *joint) const
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_...
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())
std::map< std::string, AttachedBody * > attached_body_map_
All attached bodies that are part of this state, indexed by their name.
double getVariableEffort(const std::string &variable) const
Get the effort of a particular variable. An exception is thrown if the variable is not known...
void setJointPositions(const std::string &joint_name, const Eigen::Affine3d &transform)
MOVEIT_DEPRECATED void updateMimicJoint(const std::vector< const JointModel * > &mim)
Update a set of joints that are certain to be mimicking other joints.
void setJointVelocities(const JointModel *joint, const double *velocity)