visualization_meshcat.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019
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_VISUALIZATION_MESHCAT_H_
31 #define EXOTICA_CORE_VISUALIZATION_MESHCAT_H_
32 
33 #include <memory>
34 #include <zmq.hpp>
35 
36 #include <exotica_core/scene.h>
38 
39 namespace exotica
40 {
42 {
43 public:
44  VisualizationMeshcat(ScenePtr scene, const std::string& url, bool use_mesh_materials = true, const std::string& file_url = "");
45  virtual ~VisualizationMeshcat();
46 
47  void Initialize(bool use_mesh_materials);
48 
49  void DisplayScene(bool use_mesh_materials = true);
50  void DisplayState(Eigen::VectorXdRefConst state, double t = 0.0);
51  void DisplayTrajectory(Eigen::MatrixXdRefConst trajectory, double dt = 1.0);
52  void Delete(const std::string& path = "");
53  void SetProperty(const std::string& path, const std::string& property, const double& value);
54  void SetProperty(const std::string& path, const std::string& property, const std::string& value);
55  void SetProperty(const std::string& path, const std::string& property, const bool& value);
56  void SetProperty(const std::string& path, const std::string& property, const Eigen::Vector3d& value);
57  void SetProperty(const std::string& path, const std::string& property, const Eigen::Vector4d& value);
58  std::string GetWebURL();
59  std::string GetFileURL();
60 
61 private:
62  ScenePtr scene_ = std::make_shared<Scene>(nullptr);
63 
64  void ConnectZMQ();
65  void SendZMQ(const std::string& data);
66  std::string ReceiveZMQ();
67  std::string RequestWebURL();
68 
69  template <typename T>
70  void SendMsg(T msg);
71 
72  std::string zmq_url_;
73  std::string web_url_;
74  std::string file_url_;
75 
76  std::string path_prefix_;
77 
78  zmq::context_t context_;
79  std::unique_ptr<zmq::socket_t> socket_;
80 };
81 } // namespace exotica
82 
83 #endif // EXOTICA_CORE_VISUALIZATION_MESHCAT_H_
exotica::VisualizationMeshcat::GetFileURL
std::string GetFileURL()
exotica::VisualizationMeshcat::zmq_url_
std::string zmq_url_
Definition: visualization_meshcat.h:72
exotica::Uncopyable
Definition: uncopyable.h:35
exotica::VisualizationMeshcat::RequestWebURL
std::string RequestWebURL()
exotica::VisualizationMeshcat::ConnectZMQ
void ConnectZMQ()
exotica::VisualizationMeshcat::ReceiveZMQ
std::string ReceiveZMQ()
exotica::VisualizationMeshcat
Definition: visualization_meshcat.h:41
exotica
Definition: collision_scene.h:46
exotica::VisualizationMeshcat::file_url_
std::string file_url_
Definition: visualization_meshcat.h:74
exotica::VisualizationMeshcat::SendMsg
void SendMsg(T msg)
scene.h
exotica::VisualizationMeshcat::SetProperty
void SetProperty(const std::string &path, const std::string &property, const double &value)
exotica::ScenePtr
std::shared_ptr< Scene > ScenePtr
Definition: scene.h:246
Eigen::VectorXdRefConst
const typedef Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
Definition: conversions.h:53
exotica::VisualizationMeshcat::VisualizationMeshcat
VisualizationMeshcat(ScenePtr scene, const std::string &url, bool use_mesh_materials=true, const std::string &file_url="")
exotica::VisualizationMeshcat::DisplayTrajectory
void DisplayTrajectory(Eigen::MatrixXdRefConst trajectory, double dt=1.0)
Eigen::MatrixXdRefConst
const typedef Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
Definition: conversions.h:54
exotica::VisualizationMeshcat::web_url_
std::string web_url_
Definition: visualization_meshcat.h:73
exotica::VisualizationMeshcat::socket_
std::unique_ptr< zmq::socket_t > socket_
Definition: visualization_meshcat.h:79
exotica::VisualizationMeshcat::DisplayScene
void DisplayScene(bool use_mesh_materials=true)
exotica::VisualizationMeshcat::Initialize
void Initialize(bool use_mesh_materials)
exotica::VisualizationMeshcat::~VisualizationMeshcat
virtual ~VisualizationMeshcat()
exotica::VisualizationMeshcat::path_prefix_
std::string path_prefix_
Definition: visualization_meshcat.h:76
exotica::VisualizationMeshcat::context_
zmq::context_t context_
Definition: visualization_meshcat.h:78
exotica::VisualizationMeshcat::SendZMQ
void SendZMQ(const std::string &data)
exotica::VisualizationMeshcat::scene_
ScenePtr scene_
Definition: visualization_meshcat.h:62
exotica::VisualizationMeshcat::GetWebURL
std::string GetWebURL()
uncopyable.h
exotica::VisualizationMeshcat::DisplayState
void DisplayState(Eigen::VectorXdRefConst state, double t=0.0)
t
geometry_msgs::TransformStamped t
exotica::VisualizationMeshcat::Delete
void Delete(const std::string &path="")


exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Fri Aug 2 2024 08:43:02