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

robocup_ssl_msgsのproto2ros化 #717

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion crane_visualization_interfaces/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package format="3">
<name>crane_visualization_interfaces</name>
<version>0.1.0</version>
<description>Message types for CON-SAI visualization</description>
<description>crane_visualization_interfaces</description>
<maintainer email="[email protected]">ibis-ssl</maintainer>
<license>MIT</license>

Expand Down
100 changes: 100 additions & 0 deletions robocup_ssl_interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
cmake_minimum_required(VERSION 3.5)
project(robocup_ssl_interfaces)

# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# 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 -Wno-deprecated-declarations)
endif()

find_package(Protobuf REQUIRED)

file(GLOB proto_files "proto/*.proto")
message(WARNING ${proto_files})

#add_subdirectory(proto)

# find dependencies
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

protobuf_generate(
LANGUAGE python
OUT_VAR proto_py_sources
PROTOS ${proto_files}
)

message(WARNING "protobuf_generate python!")

protobuf_generate(
LANGUAGE cpp
OUT_VAR proto_cpp_sources
PROTOS ${proto_files}
)

message(WARNING "protobuf_generate cpp!")

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}
#)

### proto -> ROS msg
proto2ros_generate(
${PROJECT_NAME}_messages_gen
PROTOS ${proto_files}
# IMPORT_DIRS proto
INTERFACES_OUT_VAR ros_messages
PYTHON_OUT_VAR py_sources
CPP_OUT_VAR cpp_sources
INCLUDE_OUT_VAR cpp_include_dir
APPEND_PYTHONPATH "${CMAKE_CURRENT_BINARY_DIR}/proto"
# DEPENDS ${PROJECT_NAME}_proto_gen
)

message(WARNING "proto2ros_generate!")

## ROS msg -> C++ / Python
rosidl_generate_interfaces(
${PROJECT_NAME} ${ros_messages}
DEPENDENCIES builtin_interfaces proto2ros
)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_messages_gen)

message(WARNING "rosidl_generate_interfaces!")

#rosidl_generated_python_package_add(
# ${PROJECT_NAME}_additional_modules
# MODULES ${proto_py_sources} ${py_sources}
# PACKAGES ${PROJECT_NAME}
# DESTINATION ${PROJECT_NAME}
#)

# C++ファイルインストール
set(cpp_headers ${cpp_sources} ${proto_cpp_sources})
list(FILTER cpp_headers INCLUDE REGEX ".*\.(hpp|h)$")
install(
FILES ${cpp_headers}
DESTINATION include/${PROJECT_NAME}/${PROJECT_NAME}/
)

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

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

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>

<depend>builtin_interfaces</depend>
<depend>proto2ros</depend>
<depend>protobuf-dev</depend>
<depend>std_msgs</depend>

<exec_depend>python3-protobuf</exec_depend>
<exec_depend>rosidl_default_runtime</exec_depend>

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

<member_of_group>rosidl_interface_packages</member_of_group>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
26 changes: 26 additions & 0 deletions robocup_ssl_interfaces/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 ${proto_files}
)

protobuf_generate(
LANGUAGE cpp
OUT_VAR proto_cpp_sources
PROTOS ${proto_files}
)

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)
28 changes: 28 additions & 0 deletions robocup_ssl_interfaces/proto/ssl_gc_common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
syntax = "proto3";

option go_package = "github.com/RoboCup-SSL/ssl-game-controller/internal/app/state";

// Team is either blue or yellow
enum Team {
// team not set
UNKNOWN = 0;
// yellow team
YELLOW = 1;
// blue team
BLUE = 2;
}

// RobotId is the combination of a team and a robot id
message RobotId {
// the robot number
optional uint32 id = 1;
// the team that the robot belongs to
optional Team team = 2;
}

// Division denotes the current division, which influences some rules
enum Division {
DIV_UNKNOWN = 0;
DIV_A = 1;
DIV_B = 2;
}
Loading
Loading