浏览代码

Adding proto files.

/develop-generalizationTraining-TrainerController
Deric Pang 6 年前
当前提交
a7bd1c98
共有 26 个文件被更改,包括 318 次插入0 次删除
  1. 5
      .gitignore
  2. 31
      ml-agents-protobuf/README.md
  3. 43
      ml-agents-protobuf/make.bat
  4. 11
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/agent_action_proto.proto
  5. 18
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/agent_info_proto.proto
  6. 19
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/brain_parameters_proto.proto
  7. 14
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/brain_type_proto.proto
  8. 10
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/command_proto.proto
  9. 13
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/engine_configuration_proto.proto
  10. 8
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/environment_parameters_proto.proto
  11. 9
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/header.proto
  12. 11
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/resolution_proto.proto
  13. 12
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/space_type_proto.proto
  14. 14
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_input.proto
  15. 15
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_message.proto
  16. 15
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_output.proto
  17. 9
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_rl_initialization_input.proto
  18. 16
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_rl_initialization_output.proto
  19. 18
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_rl_input.proto
  20. 15
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_rl_output.proto
  21. 12
      ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_to_external.proto

5
.gitignore


# pytest cache
*.pytest_cache/
# Ignore compiled protobuf files.
ml-agents-protobuf/cs
ml-agents-protobuf/python
ml-agents-protobuf/Grpc*

31
ml-agents-protobuf/README.md


# Unity ML-Agents Protobuf Definitions
Contains relevant definitions needed to generate probobuf files used in [ML-Agents Toolkit](https://github.com/Unity-Technologies/ml-agents).
## Requirements
* grpc 1.10.1
* protobuf 3.6.0
## Set-up & Installation
`pip install protobuf==3.6.0 --force`
`pip install grpcio-tools`
`nuget install Grpc.Tools` into known directory.
### Installing Protobuf Compiler
On Mac: `brew install protobuf`
On Windows & Linux: [See here](https://github.com/google/protobuf/blob/master/src/README.md).
## Running
1. Install pre-requisites.
2. Un-comment line 4 in `make.bat`, and set to correct Grpc.Tools sub-directory.
3. Run `make.bat`
4. Copy created `communicator_objects` and `CommunicatorObjects` folders to their respective sub-directories within the `ml-agents` repository.
* For Python, the generated files should be copied to: `python/communicator_objects`
* For C#, the generated files should be copied to: `unity-environment/Assets/ML-Agents/Scripts/CommunicatorObjects`.

43
ml-agents-protobuf/make.bat


# variables
# GRPC-TOOLS required. Install with `nuget install Grpc.Tools`.
# Then un-comment and replace [DIRECTORY] with location of files.
# For example, on macOS, you might have something like:
COMPILER=Grpc.Tools.1.14.1/tools/macosx_x64
# COMPILER=[DIRECTORY]
SRC_DIR=proto/mlagents/envs/communicator_objects
DST_DIR_C=cs/CommunicatorObjects
DST_DIR_P=python
PROTO_PATH=proto
PYTHON_PACKAGE=mlagents/envs/communicator_objects
# clean
rm -rf $DST_DIR_C
rm -rf $DST_DIR_P
mkdir -p $DST_DIR_C
mkdir -p $DST_DIR_P/$PYTHON_PACKAGE
# generate proto objects in python and C#
protoc --proto_path=proto --csharp_out=$DST_DIR_C $SRC_DIR/*.proto
protoc --proto_path=proto --python_out=$DST_DIR_P $SRC_DIR/*.proto
# grpc
GRPC=unity_to_external.proto
$COMPILER/protoc --proto_path=proto --csharp_out $DST_DIR_C --grpc_out $DST_DIR_C $SRC_DIR/$GRPC --plugin=protoc-gen-grpc=$COMPILER/grpc_csharp_plugin
python3 -m grpc_tools.protoc --proto_path=proto --python_out=$DST_DIR_P --grpc_python_out=$DST_DIR_P $SRC_DIR/$GRPC
# Generate the init file for the python module
# rm -f $DST_DIR_P/$PYTHON_PACKAGE/__init__.py
for FILE in $DST_DIR_P/$PYTHON_PACKAGE/*.py
do
FILE=${FILE##*/}
# echo from .$(basename $FILE) import \* >> $DST_DIR_P/$PYTHON_PACKAGE/__init__.py
echo from .${FILE%.py} import \* >> $DST_DIR_P/$PYTHON_PACKAGE/__init__.py
done

11
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/agent_action_proto.proto


syntax = "proto3";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message AgentActionProto {
repeated float vector_actions = 1;
string text_actions = 2;
repeated float memories = 3;
float value = 4;
}

18
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/agent_info_proto.proto


syntax = "proto3";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message AgentInfoProto {
repeated float stacked_vector_observation = 1;
repeated bytes visual_observations = 2;
string text_observation = 3;
repeated float stored_vector_actions = 4;
string stored_text_actions = 5;
repeated float memories = 6;
float reward = 7;
bool done = 8;
bool max_step_reached = 9;
int32 id = 10;
}

19
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/brain_parameters_proto.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/resolution_proto.proto";
import "mlagents/envs/communicator_objects/brain_type_proto.proto";
import "mlagents/envs/communicator_objects/space_type_proto.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message BrainParametersProto {
int32 vector_observation_size = 1;
int32 num_stacked_vector_observations = 2;
repeated int32 vector_action_size = 3;
repeated ResolutionProto camera_resolutions = 4;
repeated string vector_action_descriptions = 5;
SpaceTypeProto vector_action_space_type = 6;
string brain_name = 7;
BrainTypeProto brain_type = 8;
}

14
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/brain_type_proto.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/resolution_proto.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
enum BrainTypeProto {
Player = 0;
Heuristic = 1;
External = 2;
Internal = 3;
}

10
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/command_proto.proto


syntax = "proto3";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
enum CommandProto {
STEP = 0;
RESET = 1;
QUIT = 2;
}

13
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/engine_configuration_proto.proto


syntax = "proto3";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message EngineConfigurationProto {
int32 width = 1;
int32 height = 2;
int32 quality_level = 3;
float time_scale = 4;
int32 target_frame_rate = 5;
bool show_monitor = 6;
}

8
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/environment_parameters_proto.proto


syntax = "proto3";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message EnvironmentParametersProto {
map<string, float> float_parameters = 1;
}

9
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/header.proto


syntax = "proto3";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message Header {
int32 status = 1;
string message = 2;
}

11
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/resolution_proto.proto


syntax = "proto3";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message ResolutionProto {
int32 width = 1;
int32 height = 2;
bool gray_scale = 3;
}

12
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/space_type_proto.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/resolution_proto.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
enum SpaceTypeProto {
discrete = 0;
continuous = 1;
}

14
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_input.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/unity_rl_input.proto";
import "mlagents/envs/communicator_objects/unity_rl_initialization_input.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message UnityInput {
UnityRLInput rl_input = 1;
UnityRLInitializationInput rl_initialization_input = 2;
//More messages can be added here
}

15
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_message.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/unity_output.proto";
import "mlagents/envs/communicator_objects/unity_input.proto";
import "mlagents/envs/communicator_objects/header.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message UnityMessage {
Header header = 1;
UnityOutput unity_output = 2;
UnityInput unity_input = 3;
}

15
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_output.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/unity_rl_output.proto";
import "mlagents/envs/communicator_objects/unity_rl_initialization_output.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message UnityOutput {
UnityRLOutput rl_output = 1;
UnityRLInitializationOutput rl_initialization_output = 2;
//More messages can be added here
}

9
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_rl_initialization_input.proto


syntax = "proto3";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message UnityRLInitializationInput {
int32 seed = 1;
}

16
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_rl_initialization_output.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/brain_parameters_proto.proto";
import "mlagents/envs/communicator_objects/environment_parameters_proto.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
// The request message containing the academy's parameters.
message UnityRLInitializationOutput {
string name = 1;
string version = 2;
string log_path = 3;
repeated BrainParametersProto brain_parameters = 5;
EnvironmentParametersProto environment_parameters = 6;
}

18
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_rl_input.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/agent_action_proto.proto";
import "mlagents/envs/communicator_objects/environment_parameters_proto.proto";
import "mlagents/envs/communicator_objects/command_proto.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message UnityRLInput {
message ListAgentActionProto {
repeated AgentActionProto value = 1;
}
map<string, ListAgentActionProto> agent_actions = 1;
EnvironmentParametersProto environment_parameters = 2;
bool is_training = 3;
CommandProto command = 4;
}

15
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_rl_output.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/agent_info_proto.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
message UnityRLOutput {
message ListAgentInfoProto {
repeated AgentInfoProto value = 1;
}
bool global_done = 1;
map<string, ListAgentInfoProto> agentInfos = 2;
}

12
ml-agents-protobuf/proto/mlagents/envs/communicator_objects/unity_to_external.proto


syntax = "proto3";
import "mlagents/envs/communicator_objects/unity_message.proto";
option csharp_namespace = "MLAgents.CommunicatorObjects";
package communicator_objects;
service UnityToExternal {
// Sends the academy parameters
rpc Exchange(UnityMessage) returns (UnityMessage) {}
}
正在加载...
取消
保存