diff --git a/CMakeLists.txt b/CMakeLists.txt index bd6d386..62b055f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,41 @@ 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}") + +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}/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}/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}/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) +target_compile_features(akushon_proto PUBLIC cxx_std_17) + +target_link_libraries(akushon_proto + protobuf::libprotobuf +) + rosidl_generate_interfaces(${PROJECT_NAME} "msg/RunAction.msg" "msg/Status.msg" @@ -23,4 +58,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}/proto/ + DESTINATION include/${PROJECT_NAME} +) + +install ( + TARGETS akushon_proto + EXPORT akushon_proto + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + ament_package() diff --git a/proto/akushon.proto b/proto/akushon.proto new file mode 100644 index 0000000..49008ce --- /dev/null +++ b/proto/akushon.proto @@ -0,0 +1,43 @@ +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; +}