Go to the documentation of this file.
26 #ifndef TESSERACT_ENVIRONMENT_ENVIRONMENT_H
27 #define TESSERACT_ENVIRONMENT_ENVIRONMENT_H
37 #include <shared_mutex>
38 #include <Eigen/Geometry>
75 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
78 using Ptr = std::shared_ptr<Environment>;
79 using ConstPtr = std::shared_ptr<const Environment>;
80 using UPtr = std::unique_ptr<Environment>;
81 using ConstUPtr = std::unique_ptr<const Environment>;
99 bool init(
const std::vector<std::shared_ptr<const Command>>& commands);
110 const std::shared_ptr<const tesseract_srdf::SRDFModel>& srdf_model =
nullptr);
112 bool init(
const std::string& urdf_string,
const std::shared_ptr<const tesseract_common::ResourceLocator>& locator);
114 bool init(
const std::string& urdf_string,
115 const std::string& srdf_string,
116 const std::shared_ptr<const tesseract_common::ResourceLocator>& locator);
118 bool init(
const std::filesystem::path& urdf_path,
119 const std::shared_ptr<const tesseract_common::ResourceLocator>& locator);
121 bool init(
const std::filesystem::path& urdf_path,
122 const std::filesystem::path& srdf_path,
123 const std::shared_ptr<const tesseract_common::ResourceLocator>& locator);
168 bool applyCommands(
const std::vector<std::shared_ptr<const Command>>& commands);
176 bool applyCommand(std::shared_ptr<const Command> command);
182 std::shared_ptr<const tesseract_scene_graph::SceneGraph>
getSceneGraph()
const;
196 std::shared_ptr<const tesseract_kinematics::JointGroup>
getJointGroup(
const std::string& group_name)
const;
204 std::shared_ptr<const tesseract_kinematics::JointGroup>
205 getJointGroup(
const std::string& name,
const std::vector<std::string>& joint_names)
const;
214 std::shared_ptr<const tesseract_kinematics::KinematicGroup>
215 getKinematicGroup(
const std::string& group_name,
const std::string& ik_solver_name =
"")
const;
274 void setResourceLocator(std::shared_ptr<const tesseract_common::ResourceLocator> locator);
284 void setName(
const std::string& name);
290 const std::string&
getName()
const;
299 void setState(
const std::unordered_map<std::string, double>& joints,
301 void setState(
const std::vector<std::string>& joint_names,
302 const Eigen::Ref<const Eigen::VectorXd>& joint_values,
322 const Eigen::Ref<const Eigen::VectorXd>& joint_values,
336 std::chrono::system_clock::time_point
getTimestamp()
const;
346 std::shared_ptr<const tesseract_scene_graph::Link>
getLink(
const std::string& name)
const;
353 std::shared_ptr<const tesseract_scene_graph::Joint>
getJoint(
const std::string& name)
const;
360 std::shared_ptr<const tesseract_scene_graph::JointLimits>
getJointLimits(
const std::string& joint_name)
const;
445 std::vector<std::string>
getActiveLinkNames(
const std::vector<std::string>& joint_names)
const;
458 std::vector<std::string>
getStaticLinkNames(
const std::vector<std::string>& joint_names)
const;
481 Eigen::Isometry3d
getRelativeLinkTransform(
const std::string& from_link_name,
const std::string& to_link_name)
const;
491 std::unique_ptr<tesseract_scene_graph::StateSolver>
getStateSolver()
const;
547 std::unique_ptr<tesseract_collision::ContinuousContactManager>
558 std::shared_lock<std::shared_mutex>
lockRead()
const;
574 std::unique_ptr<Implementation>
impl_;
578 template <
class Archive>
579 void save(Archive& ar,
const unsigned int version)
const;
581 template <
class Archive>
582 void load(Archive& ar,
const unsigned int version);
584 template <
class Archive>
585 void serialize(Archive& ar,
const unsigned int version);
589 explicit Environment(std::unique_ptr<Implementation> impl);
599 #endif // TESSERACT_ENVIRONMENT_ENVIRONMENT_H
AlignedVector< Eigen::Isometry3d > VectorIsometry3d
std::shared_ptr< const tesseract_scene_graph::SceneGraph > getSceneGraph() const
Get the Scene Graph.
std::shared_ptr< const tesseract_common::ResourceLocator > getResourceLocator() const
Get the resource locator assigned.
bool operator!=(const Environment &rhs) const
std::unique_ptr< tesseract_collision::ContinuousContactManager > getContinuousContactManager() const
Get a copy of the environments active continuous contact manager.
std::shared_ptr< const tesseract_scene_graph::Joint > getJoint(const std::string &name) const
Get joint by name.
bool setActiveDiscreteContactManager(const std::string &name)
Set the active discrete contact manager.
void serialize(Archive &ar, const unsigned int version)
void clearEventCallbacks()
clear all event callbacks
tesseract_common::CollisionMarginData getCollisionMarginData() const
Get the environment collision margin data.
std::chrono::system_clock::time_point getTimestamp() const
Last update time. Updated when any change to the environment occurs.
void setResourceLocator(std::shared_ptr< const tesseract_common::ResourceLocator > locator)
Set resource locator for environment.
std::shared_ptr< Environment > Ptr
bool applyCommand(std::shared_ptr< const Command > command)
Apply command to the environment.
void load(Archive &ar, const unsigned int version)
Environment()
Default constructor.
void clear()
clear content and uninitialized
std::vector< std::string > getStaticLinkNames() const
Get a vector of static link names in the environment.
Eigen::Isometry3d getLinkTransform(const std::string &link_name) const
Get the transform corresponding to the link.
std::shared_mutex mutex_
The environment can be accessed from multiple threads, need use mutex throughout.
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
std::unique_ptr< const Environment > ConstUPtr
void clearCachedContinuousContactManager() const
Set the cached internal copy of the environments active continuous contact manager not nullptr.
std::chrono::system_clock::time_point getCurrentStateTimestamp() const
Last update time to current state. Updated only when current state is updated.
friend class boost::serialization::access
Tesseract Environment Forward Declarations.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
const std::string & getName() const
Get the name of the environment.
std::vector< std::shared_ptr< const Command > > getCommandHistory() const
Get Environment command history post initialization.
tesseract_common::VectorIsometry3d getLinkTransforms() const
Get all of the links transforms.
int getRevision() const
Get the current revision number.
std::unique_ptr< tesseract_scene_graph::StateSolver > getStateSolver() const
Returns a clone of the environments state solver.
tesseract_scene_graph::SceneState getState() const
Get the current state of the environment.
Eigen::VectorXd getCurrentJointValues() const
Get the current state of the environment.
Environment::UPtr clone() const
Clone the environment.
std::set< std::string > getGroupNames() const
Get the available group names.
std::unique_ptr< Implementation > impl_
void addEventCallback(std::size_t hash, const EventCallbackFn &fn)
Add an event callback function.
tesseract_srdf::KinematicsInformation getKinematicsInformation() const
Get the kinematics information.
std::string getRootLinkName() const
Get the root link name.
std::shared_ptr< const Environment > ConstPtr
std::unique_ptr< tesseract_collision::DiscreteContactManager > getDiscreteContactManager() const
Get a copy of the environments active discrete contact manager.
std::unique_ptr< Environment > UPtr
std::shared_ptr< const tesseract_scene_graph::Link > getLink(const std::string &name) const
Get a link in the environment.
void addFindTCPOffsetCallback(const FindTCPOffsetCallbackFn &fn)
This allows for user defined callbacks for looking up TCP information.
bool getLinkVisibility(const std::string &name) const
Get a given links visibility setting.
bool reset()
reset to initialized state
std::shared_lock< std::shared_mutex > lockRead() const
Lock the environment when wanting to make multiple reads.
std::vector< std::string > getLinkNames() const
Get a vector of link names in the environment.
bool operator==(const Environment &rhs) const
These operators are to facilitate checking serialization but may have value elsewhere.
std::shared_ptr< const tesseract_scene_graph::JointLimits > getJointLimits(const std::string &joint_name) const
Gets the limits associated with a joint.
std::vector< std::string > getGroupJointNames(const std::string &group_name) const
Get a groups joint names.
std::function< void(const Event &event)> EventCallbackFn
std::shared_ptr< const tesseract_kinematics::KinematicGroup > getKinematicGroup(const std::string &group_name, const std::string &ik_solver_name="") const
Get a kinematic group given group name and solver name.
std::function< Eigen::Isometry3d(const tesseract_common::ManipulatorInfo &)> FindTCPOffsetCallbackFn
Function signature for adding additional callbacks for looking up TCP information.
std::shared_ptr< const tesseract_kinematics::JointGroup > getJointGroup(const std::string &group_name) const
Get a joint group by name.
std::vector< FindTCPOffsetCallbackFn > getFindTCPOffsetCallbacks() const
This get the current find tcp callbacks stored in the environment.
int getInitRevision() const
Get the initialization revision number.
Environment & operator=(const Environment &)=delete
void save(Archive &ar, const unsigned int version) const
tesseract_common::TransformMap getCurrentFloatingJointValues() const
Get the current floating joint values.
bool getLinkCollisionEnabled(const std::string &name) const
Get whether a link should be considered during collision checking.
Eigen::Isometry3d getRelativeLinkTransform(const std::string &from_link_name, const std::string &to_link_name) const
Get transform between two links using the current state.
bool isInitialized() const
check if the environment is initialized
std::map< std::size_t, EventCallbackFn > getEventCallbacks() const
Get the current event callbacks stored in the environment.
std::vector< std::string > getActiveLinkNames() const
Get a vector of active link names in the environment.
std::shared_ptr< const tesseract_common::AllowedCollisionMatrix > getAllowedCollisionMatrix() const
Get the allowed collision matrix.
void setState(const std::unordered_map< std::string, double > &joints, const tesseract_common::TransformMap &floating_joints={})
Set the current state of the environment.
tesseract_common::ContactManagersPluginInfo getContactManagersPluginInfo() const
Get the contact managers plugin information.
void removeEventCallback(std::size_t hash)
Remove event callbacks.
std::vector< std::string > getJointNames() const
Get a vector of joint names in the environment.
void clearCachedDiscreteContactManager() const
Set the cached internal copy of the environments active discrete contact manager not nullptr.
bool applyCommands(const std::vector< std::shared_ptr< const Command >> &commands)
Applies the commands to the environment.
bool init(const std::vector< std::shared_ptr< const Command >> &commands)
Initialize the Environment.
std::vector< std::string > getActiveJointNames() const
Get a vector of active joint names in the environment.
Eigen::Isometry3d findTCPOffset(const tesseract_common::ManipulatorInfo &manip_info) const
Find tool center point provided in the manipulator info.
bool setActiveContinuousContactManager(const std::string &name)
Set the active continuous contact manager.
void setName(const std::string &name)
Give the environment a name.