From a2c596b3e4925f264a8ed38a5dc1af1652aadb18 Mon Sep 17 00:00:00 2001 From: marfanr Date: Fri, 6 Oct 2023 18:21:47 +0700 Subject: [PATCH 1/7] Feat/add new RPC --- proto/akushon.proto | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 proto/akushon.proto diff --git a/proto/akushon.proto b/proto/akushon.proto new file mode 100644 index 0000000..6e67614 --- /dev/null +++ b/proto/akushon.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +package akushon_interfaces.proto; + +service Config { + rpc GetConfig (Empty) returns (ConfigActions) {} + + rpc SaveConfig (ConfigActions) returns (Empty) {} + + rpc PublishSetJoints (SetJointsData) returns (Empty) {} + + rpc RunAction (ConfigRunAction) returns (Empty) {} + + rpc SetTorques (SetTorquesData) returns (Empty) {} + + rpc SubscribeCurrentJoints (Empty) returns (CurrentJoints) {} +} + +message Empty {} + +message ConfigActions { + string json_actions = 1; +} + +message SetJointsData { + int32 control_type = 1; + string joints_actions = 2; +} + +message ConfigRunAction { + int32 control_type = 1; + string action_name = 2; + string json_action = 3; +} + +message SetTorquesData { + string ids = 1; + bool torque_enable = 2; +} + +message CurrentJoints { + string msg_joints = 1; +} + From fcc5437b04c3f761edc51c56442bea0812c97f3e Mon Sep 17 00:00:00 2001 From: FaaizHaikal Date: Fri, 13 Oct 2023 22:48:16 +0700 Subject: [PATCH 2/7] fix: remove unused line --- proto/akushon.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/proto/akushon.proto b/proto/akushon.proto index 6e67614..49008ce 100644 --- a/proto/akushon.proto +++ b/proto/akushon.proto @@ -41,4 +41,3 @@ message SetTorquesData { message CurrentJoints { string msg_joints = 1; } - From 17e5f1200b42c9f0291b3d17bef37c484ef0f0b1 Mon Sep 17 00:00:00 2001 From: marfanr Date: Fri, 3 Nov 2023 18:53:44 +0700 Subject: [PATCH 3/7] feat: move proto compile part to akushon interfaces --- CMakeLists.txt | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd6d386..5adb7f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,59 @@ endif() find_package(ament_cmake REQUIRED) find_package(rosidl_default_generators REQUIRED) +set(protobuf_MODULE_COMPATIBLE TRUE) +find_package(Protobuf CONFIG REQUIRED) +message(STATUS "Using protobuf ${Protobuf_VERSION}") + +set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) +set(_REFLECTION gRPC::grpc++_reflection) +if(CMAKE_CROSSCOMPILING) + find_program(_PROTOBUF_PROTOC protoc) +else() + set(_PROTOBUF_PROTOC $) +endif() + +find_package(gRPC CONFIG REQUIRED) +message(STATUS "Using gRPC ${gRPC_VERSION}") + +set(_GRPC_GRPCPP gRPC::grpc++) +if(CMAKE_CROSSCOMPILING) + find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin) +else() + set(_GRPC_CPP_PLUGIN_EXECUTABLE $) +endif() + +# Proto file +get_filename_component(akushon_proto "./proto/akushon.proto" ABSOLUTE) +get_filename_component(akushon_proto_path "${akushon_proto}" PATH) + +# Generated sources +set(akushon_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.cc") +set(akushon_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.h") +set(akushon_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.cc") +set(akushon_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h") +add_custom_command( + OUTPUT "${akushon_proto_srcs}" "${akushon_proto_hdrs}" "${akushon_grpc_srcs}" "${akushon_grpc_hdrs}" + COMMAND ${_PROTOBUF_PROTOC} + ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" + --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" + -I "${akushon_proto_path}" + --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" + "${akushon_proto}" + DEPENDS "${akushon_proto}") + +add_library(akushon_proto + ${akushon_proto_srcs} + ${akushon_proto_hdrs} + ${akushon_grpc_srcs} + ${akushon_grpc_hdrs}) + +target_link_libraries(akushon_proto + ${_REFLECTION} + ${_GRPC_GRPCPP} + ${_PROTOBUF_LIBPROTOBUF} +) + rosidl_generate_interfaces(${PROJECT_NAME} "msg/RunAction.msg" "msg/Status.msg" @@ -23,4 +76,20 @@ rosidl_generate_interfaces(${PROJECT_NAME} "srv/SaveActions.srv") ament_export_dependencies(rosidl_default_runtime) +ament_export_targets(akushon_proto HAS_LIBRARY_TARGET) + +install ( + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DESTINATION include +) + +install ( + TARGETS akushon_proto + EXPORT akushon_proto + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + ament_package() From 9993f847ae9551a8da2f3bad96eb1a0b3cb92988 Mon Sep 17 00:00:00 2001 From: marfanr Date: Tue, 14 Nov 2023 18:47:50 +0700 Subject: [PATCH 4/7] feat: move grpc to akushon_interfaces --- CMakeLists.txt | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5adb7f0..80b9412 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,33 +22,24 @@ message(STATUS "Using protobuf ${Protobuf_VERSION}") set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) set(_REFLECTION gRPC::grpc++_reflection) -if(CMAKE_CROSSCOMPILING) - find_program(_PROTOBUF_PROTOC protoc) -else() - set(_PROTOBUF_PROTOC $) -endif() +set(_PROTOBUF_PROTOC $) find_package(gRPC CONFIG REQUIRED) message(STATUS "Using gRPC ${gRPC_VERSION}") set(_GRPC_GRPCPP gRPC::grpc++) -if(CMAKE_CROSSCOMPILING) - find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin) -else() - set(_GRPC_CPP_PLUGIN_EXECUTABLE $) -endif() +set(_GRPC_CPP_PLUGIN_EXECUTABLE $) # Proto file get_filename_component(akushon_proto "./proto/akushon.proto" ABSOLUTE) get_filename_component(akushon_proto_path "${akushon_proto}" PATH) # Generated sources -set(akushon_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.cc") -set(akushon_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.h") -set(akushon_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.cc") -set(akushon_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h") add_custom_command( - OUTPUT "${akushon_proto_srcs}" "${akushon_proto_hdrs}" "${akushon_grpc_srcs}" "${akushon_grpc_hdrs}" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.cc" + "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.h" + "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.cc" + "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h" COMMAND ${_PROTOBUF_PROTOC} ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" @@ -58,10 +49,10 @@ add_custom_command( DEPENDS "${akushon_proto}") add_library(akushon_proto - ${akushon_proto_srcs} - ${akushon_proto_hdrs} - ${akushon_grpc_srcs} - ${akushon_grpc_hdrs}) + ${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.cc + ${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.h + ${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.cc + ${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h) target_link_libraries(akushon_proto ${_REFLECTION} From dffd7b95836ef6d4d060a40b78816e17fb15f153 Mon Sep 17 00:00:00 2001 From: marfanr Date: Tue, 12 Dec 2023 12:12:14 +0000 Subject: [PATCH 5/7] feat: fix problem on running grpc --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80b9412..0125b9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,9 @@ if(NOT CMAKE_C_STANDARD) endif() if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD 17) endif() +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" ) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) @@ -55,8 +56,8 @@ add_library(akushon_proto ${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h) target_link_libraries(akushon_proto - ${_REFLECTION} - ${_GRPC_GRPCPP} + # ${_REFLECTION} + # ${_GRPC_GRPCPP} ${_PROTOBUF_LIBPROTOBUF} ) From 99fc5fcf48948d7076e5f34be542a79518e6659f Mon Sep 17 00:00:00 2001 From: marfanr Date: Mon, 1 Jan 2024 11:56:25 +0000 Subject: [PATCH 6/7] feat: refractor and resolve pull request --- CMakeLists.txt | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0125b9a..aa1880f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,8 @@ if(NOT CMAKE_C_STANDARD) endif() if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD 14) endif() -set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" ) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) @@ -23,31 +22,23 @@ message(STATUS "Using protobuf ${Protobuf_VERSION}") set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) set(_REFLECTION gRPC::grpc++_reflection) -set(_PROTOBUF_PROTOC $) find_package(gRPC CONFIG REQUIRED) message(STATUS "Using gRPC ${gRPC_VERSION}") -set(_GRPC_GRPCPP gRPC::grpc++) -set(_GRPC_CPP_PLUGIN_EXECUTABLE $) - -# Proto file -get_filename_component(akushon_proto "./proto/akushon.proto" ABSOLUTE) -get_filename_component(akushon_proto_path "${akushon_proto}" PATH) - # Generated sources add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.cc" "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.h" "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.cc" "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h" - COMMAND ${_PROTOBUF_PROTOC} + COMMAND $ ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" - -I "${akushon_proto_path}" - --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" - "${akushon_proto}" - DEPENDS "${akushon_proto}") + -I ${CMAKE_CURRENT_SOURCE_DIR}/proto + --plugin=protoc-gen-grpc=$ + ${CMAKE_CURRENT_SOURCE_DIR}/proto/akushon.proto + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/proto/akushon.proto) add_library(akushon_proto ${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.cc @@ -55,10 +46,11 @@ add_library(akushon_proto ${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h) +target_compile_options(akushon_proto PRIVATE -fPIC) +set_property(TARGET akushon_proto PROPERTY CXX_STANDARD 17) + target_link_libraries(akushon_proto - # ${_REFLECTION} - # ${_GRPC_GRPCPP} - ${_PROTOBUF_LIBPROTOBUF} + protobuf::libprotobuf ) rosidl_generate_interfaces(${PROJECT_NAME} From 7fdf0b78cc1695f0c9f7bc4474166a6a8f6be9f7 Mon Sep 17 00:00:00 2001 From: marfanr Date: Mon, 15 Jan 2024 14:29:56 +0700 Subject: [PATCH 7/7] feat: resolve change request on pull request --- CMakeLists.txt | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa1880f..62b055f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,34 +20,32 @@ set(protobuf_MODULE_COMPATIBLE TRUE) find_package(Protobuf CONFIG REQUIRED) message(STATUS "Using protobuf ${Protobuf_VERSION}") -set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf) -set(_REFLECTION gRPC::grpc++_reflection) - find_package(gRPC CONFIG REQUIRED) message(STATUS "Using gRPC ${gRPC_VERSION}") # Generated sources +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/proto) add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.cc" - "${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.h" - "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.cc" - "${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/proto/akushon.pb.cc" + "${CMAKE_CURRENT_BINARY_DIR}/proto/akushon.pb.h" + "${CMAKE_CURRENT_BINARY_DIR}/proto/akushon.grpc.pb.cc" + "${CMAKE_CURRENT_BINARY_DIR}/proto/akushon.grpc.pb.h" COMMAND $ - ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" - --cpp_out "${CMAKE_CURRENT_BINARY_DIR}" + ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}/proto" + --cpp_out "${CMAKE_CURRENT_BINARY_DIR}/proto" -I ${CMAKE_CURRENT_SOURCE_DIR}/proto --plugin=protoc-gen-grpc=$ ${CMAKE_CURRENT_SOURCE_DIR}/proto/akushon.proto DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/proto/akushon.proto) add_library(akushon_proto - ${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.cc - ${CMAKE_CURRENT_BINARY_DIR}/akushon.pb.h - ${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.cc - ${CMAKE_CURRENT_BINARY_DIR}/akushon.grpc.pb.h) + ${CMAKE_CURRENT_BINARY_DIR}/proto/akushon.pb.cc + ${CMAKE_CURRENT_BINARY_DIR}/proto/akushon.pb.h + ${CMAKE_CURRENT_BINARY_DIR}/proto/akushon.grpc.pb.cc + ${CMAKE_CURRENT_BINARY_DIR}/proto/akushon.grpc.pb.h) target_compile_options(akushon_proto PRIVATE -fPIC) -set_property(TARGET akushon_proto PROPERTY CXX_STANDARD 17) +target_compile_features(akushon_proto PUBLIC cxx_std_17) target_link_libraries(akushon_proto protobuf::libprotobuf @@ -63,8 +61,8 @@ ament_export_dependencies(rosidl_default_runtime) ament_export_targets(akushon_proto HAS_LIBRARY_TARGET) install ( - DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DESTINATION include + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/proto/ + DESTINATION include/${PROJECT_NAME} ) install (