Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可視化オブジェクトのproto送信サーバ #732

Draft
wants to merge 15 commits into
base: develop
Choose a base branch
from
Draft
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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2024 ibis-ssl
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

#ifndef CONSAI_VISUALIZER_MSGS__MANUAL_CONVERSIONS_HPP_
#define CONSAI_VISUALIZER_MSGS__MANUAL_CONVERSIONS_HPP_

#endif // CONSAI_VISUALIZER_MSGS__MANUAL_CONVERSIONS_HPP_
26 changes: 26 additions & 0 deletions consai_ros2/consai_visualizer_msgs/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
find_package(Protobuf REQUIRED)

protobuf_generate(
LANGUAGE python
OUT_VAR proto_py_sources
PROTOS ObjectsArray.proto
)

protobuf_generate(
LANGUAGE cpp
OUT_VAR proto_cpp_sources
PROTOS ObjectsArray.proto
)

add_library(${PROJECT_NAME}_proto SHARED ${proto_cpp_sources} )
#target_include_directories(${PROJECT_NAME}_proto PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
target_compile_options(${PROJECT_NAME}_proto PUBLIC -Wno-deprecated-declarations)
target_link_libraries(${PROJECT_NAME}_proto protobuf::libprotobuf)

add_custom_target(
${PROJECT_NAME}_proto_gen ALL DEPENDS
${proto_py_sources}
${proto_cpp_sources}
)

set(PROTO_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE)
142 changes: 142 additions & 0 deletions consai_ros2/consai_visualizer_msgs/proto/ObjectsArray.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
syntax = "proto3";

package visualizer;

// Color.msg
message Color {
string name = 1;
float red = 2;
float green = 3;
float blue = 4;
float alpha = 5;
}

// Point.msg
message Point {
float x = 1; // unit: meters
float y = 2; // unit: meters
}

// ShapeAnnotation.msg
message ShapeAnnotation {
float normalized_x = 1;
float normalized_y = 2;
float normalized_width = 3;
float normalized_height = 4;
string text = 5;
Color color = 6;
}

// ShapeArc.msg
message ShapeArc {
Point center = 1;
float radius = 2;
float start_angle = 3;
float end_angle = 4;
uint32 size = 5;
Color color = 6;
string caption = 7;
}

// ShapeCircle.msg
message ShapeCircle {
Point center = 1;
float radius = 2;
Color line_color = 3;
Color fill_color = 4;
uint32 line_size = 5;
string caption = 6;
}

// ShapeLine.msg
message ShapeLine {
Point p1 = 1;
Point p2 = 2;
uint32 size = 3;
Color color = 4;
string caption = 5;
}

// ShapePoint.msg
message ShapePoint {
float x = 1; // unit: meters
float y = 2; // unit: meters
uint32 size = 3;
Color color = 4;
string caption = 5;
}

// ShapeRectangle.msg
message ShapeRectangle {
Point center = 1;
float width = 2;
float height = 3;
uint32 line_size = 4;
Color line_color = 5;
Color fill_color = 6;
string caption = 7;
}

// ShapeRobot.msg
message ShapeRobot {
enum ColorType {
COLOR_TYPE_DEFAULT = 0;
COLOR_TYPE_REAL = 1;
}

ColorType color_type = 1;
float radius = 2;
Color line_color = 3;
Color fill_color = 4;
uint32 line_size = 5;
uint32 id = 6;
float x = 7;
float y = 8;
float theta = 9;
string caption = 10;
}

// ShapeText.msg
message ShapeText {
float x = 1; // unit: meters
float y = 2; // unit: meters
string text = 3;
uint32 size = 4;
Color color = 5;
}

// ShapeTube.msg
message ShapeTube {
Point p1 = 1;
Point p2 = 2;
float radius = 3;
Color line_color = 4;
Color fill_color = 5;
uint32 line_size = 6;
string caption = 7;
}

// Objects.msg
message Objects {
string layer = 1;
string sub_layer = 2;
uint32 z_order = 3; // Higher numbers are displayed in front

// Objects drawn in the window area
repeated ShapeAnnotation annotations = 4;

// Objects drawn in the field area
repeated ShapePoint points = 5;
repeated ShapeLine lines = 6;
repeated ShapeArc arcs = 7;
repeated ShapeRectangle rects = 8;
repeated ShapeCircle circles = 9;
repeated ShapeTube tubes = 10;
repeated ShapeText texts = 11;
repeated ShapeRobot robots = 12;
}

// ObjectsArray.msg
message ObjectsArray {
repeated Objects objects = 1;
}
8 changes: 8 additions & 0 deletions consai_ros2/consai_visualizer_msgs/src/manual_conversions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2024 ibis-ssl
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

// NOTE: 名前もmanual_conversions.cppで固定
#include <consai_visualizer_msgs/manual_conversions.hpp>
17 changes: 17 additions & 0 deletions utility/crane_visualization_bridge/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Language: Cpp
BasedOnStyle: Google

AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
BraceWrapping:
AfterClass: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
BreakBeforeBraces: Custom
ColumnLimit: 100
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 2
DerivePointerAlignment: false
PointerAlignment: Middle
ReflowComments: false
24 changes: 24 additions & 0 deletions utility/crane_visualization_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.5)
project(crane_visualization_bridge)

# Default to C++20
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -g)
endif()

# find dependencies
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

ament_auto_add_executable(${PROJECT_NAME}_node src/${PROJECT_NAME}_node.cpp)

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

ament_auto_package()
24 changes: 24 additions & 0 deletions utility/crane_visualization_bridge/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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>crane_visualization_bridge</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">ibis ssl</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

<depend>consai_visualizer_msgs</depend>
<depend>crane_msgs</depend>
<depend>proto2ros</depend>
<depend>rclcpp</depend>
<depend>std_msgs</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>crane_lint_common</test_depend>

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