diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 801f0b9..095aa2a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,22 +3,20 @@ on: push: branches: [ main ] pull_request: + schedule: + - cron: '0 0 * * *' + jobs: build_and_test: name: Build and test runs-on: ubuntu-latest container: - image: rostooling/setup-ros-docker:ubuntu-focal-latest - strategy: - matrix: - ros_distribution: - - foxy - - galactic + image: rostooling/setup-ros-docker:ubuntu-jammy-latest steps: - name: deps uses: ros-tooling/setup-ros@v0.3 with: - required-ros-distributions: ${{ matrix.ros_distribution }} + required-ros-distributions: humble - name: install_clang run: sudo apt update && sudo apt install -y clang clang-tools lld - name: build @@ -27,7 +25,7 @@ jobs: CC: clang CXX: clang++ with: - target-ros2-distro: ${{ matrix.ros_distribution }} + target-ros2-distro: humble # build all packages listed in the meta package package-name: | rmf_visualization @@ -39,7 +37,7 @@ jobs: rmf_visualization_rviz2_plugins rmf_visualization_schedule vcs-repo-file-url: | - https://raw.githubusercontent.com/open-rmf/rmf/main/rmf.repos + https://raw.githubusercontent.com/open-rmf/rmf/humble-image/rmf.repos colcon-defaults: | { "build": { @@ -47,6 +45,12 @@ jobs: } } colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml + - name: Upload failed test results + uses: actions/upload-artifact@v2 + if: failure() + with: + name: test-results + path: ros_ws/build/*/test_results/*/*.catch2.xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml new file mode 100644 index 0000000..21e873c --- /dev/null +++ b/.github/workflows/style.yaml @@ -0,0 +1,24 @@ +name: style +on: + pull_request: + push: + branches: [ main ] +defaults: + run: + shell: bash +jobs: + linter: + runs-on: ubuntu-latest + strategy: + matrix: + docker_image: ['ros:humble-ros-base'] + container: + image: ${{ matrix.docker_image }} + steps: + - name: checkout + uses: actions/checkout@v2 + - name: uncrustify + run: | + sudo apt update && sudo apt install wget + wget https://raw.githubusercontent.com/open-rmf/rmf_utils/main/rmf_utils/test/format/rmf_code_style.cfg + /ros_entrypoint.sh ament_uncrustify -c rmf_code_style.cfg . --language C++ --exclude rmf_visualization_schedule/include/json.hpp rmf_visualization_schedule/include/jwt/* rmf_visualization_schedule/include/jwt/*/* diff --git a/README.md b/README.md index 83add65..6f2fc31 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # rmf_schedule_visualizer ![](https://github.com/open-rmf/rmf_visualization/workflows/build/badge.svg) +![](https://github.com/open-rmf/rmf_visualization/workflows/style/badge.svg) [![codecov](https://codecov.io/gh/open-rmf/rmf_visualization/branch/main/graph/badge.svg)](https://codecov.io/gh/open-rmf/rmf_visualization) This repository contains several packages that aid with visualizing various entities within RMF via RViz. diff --git a/rmf_visualization_fleet_states/CMakeLists.txt b/rmf_visualization_fleet_states/CMakeLists.txt index 75394d6..401e5cf 100644 --- a/rmf_visualization_fleet_states/CMakeLists.txt +++ b/rmf_visualization_fleet_states/CMakeLists.txt @@ -53,6 +53,7 @@ rclcpp_components_register_node(fleetstates_visualizer #=============================================================================== if(BUILD_TESTING) find_package(ament_cmake_uncrustify REQUIRED) + find_package(rmf_utils REQUIRED) find_file(uncrustify_config_file NAMES "rmf_code_style.cfg" PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/") diff --git a/rmf_visualization_fleet_states/package.xml b/rmf_visualization_fleet_states/package.xml index e6e9e42..7291907 100644 --- a/rmf_visualization_fleet_states/package.xml +++ b/rmf_visualization_fleet_states/package.xml @@ -19,6 +19,7 @@ ament_lint_auto ament_lint_common + rmf_utils ament_cmake diff --git a/rmf_visualization_fleet_states/src/FleetStatesVisualizer.cpp b/rmf_visualization_fleet_states/src/FleetStatesVisualizer.cpp index e39ca74..76f2f76 100644 --- a/rmf_visualization_fleet_states/src/FleetStatesVisualizer.cpp +++ b/rmf_visualization_fleet_states/src/FleetStatesVisualizer.cpp @@ -67,76 +67,76 @@ FleetStatesVisualizer::FleetStatesVisualizer(const rclcpp::NodeOptions& options) using Location = rmf_fleet_msgs::msg::Location; auto set_body_pose = - [](const Location& loc, Marker& marker) - { - marker.pose.position.x = loc.x; - marker.pose.position.y = loc.y; - marker.pose.position.z = 0.0; - marker.pose.orientation.w = 1.0; - }; + [](const Location& loc, Marker& marker) + { + marker.pose.position.x = loc.x; + marker.pose.position.y = loc.y; + marker.pose.position.z = 0.0; + marker.pose.orientation.w = 1.0; + }; auto set_nose_pose = - [](const Location& loc, const double radius, Marker& marker) - { - marker.pose.position.x = loc.x + radius * std::cos(loc.yaw); - marker.pose.position.y = loc.y + radius * std::sin(loc.yaw); - marker.pose.position.z = 0.0; - marker.pose.orientation.w = 1.0; - }; + [](const Location& loc, const double radius, Marker& marker) + { + marker.pose.position.x = loc.x + radius * std::cos(loc.yaw); + marker.pose.position.y = loc.y + radius * std::sin(loc.yaw); + marker.pose.position.z = 0.0; + marker.pose.orientation.w = 1.0; + }; auto set_text_pose = - [](const Location& loc, const double radius, Marker& marker) - { - marker.pose.position.x = - loc.x + 2.0 * radius * std::cos(loc.yaw - 0.7853); - marker.pose.position.y = - loc.y + 2.0 * radius * std::sin(loc.yaw - 0.7853); - marker.pose.position.z = 0.0; - marker.pose.orientation.w = 1.0; - }; + [](const Location& loc, const double radius, Marker& marker) + { + marker.pose.position.x = + loc.x + 2.0 * radius * std::cos(loc.yaw - 0.7853); + marker.pose.position.y = + loc.y + 2.0 * radius * std::sin(loc.yaw - 0.7853); + marker.pose.position.z = 0.0; + marker.pose.orientation.w = 1.0; + }; auto fill_markers = - [&]( - const RobotState& state, - const double radius, - const std::size_t id, - MarkerArray& marker_array) - { - const auto& loc = state.location; - - Marker body_marker; - body_marker.header.frame_id = "map"; - body_marker.header.stamp = state.location.t; - body_marker.ns = "body"; - body_marker.id = id; - body_marker.type = body_marker.SPHERE; - body_marker.action = body_marker.MODIFY; - set_body_pose(loc, body_marker); - body_marker.scale.x = 2.0 * radius; - body_marker.scale.y = 2.0 * radius; - body_marker.scale.z = 2.0 * radius; - // TODO(YV): Get the color to match that of the navigation graph - body_marker.color.r = 1.0; - body_marker.color.b = 1.0; - body_marker.color.a = 1.0; - body_marker.lifetime = rclcpp::Duration(std::chrono::seconds(1)); - - auto nose_marker = body_marker; - nose_marker.ns = "nose"; - set_nose_pose(loc, radius, nose_marker); - nose_marker.scale.x = this->_nose_scale * radius; - nose_marker.scale.y = this->_nose_scale * radius; - nose_marker.scale.z = this->_nose_scale * radius; - - auto text_marker = body_marker; - text_marker.ns = "name"; - text_marker.type = text_marker.TEXT_VIEW_FACING; - set_text_pose(loc, radius, text_marker); - text_marker.text = state.name; - text_marker.scale.z = 0.3; - - marker_array.markers.push_back(std::move(body_marker)); - marker_array.markers.push_back(std::move(nose_marker)); - marker_array.markers.push_back(std::move(text_marker)); - }; + [&]( + const RobotState& state, + const double radius, + const std::size_t id, + MarkerArray& marker_array) + { + const auto& loc = state.location; + + Marker body_marker; + body_marker.header.frame_id = "map"; + body_marker.header.stamp = state.location.t; + body_marker.ns = "body"; + body_marker.id = id; + body_marker.type = body_marker.SPHERE; + body_marker.action = body_marker.MODIFY; + set_body_pose(loc, body_marker); + body_marker.scale.x = 2.0 * radius; + body_marker.scale.y = 2.0 * radius; + body_marker.scale.z = 2.0 * radius; + // TODO(YV): Get the color to match that of the navigation graph + body_marker.color.r = 1.0; + body_marker.color.b = 1.0; + body_marker.color.a = 1.0; + body_marker.lifetime = rclcpp::Duration(std::chrono::seconds(1)); + + auto nose_marker = body_marker; + nose_marker.ns = "nose"; + set_nose_pose(loc, radius, nose_marker); + nose_marker.scale.x = this->_nose_scale * radius; + nose_marker.scale.y = this->_nose_scale * radius; + nose_marker.scale.z = this->_nose_scale * radius; + + auto text_marker = body_marker; + text_marker.ns = "name"; + text_marker.type = text_marker.TEXT_VIEW_FACING; + set_text_pose(loc, radius, text_marker); + text_marker.text = state.name; + text_marker.scale.z = 0.3; + + marker_array.markers.push_back(std::move(body_marker)); + marker_array.markers.push_back(std::move(nose_marker)); + marker_array.markers.push_back(std::move(text_marker)); + }; if (msg->name.empty() || msg->robots.empty()) return; diff --git a/rmf_visualization_floorplans/CMakeLists.txt b/rmf_visualization_floorplans/CMakeLists.txt index 24ea4a4..46e57ab 100644 --- a/rmf_visualization_floorplans/CMakeLists.txt +++ b/rmf_visualization_floorplans/CMakeLists.txt @@ -61,6 +61,7 @@ rclcpp_components_register_node(floorplan_visualizer #=============================================================================== if(BUILD_TESTING) find_package(ament_cmake_uncrustify REQUIRED) + find_package(rmf_utils REQUIRED) find_file(uncrustify_config_file NAMES "rmf_code_style.cfg" PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/") diff --git a/rmf_visualization_floorplans/package.xml b/rmf_visualization_floorplans/package.xml index 578ea66..bd10213 100644 --- a/rmf_visualization_floorplans/package.xml +++ b/rmf_visualization_floorplans/package.xml @@ -20,6 +20,7 @@ ament_lint_auto ament_lint_common + rmf_utils ament_cmake diff --git a/rmf_visualization_navgraphs/CMakeLists.txt b/rmf_visualization_navgraphs/CMakeLists.txt index 9039d72..8148d67 100644 --- a/rmf_visualization_navgraphs/CMakeLists.txt +++ b/rmf_visualization_navgraphs/CMakeLists.txt @@ -64,6 +64,7 @@ rclcpp_components_register_node(navgraph_visualizer #=============================================================================== if(BUILD_TESTING) find_package(ament_cmake_uncrustify REQUIRED) + find_package(rmf_utils REQUIRED) find_file(uncrustify_config_file NAMES "rmf_code_style.cfg" PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/") diff --git a/rmf_visualization_navgraphs/package.xml b/rmf_visualization_navgraphs/package.xml index f0295ba..633b9c7 100644 --- a/rmf_visualization_navgraphs/package.xml +++ b/rmf_visualization_navgraphs/package.xml @@ -21,6 +21,7 @@ ament_lint_auto ament_lint_common + rmf_utils ament_cmake diff --git a/rmf_visualization_navgraphs/src/NavGraphVisualizer.cpp b/rmf_visualization_navgraphs/src/NavGraphVisualizer.cpp index 822708c..8ce7438 100644 --- a/rmf_visualization_navgraphs/src/NavGraphVisualizer.cpp +++ b/rmf_visualization_navgraphs/src/NavGraphVisualizer.cpp @@ -203,7 +203,9 @@ auto NavGraphVisualizer::FleetNavGraph::update_lane_states( std::optional map_name_filter) -> std::vector { if (!traffic_graph.has_value()) + { return {}; + } // TODO(YV): Avoid this copy by storing Maker::ConstSharedPtr in the cache std::vector marker_updates = {}; diff --git a/rmf_visualization_obstacles/CMakeLists.txt b/rmf_visualization_obstacles/CMakeLists.txt index 9116a1e..b6d7815 100644 --- a/rmf_visualization_obstacles/CMakeLists.txt +++ b/rmf_visualization_obstacles/CMakeLists.txt @@ -49,12 +49,13 @@ rclcpp_components_register_node(obstacle_visualizer #=============================================================================== if(BUILD_TESTING) find_package(ament_cmake_uncrustify REQUIRED) + find_package(rmf_utils REQUIRED) find_file(uncrustify_config_file NAMES "rmf_code_style.cfg" PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/") ament_uncrustify( - include/rmf_visualization_schedule src test + ARGN src CONFIG_FILE ${uncrustify_config_file} MAX_LINE_LENGTH 80 ) diff --git a/rmf_visualization_obstacles/package.xml b/rmf_visualization_obstacles/package.xml index 3af7608..7754001 100644 --- a/rmf_visualization_obstacles/package.xml +++ b/rmf_visualization_obstacles/package.xml @@ -18,6 +18,7 @@ rmf_visualization_msgs ament_cmake_uncrustify + rmf_utils ament_cmake diff --git a/rmf_visualization_rviz2_plugins/CMakeLists.txt b/rmf_visualization_rviz2_plugins/CMakeLists.txt index a826905..f0e2890 100644 --- a/rmf_visualization_rviz2_plugins/CMakeLists.txt +++ b/rmf_visualization_rviz2_plugins/CMakeLists.txt @@ -35,12 +35,13 @@ find_package(Qt5 REQUIRED COMPONENTS Widgets Test) if(BUILD_TESTING) find_package(ament_cmake_uncrustify REQUIRED) + find_package(rmf_utils REQUIRED) find_file(uncrustify_config_file NAMES "rmf_code_style.cfg" PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/") ament_uncrustify( - src test + ARGN src CONFIG_FILE ${uncrustify_config_file} MAX_LINE_LENGTH 80 ) diff --git a/rmf_visualization_rviz2_plugins/package.xml b/rmf_visualization_rviz2_plugins/package.xml index 8dd7805..1a512be 100644 --- a/rmf_visualization_rviz2_plugins/package.xml +++ b/rmf_visualization_rviz2_plugins/package.xml @@ -28,6 +28,7 @@ libqt5-widgets ament_cmake_uncrustify + rmf_utils ament_cmake diff --git a/rmf_visualization_schedule/CMakeLists.txt b/rmf_visualization_schedule/CMakeLists.txt index a3df1c1..c7cdd7a 100644 --- a/rmf_visualization_schedule/CMakeLists.txt +++ b/rmf_visualization_schedule/CMakeLists.txt @@ -32,12 +32,13 @@ find_package(Threads) if(BUILD_TESTING) find_package(ament_cmake_uncrustify REQUIRED) + find_package(rmf_utils REQUIRED) find_file(uncrustify_config_file NAMES "rmf_code_style.cfg" PATHS "${rmf_utils_DIR}/../../../share/rmf_utils/") ament_uncrustify( - include/rmf_visualization_schedule src test + ARGN include/rmf_visualization_schedule src test CONFIG_FILE ${uncrustify_config_file} MAX_LINE_LENGTH 80 ) diff --git a/rmf_visualization_schedule/package.xml b/rmf_visualization_schedule/package.xml index dfe684d..31d42e7 100644 --- a/rmf_visualization_schedule/package.xml +++ b/rmf_visualization_schedule/package.xml @@ -28,6 +28,7 @@ ament_lint_auto ament_lint_common ament_cmake_uncrustify + rmf_utils rosidl_interface_packages