Add a new plugin / extension mechanism called a resource provider along with retrofitting VFS on top of it.
A resource provider provides a mechanism for MuJoCo to read from filesystems other than the OS filesystem or the Virtual File System (VFS). PiperOrigin-RevId: 525394983 Change-Id: I077ff5a7e2e76806b48b6defb531280aadc8b169
This commit is contained in:
committed by
Copybara-Service
parent
b25728cc2e
commit
fe3dccfd1d
@@ -20,6 +20,33 @@
|
||||
#include <mujoco/mjvisualize.h>
|
||||
|
||||
|
||||
//---------------------------------- Resource Provider ---------------------------------------------
|
||||
|
||||
#define mjVFS_PREFIX "vfs://" // prefix for VFS providers
|
||||
|
||||
// callback for opeing a resource, returns zero on failure
|
||||
typedef int (*mjfOpenResource)(mjResource* resource);
|
||||
|
||||
// callback for reading a resource
|
||||
// return number of bytes stored in buffer, return -1 if error
|
||||
typedef int (*mjfReadResource)(mjResource* resource, const void** buffer);
|
||||
|
||||
// callback for closing a resource (responsible for freeing any allocated memory)
|
||||
typedef void (*mjfCloseResource)(mjResource* resource);
|
||||
|
||||
// struct describing a single resource provider
|
||||
struct mjpResourceProvider_ {
|
||||
const char* prefix; // prefix for match against a resource name
|
||||
mjfOpenResource open; // opening callback
|
||||
mjfReadResource read; // reading callback
|
||||
mjfCloseResource close; // closing callback
|
||||
void* data; // opaque data pointer (resource invariant)
|
||||
};
|
||||
typedef struct mjpResourceProvider_ mjpResourceProvider;
|
||||
|
||||
|
||||
//---------------------------------- Plugins -------------------------------------------------------
|
||||
|
||||
typedef enum mjtPluginCapabilityBit_ {
|
||||
mjPLUGIN_ACTUATOR = 1<<0,
|
||||
mjPLUGIN_SENSOR = 1<<1,
|
||||
|
||||
Reference in New Issue
Block a user