WIP Python bindings for Simulate tested on Linux only
This commit is contained in:
@@ -117,6 +117,10 @@ target_compile_options(libsimulate PUBLIC ${MUJOCO_SIMULATE_COMPILE_OPTIONS})
|
||||
target_link_libraries(libsimulate PUBLIC glfw lodepng mujoco::mujoco)
|
||||
target_link_options(libsimulate PRIVATE ${MUJOCO_SIMULATE_LINK_OPTIONS})
|
||||
|
||||
set_target_properties(
|
||||
mjsimulate PROPERTIES VERSION "${mujoco_VERSION}" PUBLIC_HEADER "simulate.h"
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
target_sources(libsimulate PRIVATE macos_save.mm)
|
||||
target_link_libraries(libsimulate PUBLIC "-framework Cocoa")
|
||||
@@ -219,6 +223,17 @@ if(_INSTALL_SIMULATE)
|
||||
MUJOCO_ENABLE_RPATH
|
||||
)
|
||||
|
||||
target_add_rpath(
|
||||
TARGETS
|
||||
mjsimulate
|
||||
INSTALL_DIRECTORY
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}"
|
||||
LIB_DIRS
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
|
||||
DEPENDS
|
||||
MUJOCO_ENABLE_RPATH
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS simulate
|
||||
EXPORT ${PROJECT_NAME}
|
||||
@@ -229,6 +244,16 @@ if(_INSTALL_SIMULATE)
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT simulate
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS mjsimulate
|
||||
EXPORT ${PROJECT_NAME}
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT simulate
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT simulate
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT simulate
|
||||
BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT simulate
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mujoco COMPONENT simulate
|
||||
)
|
||||
|
||||
if(NOT MUJOCO_SIMULATE_USE_SYSTEM_GLFW)
|
||||
# We downloaded GLFW. Depending if it is a static or shared LIBRARY we might
|
||||
# need to install it.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# Copyright 2022 DeepMind Technologies Limited
|
||||
#
|
||||
# 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.
|
||||
# ==============================================================================
|
||||
"""Python version of the simulate C++ sample"""
|
||||
|
||||
import mujoco
|
||||
from mujoco.simulate import run_simulate_and_physics
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print version, check compatibility
|
||||
print('MuJoCo version {}'.format(mujoco.mj_versionString()))
|
||||
if mujoco.mjVERSION_HEADER != mujoco.mj_version():
|
||||
raise mujoco.FatalError('Headers and library have different versions')
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
run_simulate_and_physics(sys.argv[1])
|
||||
else:
|
||||
run_simulate_and_physics()
|
||||
Reference in New Issue
Block a user