Add preliminary GRPC server for PyBullet and BulletRobotics.
Will add GRPC client and PyBullet GRPC server plugin. Will cover most/all SharedMemoryCommand/SharedMemoryStatus messages. Run the server, then test using the pybullet_client.py
This commit is contained in:
19
examples/SharedMemory/grpc/proto/createProtobufs.bat
Normal file
19
examples/SharedMemory/grpc/proto/createProtobufs.bat
Normal file
@@ -0,0 +1,19 @@
|
||||
del ..\pybullet.pb.cpp
|
||||
del ..\pybullet.pb.h
|
||||
del ..\pybullet.grpc.pb.cpp
|
||||
del ..\pybullet.grpc.pb.h
|
||||
|
||||
..\..\..\ThirdPartyLibs\grpc\lib\win32\protoc --proto_path=. --cpp_out=. pybullet.proto
|
||||
..\..\..\ThirdPartyLibs\grpc\lib\win32\protoc.exe --plugin=protoc-gen-grpc="..\..\..\ThirdPartyLibs\grpc\lib\win32\grpc_cpp_plugin.exe" --grpc_out=. pybullet.proto
|
||||
move pybullet.grpc.pb.cc ..\pybullet.grpc.pb.cpp
|
||||
move pybullet.grpc.pb.h ..\pybullet.grpc.pb.h
|
||||
move pybullet.pb.cc ..\pybullet.pb.cpp
|
||||
move pybullet.pb.h ..\pybullet.pb.h
|
||||
|
||||
del ..\pybullet_pb2.py
|
||||
del ..\pybullet_pb2_grpc.py
|
||||
|
||||
..\..\..\ThirdPartyLibs\grpc\lib\win32\protoc --proto_path=. --python_out=. pybullet.proto
|
||||
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. pybullet.proto
|
||||
move pybullet_pb2.py ..\pybullet_pb2.py
|
||||
move pybullet_pb2_grpc.py ..\pybullet_pb2_grpc.py
|
||||
85
examples/SharedMemory/grpc/proto/pybullet.proto
Normal file
85
examples/SharedMemory/grpc/proto/pybullet.proto
Normal file
@@ -0,0 +1,85 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_package = "io.grpc.pybullet_grpc";
|
||||
option java_outer_classname = "PyBulletProto";
|
||||
option objc_class_prefix = "PBG";
|
||||
|
||||
|
||||
package pybullet_grpc;
|
||||
|
||||
service PyBulletAPI {
|
||||
// Sends a greeting
|
||||
rpc SubmitCommand (PyBulletCommand) returns (PyBulletStatus) {}
|
||||
}
|
||||
|
||||
|
||||
message vec3
|
||||
{
|
||||
double x=1;
|
||||
double y=2;
|
||||
double z=3;
|
||||
};
|
||||
|
||||
message quat4
|
||||
{
|
||||
double x=1;
|
||||
double y=2;
|
||||
double z=3;
|
||||
double w=4;
|
||||
};
|
||||
|
||||
|
||||
message TerminateServerCommand
|
||||
{
|
||||
string exitReason=1;
|
||||
};
|
||||
|
||||
message StepSimulationCommand
|
||||
{
|
||||
};
|
||||
|
||||
message LoadUrdfCommand {
|
||||
string urdfFileName=1;
|
||||
vec3 initialPosition=2;
|
||||
quat4 initialOrientation=3;
|
||||
//for why oneof here, see the sad decision here:
|
||||
//https://github.com/protocolbuffers/protobuf/issues/1606
|
||||
oneof hasUseMultiBody { int32 useMultiBody=4; }
|
||||
oneof hasUseFixedBase{ bool useFixedBase=5; }
|
||||
int32 urdfFlags=6;
|
||||
oneof hasGlobalScaling { double globalScaling=7;
|
||||
}
|
||||
};
|
||||
|
||||
message LoadUrdfStatus {
|
||||
int32 objectUniqueId=1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// The request message containing the command
|
||||
message PyBulletCommand {
|
||||
int32 commandType=1;
|
||||
|
||||
oneof commands {
|
||||
LoadUrdfCommand loadUrdfCommand = 3;
|
||||
TerminateServerCommand terminateServerCommand=4;
|
||||
StepSimulationCommand stepSimulationCommand= 5;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// The response message containing the status
|
||||
message PyBulletStatus {
|
||||
int32 statusType=1;
|
||||
|
||||
oneof status
|
||||
{
|
||||
LoadUrdfStatus urdfStatus = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user