Go to the documentation of this file.
31 #ifndef TESSERACT_STATE_SOLVER_OFKT_STATE_SOLVER_H
32 #define TESSERACT_STATE_SOLVER_OFKT_STATE_SOLVER_H
36 #include <Eigen/Geometry>
39 #include <shared_mutex>
60 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
63 using Ptr = std::shared_ptr<OFKTStateSolver>;
64 using ConstPtr = std::shared_ptr<const OFKTStateSolver>;
65 using UPtr = std::unique_ptr<OFKTStateSolver>;
66 using ConstUPtr = std::unique_ptr<const OFKTStateSolver>;
80 void setState(const Eigen::Ref<const Eigen::VectorXd>& joint_values,
82 void setState(
const std::unordered_map<std::string, double>& joint_values,
84 void setState(
const std::vector<std::string>& joint_names,
85 const Eigen::Ref<const Eigen::VectorXd>& joint_values,
89 SceneState
getState(
const Eigen::Ref<const Eigen::VectorXd>& joint_values,
91 SceneState
getState(
const std::unordered_map<std::string, double>& joint_values,
93 SceneState
getState(
const std::vector<std::string>& joint_names,
94 const Eigen::Ref<const Eigen::VectorXd>& joint_values,
98 SceneState
getState() const override final;
102 Eigen::MatrixXd
getJacobian(const Eigen::Ref<const Eigen::VectorXd>& joint_values,
103 const std::
string& link_name,
106 Eigen::MatrixXd
getJacobian(
const std::unordered_map<std::string, double>& joints_values,
107 const std::string& link_name,
109 Eigen::MatrixXd
getJacobian(
const std::vector<std::string>& joint_names,
110 const Eigen::Ref<const Eigen::VectorXd>& joint_values,
111 const std::string& link_name,
114 std::vector<std::string>
getJointNames() const override final;
122 std::vector<std::
string>
getLinkNames() const override final;
130 bool hasLinkName(const std::
string& link_name) const override final;
134 Eigen::Isometry3d
getLinkTransform(const std::
string& link_name) const override final;
137 const std::
string& to_link_name) const override final;
141 bool addLink(const Link& link, const Joint& joint) override final;
143 bool moveLink(const Joint& joint) override final;
145 bool removeLink(const std::
string& name) override final;
149 bool removeJoint(const std::
string& name) override final;
151 bool moveJoint(const std::
string& name, const std::
string& parent_link) override final;
153 bool changeJointOrigin(const std::
string& name, const Eigen::Isometry3d& new_origin) override final;
165 const std::
string& prefix = "") override final;
210 update(
SceneState& state,
const OFKTNode* node,
const Eigen::Isometry3d& parent_world_tf,
bool update_required)
const;
219 Eigen::MatrixXd
calcJacobianHelper(
const std::unordered_map<std::string, double>& joints,
220 const std::string& link_name,
243 const std::string& joint_name,
244 const std::string& parent_link_name,
245 const std::string& child_link_name,
246 std::vector<std::shared_ptr<const JointLimits>>& new_joint_limits);
257 std::vector<std::string>& removed_links,
258 std::vector<std::string>& removed_joints,
259 std::vector<std::string>& removed_active_joints,
260 std::vector<long>& removed_active_joints_indices);
267 void moveLinkHelper(std::vector<std::shared_ptr<const JointLimits>>& new_joint_limits,
const Joint& joint);
274 void replaceJointHelper(std::vector<std::shared_ptr<const JointLimits>>& new_joint_limits,
const Joint& joint);
284 const std::vector<std::string>& removed_joints,
285 const std::vector<std::string>& removed_active_joints,
286 const std::vector<long>& removed_active_joints_indices);
292 void addNewJointLimits(
const std::vector<std::shared_ptr<const JointLimits>>& new_joint_limits);
298 #endif // TESSERACT_STATE_SOLVER_OFKT_STATE_SOLVER_H
bool changeJointOrigin(const std::string &name, const Eigen::Isometry3d &new_origin) override final
Changes the "origin" transform of the joint and recomputes the associated edge.
AlignedVector< Eigen::Isometry3d > VectorIsometry3d
std::vector< std::string > getActiveLinkNames() const override final
Get the vector of active link names.
std::vector< std::string > joint_names_
std::vector< std::string > getJointNames() const override final
Get the vector of joint names.
Tesseract Scene Graph Mutable State Solver Interface .
void update(OFKTNode *node, bool update_required)
This update the local and world transforms.
bool hasLinkName(const std::string &link_name) const override final
Check if link name exists.
tesseract_common::KinematicLimits getLimits() const override final
Getter for kinematic limits.
std::vector< std::string > getActiveJointNames() const override final
Get the vector of joint names which align with the limits.
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
std::unique_ptr< const MutableStateSolver > ConstUPtr
SceneState current_state_
bool removeLink(const std::string &name) override final
Removes a link from the graph.
bool insertSceneGraph(const SceneGraph &scene_graph, const Joint &joint, const std::string &prefix="") override final
Merge a scene into the current solver.
void setState(const Eigen::Ref< const Eigen::VectorXd > &joint_values, const tesseract_common::TransformMap &floating_joint_values={}) override final
Set the current state of the solver.
std::unordered_map< std::string, OFKTNode * > link_map_
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
~OFKTStateSolver() override=default
std::unique_ptr< OFKTNode > root_
OFKTStateSolver & operator=(const OFKTStateSolver &other)
bool removeJoint(const std::string &name) override final
Removes a joint from the graph.
bool changeJointJerkLimits(const std::string &name, double limit) override final
Changes the jerk limits associated with a joint.
bool initHelper(const tesseract_scene_graph::SceneGraph &scene_graph, const std::string &prefix)
A mutable state solver allows you to reconfigure the solver's links and joints.
std::vector< std::string > getLinkNames() const override final
Get the vector of link names.
std::unique_ptr< OFKTStateSolver > UPtr
void removeNode(OFKTNode *node, std::vector< std::string > &removed_links, std::vector< std::string > &removed_joints, std::vector< std::string > &removed_active_joints, std::vector< long > &removed_active_joints_indices)
Remove a node and all of its children.
void moveLinkHelper(std::vector< std::shared_ptr< const JointLimits >> &new_joint_limits, const Joint &joint)
This a helper function for moving a link.
std::shared_mutex mutex_
The state solver can be accessed from multiple threads, need use mutex throughout.
std::unique_ptr< MutableStateSolver > UPtr
bool changeJointAccelerationLimits(const std::string &name, double limit) override final
Changes the acceleration limits associated with a joint.
Eigen::MatrixXd calcJacobianHelper(const std::unordered_map< std::string, double > &joints, const std::string &link_name, const tesseract_common::TransformMap &floating_joint_values={}) const
Given a set of joint values calculate the jacobian for the provided link_name.
void addNewJointLimits(const std::vector< std::shared_ptr< const JointLimits >> &new_joint_limits)
appends the new joint limits
SceneState getRandomState() const override final
Get the random state of the environment.
The OFKT node is contains multiple trasformation which are described below.
bool addLink(const Link &link, const Joint &joint) override final
Adds a link/joint to the solver.
std::vector< std::string > getStaticLinkNames() const override final
Get a vector of static link names in the environment.
std::string getBaseLinkName() const override final
Get the base link name.
An implementation of the Optimized Forward Kinematic Tree as a stat solver.
void cloneHelper(OFKTStateSolver &cloned, const OFKTNode *node) const
A helper function used for cloning the OFKTStateSolver.
tesseract_common::KinematicLimits limits_
bool changeJointVelocityLimits(const std::string &name, double limit) override final
Changes the velocity limits associated with a joint.
bool isActiveLinkName(const std::string &link_name) const override final
Check if link is an active link.
Every time a vertex is visited for the first time add a new node to the tree.
std::shared_ptr< const MutableStateSolver > ConstPtr
void addNode(const Joint &joint, const std::string &joint_name, const std::string &parent_link_name, const std::string &child_link_name, std::vector< std::shared_ptr< const JointLimits >> &new_joint_limits)
Add a node to the tree.
bool moveLink(const Joint &joint) override final
Move a link.
std::unordered_map< std::string, std::unique_ptr< OFKTNode > > nodes_
bool changeJointPositionLimits(const std::string &name, double lower, double upper) override final
Changes the position limits associated with a joint.
std::vector< std::string > active_joint_names_
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
Eigen::MatrixXd getJacobian(const Eigen::Ref< const Eigen::VectorXd > &joint_values, const std::string &link_name, const tesseract_common::TransformMap &floating_joint_values={}) const override final
Get the jacobian of the solver given the joint values.
int getRevision() const override final
Get the state solver revision number.
void loadStaticLinkNamesRecursive(std::vector< std::string > &static_link_names, const OFKTNode *node) const
load the static link names
std::vector< std::string > link_names_
OFKTStateSolver(const tesseract_scene_graph::SceneGraph &scene_graph, const std::string &prefix="")
std::vector< std::string > floating_joint_names_
bool moveJoint(const std::string &name, const std::string &parent_link) override final
Move joint to new parent link.
A implementation of the Optimized Forward Kinematic Tree Node.
std::shared_ptr< MutableStateSolver > Ptr
bool replaceJoint(const Joint &joint) override final
Replace and existing joint with the provided one.
tesseract_common::VectorIsometry3d getLinkTransforms() const override final
Get all of the links transforms.
void setRevision(int revision) override final
Set the state solver revision number.
void loadActiveLinkNamesRecursive(std::vector< std::string > &active_link_names, const OFKTNode *node, bool active) const
load the active link names
void removeJointHelper(const std::vector< std::string > &removed_links, const std::vector< std::string > &removed_joints, const std::vector< std::string > &removed_active_joints, const std::vector< long > &removed_active_joints_indices)
This will clean up member variables joint_names_ and limits_.
Eigen::Isometry3d getRelativeLinkTransform(const std::string &from_link_name, const std::string &to_link_name) const override final
Get transform between two links using the current state.
std::vector< std::string > getFloatingJointNames() const override final
Get the vector of floating joint names.
StateSolver::UPtr clone() const override final
This should clone the object so it may be used in a multi threaded application where each thread woul...
SceneState getState() const override final
Get the current state of the scene.
void replaceJointHelper(std::vector< std::shared_ptr< const JointLimits >> &new_joint_limits, const Joint &joint)
This is a helper function for replacing a joint.
Eigen::Isometry3d getLinkTransform(const std::string &link_name) const override final
Get the transform corresponding to the link.