3 #ifndef ROBOWFLEX_ROBOT_
4 #define ROBOWFLEX_ROBOT_
11 #include <Eigen/Geometry>
13 #include <urdf/model.h>
14 #include <srdfdom/model.h>
17 #include <moveit_msgs/PositionConstraint.h>
18 #include <moveit_msgs/OrientationConstraint.h>
19 #include <moveit_msgs/Constraints.h>
21 #include <moveit/robot_model/robot_model.h>
22 #include <moveit/robot_state/robot_state.h>
23 #include <moveit/robot_trajectory/robot_trajectory.h>
24 #include <moveit/robot_model_loader/robot_model_loader.h>
25 #include <moveit/kinematic_constraints/kinematic_constraint.h>
224 robot_model::RobotModelPtr &
getModel();
229 urdf::ModelInterfaceConstSharedPtr
getURDF()
const;
239 srdf::ModelConstSharedPtr
getSRDF()
const;
279 robot_model::RobotStatePtr
allocState()
const;
301 void setState(
const sensor_msgs::JointState &state);
306 void setState(
const moveit_msgs::RobotState &state);
439 const robot_state::RobotState &start,
440 const Eigen::Vector3d &direction,
452 const robot_state::RobotState &start,
453 const Eigen::Vector3d &position_offset,
454 const Eigen::Quaterniond &rotation_offset = Eigen::Quaterniond::Identity());
465 const robot_state::RobotState &start,
493 const Eigen::Vector3d &position,
494 const Eigen::Quaterniond &orientation,
511 const Eigen::Quaterniond &orientation,
537 const moveit_msgs::PositionConstraint &pc,
538 const moveit_msgs::OrientationConstraint &oc);
596 const Eigen::Quaterniond &orientation,
745 double fps = 30,
double threshold = 0.0)
const;
#define ROBOWFLEX_CLASS_FORWARD(C)
Macro that forward declares a class and defines two shared ptrs types:
A const shared pointer wrapper for robowflex::Geometry.
ROS parameter server handler to handle namespacing and automatic parameter deletion.
Loads information about a robot from the parameter server.
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.
std::function< bool(YAML::Node &)> PostProcessYAMLFunction
A function that runs after loading a YAML file and can modify its contents. Returns true on success,...
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.
void operator=(Robot const &)=delete
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.
Robot(Robot const &)=delete
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.
std::function< bool(tinyxml2::XMLDocument &)> PostProcessXMLFunction
A function that runs after loading a XML file and can modify its contents. Returns true on success,...
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.
Functions for loading and animating robots in Blender.
static const double ik_tolerance
static const unsigned int ik_attempts
static const Eigen::Vector3d ik_vec_tolerance
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.
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.
RobotPoseVector region_poses
Poses of regions.
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.