├── .clang-format ├── .pre-commit-config.yaml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── icons └── classes │ └── Snow.png ├── include └── snowbot_operating_system │ └── snow_display.h ├── package.xml ├── rviz_plugins.xml ├── setup.cfg └── src └── snow_display.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: Google 3 | ColumnLimit: 120 4 | MaxEmptyLinesToKeep: 1 5 | SortIncludes: false 6 | 7 | Standard: Auto 8 | IndentWidth: 2 9 | TabWidth: 2 10 | UseTab: Never 11 | AccessModifierOffset: -2 12 | ConstructorInitializerIndentWidth: 2 13 | NamespaceIndentation: None 14 | ContinuationIndentWidth: 4 15 | IndentCaseLabels: true 16 | IndentFunctionDeclarationAfterType: false 17 | 18 | AlignEscapedNewlinesLeft: false 19 | AlignTrailingComments: true 20 | 21 | AllowAllParametersOfDeclarationOnNextLine: false 22 | ExperimentalAutoDetectBinPacking: false 23 | ObjCSpaceBeforeProtocolList: true 24 | Cpp11BracedListStyle: false 25 | 26 | AllowShortBlocksOnASingleLine: true 27 | AllowShortIfStatementsOnASingleLine: false 28 | AllowShortLoopsOnASingleLine: false 29 | AllowShortFunctionsOnASingleLine: None 30 | AllowShortCaseLabelsOnASingleLine: false 31 | 32 | AlwaysBreakTemplateDeclarations: true 33 | AlwaysBreakBeforeMultilineStrings: false 34 | BreakBeforeBinaryOperators: false 35 | BreakBeforeTernaryOperators: false 36 | BreakConstructorInitializersBeforeComma: true 37 | 38 | BinPackParameters: true 39 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 40 | DerivePointerBinding: false 41 | PointerBindsToType: true 42 | 43 | PenaltyExcessCharacter: 50 44 | PenaltyBreakBeforeFirstCallParameter: 30 45 | PenaltyBreakComment: 1000 46 | PenaltyBreakFirstLessLess: 10 47 | PenaltyBreakString: 100 48 | PenaltyReturnTypeOnItsOwnLine: 50 49 | 50 | SpacesBeforeTrailingComments: 2 51 | SpacesInParentheses: false 52 | SpacesInAngles: false 53 | SpaceInEmptyParentheses: false 54 | SpacesInCStyleCastParentheses: false 55 | SpaceAfterCStyleCast: false 56 | SpaceAfterControlStatementKeyword: true 57 | SpaceBeforeAssignmentOperators: true 58 | 59 | # Configure each individual brace in BraceWrapping 60 | BreakBeforeBraces: Custom 61 | 62 | # Control of individual brace wrapping cases 63 | BraceWrapping: 64 | AfterCaseLabel: true 65 | AfterClass: true 66 | AfterControlStatement: true 67 | AfterEnum: true 68 | AfterFunction: true 69 | AfterNamespace: true 70 | AfterStruct: true 71 | AfterUnion: true 72 | BeforeCatch: true 73 | BeforeElse: true 74 | IndentBraces: false 75 | ... 76 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | # Standard hooks 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v3.4.0 5 | hooks: 6 | - id: check-case-conflict 7 | - id: check-merge-conflict 8 | - id: check-symlinks 9 | - id: check-xml 10 | - id: check-yaml 11 | - id: debug-statements 12 | - id: end-of-file-fixer 13 | - id: mixed-line-ending 14 | - id: trailing-whitespace 15 | 16 | - repo: local 17 | hooks: 18 | - id: clang-format 19 | name: clang-format 20 | description: Format files with ClangFormat. 21 | entry: clang-format-10 22 | language: system 23 | files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$ 24 | args: ['-fallback-style=none', '-i'] 25 | 26 | - repo: https://github.com/codespell-project/codespell 27 | rev: v2.0.0 28 | hooks: 29 | - id: codespell 30 | args: ['--write-changes'] 31 | exclude: \.(svg|pyc)$ 32 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | project(snowbot_operating_system) 3 | set_directory_properties(PROPERTIES COMPILE_OPTIONS "-std=c++11;-Wall;-Werror") 4 | 5 | find_package(catkin REQUIRED COMPONENTS 6 | geometry_msgs 7 | pluginlib 8 | rviz 9 | ) 10 | 11 | set(CMAKE_AUTOMOC ON) 12 | 13 | find_package(Qt5 REQUIRED COMPONENTS 14 | Core 15 | Widgets 16 | ) 17 | set(QT_LIBRARIES Qt5::Widgets) 18 | 19 | add_definitions(-DQT_NO_KEYWORDS) 20 | 21 | catkin_package( 22 | CATKIN_DEPENDS 23 | geometry_msgs 24 | pluginlib 25 | rviz 26 | LIBRARIES snow_display 27 | INCLUDE_DIRS include 28 | ) 29 | 30 | include_directories(include ${catkin_INCLUDE_DIRS}) 31 | 32 | qt5_wrap_cpp(MOC_FILES 33 | include/snowbot_operating_system/snow_display.h 34 | ) 35 | 36 | add_library(snow_display 37 | src/snow_display.cpp 38 | ${MOC_FILES} 39 | ) 40 | add_dependencies(snow_display ${catkin_EXPORTED_TARGETS}) 41 | target_link_libraries(snow_display ${QT_LIBRARIES} ${catkin_LIBRARIES}) 42 | 43 | if(CATKIN_ENABLE_TESTING) 44 | find_package(catkin REQUIRED COMPONENTS roslint) 45 | roslint_cpp() 46 | roslint_add_test() 47 | endif() 48 | 49 | install(TARGETS snow_display 50 | ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 51 | LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} 52 | RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} 53 | ) 54 | install(DIRECTORY include/${PROJECT_NAME}/ 55 | DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} 56 | ) 57 | install(FILES rviz_plugins.xml 58 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} 59 | ) 60 | install(FILES icons/classes/Snow.png 61 | DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/icons/classes 62 | ) 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2020-2021, PickNik Robotics 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Snowbot Operating System 2 | 3 | A useless RViz plugin. 4 | 5 | Snowflake icon by Danielle Garbouchian from the Noun Project 6 | -------------------------------------------------------------------------------- /icons/classes/Snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PickNikRobotics/snowbot_operating_system/545e9378dbe2ef67540ba27926a154e9f2df85e8/icons/classes/Snow.png -------------------------------------------------------------------------------- /include/snowbot_operating_system/snow_display.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2020, David Lu!! 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef SNOWBOT_OPERATING_SYSTEM_SNOW_DISPLAY_H 36 | #define SNOWBOT_OPERATING_SYSTEM_SNOW_DISPLAY_H 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | namespace snowbot_operating_system 46 | { 47 | class SnowDisplay : public rviz::Display 48 | { 49 | Q_OBJECT 50 | public: 51 | SnowDisplay(); 52 | 53 | void update(float wall_dt, float ros_dt) override; 54 | 55 | protected: 56 | void onInitialize() override; 57 | 58 | private Q_SLOTS: 59 | void updateSize(); 60 | void updatePosition(); 61 | 62 | private: 63 | void letItSnow(); 64 | 65 | void initializeXY(geometry_msgs::Point& pt) const; 66 | 67 | rviz::PointCloud* point_cloud_; 68 | std::vector flakes_; 69 | 70 | std::vector points_; 71 | 72 | rviz::FloatProperty* width_property_; 73 | rviz::FloatProperty* height_property_; 74 | rviz::FloatProperty* gravity_property_; 75 | rviz::FloatProperty* wind_property_; 76 | rviz::FloatProperty* jiggle_property_; 77 | rviz::IntProperty* size_property_; 78 | 79 | double width_, height_; 80 | }; 81 | } // namespace snowbot_operating_system 82 | 83 | #endif // SNOWBOT_OPERATING_SYSTEM_SNOW_DISPLAY_H 84 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | snowbot_operating_system 4 | 0.0.5 5 | The weather outside is frightful 6 | David V. Lu!! 7 | BSD 8 | 9 | catkin 10 | qtbase5-dev 11 | geometry_msgs 12 | pluginlib 13 | rviz 14 | libqt5-core 15 | libqt5-widgets 16 | roslint 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /rviz_plugins.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | The weather outside is frightful 4 | 5 | 6 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [pep8] 2 | max_line_length = 120 3 | 4 | [flake8] 5 | max_line_length = 120 6 | -------------------------------------------------------------------------------- /src/snow_display.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (c) 2020, David Lu!! 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #include 36 | #include 37 | 38 | namespace snowbot_operating_system 39 | { 40 | static unsigned int random_seed = std::time(NULL); 41 | inline double randScale() 42 | { 43 | return static_cast(rand_r(&random_seed)) / RAND_MAX; 44 | } 45 | 46 | SnowDisplay::SnowDisplay() : point_cloud_(nullptr) 47 | { 48 | height_property_ = new rviz::FloatProperty("Height", 10.0, "Maximum Height", this, SLOT(updatePosition())); 49 | height_property_->setMin(0.0); 50 | 51 | width_property_ = new rviz::FloatProperty("Width", 10.0, "Total XY Dimension", this, SLOT(updatePosition())); 52 | width_property_->setMin(0.0); 53 | 54 | gravity_property_ = new rviz::FloatProperty("Gravity", 0.05, "Z motion per time step", this, SLOT(updatePosition())); 55 | wind_property_ = new rviz::FloatProperty("Wind", 0.02, "X motion per time step", this, SLOT(updatePosition())); 56 | jiggle_property_ = new rviz::FloatProperty("Jiggle", 0.03, "Magnitude of Jiggle", this, SLOT(updatePosition())); 57 | 58 | size_property_ = new rviz::IntProperty("Snowflakes", 1000, "Number of snowflakes", this, SLOT(updateSize())); 59 | size_property_->setMin(1); 60 | } 61 | 62 | void SnowDisplay::onInitialize() 63 | { 64 | Display::onInitialize(); 65 | if (!point_cloud_) 66 | { 67 | point_cloud_ = new rviz::PointCloud(); 68 | scene_node_->attachObject(point_cloud_); 69 | point_cloud_->setAlpha(1.0); 70 | } 71 | 72 | updateSize(); 73 | } 74 | 75 | void SnowDisplay::update(float wall_dt, float ros_dt) 76 | { 77 | updatePosition(); 78 | } 79 | 80 | void SnowDisplay::initializeXY(geometry_msgs::Point& pt) const 81 | { 82 | pt.x = (randScale() - 0.5) * width_; 83 | pt.y = (randScale() - 0.5) * width_; 84 | } 85 | 86 | void SnowDisplay::updateSize() 87 | { 88 | unsigned int size = static_cast(size_property_->getInt()); 89 | height_ = height_property_->getFloat(); 90 | width_ = width_property_->getFloat(); 91 | 92 | points_.resize(size); 93 | flakes_.resize(size); 94 | 95 | for (geometry_msgs::Point& point : points_) 96 | { 97 | initializeXY(point); 98 | point.z = randScale() * height_; 99 | } 100 | updatePosition(); 101 | } 102 | 103 | void SnowDisplay::updatePosition() 104 | { 105 | double gravity = gravity_property_->getFloat(); 106 | double wind = wind_property_->getFloat(); 107 | double jiggle = jiggle_property_->getFloat(); 108 | 109 | for (geometry_msgs::Point& point : points_) 110 | { 111 | point.x += wind; 112 | 113 | point.x += (randScale() - 0.5) * jiggle; 114 | point.y += (randScale() - 0.5) * jiggle; 115 | 116 | if (point.x >= width_ / 2) 117 | { 118 | point.x -= width_; 119 | } 120 | else if (point.x <= -width_ / 2) 121 | { 122 | point.x += width_; 123 | } 124 | 125 | point.z -= gravity; 126 | if (point.z <= 0.0) 127 | { 128 | initializeXY(point); 129 | point.z = height_; 130 | } 131 | else if (point.z >= height_) 132 | { 133 | point.z = 0.0; 134 | } 135 | } 136 | letItSnow(); 137 | } 138 | 139 | void SnowDisplay::letItSnow() 140 | { 141 | if (!point_cloud_) 142 | { 143 | return; 144 | } 145 | 146 | point_cloud_->clear(); 147 | for (unsigned int i = 0; i < flakes_.size(); ++i) 148 | { 149 | flakes_[i].position.x = points_[i].x; 150 | flakes_[i].position.y = points_[i].y; 151 | flakes_[i].position.z = points_[i].z; 152 | flakes_[i].setColor(1.0, 1.0, 1.0, 1.0); 153 | } 154 | point_cloud_->addPoints(&flakes_.front(), flakes_.size()); 155 | } 156 | } // namespace snowbot_operating_system 157 | 158 | #include 159 | PLUGINLIB_EXPORT_CLASS(snowbot_operating_system::SnowDisplay, rviz::Display) 160 | --------------------------------------------------------------------------------