6 #include <moveit/robot_state/conversions.h>
7 #include <moveit/robot_state/robot_state.h>
71 if (not limits_file.
empty())
74 RBX_ERROR(
"Failed to load joint limits!");
78 if (not kinematics_file.
empty())
100 RBX_ERROR(
"Failed to load YAML file `%s`.", config_file);
104 const auto &node = yaml.second;
112 RBX_ERROR(
"No URDF entry in YAML file `%s`!", config_file);
127 if (srdf_file.
empty())
129 RBX_ERROR(
"Cannot provide joint limits without SRDF in YAML file `%s`!", config_file);
136 RBX_WARN(
"No joint limits provided!");
142 if (srdf_file.
empty())
144 RBX_ERROR(
"Cannot provide kinematics without SRDF in YAML file `%s`!", config_file);
148 kinematics_file = node[
"kinematics"].as<
std::string>();
151 RBX_WARN(
"No kinematics plugins provided!");
155 if (srdf_file.
empty())
158 r =
initialize(urdf_file, srdf_file, limits_file, kinematics_file);
169 RBX_WARN(
"No default state provided!");
187 tinyxml2::XMLDocument doc;
189 const auto &name = doc.FirstChildElement(
"robot")->Attribute(
"name");
217 auto *node = doc.FirstChildElement(
"robot")->FirstChildElement(
"link");
218 while (node !=
nullptr)
220 if (node->Attribute(
"name", name.
c_str()))
223 node = node->NextSiblingElement(
"link");
255 RBX_ERROR(
"Failed to load YAML file `%s`.", file);
261 YAML::Node copy = yaml.second;
264 RBX_ERROR(
"Failed to process YAML file `%s`.", file);
281 RBX_ERROR(
"Failed to load XML file `%s`.", file);
292 tinyxml2::XMLDocument doc;
293 doc.Parse(
string.c_str());
295 if (not
function(doc))
297 RBX_ERROR(
"Failed to process XML string `%s`.",
string);
301 tinyxml2::XMLPrinter printer;
322 RBX_INFO(
"Reloading model after URDF/SRDF post-process function...");
336 robot_model_loader::RobotModelLoader::Options options(description);
337 options.load_kinematics_solvers_ =
false;
338 options.urdf_string_ =
urdf_;
339 options.srdf_string_ =
srdf_;
341 loader_.
reset(
new robot_model_loader::RobotModelLoader(options));
342 kinematics_.reset(
new kinematics_plugin_loader::KinematicsPluginLoader(description));
350 robot_model::SolverAllocatorFn allocator =
kinematics_->getLoaderFunction(
loader_->getSRDF());
352 const auto &groups =
kinematics_->getKnownGroups();
355 RBX_ERROR(
"No kinematics plugins defined. Fill and load kinematics.yaml!");
359 if (!
model_->hasJointModelGroup(group_name))
361 RBX_ERROR(
"No JMG defined for `%s`!", group_name);
370 const auto &subgroups =
model_->getJointModelGroup(group_name)->getSubgroupNames();
371 load_names.
insert(load_names.
end(), subgroups.begin(), subgroups.end());
375 if (
std::find(groups.begin(), groups.end(), group_name) != groups.end())
380 for (
const auto &name : load_names)
386 if (!
model_->hasJointModelGroup(name) ||
387 std::find(groups.begin(), groups.end(), name) == groups.end())
389 RBX_ERROR(
"No JMG or Kinematics defined for `%s`!", name);
393 robot_model::JointModelGroup *jmg =
model_->getJointModelGroup(name);
394 kinematics::KinematicsBasePtr solver = allocator(jmg);
399 if (solver->supportsGroup(jmg, &error_msg))
400 imap_[name] = allocator;
403 RBX_ERROR(
"Kinematics solver %s does not support joint group %s. Error: %s",
404 typeid(*solver).name(), name, error_msg);
410 RBX_ERROR(
"Kinematics solver could not be instantiated for joint group `%s`.", name);
414 RBX_INFO(
"Loaded Kinematics Solver for `%s`", name);
415 jmg->setDefaultIKTimeout(timeout[name]);
425 tinyxml2::XMLElement *virtual_joint = doc.NewElement(
"virtual_joint");
426 virtual_joint->SetAttribute(
"name", name.
c_str());
427 virtual_joint->SetAttribute(
"type",
"planar");
428 virtual_joint->SetAttribute(
"parent_frame",
"world");
429 virtual_joint->SetAttribute(
"child_link",
model_->getRootLink()->getName().c_str());
431 doc.FirstChildElement(
"robot")->InsertFirstChild(virtual_joint);
440 tinyxml2::XMLElement *virtual_joint = doc.NewElement(
"virtual_joint");
441 virtual_joint->SetAttribute(
"name", name.
c_str());
442 virtual_joint->SetAttribute(
"type",
"floating");
443 virtual_joint->SetAttribute(
"parent_frame",
"world");
444 virtual_joint->SetAttribute(
"child_link",
model_->getRootLink()->getName().c_str());
446 doc.FirstChildElement(
"robot")->InsertFirstChild(virtual_joint);
522 scratch_->setVariablePositions(positions);
528 scratch_->setVariablePositions(variable_map);
535 scratch_->setVariablePositions(variable_names, variable_position);
553 moveit_msgs::RobotState state;
561 scratch_->setJointGroupPositions(name, positions);
567 const double *positions =
scratch_->getVariablePositions();
574 moveit_msgs::RobotState message;
587 temp.setJointGroupPositions(jmg, positions);
594 return scratch_->getVariableNames();
600 return (
std::find(joint_names.begin(), joint_names.end(), joint) != joint_names.end());
612 const robot_state::RobotState &start,
const Eigen::Vector3d &direction,
614 :
IKQuery(group, tip, start, distance * direction.normalized())
619 const robot_state::RobotState &start,
const Eigen::Vector3d &position_offset,
620 const Eigen::Quaterniond &rotation_offset)
626 const robot_state::RobotState &start,
const RobotPose &offset)
627 :
IKQuery(group, start.getGlobalLinkTransform(tip) * offset)
635 const Eigen::Vector3d &tolerances,
637 : group(group),
scene(
scene), verbose(verbose)
639 const auto &pose =
scene->getObjectGraspPose(
object, offset);
643 Eigen::Quaterniond(pose.rotation()));
647 const Eigen::Vector3d &tolerance)
650 Eigen::Quaterniond{pose.rotation()},
657 const Eigen::Vector3d &position,
const Eigen::Quaterniond &orientation,
658 double radius,
const Eigen::Vector3d &tolerance)
668 const Eigen::Quaterniond &orientation,
const Eigen::Vector3d &tolerance,
670 : group(group),
scene(
scene), verbose(verbose)
672 addRequest(
"", region, pose, orientation, tolerance);
676 const moveit_msgs::OrientationConstraint &oc)
679 if (pc.link_name != oc.link_name)
681 1,
log::format(
"Link name mismatch in constraints, `%1%` != `%2%`", pc.link_name, oc.link_name));
684 throw Exception(1,
"target_point_offset in position constraint not supported.");
686 const auto &cr = pc.constraint_region;
688 if (not cr.meshes.empty())
689 throw Exception(1,
"Cannot specify mesh regions!");
691 if (cr.primitives.size() > 1)
692 throw Exception(1,
"Cannot specify more than one primitive!");
698 Eigen::Vector3d tolerance{oc.absolute_x_axis_tolerance,
699 oc.absolute_y_axis_tolerance,
700 oc.absolute_z_axis_tolerance};
702 addRequest(pc.link_name, region, pose, rotation, tolerance);
707 const Eigen::Vector3d &tolerance,
const ScenePtr &
scene,
bool verbose)
708 : group(group),
scene(
scene), verbose(verbose)
710 if (poses.
size() != input_tips.
size())
711 throw Exception(1,
"Invalid multi-target IK query. poses != tips.");
717 Eigen::Quaterniond{poses[i].rotation()},
724 const EigenSTL::vector_Vector3d &tolerances,
const ScenePtr &
scene,
bool verbose)
725 : group(group),
scene(
scene), verbose(verbose)
727 if (poses.
size() != input_tips.
size()
731 throw Exception(1,
"Invalid multi-target IK query. Vectors are of different length.");
738 const Eigen::Quaterniond &orientation,
const Eigen::Vector3d &tolerance)
741 regions.emplace_back(region);
742 region_poses.emplace_back(pose);
743 orientations.emplace_back(orientation);
744 tolerances.emplace_back(tolerance);
750 verbose = verbose_in;
755 metrics.emplace_back(metric_function);
768 addMetric([&, weight](
const robot_state::RobotState &state,
const SceneConstPtr &
scene,
770 const auto &jmg = state.getJointModelGroup(group);
771 const auto &min = state.getMinDistanceToPositionBounds(jmg);
772 double extent = min.second->getMaximumExtent() / 2.;
773 return weight * (extent - min.first) / extent;
779 addMetric([&, weight](
const robot_state::RobotState &state,
const SceneConstPtr &
scene,
783 double v =
scene->distanceToCollision(state);
793 const auto &point = regions[index]->sample();
796 pose = region_poses[index];
797 pose.translate(point.second);
811 sampled &= sampleRegion(poses[j], j);
820 msg.name =
"IKQuery";
827 orn.weight = 1. / n / 2.;
829 msg.position_constraints.emplace_back(pos);
830 msg.orientation_constraints.emplace_back(orn);
836 moveit_msgs::Constraints msg;
837 const auto &root =
robot.getModelConst()->getRootLink()->getName();
838 getMessage(root, msg);
840 auto constraints = std::make_shared<kinematic_constraints::KinematicConstraintSet>(
robot.getModelConst());
843 constraints->add(msg, none);
852 for (
const auto &metric : metrics)
853 v += metric(state,
scene, result);
873 const robot_model::JointModelGroup *jmg =
model_->getJointModelGroup(query_copy.
group);
874 const auto &gsvcf = (query_copy.
scene) ? query_copy.
scene->getGSVCF(query_copy.
verbose) :
880 const auto &constraints = (evaluate) ? query_copy.
getAsConstraints(*
this) :
nullptr;
883 auto best = (query_copy.
metrics.empty()) ?
nullptr : std::make_shared<robot_state::RobotState>(state);
886 bool success =
false;
893 #if ROBOWFLEX_AT_LEAST_MELODIC
897 state.setFromIK(jmg, targets, query_copy.
tips, query_copy.
timeout, gsvcf, query_copy.
options);
901 state.setFromIK(jmg, targets, query_copy.
tips, 1, query_copy.
timeout, gsvcf, query_copy.
options);
907 result = constraints->decide(state, query_copy.
verbose);
917 (query_copy.
scene) ? not query_copy.
scene->checkCollision(state).collision :
true;
926 if (success and not query_copy.
metrics.empty())
931 RBX_INFO(
"State Metric Value: %1%", v);
946 state.setToRandomPositions(jmg);
963 const auto &result = constraints->decide(state, query.
verbose);
970 const auto &result = constraints->decide(state, query.
verbose);
971 return result.distance;
976 return scratch_->getGlobalLinkTransform(name);
981 auto base_tf =
scratch_->getGlobalLinkTransform(base);
982 auto target_tf =
scratch_->getGlobalLinkTransform(target);
984 return base_tf.inverse() * target_tf;
989 moveit_msgs::RobotState msg;
999 robot_state::RobotStatePtr state;
1001 state->setToDefaultValues();
1008 const auto &jmg =
model_->getJointModelGroup(group);
1009 const auto &solver = jmg->getSolverInstance();
1011 return solver->getTipFrames();
1018 const auto &jmg =
model_->getJointModelGroup(group);
1019 const auto &solver = jmg->getSolverInstance();
1021 return solver->getBaseFrame();
1028 YAML::Node addLinkGeometry(
const urdf::GeometrySharedPtr &geometry,
bool resolve =
true)
1031 switch (geometry->type)
1033 case urdf::Geometry::MESH:
1035 const auto &mesh =
static_cast<urdf::Mesh *
>(geometry.get());
1036 node[
"type"] =
"mesh";
1041 node[
"resource"] = mesh->filename;
1043 if (mesh->scale.x != 1 || mesh->scale.y != 1 || mesh->scale.z != 1)
1050 case urdf::Geometry::BOX:
1052 const auto &box =
static_cast<urdf::Box *
>(geometry.get());
1053 node[
"type"] =
"box";
1058 case urdf::Geometry::SPHERE:
1060 const auto &sphere =
static_cast<urdf::Sphere *
>(geometry.get());
1061 node[
"type"] =
"sphere";
1066 case urdf::Geometry::CYLINDER:
1068 const auto &cylinder =
static_cast<urdf::Cylinder *
>(geometry.get());
1069 node[
"type"] =
"cylinder";
1081 void addLinkMaterial(YAML::Node &node,
const urdf::MaterialSharedPtr &material)
1084 std::vector<double>({material->color.r, material->color.g, material->color.b, material->color.a});
1090 void addLinkOrigin(YAML::Node &node,
const urdf::Pose &pose)
1093 origin[
"position"] =
std::vector<double>({pose.position.x, pose.position.y, pose.position.z});
1094 origin[
"orientation"] =
1095 std::vector<double>({pose.rotation.x, pose.rotation.y, pose.rotation.z, pose.rotation.w});
1096 node[
"origin"] = origin;
1100 YAML::Node addLinkVisual(
const urdf::VisualSharedPtr &visual,
bool resolve =
true)
1105 if (visual->geometry)
1107 const auto &geometry = visual->geometry;
1108 node = addLinkGeometry(geometry, resolve);
1110 if (visual->material)
1112 const auto &material = visual->material;
1113 addLinkMaterial(node, material);
1116 const auto &pose = visual->origin;
1118 Eigen::Vector3d position(pose.position.x, pose.position.y, pose.position.z);
1119 Eigen::Quaterniond rotation(pose.rotation.w,
1120 pose.rotation.x, pose.rotation.y, pose.rotation.z);
1121 Eigen::Quaterniond
identity = Eigen::Quaterniond::Identity();
1124 if (position.norm() > 0 || rotation.angularDistance(
identity) > 0)
1125 addLinkOrigin(node, pose);
1132 YAML::Node addLinkCollision(
const urdf::CollisionSharedPtr &collision)
1137 if (collision->geometry)
1139 const auto &geometry = collision->geometry;
1140 node = addLinkGeometry(geometry);
1147 RobotPose urdfPoseToEigen(
const urdf::Pose &pose)
1149 geometry_msgs::Pose msg;
1150 msg.position.x = pose.position.x;
1151 msg.position.y = pose.position.y;
1152 msg.position.z = pose.position.z;
1154 msg.orientation.x = pose.rotation.x;
1155 msg.orientation.y = pose.rotation.y;
1156 msg.orientation.z = pose.rotation.z;
1157 msg.orientation.w = pose.rotation.w;
1165 YAML::Node link_geometry;
1166 const auto &urdf =
model_->getURDF();
1169 urdf->getLinks(links);
1171 for (
const auto &link : links)
1176 #if ROBOWFLEX_AT_LEAST_KINETIC
1177 for (
const auto &element : link->visual_array)
1179 visual[
"elements"].
push_back(addLinkVisual(element));
1182 visual[
"elements"].push_back(addLinkVisual(link->visual));
1185 YAML::Node collision;
1186 #if ROBOWFLEX_AT_LEAST_KINETIC
1187 for (
const auto &element : link->collision_array)
1189 collision[
"elements"].push_back(addLinkCollision(element));
1191 if (link->collision)
1192 collision[
"elements"].push_back(addLinkCollision(link->collision));
1195 if (!visual.IsNull() || !collision.IsNull())
1198 add[
"name"] = link->name;
1200 if (!visual.IsNull())
1201 add[
"visual"] = visual;
1203 if (!collision.IsNull())
1204 add[
"collision"] = collision;
1206 link_geometry.push_back(add);
1222 double fps,
double threshold)
const
1224 YAML::Node node, values;
1225 const double rate = 1.0 / fps;
1231 const auto &urdf =
model_->getURDF();
1233 robot_state::RobotStatePtr previous, state(
new robot_state::RobotState(
model_));
1235 for (
double duration = 0.0, delay = 0.0; duration <= total_duration; duration += rate, delay += rate)
1240 if (previous && state->distance(*previous) < threshold)
1244 for (
const auto &link_name :
model_->getLinkModelNames())
1246 const auto &urdf_link = urdf->getLink(link_name);
1247 if (urdf_link->visual)
1249 const auto &link =
model_->getLinkModel(link_name);
1251 state->getGlobalLinkTransform(link);
1257 value[
"point"] = point;
1258 value[
"duration"] = delay;
1259 values.push_back(value);
1264 previous.reset(
new robot_state::RobotState(
model_));
1269 node[
"transforms"] = values;
1279 const auto &urdf =
model_->getURDF();
1280 for (
const auto &link_name :
model_->getLinkModelNames())
1282 const auto &urdf_link = urdf->getLink(link_name);
1283 if (urdf_link->visual)
1285 const auto &link =
model_->getLinkModel(link_name);
1288 #if ROBOWFLEX_AT_LEAST_KINETIC
1289 for (
const auto &element : urdf_link->visual_array)
1293 if (urdf_link->visual)
1294 visuals.
push_back(addLinkVisual(urdf_link->visual,
false));
1298 object[
"id"] = link->getName();
1301 YAML::Node mesh_poses;
1303 YAML::Node primitive_poses;
1306 for (
const auto &visual : visuals)
1312 pose = pose * offset;
1317 const auto &type = visual[
"type"].as<
std::string>();
1321 mesh[
"resource"] = visual[
"resource"];
1323 mesh[
"dimensions"] = visual[
"dimensions"];
1327 mesh[
"dimensions"].push_back(1.);
1328 mesh[
"dimensions"].push_back(1.);
1333 meshes.push_back(mesh);
1334 mesh_poses.push_back(posey);
1338 YAML::Node primitive;
1339 primitive[
"type"] = type;
1340 primitive[
"dimensions"] = visual[
"dimensions"];
1341 primitive_poses.push_back(posey);
1347 object[
"meshes"] = meshes;
1348 object[
"mesh_poses"] = mesh_poses;
1354 object[
"primitive_poses"] = primitive_poses;
1357 node[
"collision_objects"].push_back(
object);
1362 scene[
"world"] = node;
const std::deque< double > & getWayPointDurations() const
bool getStateAtDurationFromStart(const double request_duration, robot_state::RobotStatePtr &output_state) const
void addSuffixWayPoint(const robot_state::RobotState &state, double dt)
Exception that contains a message and an error code.
A const shared pointer wrapper for robowflex::Geometry.
A class that manages both solid and mesh geometry for various parts of the motion planning system.
static GeometryPtr makeSphere(double radius)
Create a sphere.
static GeometryPtr makeBox(double x, double y, double z)
Create a box.
static GeometryPtr makeSolidPrimitive(const shape_msgs::SolidPrimitive &msg)
Create a solid primitive.
ROS parameter server handler to handle namespacing and automatic parameter deletion.
void setParam(const std::string &key, const T &value)
Sets a parameter on the parameter server.
bool getParam(const std::string &key, T &value) const
Gets a parameter from the parameter server.
void loadYAMLtoROS(const YAML::Node &node, const std::string &prefix="")
Loads the contents of a YAML node to the parameter server under a prefix.
const std::string & getNamespace() const
Gets the namespace of the handler.
ParamRobot(const std::string &name="DEFAULT")
Loads information about a robot and maintains information about a robot's state.
bool dumpGeometry(const std::string &file) const
Dumps the names of links and absolute paths to their visual mesh files to a YAML file.
std::vector< std::string > getJointNames() const
Gets the names of joints of the robot.
const RobotPose & getLinkTF(const std::string &name) const
Get the current pose of a link on the scratch state.
void setSRDFPostProcessAddFloatingJoint(const std::string &name)
Adds a planar virtual joint through the SRDF to the loaded robot with name name. This joint will have...
void setLimitsPostProcessFunction(const PostProcessYAMLFunction &function)
Sets a post processing function for loading the joint limits file.
static const std::string ROBOT_KINEMATICS
Default robot kinematics description suffix.
bool initializeFromYAML(const std::string &config_file)
Initializes a robot from a YAML config which includes URDF (urdf) and optional the SRDF (srdf),...
std::vector< double > getState() const
Gets the current joint positions of the scratch state.
kinematics_plugin_loader::KinematicsPluginLoaderPtr kinematics_
Kinematic plugin loader.
void loadRobotModel(const std::string &description)
Loads a robot model from the loaded information on the parameter server.
std::string urdf_
The URDF as a string.
const RobotPose getRelativeLinkTF(const std::string &base, const std::string &target) const
Get the current pose of a link target in the frame of base.
PostProcessXMLFunction urdf_function_
URDF post-processing function.
bool validateIKQuery(const IKQuery &query, const robot_state::RobotState &state) const
Validates that a state satisfies an IK query's request poses.
Robot(const std::string &name)
Constructor.
bool dumpTransforms(const std::string &filename) const
Dumps the tranforms of all links of a robot at its current state to a file.
IO::Handler & getHandler()
Get the underlying IO handler used for this robot.
robot_model::RobotStatePtr cloneScratchState() const
Allocate a new robot state that is a clone of the current scratch state.
void initializeInternal(bool namespaced=true)
Initializes and loads the robot. Calls post-processing functions and creates scratch state.
srdf::ModelConstSharedPtr getSRDF() const
Get the raw SRDF Model.
PostProcessXMLFunction srdf_function_
SRDF post-processing function.
void setSRDFPostProcessFunction(const PostProcessXMLFunction &function)
Sets a post processing function for loading the SRDF.
const IO::Handler & getHandlerConst() const
Get the underlying IO handler used for this robot.
std::string loadXMLFile(const std::string &file)
Loads an XML or .xacro file into a string.
PostProcessYAMLFunction limits_function_
Limits YAML post-processing function.
void setKinematicsPostProcessFunction(const PostProcessYAMLFunction &function)
Sets a post processing function for loading the kinematics plugin file.
void setURDFPostProcessFunction(const PostProcessXMLFunction &function)
Sets a post processing function for loading the URDF.
const std::string name_
Robot name.
std::vector< std::string > getSolverTipFrames(const std::string &group) const
Get the tip frames for the IK solver for a given joint model group group.
void updateXMLString(std::string &string, const PostProcessXMLFunction &function)
Updates a loaded XML string based on an XML post-process function. Called after initial,...
double distanceToIKQuery(const IKQuery &query, const robot_state::RobotState &state) const
Returns the distance of the state to satisfying the IK query.
bool isLinkURDF(tinyxml2::XMLDocument &doc, const std::string &name)
Checks if a node link exist with named name_link.
PostProcessYAMLFunction kinematics_function_
Kinematics plugin YAML post-processing function.
bool loadURDFFile(const std::string &urdf_file)
Loads the URDF file.
bool toYAMLFile(const std::string &file) const
Dumps the current configuration of the robot as a YAML file.
robot_model::RobotStatePtr & getScratchState()
Get a reference to the scratch robot state.
urdf::ModelInterfaceConstSharedPtr getURDF() const
Get the raw URDF Model.
std::string getSolverBaseFrame(const std::string &group) const
Get the base frame for the IK solver given a joint model group group.
IO::Handler handler_
IO handler (namespaced with name_)
void setGroupState(const std::string &name, const std::vector< double > &positions)
Sets the group of the scratch state to a vector of joint positions.
bool initialize(const std::string &urdf_file)
Initializes a robot from a kinematic description. A default semantic description is used.
void setStateMsgGroupState(moveit_msgs::RobotState &state, const std::string &group, const std::vector< double > &positions) const
Set the group state of a MoveIt RobotState message.
std::string srdf_
The SRDF as a string.
bool dumpToScene(const std::string &filename) const
Dumps the current scratch configuration of the robot to a YAML file compatible with a scene.
bool setFromIK(const IKQuery &query)
Sets a group of the scratch state from an IK query. If the IK query fails the scratch state retains i...
bool loadYAMLFile(const std::string &name, const std::string &file)
Loads a YAML file into the robot's namespace under name.
void setSRDFPostProcessAddPlanarJoint(const std::string &name)
Adds a planar virtual joint through the SRDF to the loaded robot with name name. This joint will have...
bool loadKinematics(const std::string &group, bool load_subgroups=true)
Loads the kinematics plugin for a joint group and its subgroups. No kinematics are loaded by default.
const std::string & getName() const
Get the robot's name.
static const std::string ROBOT_DESCRIPTION
Default robot description name.
const robot_model::RobotStatePtr & getScratchStateConst() const
Get a const reference to the scratch robot state.
static const std::string ROBOT_SEMANTIC
Default robot semantic description suffix.
const std::string & getSRDFString() const
Get the raw SRDF Model as a string.
moveit_msgs::RobotState getStateMsg() const
Get the current scratch state as a message.
robot_model::RobotModelPtr & getModel()
Get a reference to the loaded robot model.
std::map< std::string, robot_model::SolverAllocatorFn > imap_
Kinematic solver allocator map.
const std::string & getModelName() const
Get the robot's model name.
robot_state::RobotStatePtr scratch_
Scratch robot state.
void setState(const std::vector< double > &positions)
Sets the scratch state from a vector of joint positions (all must be specified)
std::shared_ptr< robot_model_loader::RobotModelLoader > loader_
Robot model loader.
robot_model::RobotModelPtr model_
Loaded robot model.
bool hasJoint(const std::string &joint) const
Checks if a joint exists in the robot.
const robot_model::RobotModelPtr & getModelConst() const
Get a const reference to the loaded robot model.
robot_model::RobotStatePtr allocState() const
Allocate a new robot state.
static const std::string ROBOT_PLANNING
Default robot planning description suffix.
const std::string & getURDFString() const
Get the raw URDF Model as a string.
void setStateFromYAMLFile(const std::string &file)
Sets the scratch state from a robot state message saved to a YAML file.
bool initializeKinematics(const std::string &kinematics_file)
Initialize a robot with a kinematics description.
bool dumpPathTransforms(const robot_trajectory::RobotTrajectory &path, const std::string &filename, double fps=30, double threshold=0.0) const
Dumps the tranforms of all links of a robot through a robot trajectory to a file.
bool loadSRDFFile(const std::string &srdf_file)
Loads the SRDF file.
A const shared pointer wrapper for robowflex::Scene.
A shared pointer wrapper for robowflex::Scene.
T emplace_back(T... args)
#define RBX_WARN(fmt,...)
Output a warning logging message.
#define RBX_ERROR(fmt,...)
Output a error logging message.
#define RBX_INFO(fmt,...)
Output a info logging message.
#define ROBOWFLEX_YAML_FLOW(n)
bool robotStateMsgToRobotState(const Transforms &tf, const moveit_msgs::RobotState &robot_state, RobotState &state, bool copy_attached_bodies=true)
void robotStateToRobotStateMsg(const RobotState &state, moveit_msgs::RobotState &robot_state, bool copy_attached_bodies=true)
boost::function< bool(RobotState *robot_state, const JointModelGroup *joint_group, const double *joint_group_variable_values)> GroupStateValidityCallbackFn
Functions for constructing shapes in Blender.
Functions for loading and animating robots in Blender.
bool YAMLToFile(const YAML::Node &node, const std::string &file)
Write the contents of a YAML node out to a potentially new file.
bool isNode(const YAML::Node &node)
Checks if a key exists within a YAML node.
bool fromYAMLFile(moveit_msgs::PlanningScene &msg, const std::string &file)
Loads a planning scene from a YAML file.
std::pair< bool, YAML::Node > loadFileToYAML(const std::string &path)
Loads a file to a YAML node.
moveit_msgs::RobotState robotStateFromNode(const YAML::Node &node)
Converts a robot state YAML to a robot_state message.
std::string resolvePath(const std::string &path)
Resolves package:// URLs and relative file paths to their canonical form.
geometry_msgs::Pose poseFromNode(const YAML::Node &node)
Converts a pose YAML to a goemetry message.
std::string loadXMLToString(const std::string &path)
Loads an XML or .xacro file to a string.
YAML::Node toNode(const geometry_msgs::Pose &msg)
Converts a pose message to YAML.
moveit_msgs::OrientationConstraint getOrientationConstraint(const std::string &ee_name, const std::string &base_name, const Eigen::Quaterniond &orientation, const Eigen::Vector3d &tolerances)
Get an orientation constraint message.
Eigen::Vector3d vectorMsgToEigen(const geometry_msgs::Vector3 &msg)
Converts a vector message to an Eigen::Vector3d.
RobotPose poseMsgToEigen(const geometry_msgs::Pose &msg)
Converts a pose message to RobotPose.
RobotPose createPoseQ(double x, double y, double z, double W, double X, double Y, double Z)
Creates a robot pose from a linear component and a Quaternion.
RobotPose createPoseXYZ(double x, double y, double z)
Creates a robot pose from a linear component and zero orientation.
Eigen::Quaterniond sampleOrientation(const Eigen::Quaterniond &orientation, const Eigen::Vector3d &tolerances)
Sample an orientation from a given orientation with XYZ Euler angle tolerances.
geometry_msgs::Pose poseEigenToMsg(const RobotPose &pose)
Converts an RobotPose to a pose message.
Eigen::Quaterniond quaternionMsgToEigen(const geometry_msgs::Quaternion &msg)
Converts a quaternion message to Eigen::Quaterniond.
RobotPose identity()
Creates the Identity pose.
moveit_msgs::PositionConstraint getPositionConstraint(const std::string &ee_name, const std::string &base_name, const RobotPose &pose, const GeometryConstPtr &geometry)
Get a position constraint message.
bool isVecZero(const Eigen::Ref< const Eigen::VectorXd > &v, double tolerance=constants::eps)
Checks if a vector is close to zero.
std::shared_ptr< dart::dynamics::SphereShape > makeSphere(double radius)
Create a sphere.
std::string format(const std::string &fmt, Args &&... args)
Recursion base case, return string form of formatted arguments.
Main namespace. Contains all library classes and functions.
std::decay< decltype(std::declval< moveit::core::Transforms >().getTransform("")) >::type RobotPose
A pose (point in SE(3)) used in various functions. Defined from what MoveIt! uses.
Functions for loading and animating scenes in Blender.
const std::vector< std::string > tips
Robot IK Query options. IK queries in Robowflex consist of: a) A position specified by some geometric...
void addRequest(const std::string &tip, const GeometryConstPtr ®ion, const RobotPose &pose, const Eigen::Quaterniond &orientation, const Eigen::Vector3d &tolerance=constants::ik_vec_tolerance)
Add a request for a tip.
kinematics::KinematicsQueryOptions options
Other query options.
void addCenteringMetric(double weight=1.)
Add a metric to the query to evaluate how "centered" the joints of the robot are (from their 0 positi...
std::string group
Target joint group to do IK for.
bool verbose
Verbose output of collision checking.
void addClearanceMetric(double weight=1.)
Add a metric to the query to evaluate clearance from provided scene.
EigenSTL::vector_Vector3d tolerances
XYZ Euler orientation tolerances.
bool sampleRegion(RobotPose &pose, std::size_t index) const
Sample desired end-effector pose for region at index.
kinematic_constraints::KinematicConstraintSetPtr getAsConstraints(const Robot &robot) const
Get this IK query as a kinematic constraint set.
bool sampleRegions(RobotPoseVector &poses) const
Sample desired end-effector pose for each region.
double getMetricValue(const robot_state::RobotState &state, const kinematic_constraints::ConstraintEvaluationResult &result) const
Get the value of the metrics assigned to this query for a given state and result.
void setScene(const ScenePtr &scene, bool verbose=false)
Set a scene to use for collision checking for this IK request.
double timeout
Timeout for each query.
std::vector< Eigen::Quaterniond > orientations
Target orientations.
SceneConstPtr scene
If provided, use this scene for collision checking.
std::vector< Metric > metrics
void addMetric(const Metric &metric_function)
Add a metric to this IK query.
bool random_restart
Randomly reset joint states.
std::size_t attempts
IK attempts (samples within regions).
void addDistanceMetric(double weight=1.)
Add a metric to the query to evaluate distance to constraint.
std::vector< std::string > tips
List of end-effectors.
IKQuery(const std::string &group)
Constructor. Empty for fine control.
std::vector< GeometryConstPtr > regions
Regions to sample target positions from.
void getMessage(const std::string &base_frame, moveit_msgs::Constraints &msg) const
Get this IK query as a constraint message.
robot_trajectory::RobotTrajectory trajectory(rmodel,"right_arm")