diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a5cb5efc..7455a082f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,7 @@ set(GZ_UTILS_VER ${gz-utils2_VERSION_MAJOR}) #-------------------------------------- # Find gz-msgs -gz_find_package(gz-msgs10 REQUIRED) +gz_find_package(gz-msgs10 REQUIRED COMPONENTS msgs) set(GZ_MSGS_VER ${gz-msgs10_VERSION_MAJOR}) #-------------------------------------- @@ -165,6 +165,8 @@ gz_configure_build(QUIT_IF_BUILD_ERRORS #============================================================================ add_subdirectory(conf) +add_subdirectory(proto) + #============================================================================ # gz transport python bindings #============================================================================ diff --git a/include/gz/transport/Discovery.hh b/include/gz/transport/Discovery.hh index 43ef7eadc..f0ee488d2 100644 --- a/include/gz/transport/Discovery.hh +++ b/include/gz/transport/Discovery.hh @@ -68,7 +68,7 @@ #include #include -#include +#include #include "gz/transport/config.hh" #include "gz/transport/Export.hh" diff --git a/proto/CMakeLists.txt b/proto/CMakeLists.txt new file mode 100644 index 000000000..9f4d19ca0 --- /dev/null +++ b/proto/CMakeLists.txt @@ -0,0 +1,23 @@ +set(proto_files + ${PROJECT_SOURCE_DIR}/proto/gz/msgs/discovery.proto + ${PROJECT_SOURCE_DIR}/proto/gz/msgs/parameter.proto + ${PROJECT_SOURCE_DIR}/proto/gz/msgs/parameter_declaration.proto + ${PROJECT_SOURCE_DIR}/proto/gz/msgs/parameter_declarations.proto + ${PROJECT_SOURCE_DIR}/proto/gz/msgs/parameter_error.proto + ${PROJECT_SOURCE_DIR}/proto/gz/msgs/parameter_name.proto + ${PROJECT_SOURCE_DIR}/proto/gz/msgs/parameter_value.proto +) + +gz_msgs_generate_messages( + TARGET gz-transport${PROJECT_VERSION_MAJOR}-msgs + PROTO_PACKAGE "gz.msgs" + MSGS_PATH ${PROJECT_SOURCE_DIR}/proto + MSGS_PROTOS ${proto_files} + DEPENDENCIES gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER}-msgs +) + +install( + DIRECTORY gz + DESTINATION share/protos + COMPONENT proto + FILES_MATCHING PATTERN "*.proto") diff --git a/proto/gz/msgs/discovery.proto b/proto/gz/msgs/discovery.proto new file mode 100644 index 000000000..93c56792f --- /dev/null +++ b/proto/gz/msgs/discovery.proto @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2019 Open Source Robotics Foundation + * + * 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. + * +*/ + +syntax = "proto3"; +package gz.msgs; +option java_package = "com.gz.msgs"; +option java_outer_classname = "DiscoveryProtos"; + +/// \ingroup gz.msgs +/// \interface Discovery +/// \brief Message that contains Discovery information. + +import "gz/msgs/header.proto"; + +message Discovery +{ + /// \brief Type of discovery message. + enum Type + { + /// \brief Type not initialized. + UNINITIALIZED = 0; + + /// \brief Advertise message. + ADVERTISE = 1; + + /// \brief Subscribe message. + SUBSCRIBE = 2; + + /// \brief Unadvertise message. + UNADVERTISE = 3; + + /// \brief Hearbeat message. + HEARTBEAT = 4; + + /// \brief Bye message. + BYE = 5; + + /// \brief New connection message. + NEW_CONNECTION = 6; + + /// \brief End connection message. + END_CONNECTION = 7; + + /// \brief Request the list of subscribers. + SUBSCRIBERS_REQ = 8; + + /// \brief Reply to a SUBSCRIBERS_REQ. + SUBSCRIBERS_REP = 9; + } + + /// \brief Discovery flags. + message Flags + { + /// \brief Flag set when a discovery message is relayed. + bool relay = 1; + + /// \brief Flag set when we want to avoid to relay a discovery message. + /// This is used to avoid loops. + bool no_relay = 2; + } + + /// \brief Information about a subscriber. + message Subscriber + { + string topic = 1; + } + + /// \brief Information about a publisher. + message Publisher + { + /// \brief Defines the different options for the scope of a topic/service. + enum Scope + { + /// \brief Topic/service only available to subscribers in the same + /// process as the publisher. + PROCESS = 0; + + /// \brief Topic/service only available to subscribers in the same + /// machine as the publisher. + HOST = 1; + + /// \brief Topic/service available to any subscriber. + ALL = 2; + } + + /// \brief Information about a message publisher. + message MessagePublisher + { + /// \brief ZeroMQ control address of the publisher. + /// \todo(caguero) Is this the same as 'socket_id' in the + /// ServicePublisher message? + string ctrl = 1; + + /// \brief Message type advertised by this publisher. + string msg_type = 2; + + /// \brief Whether the publication has been throttled. + bool throttled = 3; + + /// \brief The maximum number of messages per second to be published. + uint64 msgs_per_sec = 4; + } + + /// \brief Information about service provider. + message ServicePublisher + { + /// \brief ZeroMQ socket ID used by this publisher. + string socket_id = 1; + + /// \brief The name of the request's protobuf message advertised. + string request_type = 2; + + /// \brief The name of the response's protobuf message advertised. + string response_type = 3; + } + + /// \brief Topic name. + string topic = 1; + + /// \brief ZeroMQ address of the publisher. + string address = 2; + + /// \brief Process UUID of the publisher. + string process_uuid = 3; + + /// \brief Node UUID of the publisher. + string node_uuid = 4; + + /// \brief The scope of this publisher. + Scope scope = 5; + + /// \brief Information about a message or service publisher. + oneof pub_type + { + /// \brief Message publisher. + MessagePublisher msg_pub = 6; + + /// \brief Service provider. + ServicePublisher srv_pub = 7; + } + } + + /// \brief Optional header data. + Header header = 1; + + /// \brief Version of the discovery protocol. + uint32 version = 2; + + /// \brief Process UUID. + string process_uuid = 3; + + /// \brief The type of this message. + Type type = 4; + + /// \brief Optional flags. + Flags flags = 5; + + /// \brief Optional subscriber or publisher information. + oneof disc_contents + { + /// \brief Subscriber information. + Subscriber sub = 6; + + /// \brief Publisher information. + Publisher pub = 7; + } +} diff --git a/proto/gz/msgs/parameter.proto b/proto/gz/msgs/parameter.proto new file mode 100644 index 000000000..66fb40dd3 --- /dev/null +++ b/proto/gz/msgs/parameter.proto @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * 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. + * +*/ + +syntax = "proto3"; +package gz.msgs; +option java_package = "com.gz.msgs"; +option java_outer_classname = "ParameterProtos"; + +/// \ingroup gz.msgs +/// \interface Parameter +/// \brief Representation of a parameter, used to request to set a parameter. + +import "google/protobuf/any.proto"; + +message Parameter +{ + /// \brief Parameter name. + string name = 1; + + /// \brief Serialized parameter value. + google.protobuf.Any value = 2; +}; diff --git a/proto/gz/msgs/parameter_declaration.proto b/proto/gz/msgs/parameter_declaration.proto new file mode 100644 index 000000000..c33dcf173 --- /dev/null +++ b/proto/gz/msgs/parameter_declaration.proto @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * 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. + * +*/ + +syntax = "proto3"; +package gz.msgs; +option java_package = "com.gz.msgs"; +option java_outer_classname = "ParameterDeclarationProtos"; + +/// \ingroup gz.msgs +/// \interface ParameterDeclaration +/// \brief Representation of a parameter declaration. + +message ParameterDeclaration +{ + /// \brief Parameter name. + string name = 1; + + /// \brief Parameter type, i.e. the associated protobuf type. + string type = 2; +}; diff --git a/proto/gz/msgs/parameter_declarations.proto b/proto/gz/msgs/parameter_declarations.proto new file mode 100644 index 000000000..4dd3399d1 --- /dev/null +++ b/proto/gz/msgs/parameter_declarations.proto @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * 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. + * +*/ + +syntax = "proto3"; +package gz.msgs; +option java_package = "com.gz.msgs"; +option java_outer_classname = "ParameterDeclarationsProtos"; + +/// \ingroup gz.msgs +/// \interface ParameterDeclarations +/// \brief Collection of parameter declarations. + +import "gz/msgs/parameter_declaration.proto"; + +message ParameterDeclarations +{ + /// \brief Parameter declarations. + repeated ParameterDeclaration parameter_declarations = 1; +}; diff --git a/proto/gz/msgs/parameter_error.proto b/proto/gz/msgs/parameter_error.proto new file mode 100644 index 000000000..11dbb249f --- /dev/null +++ b/proto/gz/msgs/parameter_error.proto @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * 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. + * +*/ + +syntax = "proto3"; +package gz.msgs; +option java_package = "com.gz.msgs"; +option java_outer_classname = "ParameterErrorProtos"; + +/// \ingroup gz.msgs +/// \interface ParameterError +/// \brief Parameter server errors for declare or set parameter. + +message ParameterError +{ + enum Type { + SUCCESS = 0; + ALREADY_DECLARED = 1; + INVALID_TYPE = 2; + NOT_DECLARED = 3; + } + Type data = 1; +}; diff --git a/proto/gz/msgs/parameter_name.proto b/proto/gz/msgs/parameter_name.proto new file mode 100644 index 000000000..37335c7cf --- /dev/null +++ b/proto/gz/msgs/parameter_name.proto @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * 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. + * +*/ + +syntax = "proto3"; +package gz.msgs; +option java_package = "com.gz.msgs"; +option java_outer_classname = "ParameterNameProtos"; + +/// \ingroup gz.msgs +/// \interface ParameterName +/// \brief Parameter name, used as a request to get a parameter. + +message ParameterName +{ + /// \brief Parameter name. + string name = 1; +}; diff --git a/proto/gz/msgs/parameter_value.proto b/proto/gz/msgs/parameter_value.proto new file mode 100644 index 000000000..8cc8610f5 --- /dev/null +++ b/proto/gz/msgs/parameter_value.proto @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * 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. + * +*/ + +syntax = "proto3"; +package gz.msgs; +option java_package = "com.gz.msgs"; +option java_outer_classname = "ParameterValueProtos"; + +/// \ingroup gz.msgs +/// \interface ParameterValue +/// \brief Representation of a parameter value, used as a response to get a parameter. + +import "google/protobuf/any.proto"; + +message ParameterValue +{ + /// \brief Serialized protobuf message. + google.protobuf.Any data = 1; +}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cfb71dd55..a2ccaafe4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,12 +11,13 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER} gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER} CPPZMQ::CPPZMQ + gz-transport${PROJECT_VERSION_MAJOR}-msgs PRIVATE ${ZeroMQ_TARGET} ) target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} - SYSTEM PUBLIC + SYSTEM PUBLIC $ $)