30 #ifndef EXOTICA_CORE_SCENE_H_ 31 #define EXOTICA_CORE_SCENE_H_ 40 #include <moveit_msgs/PlanningScene.h> 49 #include <exotica_core/scene_initializer.h> 62 #ifndef EXOTICA_CORE_DYNAMICS_SOLVER_H_ 63 template <
typename T,
int NX,
int NU>
72 Scene(
const std::string& name);
75 virtual void Instantiate(
const SceneInitializer& init);
76 void RequestKinematics(
KinematicsRequest& request, std::function<
void(std::shared_ptr<KinematicResponse>)> callback);
77 const std::string& GetName()
const;
84 std::shared_ptr<DynamicsSolver> GetDynamicsSolver()
const;
86 std::string GetRootFrameName();
87 std::string GetRootJointName();
90 std::vector<std::string> GetControlledJointNames();
91 std::vector<std::string> GetModelJointNames();
92 std::vector<std::string> GetControlledLinkNames();
93 std::vector<std::string> GetModelLinkNames();
94 Eigen::VectorXd GetControlledState();
95 Eigen::VectorXd GetModelState();
96 std::map<std::string, double> GetModelStateMap();
97 std::map<std::string, std::weak_ptr<KinematicElement>> GetTreeMap();
99 void SetModelState(
const std::map<std::string, double>& x,
double t = 0,
bool update_traj =
true);
101 void AddTrajectoryFromFile(
const std::string& link,
const std::string& traj);
102 void AddTrajectory(
const std::string& link,
const std::string& traj);
103 void AddTrajectory(
const std::string& link, std::shared_ptr<Trajectory> traj);
104 std::shared_ptr<Trajectory> GetTrajectory(
const std::string& link);
105 void RemoveTrajectory(
const std::string& link);
108 void UpdateSceneFrames();
114 void AttachObject(
const std::string& name,
const std::string&
parent);
121 void AttachObjectLocal(
const std::string& name,
const std::string& parent,
const KDL::Frame&
pose);
122 void AttachObjectLocal(
const std::string& name,
const std::string& parent,
const Eigen::VectorXd& pose);
127 void DetachObject(
const std::string& name);
128 bool HasAttachedObject(
const std::string& name);
132 void AddObject(
const std::string& name,
const KDL::Frame& transform =
KDL::Frame(),
const std::string& parent =
"",
const std::string& shape_resource_path =
"",
const Eigen::Vector3d& scale = Eigen::Vector3d::Ones(),
const KDL::RigidBodyInertia& inertia =
KDL::RigidBodyInertia::Zero(),
const Eigen::Vector4d& color = Eigen::Vector4d(0.5, 0.5, 0.5, 1.0),
const bool update_collision_scene =
true);
134 void AddObjectToEnvironment(
const std::string& name,
const KDL::Frame& transform =
KDL::Frame(),
shapes::ShapeConstPtr shape =
nullptr,
const Eigen::Vector4d& color = Eigen::Vector4d(0.5, 0.5, 0.5, 1.0),
const bool update_collision_scene =
true);
136 void RemoveObject(
const std::string& name);
140 void UpdatePlanningSceneWorld(
const moveit_msgs::PlanningSceneWorldConstPtr& world);
144 void UpdatePlanningScene(
const moveit_msgs::PlanningScene& scene);
148 moveit_msgs::PlanningScene GetPlanningSceneMsg();
150 void UpdateCollisionObjects();
151 void UpdateTrajectoryGenerators(
double t = 0);
154 void PublishProxies(
const std::vector<CollisionProxy>& proxies);
155 visualization_msgs::Marker ProxyToMarker(
const std::vector<CollisionProxy>& proxies,
const std::string& frame);
156 void LoadScene(
const std::string& scene,
const Eigen::Isometry3d&
offset = Eigen::Isometry3d::Identity(),
bool update_collision_scene =
true);
158 void LoadSceneFile(
const std::string& file_name,
const Eigen::Isometry3d&
offset = Eigen::Isometry3d::Identity(),
bool update_collision_scene =
true);
159 void LoadSceneFile(
const std::string& file_name,
const KDL::Frame&
offset =
KDL::Frame(),
bool update_collision_scene =
true);
160 std::string GetScene();
177 int get_num_positions()
const;
178 int get_num_velocities()
const;
179 int get_num_controls()
const;
180 int get_num_state()
const;
181 int get_num_state_derivative()
const;
182 bool get_has_quaternion_floating_base()
const;
185 bool has_quaternion_floating_base_ =
false;
187 void UpdateInternalFrames(
bool update_request =
true);
190 void UpdateMoveItPlanningScene();
192 void LoadSceneFromStringStream(std::istream& in,
const Eigen::Isometry3d&
offset,
bool update_collision_scene);
201 std::shared_ptr<DynamicsSolver> dynamics_solver_ = std::shared_ptr<DynamicsSolver>(
nullptr);
203 int num_positions_ = 0;
204 int num_velocities_ = 0;
205 int num_controls_ = 0;
207 int num_state_derivative_ = 0;
210 planning_scene::PlanningScenePtr
ps_;
242 std::function<void(std::shared_ptr<KinematicResponse>)> kinematic_request_callback_;
249 #endif // EXOTICA_CORE_SCENE_H_
planning_scene::PlanningScenePtr ps_
Internal MoveIt planning scene.
const std::set< std::string > & get_world_links_to_exclude_from_collision_scene() const
Returns world links that are to be excluded from collision checking.
const std::map< std::string, std::vector< std::string > > & GetControlledJointToCollisionLinkMap() const
Returns a map between controlled robot joint names and associated collision link names. Here we consider all fixed links between controlled links as belonging to the previous controlled joint (as if the collision links had been fused).
AttachedObject(std::string _parent)
std::vector< std::shared_ptr< KinematicElement > > custom_links_
List of frames/links added on top of robot links and scene objects defined in the MoveIt scene...
std::shared_ptr< Scene > ScenePtr
bool AlwaysUpdatesCollisionScene() const
Whether the collision scene transforms get updated on every scene update.
exotica::KinematicTree kinematica_
The kinematica tree.
std::set< std::string > robot_links_to_exclude_from_collision_scene_
List of robot links to be excluded from the collision scene.
std::shared_ptr< KinematicResponse > kinematic_solution_
std::set< std::string > world_links_to_exclude_from_collision_scene_
List of world links to be excluded from the collision scene.
ros::Publisher proxy_pub_
The class of EXOTica Scene.
static RigidBodyInertia Zero()
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
std::map< std::string, std::vector< std::string > > controlled_joint_to_collision_link_map_
Mapping between controlled joint name and collision links.
ros::Publisher ps_pub_
Visual debug.
KinematicsRequest kinematic_request_
CollisionScenePtr collision_scene_
The collision scene.
AttachedObject(std::string _parent, KDL::Frame _pose)
std::map< std::string, AttachedObject > attached_objects_
List of attached objects These objects will be reattached if the scene gets reloaded.
std::shared_ptr< CollisionScene > CollisionScenePtr
const std::map< std::string, std::vector< std::shared_ptr< KinematicElement > > > & GetModelLinkToCollisionElementMap() const
Returns a map between a model link name and the KinematicElement of associated collision links...
std::map< std::string, std::pair< std::weak_ptr< KinematicElement >, std::shared_ptr< Trajectory > > > trajectory_generators_
std::map< std::string, std::vector< std::string > > model_link_to_collision_link_map_
Mapping between model link names and collision links.
AbstractDynamicsSolver< double, Eigen::Dynamic, Eigen::Dynamic > DynamicsSolver
bool request_needs_updating_
const std::map< std::string, std::vector< std::string > > & GetModelLinkToCollisionLinkMap() const
Returns a map between a model link name and the names of associated collision links.
std::map< std::string, std::vector< std::shared_ptr< KinematicElement > > > model_link_to_collision_element_map_
std::shared_ptr< const Shape > ShapeConstPtr