Implement plugin mechanism for actuators and sensors.

PiperOrigin-RevId: 474874088
Change-Id: I65a8ffdf845f4fa0f8266c165883a747ab5812d8
This commit is contained in:
Saran Tunyasuvunakool
2022-09-16 12:20:56 -07:00
committed by Copybara-Service
parent f556d4d94f
commit 1e2a9a53bc
29 changed files with 2121 additions and 51 deletions
+97
View File
@@ -2672,6 +2672,32 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
),
doc='Scale body masses and inertias to achieve specified total mass.',
)),
('mj_getPluginConfig',
FunctionDecl(
name='mj_getPluginConfig',
return_type=PointerType(
inner_type=ValueType(name='char', is_const=True),
),
parameters=(
FunctionParameterDecl(
name='m',
type=PointerType(
inner_type=ValueType(name='mjModel', is_const=True),
),
),
FunctionParameterDecl(
name='plugin_id',
type=ValueType(name='int'),
),
FunctionParameterDecl(
name='attrib',
type=PointerType(
inner_type=ValueType(name='char', is_const=True),
),
),
),
doc='Return a config attribute value of a plugin instance; NULL: invalid plugin instance ID or attribute name', # pylint: disable=line-too-long
)),
('mj_version',
FunctionDecl(
name='mj_version',
@@ -7147,4 +7173,75 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
),
doc='Finite differenced transition matrices (control theory notation) d(x_next) = A*dx + B*du d(sensor) = C*dx + D*du required output matrix dimensions: A: (2*nv+na x 2*nv+na) B: (2*nv+na x nu) D: (nsensordata x 2*nv+na) C: (nsensordata x nu)', # pylint: disable=line-too-long
)),
('mjp_defaultPlugin',
FunctionDecl(
name='mjp_defaultPlugin',
return_type=ValueType(name='void'),
parameters=(
FunctionParameterDecl(
name='plugin',
type=PointerType(
inner_type=ValueType(name='mjpPlugin'),
),
),
),
doc='Set default plugin definition.',
)),
('mjp_registerPlugin',
FunctionDecl(
name='mjp_registerPlugin',
return_type=ValueType(name='int'),
parameters=(
FunctionParameterDecl(
name='plugin',
type=PointerType(
inner_type=ValueType(name='mjpPlugin', is_const=True),
),
),
),
doc='Globally register a plugin. This function is thread-safe. If an identical mjpPlugin is already registered, this function does nothing. If a non-identical mjpPlugin with the same name is already registered, an mju_error is raised. Two mjpPlugins are considered identical if all member function pointers and numbers are equal, and the name and attribute strings are all identical, however the char pointers to the strings need not be the same.', # pylint: disable=line-too-long
)),
('mjp_pluginCount',
FunctionDecl(
name='mjp_pluginCount',
return_type=ValueType(name='int'),
parameters=(),
doc='Return the number of globally registered plugins.',
)),
('mjp_getPlugin',
FunctionDecl(
name='mjp_getPlugin',
return_type=PointerType(
inner_type=ValueType(name='mjpPlugin', is_const=True),
),
parameters=(
FunctionParameterDecl(
name='name',
type=PointerType(
inner_type=ValueType(name='char', is_const=True),
),
),
FunctionParameterDecl(
name='slot',
type=PointerType(
inner_type=ValueType(name='int'),
),
),
),
doc='Look up a plugin by name. If slot is not NULL, also write its registered slot number into it.', # pylint: disable=line-too-long
)),
('mjp_getPluginAtSlot',
FunctionDecl(
name='mjp_getPluginAtSlot',
return_type=PointerType(
inner_type=ValueType(name='mjpPlugin', is_const=True),
),
parameters=(
FunctionParameterDecl(
name='slot',
type=ValueType(name='int'),
),
),
doc='Look up a plugin by the registered slot number that was returned by mjp_registerPlugin.', # pylint: disable=line-too-long
)),
])