|
| 1 | +/* ----------------------------------------------------------------------------- |
| 2 | + * Copyright 2022 Massachusetts Institute of Technology. |
| 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 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | + * this list of conditions and the following disclaimer. |
| 10 | + * |
| 11 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | + * this list of conditions and the following disclaimer in the documentation |
| 13 | + * and/or other materials provided with the distribution. |
| 14 | + * |
| 15 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 16 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 17 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 18 | + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 19 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 20 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 21 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 22 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 23 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | + * |
| 26 | + * Research was sponsored by the United States Air Force Research Laboratory and |
| 27 | + * the United States Air Force Artificial Intelligence Accelerator and was |
| 28 | + * accomplished under Cooperative Agreement Number FA8750-19-2-1000. The views |
| 29 | + * and conclusions contained in this document are those of the authors and should |
| 30 | + * not be interpreted as representing the official policies, either expressed or |
| 31 | + * implied, of the United States Air Force or the U.S. Government. The U.S. |
| 32 | + * Government is authorized to reproduce and distribute reprints for Government |
| 33 | + * purposes notwithstanding any copyright notation herein. |
| 34 | + * -------------------------------------------------------------------------- */ |
| 35 | +#pragma once |
| 36 | + |
| 37 | +#include <config_utilities/dynamic_config.h> |
| 38 | + |
| 39 | +#include "hydra_visualizer/plugins/layer_plugin.h" |
| 40 | + |
| 41 | +namespace hydra { |
| 42 | + |
| 43 | +/** |
| 44 | + * @brief Plugin to draw mesh points that comprise a node |
| 45 | + * |
| 46 | + * Works for 2D places or objects |
| 47 | + */ |
| 48 | +class MeshPointPlugin : public LayerPlugin { |
| 49 | + public: |
| 50 | + struct Config { |
| 51 | + //! Draw size for mesh points |
| 52 | + double point_size = 0.02; |
| 53 | + //! Use spheres for mesh points instead of cubes |
| 54 | + bool use_spheres = false; |
| 55 | + //! Use the node color instead of the mesh color |
| 56 | + bool use_node_color = true; |
| 57 | + //! Alpha for mesh points |
| 58 | + double alpha = 1.0; |
| 59 | + }; |
| 60 | + |
| 61 | + MeshPointPlugin(const Config& config, const std::string& ns); |
| 62 | + |
| 63 | + void draw(const std_msgs::msg::Header& header, |
| 64 | + const visualizer::LayerInfo& info, |
| 65 | + const spark_dsg::SceneGraphLayer& layer, |
| 66 | + const spark_dsg::Mesh* mesh, |
| 67 | + visualization_msgs::msg::MarkerArray& msg, |
| 68 | + MarkerTracker& tracker) override; |
| 69 | + |
| 70 | + private: |
| 71 | + std::string ns_; |
| 72 | + config::DynamicConfig<Config> config_; |
| 73 | +}; |
| 74 | + |
| 75 | +void declare_config(MeshPointPlugin::Config& config); |
| 76 | + |
| 77 | +} // namespace hydra |
0 commit comments