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

Allow transport to generate messages #425

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

#--------------------------------------
Expand Down Expand Up @@ -165,6 +165,8 @@ gz_configure_build(QUIT_IF_BUILD_ERRORS
#============================================================================
add_subdirectory(conf)

add_subdirectory(proto)

#============================================================================
# gz transport python bindings
#============================================================================
Expand Down
2 changes: 1 addition & 1 deletion include/gz/transport/Discovery.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#include <thread>
#include <vector>

#include <gz/msgs/Utility.hh>
#include <gz/msgs/convert/DiscoveryType.hh>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the plan to leave the conversion functions in gz-msgs even for protos that have been moved elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't particularly clear on that. The conversion functions are in the gz::msgs namespace, so putting them in other packages could end up being a little awkward?


#include "gz/transport/config.hh"
#include "gz/transport/Export.hh"
Expand Down
23 changes: 23 additions & 0 deletions proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed making the generated library a component so it can be used by third-party applications without having to link against the containing library. Is that still possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to use the msgs component without using the core library for each package that has it.

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")
181 changes: 181 additions & 0 deletions proto/gz/msgs/discovery.proto
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so we're keeping the package name gz.msgs. I think it's okay, but would be a little confusing for future users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little confusing, but also limits the number of changes that need to be made. I think if we want, we can then alter the package names in a later revision, but it makes the diff quite large here.

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;
}
}
36 changes: 36 additions & 0 deletions proto/gz/msgs/parameter.proto
Original file line number Diff line number Diff line change
@@ -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;
};
34 changes: 34 additions & 0 deletions proto/gz/msgs/parameter_declaration.proto
Original file line number Diff line number Diff line change
@@ -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;
};
33 changes: 33 additions & 0 deletions proto/gz/msgs/parameter_declarations.proto
Original file line number Diff line number Diff line change
@@ -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;
};
36 changes: 36 additions & 0 deletions proto/gz/msgs/parameter_error.proto
Original file line number Diff line number Diff line change
@@ -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;
};
Loading