Exotica
interaction_mesh.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018, University of Edinburgh
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without specific
15 // prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 
30 #ifndef EXOTICA_CORE_TASK_MAPS_INTERACTION_MESH_H_
31 #define EXOTICA_CORE_TASK_MAPS_INTERACTION_MESH_H_
32 
34 #include <exotica_core/task_map.h>
35 
36 #include <exotica_core_task_maps/interaction_mesh_initializer.h>
37 
38 #include <visualization_msgs/Marker.h>
39 
40 namespace exotica
41 {
42 class InteractionMesh : public TaskMap, public Instantiable<InteractionMeshInitializer>
43 {
44 public:
46  virtual ~InteractionMesh();
47 
48  void Instantiate(const InteractionMeshInitializer& init) override;
49  void AssignScene(ScenePtr scene) override;
50 
53  int TaskSpaceDim() override;
54 
55  void SetWeight(int i, int j, double weight);
56  void SetWeights(const Eigen::MatrixXd& weights);
57  Eigen::MatrixXd GetWeights();
58 
59  static Eigen::VectorXd ComputeLaplace(Eigen::VectorXdRefConst eff_Phi, Eigen::MatrixXdRefConst weights, Eigen::MatrixXd* dist = nullptr, Eigen::VectorXd* wsum = nullptr);
60  void ComputeGoalLaplace(const Eigen::VectorXd& x, Eigen::VectorXd& goal);
61  static void ComputeGoalLaplace(const std::vector<KDL::Frame>& nodes, Eigen::VectorXd& goal, Eigen::MatrixXdRefConst weights);
62 
63 protected:
65  void InitializeDebug(std::string ref);
66  void DestroyDebug();
67 
68  Eigen::MatrixXd weights_;
69  int eff_size_ = 0;
70 
71  ros::Publisher imesh_mark_pub_;
72  visualization_msgs::Marker imesh_mark_;
73 };
74 } // namespace exotica
75 
76 #endif // EXOTICA_CORE_TASK_MAPS_INTERACTION_MESH_H_
exotica::InteractionMesh::InteractionMesh
InteractionMesh()
exotica::InteractionMesh::Debug
void Debug(Eigen::VectorXdRefConst phi)
exotica::InteractionMesh::eff_size_
int eff_size_
Definition: interaction_mesh.h:69
exotica::TaskMap
Definition: task_map.h:52
exotica::InteractionMesh::DestroyDebug
void DestroyDebug()
exotica::InteractionMesh::SetWeight
void SetWeight(int i, int j, double weight)
exotica::InteractionMesh::ComputeLaplace
static Eigen::VectorXd ComputeLaplace(Eigen::VectorXdRefConst eff_Phi, Eigen::MatrixXdRefConst weights, Eigen::MatrixXd *dist=nullptr, Eigen::VectorXd *wsum=nullptr)
exotica::InteractionMesh::imesh_mark_
visualization_msgs::Marker imesh_mark_
Definition: interaction_mesh.h:72
exotica::Instantiable
Definition: property.h:110
exotica::InteractionMesh::weights_
Eigen::MatrixXd weights_
Definition: interaction_mesh.h:68
exotica
Definition: cartpole_dynamics_solver.h:38
exotica::InteractionMesh::~InteractionMesh
virtual ~InteractionMesh()
exotica::ScenePtr
std::shared_ptr< Scene > ScenePtr
Definition: scene.h:246
Eigen::VectorXdRef
Eigen::Ref< Eigen::VectorXd > VectorXdRef
Definition: conversions.h:54
Eigen::VectorXdRefConst
const typedef Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
Definition: conversions.h:52
Eigen::MatrixXdRef
Eigen::Ref< Eigen::MatrixXd > MatrixXdRef
Definition: conversions.h:55
Eigen::MatrixXdRefConst
const typedef Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
Definition: conversions.h:53
exotica::InteractionMesh::ComputeGoalLaplace
void ComputeGoalLaplace(const Eigen::VectorXd &x, Eigen::VectorXd &goal)
exotica::InteractionMesh::TaskSpaceDim
int TaskSpaceDim() override
exotica::InteractionMesh::imesh_mark_pub_
ros::Publisher imesh_mark_pub_
Definition: interaction_mesh.h:71
exotica::InteractionMesh::Update
void Update(Eigen::VectorXdRefConst x, Eigen::VectorXdRef phi) override
exotica::InteractionMesh::SetWeights
void SetWeights(const Eigen::MatrixXd &weights)
exotica::InteractionMesh::AssignScene
void AssignScene(ScenePtr scene) override
exotica::InteractionMesh::InitializeDebug
void InitializeDebug(std::string ref)
task_map.h
exotica::InteractionMesh
Definition: interaction_mesh.h:42
exotica::InteractionMesh::Instantiate
void Instantiate(const InteractionMeshInitializer &init) override
kinematic_tree.h
exotica::InteractionMesh::GetWeights
Eigen::MatrixXd GetWeights()