Mujoco编程开发-官方文档

https://mujoco.readthedocs.io/en/latest/programming.html

复制一份到这里,后面需要做笔记


Introduction

This chapter is the MuJoCo programming guide. A separate chapter contains the API Reference documentation. MuJoCo is a dynamic library compatible with Windows, Linux and macOS, which requires a process with AVX instructions. The library exposes the full functionality of the simulator through a compiler-independent shared-memory C API. It can also be used in C++ programs.

MuJoCo is a free product currently distributed as a pre-built dynamic library and will soon be made available as an open-source project. The software distribution contains a compiled version of GLFW which is used in the code samples to create an OpenGL window and direct user input to it. The Linux distribution also contains compiled versions of GLEW which is used for OpenGL symbol loading and allow the user to choose between X11, EGL or MESA. For projects where rendering is not needed, there is a smaller “nogl” library which does not have a dependence on OpenGL. This is suitable for running on headless servers without video drivers installed. The distribution for each platform contains the following dynamic libraries:

Windows:  mujoco210.dll     (stub library: mujoco210.lib)
          mujoco210nogl.dll (stub library: mujoco210nogl.lib)
          glfw3.dll         (stub library: glfw3.lib)

Linux:    mujoco210.so
          mujoco210nogl.so
          glewXXX.so
          glfw.so.3

macOS:    mujoco210.dylib
          mujoco210nogl.dylib
          glfw.3.dylib

Note that the software version number is contained in the library name (and obviously changes with every release), so for example mujoco210 means version 2.1.

Even though MuJoCo is a single dynamic library with unified C API, it contains several modules, some of which are implemented in C++. We have taken advantage of the convenience of C++ for functionality that is used before the simulation starts (namely the parser and compiler), and have gone to the trouble of writing carefully-tuned C code for all runtime functionality. The modules are:

Parser
The XML parser is written in C++. It can parse MJCF models and URDF models, converting them into an internal mjCModel C++ object which is not directly exposed to the user.

Compiler
The compiler is written in C++. It takes an mjCModel C++ object constructed by the parser, and converts it into an mjModel C structure used at runtime.

Simulator
The simulator (or physics engine) is written in C. It is responsible for all runtime computations.

Abstract visualizer
The abstract visualizer is written in C. It generates a list of abstract geometric entities representing the simulation state, with all information needed for actual rendering. It also provides abstract mouse hooks for camera and perturbation control.

OpenGL renderer
The renderer is written in C and is based on fixed-function OpenGL. It does not have all the features of state-of-the-art rendering engines (and can be replaced with such an engine if desired) but nevertheless it provides efficient and informative 3D rendering.

UI framework
The UI framework (new in MuJoCo 2.0) is written in C. UI elements are rendered in OpenGL. It has its own event mechanism and abstract hooks for keyboard and mouse input. The code samples use it with GLFW, but it can also be used with other window libraries.

Getting started

The software distribution is a single .zip (Windows) or .tar.gz (Mac and Linux) archive whose name contains the platform and software version, e.g. mujoco210_windows.zip. There is no installer. Simply unzip this archive in a directory of your choice (where you have write access). You may need to use chmod to set execute permissions or otherwise give permissions to run the libraries. From the bin subdirectory, you can now run the precompiled code samples, for example:

Windows:           simulate ..\model\humanoid.xml
Linux and macOS:   ./simulate ../model/humanoid.xml

Prior to MuJoCo 2.0, running the code samples needed LD_LIBRARY_PATH on Linux. As of MuJoCo 2.0, they are compiled with “rpath $ORIGIN” so the library is found in the executable directory (if it is not in the path).

The directory structure is shown below. Users can re-organize it if needed, as well as install the dynamic libraries in other directories and set the path accordingly. The only file created automatically is MUJOCO_LOG.TXT in the executable directory; it contains error and warning messages, and can be deleted at any time.

mujoco210
  bin     - dynamic libraries, executables, MUJOCO_LOG.TXT
  doc     - README.txt and REFERENCE.txt
  include - header files needed to develop with MuJoCo
  model   - model collection (extra models available on the Forum)
  sample  - code samples and makefile need to build them

After verifying that the simulator works, the next step is to re-compile the code samples so as to ensure that the development environment is properly installed. The distribution includes a platform-specific makefile in the sample subdirectory, which assumes Visual Studio on Windows, GCC on Linux and Clang on macOS. On Windows, remember to open a Visual Studio command prompt with native x64 tools. Assuming the compilation succeeded and the resulting executables in the bin subdirectory work, you are ready to start developing with MuJoCo.

As already mentioned, MuJoCo is a compiler-independent library. In theory the user should be able to switch to any compiler of their choice. In practice we are using C++11 features as well as std:: functionality internally, and despite our efforts to statically link all necessary runtime libraries, this is not always possible - especially on Linux where licensing restrictions prevent static linking. If MuJoCo fails to start because of missing or incompatible dynamic libraries, please install the necessary libraries.

Header files

The distribution contains several header files which are identical on all platforms. They are also available from the links below, to make this documentation self-contained.
mujoco.h (source)
This is the main header file and must be included in all programs using MuJoCo. It defines all API functions and global variables, and includes the next 5 files which provide the necessary type definitions.

mjmodel.h (source)
This file defines the C structure mjModel which is the runtime representation of the model being simulated. It also defines a number of primitive types and other structures needed to define mjModel.

mjdata.h (source)
This file defines the C structure mjData which is the workspace where all computations read their inputs and write their outputs. It also defines primitive types and other structures needed to define mjData.

mjvisualize.h (source)
This file defines the primitive types and structures needed by the abstract visualizer.

mjrender.h (source)
This file defines th

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值