allow pybullet to connect to GRPC server. (need to use flag --enable_grpc in premake build system)
add grpcPlugin, it can work in GUI, SHARED_MEMORY_SERVER, DIRECT and other modes.
example script to start server from pybullet:
import pybullet as p
p.connect(p.GUI)
#if statically linked plugin
id = p.loadPlugin("grpcPlugin")
#dynamics loading the plugin
#id = p.loadPlugin("E:/develop/bullet3/bin/pybullet_grpcPlugin_vs2010_x64_debug.dll", postFix="_grpcPlugin")
#start the GRPC server at hostname, port
if (id>=0):
p.executePluginCommand(id, "localhost:1234")
Only in DIRECT mode, since there is no 'ping' you need to call to handle RCPs:
numRPC = 10
while (1):
p.executePluginCommand(id, intArgs=[numRPC])
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
act = _ACTION
|
||||
end
|
||||
|
||||
projectRootDir = os.getcwd() .. "/../"
|
||||
print("Project root directory: " .. projectRootDir);
|
||||
|
||||
newoption {
|
||||
trigger = "ios",
|
||||
description = "Enable iOS target (requires xcode4)"
|
||||
@@ -79,19 +82,23 @@
|
||||
|
||||
if os.is("Linux") then
|
||||
default_grpc_include_dir = "usr/local/include/GRPC"
|
||||
default_grpc_lib_dir = "/usr/local/lib/"
|
||||
default_grpc_lib_dir = "/usr/local/lib"
|
||||
default_protobuf_include_dir = "/usr/local/include/protobuf"
|
||||
default_protobuf_lib_dir = "/usr/local/lib"
|
||||
end
|
||||
|
||||
if os.is("macosx") then
|
||||
default_grpc_include_dir = "/usr/local/Cellar/grpc/1.14.1/include"
|
||||
default_grpc_lib_dir = "/usr/local/Cellar/grpc/1.14.1/lib"
|
||||
default_protobuf_include_dir = "/usr/local/Cellar/protobuf/3.6.0/include/"
|
||||
default_protobuf_include_dir = "/usr/local/Cellar/protobuf/3.6.0/include"
|
||||
default_protobuf_lib_dir = "/usr/local/Cellar/protobuf/3.6.0/lib"
|
||||
end
|
||||
|
||||
if os.is("Windows") then
|
||||
default_grpc_include_dir = "c:/grpc/include"
|
||||
default_grpc_lib_dir = "c:/grpc/lib"
|
||||
default_grpc_include_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/include"
|
||||
default_grpc_lib_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/lib"
|
||||
default_protobuf_include_dir =projectRootDir .. "examples/ThirdPartyLibs/grpc/include"
|
||||
default_protobuf_lib_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/lib"
|
||||
end
|
||||
|
||||
newoption
|
||||
@@ -124,27 +131,80 @@
|
||||
}
|
||||
|
||||
|
||||
if not _OPTIONS["grpc_lib_dir"] then
|
||||
_OPTIONS["grpc_lib_dir"] = default_grpc_lib_dir
|
||||
end
|
||||
if not _OPTIONS["grpc_include_dir"] then
|
||||
_OPTIONS["grpc_include_dir"] = default_grpc_include_dir
|
||||
end
|
||||
if not _OPTIONS["protobuf_include_dir"] then
|
||||
_OPTIONS["protobuf_include_dir"] = default_protobuf_include_dir
|
||||
end
|
||||
|
||||
if not _OPTIONS["protobuf_lib_dir"] then
|
||||
_OPTIONS["protobuf_lib_dir"] = default_protobuf_lib_dir
|
||||
end
|
||||
|
||||
|
||||
if _OPTIONS["enable_grpc"] then
|
||||
function initGRPC()
|
||||
|
||||
|
||||
print "BT_ENABLE_GRPC"
|
||||
|
||||
print("grpc_include_dir=")
|
||||
print(_OPTIONS["grpc_include_dir"])
|
||||
print("grpc_lib_dir=")
|
||||
print(_OPTIONS["grpc_lib_dir"])
|
||||
print("protobuf_include_dir=")
|
||||
print(_OPTIONS["protobuf_include_dir"])
|
||||
print("protobuf_lib_dir=")
|
||||
print(_OPTIONS["protobuf_lib_dir"])
|
||||
|
||||
defines {"BT_ENABLE_GRPC"}
|
||||
|
||||
if os.is("macosx") then
|
||||
buildoptions { "-std=c++11" }
|
||||
links{ "dl"}
|
||||
end
|
||||
|
||||
if os.is("Linux") then
|
||||
buildoptions { "-std=c++11" }
|
||||
links{ "dl"}
|
||||
end
|
||||
|
||||
if os.is("Windows") then
|
||||
defines {"_WIN32_WINNT=0x0600"}
|
||||
links{ "zlibstatic","ssl","crypto"}
|
||||
end
|
||||
|
||||
defines {"BT_ENABLE_GRPC"}
|
||||
includedirs {
|
||||
projectRootDir .. "examples/SharedMemory", _OPTIONS["grpc_include_dir"], _OPTIONS["protobuf_include_dir"],
|
||||
}
|
||||
|
||||
includedirs {
|
||||
_OPTIONS["grpc_include_dir"], _OPTIONS["protobuf_include_dir"],
|
||||
}
|
||||
|
||||
libdirs {
|
||||
_OPTIONS["grpc_lib_dir"], _OPTIONS["protobuf_lib_dir"],
|
||||
}
|
||||
links { "grpc","grpc++", "grpc++_reflection", "gpr", "protobuf", "dl"}
|
||||
files { projectRootDir .. "examples/SharedMemory/grpc/ConvertGRPCBullet.cpp",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/ConvertGRPCBullet.h",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/pybullet.grpc.pb.cpp",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/pybullet.grpc.pb.h",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/pybullet.pb.cpp",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/pybullet.pb.h", }
|
||||
end
|
||||
if os.is("Windows") then
|
||||
configuration {"x64", "debug"}
|
||||
libdirs {_OPTIONS["grpc_lib_dir"] .. "/win64_debug" , _OPTIONS["protobuf_lib_dir"] .. "win64_debug",}
|
||||
configuration {"x86", "debug"}
|
||||
libdirs {_OPTIONS["grpc_lib_dir"] .. "/win32_debug" , _OPTIONS["protobuf_lib_dir"] .. "win32_debug",}
|
||||
configuration {"x64", "release"}
|
||||
libdirs {_OPTIONS["grpc_lib_dir"] .. "/win64_release", _OPTIONS["protobuf_lib_dir"] .. "win64_release",}
|
||||
configuration {"x86", "release"}
|
||||
libdirs {_OPTIONS["grpc_lib_dir"] .. "/win32_release" , _OPTIONS["protobuf_lib_dir"] .. "win32_release",}
|
||||
configuration{}
|
||||
|
||||
else
|
||||
libdirs {_OPTIONS["grpc_lib_dir"], _OPTIONS["protobuf_lib_dir"],}
|
||||
end
|
||||
|
||||
links { "grpc","grpc++", "grpc++_reflection", "gpr", "protobuf"}
|
||||
files { projectRootDir .. "examples/SharedMemory/grpc/ConvertGRPCBullet.cpp",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/ConvertGRPCBullet.h",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/pybullet.grpc.pb.cpp",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/pybullet.grpc.pb.h",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/pybullet.pb.cpp",
|
||||
projectRootDir .. "examples/SharedMemory/grpc/pybullet.pb.h", }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -337,8 +397,7 @@ end
|
||||
targetdir( _OPTIONS["targetdir"] or "../bin" )
|
||||
location("./" .. act .. postfix)
|
||||
|
||||
projectRootDir = os.getcwd() .. "/../"
|
||||
print("Project root directory: " .. projectRootDir);
|
||||
|
||||
|
||||
if not _OPTIONS["python_include_dir"] then
|
||||
_OPTIONS["python_include_dir"] = default_python_include_dir
|
||||
|
||||
Reference in New Issue
Block a user