Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci_humble.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ci_humble

on:
push:
branches:
- "humble"
pull_request:
types: [opened, synchronize, labeled]

jobs:
ci:
runs-on: ${{ matrix.os }}
if: |
((github.event.action == 'labeled') && (github.event.label.name == 'TESTING') && (github.base_ref == 'humble' )) ||
((github.event.action == 'synchronize') && (github.base_ref == 'humble') && contains(github.event.pull_request.labels.*.name, 'TESTING')) ||
(github.ref_name == 'humble')
container:
image: osrf/ros:${{ matrix.ros_distribution }}-desktop
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
ros_distribution: [humble]
steps:
- uses: actions/checkout@v3
- uses: ros-tooling/setup-ros@v0.7
- name: Build and Test
uses: ros-tooling/action-ros-ci@v0.3
with:
target-ros2-distro: ${{ matrix.ros_distribution }}
import-token: ${{ secrets.GITHUB_TOKEN }}
package-name: |
minecraft_utils
minecraft_utils_visualization
vcs-repo-file-url: build_depends.repos
5 changes: 5 additions & 0 deletions build_depends.repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repositories:
minecraft-ros2/minecraft_msgs:
type: git
url: https://github.com/minecraft-ros2/minecraft_msgs.git
version: humble
6 changes: 6 additions & 0 deletions minecraft_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.5)
project(minecraft_utils)

find_package(ament_cmake_auto REQUIRED)

ament_auto_package()
20 changes: 20 additions & 0 deletions minecraft_utils/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>minecraft_utils</name>
<version>0.0.1</version>
<description>The minecraft_utils package</description>
<maintainer email="ray255ar@gmail.com">Ar-Ray-code</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<depend>minecraft_utils_visualization</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
23 changes: 23 additions & 0 deletions minecraft_utils_visualization/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.5)
project(minecraft_utils_visualization)

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

set(TARGET mob_marker)
ament_auto_add_library(${TARGET} SHARED ./src/${TARGET}.cpp)
rclcpp_components_register_node(
${TARGET}
PLUGIN "minecraft_utils_visualization::MobMarker"
EXECUTABLE ${TARGET}_exec)
target_include_directories(
${TARGET} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright 2025 minecraft-ros2
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef MINECRAFT_UTILS_VISUALIZATION__MOB_MARKER_HPP_
#define MINECRAFT_UTILS_VISUALIZATION__MOB_MARKER_HPP_

#include <tf2/LinearMath/Matrix3x3.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2/LinearMath/Vector3.h>
#include <tf2_ros/buffer.h>
#include <tf2_ros/transform_listener.h>

#include <cmath>
#include <functional>
#include <memory>
#include <sstream>
#include <string>

#include <geometry_msgs/msg/transform_stamped.hpp>
#include <minecraft_msgs/msg/living_entity.hpp>
#include <minecraft_msgs/msg/living_entity_array.hpp>
#include <minecraft_msgs/msg/mob_category.hpp>
#include <rclcpp/rclcpp.hpp>
#include <std_msgs/msg/header.hpp>
#include <visualization_msgs/msg/marker.hpp>
#include <visualization_msgs/msg/marker_array.hpp>


namespace minecraft_utils_visualization
{
class MobMarker : public rclcpp::Node
{
public:
explicit MobMarker(rclcpp::NodeOptions);
~MobMarker() = default;

private:
void mobCallback(const minecraft_msgs::msg::LivingEntityArray::SharedPtr);

void setMarkerColor(const uint8_t, visualization_msgs::msg::Marker &);

void addNameHealthMarker(
const minecraft_msgs::msg::LivingEntity &,
const std_msgs::msg::Header &,
const float, const float, const float,
const geometry_msgs::msg::Quaternion &,
visualization_msgs::msg::MarkerArray &);

tf2::Vector3 transformToPlayerFrame(
const geometry_msgs::msg::Quaternion & player_orientation,
const float, const float, const float);

rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr marker_pub_;
rclcpp::Subscription<minecraft_msgs::msg::LivingEntityArray>::SharedPtr mob_sub_;

std::unique_ptr<tf2_ros::Buffer> tf_buffer_;
std::shared_ptr<tf2_ros::TransformListener> tf_listener_;

std::string world_frame_id_;
std::string player_frame_id_;
std::string mob_namespace_;
std::string mob_text_namespace_;
};

} // namespace minecraft_utils_visualization

#endif // MINECRAFT_UTILS_VISUALIZATION__MOB_MARKER_HPP_
25 changes: 25 additions & 0 deletions minecraft_utils_visualization/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>minecraft_utils_visualization</name>
<version>0.0.1</version>
<description>The minecraft_utils_visualization package</description>
<maintainer email="ray255ar@gmail.com">Ar-Ray-code</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<depend>minecraft_msgs</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>std_msgs</depend>
<depend>tf2_ros</depend>
<depend>visualization_msgs</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading