Available plugins¶
Built-in plugins by package. Reference each by its short name in a world file (or by
module:Class / file.py:Class for your own — see Interfaces).
The static environment — ground, light, enclosure — is one slot, filled either by a world
definition selected with sim.world (default empty_room; see Architecture & porting playbook) or by a
scene plugin that builds its own, such as the mobile floorplan or heightfield. A fixed cell
needs no scene plugin. Naming both is refused, and so is carrying two such plugins: two grounds
compile into a scene that looks right and is not the one you wrote.
Which route a given environment takes follows from whether it is baked or computed. A world definition is a builder or an MJCF file — fixed geometry, chosen by name. A plugin builds from a config, so a sweep can vary it and each run records the values it used. An environment whose shape is an experiment’s variable is therefore a plugin.
floorplan takes its building from one of two sources, and you pick by what you have. A
mesh: is right when the building already exists as geometry (imported from CAD, or produced by
Floorplan-DSL); its json-ld supplies exact colliders. Wall segments are right when the walls
are the experiment’s variable:
components:
- floorplan:
lines:
- {id: 0, x0_m: 0.0, y0_m: 0.0, x1_m: 6.0, y1_m: 0.0}
- {id: 1, x0_m: 6.0, y0_m: 0.0, x1_m: 6.0, y1_m: 4.0}
doors: [{line_id: 0, t: 0.5, width_m: 0.9}]
height: 2.5
floorplan: rooms.json reads the same shape from the file roqsim scenes dxf-to-floorplan and
the scene-builder’s sketch window write, which is the usual way in. Segments build one box per wall
— visible and collidable, since a box is already convex, so there is no hidden companion collider
to disagree with what is drawn. A corridor width is then an ordinary config value a sweep varies and
the run’s provenance records, rather than a mesh baked ahead of time that nothing downstream can
tell apart from another mesh. Naming both sources, or neither, is refused. The wall arithmetic is
shared with the mesh baker and the plan-view renderer, so a preview, a baked world and this plugin
cut the same openings, and walls meet as the baker joins them: where walls meet at a corner, a T, a
crossing or a lintel, no two boxes show a face in one place (roqsim.floorplan_geometry.wall_pieces);
two lines drawn over each other along their length still do.
Any endpoint-producing plugin below accepts an optional topics: map to set an endpoint’s ROS
topic. An absolute name hardwires it, overriding the namespace+default — e.g. topics: {image:
/camera/color/image_raw}; a relative name renames it inside the namespace — e.g. topics: {scan:
scan2} for a robot’s second scanner. See Architecture & porting playbook › Hardwired topics. The map is keyed
on the name the plugin renames by – the endpoint’s own name, not the topic it publishes on by
default – and a key the plugin never renames is refused once the plugin has registered its
endpoints, naming the names it does rename.
A plugin without a CONFIG_SCHEMA accepts any key, so roqsim check and roqsim scenes
describe warn (config-key) about each key its Config:: block does not document, and a run
logs the same warning: a misspelled key otherwise leaves its setting at the default. A warning and
not a refusal, because such a plugin may read a key it does not document. enabled written inside
a config is refused where the plugin neither documents nor names it: it is the sibling of the plugin
ref, and one level too deep it switches nothing off.
Core (roqsim)
baked_lighting
Draw a world’s static geometry with its baked light (see the module docstring).
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
baked_lighting:
path: "" # the bake's directory; default <mjcf stem>.bake beside the MJCF
require: false # a missing or stale bake stops the world
quality: default # the preset
texels_per_m: <unset> # light-map texels per metre: {shell, floor, props}
samples: 0 # Cycles samples per texel (0: the preset's)
denoise: true # Open Image Denoise over the passes
lights: auto # auto, or a list of lights
emitters: <unset> # lamps no material declares: [{match, strength_w_m2}]
exclude: <unset> # static geoms (glob) left unbaked
occluders: <unset> # moving geoms (glob) whose shadow is baked
moving_shadows: true # the key light throws what moves' shadow
max_mb: 5.0 # MB; the bake's size cap on disk
bumper
Flags: parallel_safe
Observation plugin: a bumper – which ZONE of a body is being pushed, every step.
Config:
bumper:
# The entity watched is the one this entry is NESTED UNDER -- there is no key for it, and
# declaring it at the top of a document is refused (`requires_owner`).
body: "" # a body of the entity, as a path within it; default: the whole entity
namespace: "" # transport scope for the endpoints
zones: # bearing sectors, radians in the base frame, counter-clockwise from
front: [-0.52, 0.52] # +x: {<zone>: [from, to]}. A sector with from > to wraps through
left: [0.52, 1.57] # +/-pi, so a rear zone is `[2.6, -2.6]`.
geoms: [] # geom NAMES that ARE the bumper (default: the whole entity,
# like contact_monitor, its flexes included). A real bumper is one
# shell; a contact on the chassis roof presses no switch, so a model
# that names its shell geoms lists them here.
geom_prefixes: [] # geom name prefixes that are the bumper
ignore: [floor] # geom or flex NAMES that never count (default: ['floor'])
ignore_prefixes: [] # geom or flex name prefixes that never count (e.g. ['ground'])
min_force: 1.0 # N; contacts below this normal force are ignored (numerical grazing)
rate_hz: 62.0 # endpoint publish rate
One out endpoint per zone, named bumper/<zone>, reads a bool: is that zone pressed this
step. ROS carries each as a std_msgs/Bool on bumper/<zone> (relative, so it is scoped by
the entity’s namespace). A stack that wants a vendor’s message assembles it from
these in its own adapter node – a bumper switch is a bool on every robot, and the vendor’s
envelope around it is the stack’s business, not the simulator’s.
Read it through the blackboard, not the endpoint, inside a control loop.
ctx.blackboard.get(f"bumper:{address}") returns a callable giving the current
BumperReading, the same convention contact_monitor and contact_location use.
Not latched, on purpose: a bumper releases when the robot backs off, and a stack that needs “it
bumped at some point” reads contact_monitor. Where a contact falls into no declared zone
(behind a robot with a front bumper only), nothing is pressed – exactly as a shell that is not
there reports nothing, and as contact_monitor still reports the collision.
ceiling
Flags: parallel_safe
Scene plugin: open a world’s roof by deleting its ceiling geometry at build time.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
ceiling:
keep: true # false removes the ceiling; true is a no-op
above_z: 2.5 # m; a geom is 'ceiling' iff its whole world-space AABB is above this height
clearance_monitor
Flags: parallel_safe
Observation plugin: how close an entity came to something it should not touch.
Config:
clearance_monitor:
body: "" # a body of the entity, as a path within it; default: the whole entity
ignore: [floor] # geom NAMES that never count (default: ['floor'])
ignore_prefixes: [] # geom name prefixes that never count
entities: null # entity names: measure to their geoms alone (default: every geom)
hit_geometry: false # with `entities`: also their collision-group geoms that do not collide
distmax: 5.0 # [m] cutoff: beyond this the distance is not computed
compute_rate_hz: 200.0 # how often the distance is MEASURED
rate_hz: 30.0 # how often the endpoint is PUBLISHED
Two endpoints, both reading a ClearanceReport
(current, minimum, at_time, geom, saturated), where minimum is the closest approach
since the last reset and geom names what it was to, so a near-miss is attributable
rather than merely flagged:
clearance(out): on ROS,currentalone, as astd_msgs/Float32– the series, from which a reader reconstructs the shape of an approach and reduces the minimum of the published samples.clearance_report(out): on ROS, the whole report, as the named readings of adiagnostic_msgs/DiagnosticStatus. Two of the five fields are in no series at all: nothing in a distance says what it was measured to, or whether it is a measurement rather than thedistmaxcutoff. Both are what a recorded table needs in order to say which near-miss it is looking at.
The two flags are about different numbers, which is what makes them worth publishing side by
side: saturated says current is the cutoff, while an empty geom says the same of
minimum – the closest approach was set by a step that found nothing inside distmax,
so it reads minimum == distmax and names nothing. A trial that was never near anything
reports exactly that, with at_time the first measurement of the run.
Both endpoints read the same report and publish at rate_hz; a transport that carries the
payload itself (roqsim read) sees the whole report on either. The reduction in it runs from
the last reset: on_reset starts a new trial’s measurement.
compute_rate_hz is separate from rate_hz because they answer different questions.
Publishing is cheap; measuring is a distance query per (watched geom, candidate geom) pair,
which on a nav world costs about a quarter of the step budget if done every physics step –
against a budget the simulator may already be over. Poses reach a consumer at ~30 Hz, so
measuring at 200 Hz resolves ~1.5 mm at walking pace: far finer than anything downstream can
use, at a fraction of the cost. Raise it if a fast pass matters more than throughput; the
trade is stated here rather than hidden in a default.
To what. By default every geom the entity could touch counts, the room’s walls with the
rest. entities narrows that to the named entities’ geoms (roqsim.presence.entity_geoms(),
which follows an entity’s bodies as well as its root: a walker’s limbs are bodies of the world,
not children of its pelvis, and their geoms have no names an ignore could match). Two monitors
on one robot, each with its own name: and entities, then give one separation per kind of
obstacle, where one monitor would report only the nearest of them. hit_geometry: true adds the
named entities’ geoms in the collision group (roqsim.scene_content.COLLISION_GROUP) that do
not collide: a walker’s arms, which rays see and contacts ignore so that a swinging arm does not
shove a robot, are still part of how close it came. Entities register while the world configures,
so the names are resolved at the first measurement, and a name no entity has fails it there. A
named entity counts while it is present: one the world starts absent is measured from the moment
it appears.
From what. Without body the watched side is the whole entity the monitor is nested under:
its root and each of its bodies, with their subtrees, so a monitor under a walker watches its
limbs as well as its pelvis. body narrows it to one body of the entity and that body’s subtree.
distmax is the other performance knob and it is a real one: the cost is a distance query
per (watched geom, candidate geom) pair, and the cutoff lets MuJoCo reject far pairs
cheaply. Beyond it the report reads current == distmax with saturated true, which
says “at least this far” rather than offering a number that looks measured.
contact_impulse
Observation plugin: how hard a watched entity was hit, integrated over the run.
Config:
contact_impulse:
# The entity watched is the one this entry is NESTED UNDER -- there is no key for it, and
# declaring it at the top of a document is refused (`requires_owner`).
body: "" # a body of the entity, as a path within it; default: the whole entity
namespace: "" # transport scope for the endpoint
ignore: [floor] # geom or flex NAMES that never count (default: ['floor'])
ignore_prefixes: [] # geom or flex name prefixes that never count (e.g. ['ground'])
reset_on_spawn: true # spawning the watched entity restarts the integral
rate_hz: 30.0 # endpoint publish rate -- of the RUNNING TOTAL, not of the integrand
Endpoint contact_impulse (out) reads a ContactImpulseReport:
(impulse_ns, peak_normal_n, contact_time_s, normal_n, count, peak_time, peak_geom_a,
peak_geom_b). The three totals run from the last reset; normal_n and count are the current
step’s, so the report says what it is integrating as well as what it has integrated. peak_time
is the sim time of the largest single-step load (-1.0 if nothing was touched) and the two
peak_geom names are the sides of that step’s strongest single contact, so a severity figure is
attributable rather than merely large – a geom by its name, a flex as flex:<name>[v<i>].
contact_time_s is the time a qualifying contact existed, which is contact_monitor’s
notion of touching and is longer than the time force was transmitted: MuJoCo goes on listing a pair
while the two geoms still overlap on the way apart, and those steps carry a zero normal force. The
impulse is unaffected – a zero integrand adds nothing – and the alternative, a duration that
switched off before the monitor’s in_contact did, would be the second rule this plugin exists
not to have. ROS carries impulse_ns alone, a std_msgs/Float64 on contact_impulse; a
consumer that wants the rest reads the report through the blackboard handle
contact_impulse:<address>.
Publishing is rate-limited and the integral is not. rate_hz decides how often the running
total leaves the plugin, and no value of it can lose a contact: the total a slow endpoint publishes
is the same total a fast one publishes, just later. There is deliberately no compute_rate_hz
knob of the kind clearance_monitor and contact_location offer – decimating this
computation would drop the samples the integral is made of, and the number would then be a function
of the knob.
It never ends a trial, the line clearance_monitor and energy_monitor draw as well. What
counts as too hard is the experiment’s threshold, stated in the experiment; a scenario reads the
endpoint and decides for itself.
What a reset does. on_reset – ResetSimulation with SCOPE_STATE, and what runs
between the trials one process serves – zeroes all three totals. Without it the second cell of a
campaign starts with the first cell’s collisions on its bill. reset_on_spawn (default true)
does the same when the watched entity gains presence, because an entity that was not in the world a
moment ago carries no history and because contact_monitor restarts there too – one of the two
carrying a contact the other had forgotten is exactly the disagreement this plugin is shaped to
avoid. A SetEntityState is a pose and a twist, and resets nothing.
Untouched, the report reads impulse_ns = 0.0, peak_normal_n = 0.0, contact_time_s = 0.0
and peak_time = -1.0 – a measured zero, which is what “nothing was hit” is.
contact_location
Flags: parallel_safe
Observation plugin: report where a watched entity is being touched, every step.
Config:
contact_location:
# The entity watched is the one this entry is NESTED UNDER -- there is no key for it, and
# declaring it at the top of a document is refused (`requires_owner`).
body: "" # a body of the entity, as a path within it; default: the whole entity
namespace: "" # transport scope for the endpoint
ignore: [floor] # geom or flex NAMES that never count (default: ['floor'])
ignore_prefixes: [] # geom or flex name prefixes that never count (e.g. ['ground'])
min_force: 1.0 # N; contacts below this normal force are ignored (numerical grazing)
merge_radius: 0.02 # m; contacts closer than this count as one sensing area
frame: base # 'base' -> report in the watched body's frame; 'world' -> world frame
compute_rate_hz: 0.0 # how often the reading is COMPUTED; 0 = every physics step
rate_hz: 30.0 # how often the endpoint is PUBLISHED
Endpoint contact_location (out) reads a ContactLocation:
(in_contact, kind, x, y, z, extent, count, time). kind is "none", "point" or
"line"; x/y/z is the region’s centre and extent the distance between its two furthest
members (0.0 for a point), so a consumer gets both the location and how spread out it is. ROS
carries the centre, a geometry_msgs/PointStamped on contact_location.
Read it through the blackboard, not the endpoint, inside a control loop. The endpoint is
rate-limited for logging; ctx.blackboard.get(f"contact_location:{address}") returns a callable
giving the current reading, the same convention contact_monitor and force_torque use.
Which contacts: the ones contact_monitor counts, by the same
roqsim.contact_scope.ContactScope – exactly one side in the watched entity (a geom, or a
flex the entity owns), neither side in ignore. A reading and a verdict over one geometry then
cannot disagree about which contacts they describe.
Cost. The per-step work is a vectorised pass over data.contact – a mask lookup per contact and
an xor – and a contact force query only for the handful that survive it. That matters because a
world’s contacts are overwhelmingly pairs the robot is not in (props resting on the floor, a
crowd’s feet), and touching each of them from Python costs more than the physics step that produced
them. compute_rate_hz decimates the whole computation for the case where even that is too much;
it defaults to 0, meaning every step, because unlike a latching monitor this plugin cannot recover a
contact it did not look at – one shorter than the interval is simply missed.
Frames. frame: base (the default) rotates the position into the watched body’s own frame, which
is what a controller reasoning about “contact on my left” wants and what makes a reading independent
of where the robot happens to be standing. frame: world leaves it in world coordinates. The
PointStamped header names that frame: the watched body without the entity’s prefix, or world.
contact_monitor
Flags: parallel_safe
Observation plugin: report when an entity touches something it should not.
Config:
contact_monitor:
# The entity watched is the one this entry is NESTED UNDER -- there is no key for it, and
# declaring it at the top of a document is refused (`requires_owner`).
body: "" # a body of the entity, as a path within it; default: the whole entity
namespace: "" # transport scope for the endpoint
ignore: [floor] # geom or flex NAMES that never count as a collision (default: ['floor'])
ignore_prefixes: [] # geom or flex name prefixes that never count (e.g. ['ground'])
min_force: 1.0 # N; contacts below this normal force are ignored (numerical grazing)
latch: true # once true, stay true until on_reset (a trial is failed, not un-failed)
reset_on_spawn: true # spawning the watched entity restarts the report (see below)
rate_hz: 30.0 # endpoint publish rate
Endpoint contact (out) reads a ContactReport:
(in_contact, first_time, count, geom_a, geom_b) – first_time is the simulation time of the
first qualifying contact since reset (-1.0 if none), and geom_a/geom_b name the two sides
of that first contact, so a failure is attributable rather than just flagged – a geom by its name, a
flex as flex:<name>[v<i>] with the vertex that touched. ROS carries in_contact alone, a
std_msgs/Bool on collision (relative, so it is scoped by the
entity’s namespace: two namespaced robots get /a/collision and /b/collision); a bridge that
wants the detail reads the fields directly.
The watched set is the whole entity: its body and every body it owns, each with its subtree. For a mobile base that is the chassis plus its wheels, so a wheel clipping a box counts exactly as much as the bumper does – and a flex whose vertices all hang in that set, such as a soft pad on an arm’s end effector.
When the trial spawns the watched entity. reset_on_spawn (default true) restarts the
report when the watched entity GAINS PRESENCE. An entity that has just been spawned has no
history: it was not in the world a moment ago, so nothing it touched before it went absent is a
fact about it now, and with latch that would otherwise be a permanent one.
Only presence does this. A SetEntityState does not, because the service is specified as “an
instant change in its pose and/or twist” and nothing more – a simulator that also cleared an
observer there would be answering a question the caller did not ask. The standard’s verb for
discarding accumulated state is ResetSimulation with SCOPE_STATE, which reaches this
plugin’s on_reset() like any other.
That distinction decides how a trial should place a robot it does not want observed at the pose
the world compiled it at: spawn it into position rather than teleport it there. An absent
entity’s geoms carry no contype/conaffinity, so it registers no contact at all while
absent, and presence and pose are applied in ONE transaction – so there is no step in which it is
perceivable where the world happened to put it. A trial that teleports a present robot instead is
observed at the compiled pose, and an obstacle placed there by a campaign that never knew about it
is a collision before the trial has moved.
Set reset_on_spawn false where a re-spawned entity should carry its history forward.
contact_pair_override
Scene plugin: override the contact between ONE pair of things.
Config:
contact_pair_override:
a: {entity: robot} # each side is named ONE of: entity, body, geom
b: {entity: crate}
friction: 0.35 # sliding, or the full [slide, slide, spin, roll, roll]
condim: 3 # contact dimensionality (1 frictionless, 3 sliding, 4 +spin, 6 +roll)
solref: null # optional, MuJoCo's two-element contact solver reference
solimp: null # optional, five-element solver impedance
The two sides are named separately, and independently, because a real pair often mixes kinds: the floor is a geom while the thing sliding on it is an entity, and requiring both to be the same kind would make the commonest pair in a pushing experiment inexpressible.
A declared pair also FORCES the contact to exist, which is the part to be careful with. MuJoCo
adds explicit pairs to its contact list without consulting contype/conaffinity, so overriding
the friction between two geoms that were deliberately non-colliding makes them collide. Measured:
two boxes with contype=0 conaffinity=0 generate no contacts, and four the moment a pair between
them is declared. So this plugin overrides two things at once – whether the pair touches, and how –
and a world using it on a decorative or sensor-only geom will find that geom has become solid.
Every geom of side A is paired with every geom of side B, so a robot base with twenty collision geoms touching a five-geom object declares a hundred pairs – MuJoCo handles that as a list, and the alternative (asking a world to name every geom) is how a pair silently misses the one that matters.
Ownership is a pair, so this plugin is NOT nested under an entity. It names both sides, unlike the observation plugins that watch one thing and read it from where they sit.
Declaring the same two geoms twice is refused rather than resolved: MuJoCo keeps both pairs and uses one of them, and which one is not something a world should have to know.
A side cannot be a flex. A <pair> names two geoms, and MuJoCo has no pair for a flex, so a
flex’s contacts keep the combination rule whatever is declared here. A side that is a flex – a
geom: naming one, or an entity/body whose subtree owns a collidable flex – is therefore
refused rather than paired geom by geom: the pair would govern the rigid parts and leave the flex,
often the part that touches, at the combined value. A flex’s contact is set on the flex itself
(<contact friction=... priority=...> in its <flexcomp>); a higher priority makes its
friction the contact’s outright rather than the element-wise maximum.
dummy
Flags: parallel_safe
A trivial plugin used to validate the framework end-to-end without any assets.
Config:
dummy:
size: 0.1 # half-extent (m) of the free-floating box this plugin adds; must be > 0
energy_monitor
Observation plugin: what a robot’s actuators cost it, integrated over the run.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
energy_monitor:
actuators: [] # names to meter (default: every actuator driving this entity)
efficiency: 1.0 # mechanical -> electrical, in (0, 1]
idle_w: 0.0 # W; drawn regardless of motion
resistive_w_per_nm2: 0.0 # W/(N*m)^2; winding loss k in k*tau^2; a number, or {actuator_name: k}
regenerative: false # credit negative mechanical power back
capacity_wh: 0.0 # Wh; 0: no battery modelled, no charge
voltage: 0.0 # V; nominal; 0: unknown, no current
rate_hz: 5.0 # Hz; endpoint publish rate, > 0
entity_control
Entity placement and presence, served as commands.
flex_material
Scene plugin: set a flex’s material from the world, whatever model declared the flex.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
flex_material:
flex: <required> # required; the flex's name in the model, or a list of names
young: <unset> # Pa; Young's modulus
poisson: <unset> # Poisson's ratio, below 0.5
damping: <unset> # s; stiffness-proportional damping
priority: <unset> # contact priority; the higher side's contact parameters win
radius: <unset> # m; collision radius
thickness: <unset> # m; shell thickness (dim=2 only)
elastic2d: <unset> # shell elasticity mode (dim=2 only)
friction: <unset> # sliding, or [slide, spin, roll]; each >= 0
solref: <unset> # contact solver reference; a scalar is the time constant
solimp: <unset> # contact solver impedance, up to 5 numbers
heightfield
Flags: provides_world
World plugin: outdoor ground – a height field, from a DEM or generated.
Config:
heightfield:
source: generated # 'generated', or a path to .npy / .png / .tif (relative to the world)
size: [20.0, 20.0] # ground extent in metres (x, y)
height: 1.5 # metres from the lowest sample to the highest
base: 1.0 # metres of solid below the lowest sample -- a wall, not a shell
resolution: 96 # samples per side, when generated (a DEM keeps its own)
seed: 0 # generated terrain is reproducible from this
roughness: 0.55 # 0..1: how much each finer octave contributes
octaves: 4 # how many scales of detail
friction: [1.0, 0.005, 0.0001] # ground friction, as MuJoCo's three coefficients
rgba: [0.42, 0.38, 0.30, 1.0]
light: true # add a ceiling-height light (the world definition it replaces had one)
Why it provides the world. sim.world builds a floor; a terrain that let one be built would
put a plane through its own hills. Declaring provides_world is how the floorplan plugin
says the same thing, and the engine then refuses a world that also sets sim.world.
Contact against a height field is against its triangles, not a smoothed surface, so the sample
spacing is the resolution of every wheel and foot interaction: 96 samples over 20 m is a 21 cm grid,
which a 10 cm wheel rides as facets. Raise resolution for a small rough patch rather than for a
large smooth one – the cost is quadratic and it buys nothing where the ground is flat.
ipc_bridge
The ipc bridge: every endpoint of a running simulation, served on demand over ZeroMQ.
Config (besides every bridge’s owner and rates):
ipc_bridge:
uri: ipc:///tmp/run.sock # REQUIRED: the control URI, ipc://<path> or tcp://<host>:<port>
world: "" # the world file the run serves, as the registry lists it
Messages are roqsim.ipc.wire: JSON, with numpy arrays as raw frames beside it. pyzmq is the
roqsim[ipc] extra and is imported only here, when the bridge starts.
joint_state_publisher
Flags: parallel_safe
Observation plugin: every joint of an entity as one joint_states message.
Config:
joint_state_publisher:
# The entity read is the one this entry is NESTED UNDER; at the top of a document it is
# refused (`requires_owner`).
namespace: "" # transport scope for the endpoint
joints: [] # joint NAMES to publish, the model's own before any spawn prefix;
# default: every hinge and slide joint of the entity's subtree
rate_hz: 50.0 # endpoint publish rate
Endpoint joint_states (out) reads a roqsim.types.JointState with efforts, a
sensor_msgs/JointState on joint_states over ROS (relative, so it is scoped by the entity’s
namespace). Names are published without the spawn prefix, as every other
producer here names joints, so a description published alongside matches them.
Only hinge and slide joints are published: a JointState carries one scalar per joint, which a
ball or free joint’s quaternion is not. A named joint that is not in the model, or not on this
entity, raises – a state nobody publishes is a consumer reading zeros as a fact.
model_override
Flags: parallel_safe
Fault plugin: change named MuJoCo model values while a run is in progress, on an external trigger.
Config:
model_override:
overrides: # one or more; each names a field, a selection and a target
- field: geom_friction # must be on the allowlist (see `field_catalog`)
select: [pad_left, pad_right] # names in the field's namespace (geom/body/actuator/joint/flex)
bodies: [] # ...or every geom of these bodies' subtrees (geom fields only)
entity: "" # ...or an entity's geoms, taken whole (geom fields only)
to: 0.0 # scalar (broadcast) or the field's full row
active: false # initial state; false = nominal, i.e. the plugin is inert
namespace: "" # transport scope; defaults to this instance's `name:`, so two
# faults in one world do not both serve `/override`
rate_hz: 10.0 # publish rate of the two out endpoints
Endpoint override (a command) is a service, std_srvs/SetBool: apply or restore, replying
success plus a message carrying the verdict – so a scenario’s service_call() can fail the
trial when a fault did not land, instead of a warning nobody reads. Endpoints override_state
(Bool of active) and override_verified (String of verified) publish continuously,
because a service call leaves no trace in a rosbag and mjModel is in neither the bag nor the state
recording – without them an injected fault is invisible to every downstream analysis.
All three are scoped by the instance’s name:, so the world above serves
/grip_fault/override, /grip_fault/override_state and /grip_fault/override_verified.
Over the control socket override is grip_fault/override, and override_verified confirms
it: roqsim call grip_fault/override true replies with the report the step after the change
recorded, verified included.
In-process, ctx.blackboard carries a ModelOverrideHandle under
model_override:<name>, which is how a ROS-free stepped run (an .osc action, a test) fires it –
and the plugin imports no ROS at all, so a world using it runs in a plain venv with no middleware
installed. The service is what the same fault looks like when a bridge is present.
part_state
World plugin: an entity’s discrete states – what a part looks like after a machine worked on it.
Config:
part_state:
shown: # shown at the start of every run, by entity name or fnmatch
strip_1: [plain] # pattern ("strip_*"); every other state of every entity starts hidden
press_1: [lamp_off]
exclusive: # by entity name or pattern: groups of which at most one is shown;
strip_1: [[plain, hole, bent]] # set() shows one and hides the rest of its group
Every entity is searched; an entity needs no declaration beyond having look_* bodies. An entity
is found wherever its entry stands: at configure if it was spawned before this entry, at the
first reset otherwise.
Use: a PartStates handle on the blackboard under part_state (show, hide,
set, shown, is_shown, of, entities), and the same show/hide/set
commands as endpoints. Naming an entity or a state that does not exist raises, and so does a
shown or exclusive pattern that matches no entity with states, or a group naming a state an
entity it matches lacks: a machine configured with the wrong name would otherwise run a whole line
and change nothing.
payload
Component plugin: a carried payload, as added mass on a robot’s body.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
payload:
mass: <required> # required, kg; added to the body's own mass; a payload plugin with no mass is not a payload
body: "" # body to load (default: the entity's root body)
robot: "" # entity that carries it (default: the owning entity)
pose_publisher
Flags: parallel_safe
Observation plugin: true poses of named frames, on one topic, as a ROS stack expects them.
Config:
pose_publisher:
poses:
- {frame: robot} # an entity's root, in the world
- {frame: robot/mouse, relative_to: robot/base_link}
- {frame: robot/oakd/oakd_link, relative_to: robot, child: camera}
rate_hz: 30.0 # publish rate of every pose
lazy: false # skip the reads while nobody subscribes
world_frame: map # the parent frame of a pose in the world
topics: {poses: ground_truth} # the one topic every pose goes out on (default "poses")
Each pose is a frame path (roqsim.paths): an entity (its root), or a body, site, camera,
declared frame or device frame of an entity or a component nested in one, named as TF shows it; or
a body, site or camera of the world’s own MJCF that no entity owns, by its MuJoCo name (gantry).
relative_to is another frame path, or world (the default). Nested under an entity, the
paths are relative to it: . is the entity itself, mouse its mouse, and a leading /
starts at the top of the world; at the top of a world they start with an entity’s name, and the
entry is declared after the entries that spawn what it names.
One endpoint per pose, poses/<child>: a Transform from the
relative_to frame’s TF name (world_frame for the world) to child (default the frame’s
own name: its body’s, site’s, camera’s or frame’s, or the entity’s name for a root). ROS carries
each as a one-transform tf2_msgs/TFMessage, as PosePublisher publishes one pose per
message. The poses are read from the core pose data (roqsim.frames.frame_pose()); a frame of
an entity that is absent publishes nothing, and an unowned frame always publishes.
run_control
The driver’s run control, served as endpoints.
spawn_model
Scene plugin: place a static model (a prop) into the world from the world YAML, at a fixed pose.
Config:
spawn_model:
model: industrial_table # bundled model name, filename, or absolute path
prefix: "" # MJCF name prefix (use distinct prefixes for >1 of the model)
pose: # the mount pose, as SpawnEntity states one (see below)
position: {x: 0.0, y: 0.0, z: 0.0}
orientation: {roll: 0.0, pitch: 0.0, yaw: 0.0}
scale: 1.0 # uniform geometric scale factor (see below)
motion: physics # who owns the pose: physics (default; a movable body),
# static (welded scenery), driven (a plugin writes it)
present: true # false: compiled in, but absent until it is spawned
mass: 0.5 # override the total mass (kg): root-body geoms + flex vertices
friction: [1.2, 0.005, 0.0001] # override root-body geom and flex friction (or a single sliding val)
publish_tf: false # publish the root body's world pose as TF (see below)
tf_rate: 30.0 # publish_tf: dynamic -- stream rate (Hz)
name: is the entry’s reserved SIBLING, not one of the keys above: it labels the entry and names
the entity this spawn registers (default: the plugin ref). Written inside the config block it is
silently inert, and anything addressing the prop by the name you chose then resolves to nothing.
mass and friction exist so the two properties that decide whether a grasp holds are world-YAML
keys, and therefore ordinary campaign factors – a sweep over payload or surface friction needs no new
variation plugin, just ParameterVariationList against these. mass rescales what the root body
weighs in proportion, keeping the mass distribution of a multi-geom prop: a geom that declares mass
has its mass scaled, one that states only a density has its density scaled, and a visual-only geom
(mass="0" or density="0") stays massless. A density-only prop – the usual way a model states
its mass – is therefore rescaled like any other and weighs exactly what the world asked for.
friction accepts a single sliding coefficient or the full [sliding, torsional, rolling]
triple. Both are refused when the prop has nothing to scale, rather than silently doing nothing.
A prop is in one of three states, named by motion: a free body physics moves (physics,
the default), welded scenery (static), or a mocap body some plugin drives (driven).
motion: driven makes the prop’s root body a MuJoCo mocap body: it has no degrees of freedom, so
it costs the solver nothing and nothing can push it, but it is still collision geometry a lidar sees
and a robot bumps into. Its pose is written every step by whoever owns it – a navigator
component nested under this entry, say – rather than integrated. That is what a controlled obstacle
is: it goes where the experiment says, and the robot under test cannot shove it off course. Like a
physics prop, it is re-seated at its spawn pose on on_reset (through
mocap_pos/mocap_quat rather than a joint), so a repetition never inherits where the last one
left it.
motion: physics adds a <freejoint/> to the prop’s root body, making it a body physics moves –
a box a robot can pick up. It also registers the joint as the entity’s
base_joint, which is what lets simulation_interfaces’ SetEntityState teleport or re-seat it
(the service rejects any entity without one), and what on_reset uses to put it back at its spawn
pose between runs instead of leaving it wherever the last run dropped it.
The prop must end up with mass. MuJoCo derives it from geom volume x density (default 1000), so an
ordinary prop is fine as-is; a geom carrying density="0" – the convention for visual-only
decoration, used throughout the robot models here – is not, and MuJoCo rejects a massless moving body
at compile time rather than simulating it.
Pair it with publish_tf: dynamic: nothing else publishes a free body’s pose.
scale resizes the prop at spawn time, so one asset serves every size a scene needs instead of the
library carrying a folder per size (a 2.9 m wall screen and a 1.2 m one are the same model). It is
applied to the loaded child spec before attach, and covers the whole geometry – mesh scales, and the
positions/sizes of bodies, geoms, sites, lights and joints – so a prop built from primitives or from
several offset parts scales as one piece rather than coming apart. Two spawns of one model at
different scales stay distinct assets: the dedup key in roqsim.assets includes mesh.scale.
It is deliberately a single uniform factor. Non-uniform scaling is ill-defined for a sphere or a
capsule and silently shears any child body that is rotated relative to its parent, so a prop that must
be stretched on one axis needs a purpose-built plugin instead (as door does for its leaf).
scale is geometry only – it does not touch mass or inertia, so a motion: physics prop keeps
the mass it was modelled with at every size; state mass beside scale when the two belong
together.
pose: is the mount pose, in the shape SpawnEntity.srv gives its initial_pose. Its
orientation may be a quaternion or Euler angles, so a prop turned about +Z stays short:
- spawn_model: {model: industrial_table, pose: {position: {x: -0.13, y: 0.6},
orientation: {yaw: 1.5708}}}
It is the only way to state one, for the reason roqsim.pose gives: a document declaring where
a thing sits and a SpawnEntity call placing it are the same pose, so they are written the same
way. Omitting it mounts the prop at the origin, unrotated; an omitted position.z is the floor,
which is what a prop’s frame means by z (a robot’s is its model’s resting height, since a wheeled
base has one and a prop does not). scale, mass and friction are unaffected – they are
properties of the prop, not of where it is.
present: false compiles the prop in and starts it absent: nothing sees or touches it, and the
control plane does not list it, until SpawnEntity brings it in at the pose that call states. This
is how a world provides the spares for an obstacle that must appear mid-trial – roqsim never
recompiles, so everything a trial may bring in is declared up front (see roqsim.presence). The
declared value is restored on on_reset, so a spare spawned in one run is a spare again in the
next; without that, repetitions after the first would begin with an obstacle already in the room.
It is not a way to leave a prop out: enabled: false does that, and does it properly, by never
building the body at all. An absent prop still costs its geometry in the compiled model – that is
what makes it spawnable.
A model with a <flexcomp> – a soft block, a sheet, a cable – is a prop like any other; the
model is MuJoCo’s own MJCF, and roqsim adds what the prop needs around it:
motion: physicson a model whose root body holds nothing but free flexes (no geom, no joint, no pinned vertex) means free vertices: every vertex already has its own slide joints, so no free joint is added, and none of them isbase_joint–SetEntityStatecannot re-seat such a prop, andon_resetneeds nothing, sincemj_resetDataputs every vertex back where the model declared it. A flex pinned to a rigid root body is carried by that body’s free joint, as any part of a prop is.motion: staticordrivenon a model with a free flex is refused: welding or driving the root holds nothing that is not pinned to it. Pin the vertices that should be held (<pin>) to a body, or usemotion: physics.A
<flexcomp>directly under<worldbody>is moved into a body named after the model file, at its origin and with no joint, so the prop has a root body like any other; a vertex it pins to the world is pinned to that body, which is welded where the prop is spawned.scalecovers the flex too: its vertex and node bodies are bodies, and its pinned or interpolated vertex positions,radius,margin,gapand shellthicknessscale with them.masscounts the flex: the total it sets is the root body’s geoms plus every vertex body, and both are rescaled in proportion.frictionis written to every flex as well as to the root body’s geoms. A model whose only collision is a flex can rest, somotion: physicsaccepts it.The registered entity lists its flexes by name in
meta["flexes"], andpresent: falsehides them with the rest of it (roqsim.presence).A mesh or gmsh
<flexcomp>reads itsfilewhile MuJoCo parses the model, relative to the model’s own folder and<compiler meshdir>, so that file lives beside the model: the directories a manifest borrows throughassets:are not searched for it (roqsim.flex, rule 5).
What a flex requires of the rest of the world – the integrator and solver – is
roqsim.flex’s, and sim.integrator: auto (the default) already chooses it.
Unlike the spawn_* plugins for robots/sensors this does not pull in a model manifest – a prop
is inert geometry with no intrinsic controller or sensors. Place several by listing the plugin
multiple times with distinct prefix (and name).
publish_tf puts the spawned root body’s world pose on TF so a viewer binds the scene node by name
(child_frame_id == the exported body name) and a TF-tree consumer such as rviz gets the frame. It
has no effect on an exported scene (roqsim export gltf), which already seats the body at its
spawn pose.
false(default): a static prop already seated by the baked scene needs no TF.
dynamic(ortrue): stream the live world pose on the relativetftopic attf_rate. For a free body (a<freejoint/>prop the robot moves) – nothing else publishes its pose, so a name-binding viewer would otherwise freeze it at the spawn pose. The topic is relative, so a multi-robot gateway federates it under the robot’s scope.
static: publish the world pose once on the latched/tf_static(a welded prop’s frame for the TF tree). The pose is model-fixed, so onemj_forwardat configure resolves it.
step_timers
Monitor plugin: where a physics step’s time goes, from MuJoCo’s own stage timers.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
step_timers:
every_s: 0.05 # s; simulated time between rows, > 0
path: step_timers.csv # CSV to write; a relative path lands in the run's output directory
upright_monitor
Flags: parallel_safe
Observation plugin: did a body a trial drives in the plane stop being in the plane?
Config:
upright_monitor:
# The entity watched is the one this entry is NESTED UNDER -- there is no key for it, and
# declaring it at the top of a document is refused (`requires_owner`).
body: "" # base body override; default: the entity's registered base body
max_tilt_deg: 30.0 # degrees the body's own +z may lean from world +z
max_rise_m: 0.10 # metres its height may depart from where it settled, either way
settle_s: 0.5 # sim time to let the body come to rest before judging it, and the
# moment its reference height is taken
namespace: "" # transport scope for the endpoint
latch: true # once fallen, stay fallen until on_reset (a trial is failed, not
# un-failed -- the same rule contact_monitor follows)
rate_hz: 30.0 # endpoint publish rate
Endpoint upright (out) reads an UprightReport. ROS carries its upright field, a
std_msgs/Bool on upright (relative, so two namespaced entities get /a/upright and
/b/upright); a consumer wanting the detail reads the fields.
The reference height is where the body SETTLED, not where it was spawned, which is what
settle_s buys. A body spawned twenty centimetres above the floor drops onto it, and measuring
against the spawn would call that drop a departure – flagging every world whose author did not
place a body to the millimetre, which is a monitor people turn off. Nothing is judged and no
reference is taken until settle_s; it is measured per run, so a repetition compares
against its own start.
The cost is that a body already broken at t=0 is not reported for half a second. That is the right
trade: the verdict latches, so it is reported a moment later rather than not at all, whereas a
false positive on a correct world is reported forever. Set settle_s: 0 where a trial starts in
contact and the first instant matters.
Both thresholds are departures, not limits. max_rise_m is symmetric: a body sinking through
the floor has left the plane exactly as much as one taking off, and a run where the ground gave way
is no more usable than one where the pedestrian flew. max_tilt_deg is the angle between the
body’s own +z and the world’s, so it says nothing about yaw – a body turning on the spot is doing
what a planar trial expects.
Not a failure criterion for a robot that is meant to tip. A quadruped mid-gait, an aerial vehicle banking, an arm’s wrist – all of these leave the plane on purpose. This watches an entity because somebody nested it under one; nothing infers that an entity should be upright.
zone_trigger
World plugin: presence in a region – who entered a box, who dwelt there, who left.
Config:
zone_trigger:
body: "" # a body the zone rides on; the pose is then in its frame
pose: # the box's centre (roqsim.pose), world or `body` frame
position: {x: 1.2, y: 0.0, z: 0.95}
orientation: {yaw: 0.0}
size: [0.04, 0.6, 0.2] # full extents (m), as a box's
entities: [box_1] # entity name patterns that count (fnmatch, e.g. box_*); default all
point: com # com: the root body's centre of mass | origin: its frame
dwell: 1.0 # seconds inside before `dwelled` (0: never)
roqsim_aerial
multirotor_motors
Actuation plugin: normalized per-rotor commands -> rotor thrusts and their reaction torques.
Config:
multirotor_motors:
namespace: "" # transport scope (default: inherited from spawn_robot)
body: x500 # root body the reaction torque acts on (default: entity's root)
rotors: [rotor0_thrust, rotor1_thrust, rotor2_thrust, rotor3_thrust]
spin: [1, 1, -1, -1] # +1 = CCW seen from above, -1 = CW; PX4 quad-X order
max_thrust: null # N per rotor; default: read from each actuator's ctrlrange
moment_constant: 0.05 # m, yaw torque per newton of thrust (PX4 CA_ROTOR*_KM)
time_constant: 0.02 # s, first-order motor + ESC lag
``max_thrust`` defaults to the model’s own ``ctrlrange``, not to a constant here. The MJCF is the authority on its actuator limits; a hardcoded default would let a model and its actuation plugin disagree about what “1.0” means, and the disagreement would show up as a thrust-to-weight ratio nobody chose.
``moment_constant`` is k_m/k_f, the torque a rotor drags per newton of thrust it makes, in
metres. The default 0.05 is not a generic propeller estimate: it is PX4’s published value for this
airframe, CA_ROTOR*_KM in 4001_gz_x500. This number must agree between the airframe and
the flight stack’s mixer. PX4’s control allocator inverts its own KM to decide how much
differential thrust a commanded yaw moment needs; if the simulator drags a different amount per
newton, every yaw command is scaled wrong – sluggish or oscillatory yaw that reads as a badly tuned
rate loop rather than as two halves of the system disagreeing about a propeller. It is config here
rather than a gear in the MJCF because it is a motor/propeller property, so a re-propped airframe
changes it without touching the frame.
The spin sign convention, which is the easy thing to get backwards. A rotor spinning CCW (+1)
pushes air down and, by reaction, drags the airframe CW – i.e. in -z. So the yaw torque a rotor
applies to the body is -spin_i * k_m * T_i about body z, and the contracted pattern
(+1, +1, -1, -1) sums to zero at equal thrust: two rotors of each handedness, which is the whole
reason a quad has two of each. Yaw is commanded by spinning up the pair of one handedness and down
the pair of the other, which is also why yaw authority is the weakest axis on a multirotor.
The reaction torque is applied in the WORLD frame. data.xfrc_applied is a cartesian
force/torque about the body CoM expressed in world coordinates, so the body-z torque is rotated by
the body’s rotation before it is written. Writing a body-frame torque straight in is correct only
while the drone is level – and it is wrong precisely when the drone is tilted, which is when yaw
control is being exercised. It is ADDED to what the airframe’s entry already holds, replacing only
this plugin’s own contribution from the step before, so another plugin’s external force on the same
body survives. It acts on the entity’s root body (body: names another), which is the airframe
whether the rotor sites sit on it or on rotor bodies of their own.
Air matters. density/viscosity default to 0 in MuJoCo, so a world that does not set
them flies this drone through a vacuum: full rotor authority, no aerodynamic damping, and a
disturbance that never settles. The plugin warns rather than silently flying in vacuum.
px4_sitl
Bridge plugin: PX4 SITL flies this airframe, over PX4’s simulator-agnostic MAVLink HIL API.
Config:
px4_sitl:
port: 4560 # PX4's documented simulator port; PX4 connects OUT to us
bind: "127.0.0.1" # loopback: PX4 SITL runs beside the simulator
lockstep: true
body: x500 # the flown body (default: the entity root)
imu_rate: 250.0 # Hz -- HIL_SENSOR cadence
mag_field: {north: 0.21, east: 0.0, down: 0.43} # gauss, world NED
baro: {sea_level_pressure: 1013.25, temperature: 20.0} # hPa, degC
sensor_noise: {accel: 0.02, gyro: 0.002, mag: 0.002, baro: 0.05} # 1-sigma
connect_timeout: 60.0 # s to wait for PX4 before failing
ground_truth: true # send HIL_STATE_QUATERNION
PX4 is the client, we are the server. Confirmed against PX4’s own SITL startup path, which
runs simulator_mavlink start -c <port> (or -h/-t with PX4_SIM_HOSTNAME /
PX4_SIM_HOST_ADDR): the module dials out to the simulator. The port is 4560 + instance, so
the default here is right for a single vehicle and a second PX4 instance wants port: 4561.
250 Hz is not a guess. The same startup path sets IMU_INTEG_RATE to 250, which is the rate
PX4 integrates HIL_SENSOR at; the default here matches it. That path also sets
SENS_GPS0_DELAY/SENS_GPS1_DELAY to 10 ms, i.e. EKF2 is told to expect a fix that is 10 ms
old – so timestamping HIL_GPS with the current sim time, as this plugin does, is already
consistent with PX4’s assumption and no artificial delay belongs here.
Thrust numbers live in the model, never here. HIL_ACTUATOR_CONTROLS is normalized 0..1 and
goes straight through MotorsHandle.set_normalized; what a 1.0 is worth in newtons is the MJCF’s
ctrlrange, which multirotor_motors reads and exposes as max_thrust. A number duplicated
here would be one that could disagree with the airframe being flown.
``imu_rate`` must divide sensibly into the sim rate. Sensors are sent on whole ticks, so the
achieved rate is 1 / (round(1 / (imu_rate * dt)) * dt): at the usual dt = 0.002 s an
imu_rate of 250 Hz lands exactly (every 2nd tick), 300 Hz silently becomes 250. The plugin logs
the rate it will actually achieve rather than the one that was asked for.
Zero-noise sensors are not the neutral choice. It is tempting to send the physics engine’s exact values and call the result “the ideal case”, but EKF2 is tuned against noisy inputs: its process and measurement covariances assume a certain amount of jitter, and a perfect IMU is an out-of-distribution input for it – innovation gates behave differently, covariances collapse, and the estimator’s behaviour stops being the one that flies on hardware. The defaults here are small but non-zero for that reason; set them to zero deliberately and knowing that the run no longer says anything about the estimator.
The magnetic field default [0.21, 0.0, 0.43] G (north, east, down) is a representative
mid-latitude northern-hemisphere IGRF value (~0.48 G total, ~64 degrees inclination, declination
taken as zero). It is a stand-in for the datum’s actual field, not a computed one: this plugin
does not carry an IGRF model, so an experiment whose result depends on declination must set the
field for its datum explicitly.
Frames. MuJoCo is ENU (world) / FLU (body); MAVLink HIL is NED (world) / FRD (body). Every
conversion goes through enu_to_ned(), flu_to_frd() and quat_enu_flu_to_ned_frd(),
and nowhere else. This is not fussiness: a sign error here produces a drone that flies confidently
in the wrong direction, arms and takes off exactly as it should, and is the single most common way
this integration is got wrong. One helper pair means one place to check.
Threading follows architecture.rst section 7 exactly. The socket is opened in configure
(which is where that section puts socket setup) and served by one background thread, and that
thread never touches ctx.data, the motors handle, or any plugin state the physics thread
reads. It parses frames and enqueues the result with ctx.post(...); the engine drains the queue
at the start of the next pre_step, on the physics thread, in FIFO order. So the actuator update
lands at a defined point in the tick rather than whenever the OS scheduled the reader.
Lockstep is architecture.rst section 10 – the designed synchronous mode, of which this plugin
is the first real user. It registers a consumer gate (ctx.register_gate), pending until the
expected input arrives via ctx.post, exactly as that section specifies. The engine does not
wait on gates (register_gate/gates exist and are reset each reset()), so the wait itself
is implemented here, in post_step, against that gate –
with the timeout and the deadlock diagnostic section 10 requires, naming the gate that never fired.
It is not a second concurrency scheme: the command queue is still the substrate, and this only adds
the wait. Blocking inside ``post_step`` is listed as an anti-pattern “except deliberately in sync
mode” – this is that exception, taken deliberately, and it is the reason the block is confined to
one clearly named place. Were the engine to wait on gates itself, this method would become a
gate.satisfy and nothing else would change.
Lockstep arms only after PX4’s first answer, and that is not a convenience. PX4 SITL runs on a
lockstep_scheduler whose clock is set from the timestamps in the HIL_SENSOR messages we
send: nothing in PX4 makes progress until sim time advances, including its own startup script and
therefore every module that could ever publish actuator_outputs – the topic
HIL_ACTUATOR_CONTROLS is emitted from. Blocking on the very first batch is consequently a true
deadlock, not a slow start: the bridge waits for controls that require a boot that requires the
sensor stream the bridge has just stopped. Verified against PX4 v1.18.0-beta2, which sits at
ERROR [simulator_mavlink] poll timeout 0, 25 forever. PX4’s own gazebo-classic bridge carries
exactly this gate (received_first_actuator_). So the first ticks free-run; from the first
HIL_ACTUATOR_CONTROLS onward every tick is locked, and the gate stays armed across a reset
because PX4 did not reboot.
What is locked to what: on each tick that carries a sensor batch, the plugin sends HIL_SENSOR
(plus HIL_GPS at the receiver’s own rate) and then blocks until PX4’s HIL_ACTUATOR_CONTROLS
for that batch has been received and queued; PX4 in turn blocks until the next HIL_SENSOR.
Neither side runs ahead, so the number of physics steps between two actuator updates is fixed by
construction. With ``lockstep: false`` the run is NOT reproducible: how many steps elapse
between two actuator updates then depends on host load and OS scheduling, so two runs of the
identical world with the identical seed diverge, and repetitions stop being samples of anything.
Non-lockstep exists only for interactive flying, where a stall in one process should not freeze the
other. (The sensor noise itself is reproducible either way – it draws from ctx.rng_for, keyed
on (seed, run, sim_time) per section 9, like every other stochastic plugin here. It is the
coupling that lockstep makes deterministic.)
MAVLink encoding is pymavlink’s. Imported lazily in configure() so that loading a world
containing this plugin (to render it, to export it) does not require the dependency, and so the
error names the package. Hand-rolling a serialiser for a dialect that is generated from XML and
versioned upstream would be a maintenance liability disguised as a saved dependency.
quadrotor_controller
Controller plugin: quadrotor position + attitude control over collective thrust and body moments.
Config – a component of the entry that spawns the drone, since ownership is where the entry sits rather than a config key:
quadrotor_controller:
namespace: "" # transport scope (default: inherited from spawn_robot)
body: cf2 # the drone's root body (default: the entity's root)
thrust_actuator: body_thrust # collective thrust, in newtons
moment_actuators: [x_moment, y_moment, z_moment]
target: [0.0, 0.0, 1.0] # position setpoint (x, y, z), world frame
yaw: 0.0 # heading setpoint (rad)
max_tilt: 0.5 # rad, cap on commanded tilt from vertical
max_accel: 4.0 # m/s^2, cap on the commanded horizontal acceleration
max_vel: 1.5 # m/s, cap on the velocity a position error may ask for
kp_pos: [3.0, 3.0, 12.0] # position gains (x, y, z)
kd_pos: [2.4, 2.4, 6.0] # velocity gains
kp_att: [0.0096, 0.0096, 0.0038] # attitude gains (roll, pitch, yaw), N*m per unit error
kd_att: [0.00086, 0.00086, 0.00051] # body-rate damping, N*m per rad/s
cmd_vel_timeout: 0.0 # s; > 0 brings a velocity-commanded drone to a hover (see below)
Odometry and a stale command, in three dimensions. odom is the 6-DOF pose in the spawn
frame (roqsim.odometry.SpawnFrame): x and y from the spawn point, turned to the spawn
heading, z the altitude as in the world, tilt kept; its twist is in the body frame, as
nav_msgs/Odometry states it. read_state is the world-frame truth. cmd_vel_timeout applies
to the velocity command (drive): once it is stale the drone brakes to a stop at its altitude
setpoint and then holds the position where it stopped, a hover. A position setpoint (target,
cmd_pos) does not expire, since holding one already is a hover. Reset clears both commands.
A position setpoint is read in the frame it names. cmd_pos carries a frame: odom is the
spawn frame above (z the altitude), world or map is the world, and so is an empty
frame; the configured target is a world position. Any other frame is refused by name rather
than flown to as if it were one of these. A yaw is read in the same frame as the position.
The moment actuators carry a negative gear, so a positive ctrl produces a negative body
moment. The sign is read from the model at configure time rather than hardcoded – it is upstream’s
convention, and a future airframe need not share it.
The attitude gains are in newton-metres, not normalised units, because the controller emits a
moment and the model’s actuator gear converts it to ctrl. They are sized from the airframe: for a
body inertia I and a target attitude bandwidth wn with damping zeta, kp_att ~ I*wn^2 and
kd_att ~ 2*zeta*I*wn. The defaults are I = 2.4e-5 kg*m^2 at wn = 20 rad/s, zeta = 0.9. This is
also why the Crazyflie’s moment gear is tuned rather than upstream’s: at the arbitrary 1e-5 N*m
upstream ships, full deflection buys 0.42 rad/s^2 and no attitude loop can track a position
controller’s tilt command – the drone hovers perfectly and flies away the moment it is asked to
translate.
Air matters. density/viscosity default to 0 in MuJoCo, so a world that does not set
the world’s density/viscosity flies the drone through a vacuum – no drag, and a lateral step never settles.
The plugin logs a warning rather than silently flying in vacuum.
wind_field
Flags: parallel_safe
World plugin: time-varying wind – steady flow, a discrete gust, and Dryden turbulence.
Config:
wind_field:
steady: [2.0, 0.0, 0.0] # m/s, world frame -- the mean flow
gust: # optional 1-cosine discrete gust (MIL-F-8785C shape)
magnitude: 4.0 # m/s at the peak
axis: [1.0, 0.0, 0.0] # direction (normalised; defaults to `steady`, else +x)
onset: 5.0 # s, when it starts
duration: 1.0 # s, rise-and-fall length
turbulence: # optional continuous Dryden turbulence
intensity: 0.6 # sigma, m/s (per horizontal axis)
length_scale: 5.0 # L, m -- larger = slower, more correlated gusting
vertical: 0.5 # sigma scale on the w axis (Dryden's low-altitude form)
Wind is a signal, not a value. model_override refuses every opt.* global at runtime,
because a fault-injection write would make the value a run recorded differ from the value that ran.
The wind here is fully determined by the parameters above plus the run’s seed, both recorded with
the world: re-run the same world with the same seed and the same wind happens, tick for tick.
One owner per knob: declaring both sim.wind and this plugin is refused rather than merged,
because the compiled model would say one thing, the first tick another, and the run’s provenance
would record the value that was immediately overwritten. State the mean flow in steady:.
Randomness comes from ``ctx.rng_for``, like every other stochastic plugin, so turbulence is a
pure function of (sim.seed, run, sim_time) and this plugin has no seed key of its own.
Because the run is part of the key, the runs of one configuration see different turbulence:
repetitions are samples of the weather, not copies of it, which is what makes averaging over them
mean anything.
Wind is inert in a vacuum. MuJoCo applies wind as a relative velocity into the density and viscosity drag terms, so with both at 0 this plugin has no effect whatever – a silent, plausible-looking failure, so it warns.
roqsim_assets
box
Scene plugin: a parametric rectangular box obstacle placed from the world YAML.
Config:
box:
prefix: "" # MJCF name prefix (use distinct prefixes for >1 box)
pose: # world placement (REQUIRED), as SpawnEntity states one; omit z to
position: {x: 0.0, y: 0.0} # sit the box ON the floor, give z to place its CENTRE
orientation: {yaw: 0.0} # a full rotation, so a box may be tipped onto an edge
size: [0.4, 0.4, 0.8] # full extents (not half-extents), metres (REQUIRED)
color: [r,g,b,a] # default a light warehouse grey; alpha optional
collide: true # false -> visual only (raycast still sees it; nothing bumps into it)
friction: 1.0 # sliding friction, or the full [sliding, torsional, rolling] triple
motion: physics # who owns the pose: physics (default; movable and TELEPORTABLE),
# static (welded scenery), driven (a plugin writes the pose:
# collidable, immovable, and NOT in a navigator's planner grid)
size is deliberately full extents, not MuJoCo half-extents: a world file describes a 0.4 m
box, and halving it in your head is exactly the kind of silent factor-of-two a scene should not ask
of its author.
By default (motion: physics) the box has a free joint, which buys two things: physics can move
it, and simulation_interfaces’ SetEntityState can teleport it (that service rejects any
entity without a free base_joint).
Teleporting is how an obstacle appears mid-trial. roqsim never recompiles the model at runtime, so
there is no spawning: a box that must show up on cue is compiled in at build time, kept out of the
way, and moved into place by the scenario when the moment comes. Between runs on_reset puts
it back at its declared pose, so a trial never inherits the previous trial’s obstacle position.
A teleport states the box’s centre, and no part of it may be inside the floor. The z this file’s
pose: lets you omit is a convenience of the world, not of the service: SetEntityState states
every field, so a scenario placing a floor-standing box asks for half its height and gets what it
asks for. A free box seated inside the floor is not parked – the solver answers the penetration by
launching it metres upward before it settles, in view of the run. Keep it out of the way by making
it ABSENT (DeleteEntity, which leaves its pose alone) or by moving it sideways, never downward.
motion: driven is the third state, and it is what makes this plugin’s opening paragraph achievable
without a scenario at all. A mocap box has no degrees of freedom, so nothing can push it, and it is
excluded from a navigator’s planner grid by the same rule that excludes walkers and driven props –
that grid holds only what cannot move. So a mover plans straight through it and has to discover it
with its forward probe, which is exactly the “obstacle the robot is not supposed to know about” this
plugin exists for. Welded scenery cannot do that job: it lands in the grid and gets routed around.
boxes
Scene plugin: many parametric boxes from one config value.
Config:
boxes:
instances: [] # list of box configs, each accepting every key `box` does (required)
ceiling_panels
Scene plugin: a parametric field of flat acoustic ceiling panels under a soffit.
Config:
ceiling_panels:
prefix: "" # MJCF name prefix (distinct prefixes for >1 field)
area: [x0, y0, x1, y1] # world rectangle to cover (REQUIRED)
z: 3.5 # soffit height, m -- panels hang below this
drop: 0.04 # gap between soffit and panel top, m
panel: [1.8, 0.6] # panel size [x, y] before `yaw`, m
pitch: [2.6, 1.6] # grid spacing [x, y], m (>= panel, or the panels would overlap)
thickness: 0.04 # panel thickness, m
yaw: 0.0 # rotation of the whole field about its centre, rad
color: [r,g,b,a] # panel colour (default near-white); alpha optional
emission: 0.35 # 0..1 self-illumination -- a panel faces away from every lamp in the room
# (they hang at the same height), so without it white panels render as
# dark grey slabs. This is what makes them read as the white they are.
Panels are visual only (no contacts): they are out of reach of anything driving on the floor, and a
convex collider per panel would be pure cost. The lidar raycaster still sees them – mj_multiRay
ignores contype – so an upward-looking sensor reads the panelled ceiling, as it should.
conveyor
Machine: a velocity-driven belt conveyor that runs at a speed and stops.
Config:
conveyor:
namespace: "" # optional transport scope for the speed endpoint (/<ns>/speed)
prefix: "" # MJCF name prefix (distinct prefixes for >1 belt)
model: conveyor # bundled model name / path
pose: # the belt model in the world, a geometry_msgs/Pose (roqsim.pose); omitted
position: {x: 0.0, y: 0.0, z: 0.0} # components are 0
orientation: {roll: 0.0, pitch: 0.0, yaw: 0.0} # or a quaternion x/y/z/w
length: 2.442 # optional full belt length (X, m); default keeps the base model
width: 0.58 # optional full belt width (Y, m); default keeps the base model
home: {speed: 0.1} # belt speed at the start of each run (m/s); negative reverses
ramp: 0.5 # acceleration of run/stop (m/s^2); unset: the speed changes at once
friction: 0.6 # optional belt<->package sliding friction override
roller_radius: 0.0275
belt_wrap: 0.025 # +/- position wrap (m); keep <= half the slab overhang
package_pose: # the package's free-body reset pose, in the BELT's frame (the belt's
position: {x: 1.0, y: 0.6, z: 0.996} # own pose is applied to it); a geometry_msgs/Pose,
# omitted components 0; default at the feed end
object_name: package # entity name the ridden package registers under
cylinder
Scene plugin: a parametric cylindrical obstacle placed from the world YAML.
Config:
cylinder:
prefix: "" # MJCF name prefix (use distinct prefixes for >1 cylinder)
pose: # world placement (REQUIRED), as SpawnEntity states one; omit z to
position: {x: 0.0, y: 0.0} # stand it ON the floor, give z to place its CENTRE
# [x, y, z] places its CENTRE at z (REQUIRED)
radius: 0.075 # metres (REQUIRED)
height: 0.5 # full height, metres (REQUIRED)
color: [r,g,b,a] # default a light warehouse grey; alpha optional
collide: true # false -> visual only (raycast still sees it; nothing bumps into it)
friction: 1.0 # sliding friction, or the full [sliding, torsional, rolling] triple
motion: physics # who owns the pose: physics (default; movable and TELEPORTABLE),
# static (welded scenery), driven (a plugin writes it)
mass: null # total mass, kg. Unset -> MuJoCo's default density (1000 kg/m^3), which
# for a hollow container is several times too heavy
height is the full height and radius is a true radius, matching how a world file talks
about a post. MuJoCo’s cylinder geom wants [radius, half-height]; that conversion happens here so
it never has to happen in your head – the same reason box takes full extents.
mass sets the geom’s total mass and lets MuJoCo derive the inertia from the shape, so it stays a
solid cylinder’s inertia at the stated mass. It is a separate key from the geometry because the two
are independent for anything the size of a drinks can: the diameter is set by what the fingers can
span, the mass by what the object is made of and whether it is full.
cylinders
Scene plugin: many parametric cylinders from one config value.
Config:
cylinders:
instances: [] # list of cylinder configs, each accepting every key `cylinder` does (required)
door
Machine: a hinged (swing) door with open and close programs and a ROS-controllable opening angle.
Config:
door:
prefix: door_1_ # MJCF name prefix (distinct per door)
pose: # opening CENTRE, a geometry_msgs/Pose in the world (roqsim.pose);
position: {x: 0.0, y: 0.0} # omitted components are 0
orientation: {yaw: 0.0} # yaw aligns the closed leaf along its wall
width: 0.9 # opening / leaf width (m)
height: 2.0 # leaf height (m)
thickness: 0.04 # leaf thickness (m); box leaf only
floor_gap: 0.01 # clearance above the floor and below the lintel (m), so the leaf
# does not scrape the ground and fight its actuator
leaf: true # false -> a cased opening: the casing is welded, no leaf is hung
model: door # optional leaf mesh model (door | door_glass | pkg:name); omit -> box
color: [r, g, b, a] # repaint the leaf (omit -> the model's own colours); alpha optional
frame: true # weld a static jamb/lintel casing around the opening (frame_model)
frame_model: door_frame # the static frame model to weld (visual-only)
frame_color: [r,g,b,a] # repaint the casing (default: follow `color`)
mount_offset: 0.06 # hang the leaf this far proud of the wall (m), on the swing side, so it
# clears the reveal and can open past 90 deg
hinge_side: left # 'left' | 'right' -- which edge of the opening is fixed (the hinge)
swing: 1 # +1 / -1 -- which way the leaf opens about +Z
max_angle: 120 # fully-open hinge angle (deg); a leaf can swing well past 90 in free
# space -- raise/lower per door for what its surroundings allow
home: {openness: 0.0} # the openness fraction 0..1 it starts at and a reset puts it at
speed: 0.8 # hinge speed of open/close/move_to (rad/s); unset: the target jumps
controllable: true # expose the ROS endpoints/action; false = passive, held at home
namespace: "" # transport scope -> /<ns>/openness, /<ns>/openness_state,
# /<ns>/openness_goal
kp: 40.0 # position-actuator stiffness
kv: 30.0 # position-actuator damping (velocity gain); with kp 40 it damps the
# default leaf at zeta 0.54, so a half-open target does not overshoot
max_torque: 15.0 # actuator force cap (N*m): an obstacle is nudged, never crushed
stall_timeout: 3.0 # s blocked before the door gives up and holds where it is
stall_speed: 0.02 # openness fraction/s below which a door short of its target is blocked
The leaf-mesh convention (model:) mirrors the rest of the asset library but with one addition: a
door model’s origin is its hinge (fixed) vertical edge at floor level, the leaf extending along
+X and up +Z, so the plugin can hang it on the hinge with no per-model offset. A box leaf (no
model) is built to the same convention procedurally.
Frame. Unless frame: false, a static jamb/lintel casing (the frame_model, default
door_frame) is welded around the opening while the leaf hinges inside it. The frame is centred on
the opening and rescaled to width/height like the leaf; it is visual-only (the wall already collides),
so it never narrows the doorway. A frame or leaf model that cannot be resolved is refused.
Leafless openings. leaf: false welds the casing but hangs no leaf – a cased opening (German
Türblatt-less door): no hinge joint, no actuator, no ROS surface, nothing to command. Use it where a
wall opening should read as a doorway rather than a hole, while staying a door in the floorplan so the
room loops it belongs to are unchanged. It is still registered as a door entity (on the casing body),
so anything enumerating the building’s doors still finds it. leaf: false with frame: false would
place nothing at all and is refused, as is controllable: true, which would have no leaf to command.
Colour. color repaints the leaf and (unless frame_color overrides it) the casing, so a world can
match its doors to the rest of its trim without a recoloured copy of the model. Only the leaf’s
colliding geometry is repainted: in this library a leaf’s decoration is non-colliding by convention
(the chrome handle, contype/conaffinity 0), so it keeps its own finish instead of turning into
the door colour. That also means a glazed leaf should be left alone – painting door_glass’s pane
opaque would defeat it – and only its frame_color set.
drawer_cabinet
Scene plugin: a cabinet of drawers that slide when something pulls them.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
drawer_cabinet:
pose: <required> # required; the cabinet's front-bottom centre on the floor; its front faces +x
size: [0.6, 0.7, 0.9] # m; the carcass: depth, width, height
drawers: 2 # how many drawers, stacked
travel: 0.45 # m; how far a drawer comes out
friction: 8.0 # N; a drawer's sliding friction
wall: 0.12 # m; the height of a drawer's walls
duct
Scene plugin: a parametric round ventilation duct run under a ceiling.
Config:
duct:
prefix: "" # MJCF name prefix (distinct prefixes for >1 run)
start: [x, y] # run start, world (REQUIRED)
end: [x, y] # run end, world (REQUIRED)
z: 3.2 # height of the run's AXIS, m
radius: 0.14 # main tube radius, m
branches: [] # distances along the run, m, where a drop + diffuser hangs
branch_length: 0.40 # how far a drop hangs below the main tube, m
branch_radius: 0.08 # drop tube radius, m
diffuser_radius: 0.16 # disc at the bottom of a drop, m (0 = no disc)
color: [r,g,b,a] # galvanised steel by default; alpha optional
Visual only (no contacts), for the same reason the panels are: nothing driving on the floor reaches a duct, and the raycaster sees it regardless.
floor_marking
Scene plugin: a parametric floor marking – a line, a rectangle’s outline or a filled area, painted in one colour, solid or dashed, or in yellow-and-black warning stripes.
Config:
floor_marking:
prefix: "" # MJCF name prefix (distinct prefixes for >1 marking)
pose: # a geometry_msgs/Pose in the world (roqsim.pose):
position: {x: 0.0, y: 0.0, z: 0.0} # the centre, z the floor it is painted on
orientation: {yaw: 0.0} # direction of 'length', rad; no roll or pitch
length: 1.4 # along yaw, m, over the outer edges
width: 1.0 # across it, m, over the outer edges
band: 0.05 # width of the painted outline, m; 0 paints the whole rectangle
pattern: solid # solid | dashed | hazard (warning stripes)
color: [0.90, 0.66, 0.06] # solid, dashed: the paint, [r, g, b] or [r, g, b, a]
dash: 0.5 # dashed: a dash's length and the gap after it, m
stripe: 0.035 # hazard: width of one stripe, m, measured across the stripe; by default
# 0.7 of 'band', and 0.1 where the whole rectangle is striped
angle: 45.0 # hazard: the stripes' slant against 'length', degrees, in (0, 180)
colors: # hazard: the two paints, each [r, g, b] or [r, g, b, a]
- [0.90, 0.66, 0.06]
- [0.13, 0.13, 0.14]
thickness: 0.0005 # how far the paint stands above the floor, m
moving_box
Scene plugin: a moving rectangular box obstacle, driven kinematically from the world YAML.
Config:
moving_box:
prefix: "cube1_" # MJCF name prefix (use distinct prefixes for >1 mover)
size: [0.3, 0.3, 0.3] # full extents, metres (REQUIRED)
pose: # start; omit z to sit it ON the floor, state z to set its CENTRE
position: {x: 0.0, y: 0.0}
orientation: {yaw: 0.0} # constant -- the box travels without turning
speed: 0.1 # m/s along the route (REQUIRED, > 0)
color: [r, g, b, a] # default a light warehouse grey; alpha optional
collide: true # false -> nothing bumps into it (a raycast still sees it)
friction: 1.0 # sliding friction, or the full [sliding, torsional, rolling] triple
# -- mode A: a fixed route -----------------------------------------------------------------
waypoints: [[2.0, 1.0], [2.0, -3.0]] # world metres; the box starts at `pose`
loop: true # true -> cycle the route forever; false -> stop at the last point
ping_pong: false # true -> reverse at the end instead of jumping back to the start
# -- mode B: a random walk (every key optional: `random_walk: {}`) -------------------------
random_walk:
clearance: 0.5 # m of free space required ahead; below it, a new heading is picked
bounds: [x0, y0, x1, y1] # optional axis-aligned box the centre must stay inside
turn_deg: [60, 300] # heading change sampled uniformly from this range, in degrees
pose is where the box is at on_reset, every run: a trial never inherits the previous
trial’s obstacle position. Nothing else carries over either, since no generator is held between draws.
palm_tree
Scene plugin: a parametric artificial palm-like tree – trunk, arching fronds, fruit bunches.
Config:
palm_tree:
prefix: "" # MJCF name prefix (distinct prefixes for >1 tree)
pose: # the trunk base, a geometry_msgs/Pose (roqsim.pose); omitted
position: {x: 0.0, y: 0.0, z: 0.0} # components are 0
orientation: {roll: 0.0, pitch: 0.0, yaw: 0.0} # or a quaternion x/y/z/w
trunk_height: 1.60 # m, top of the pole above the floor
trunk_radius: 0.030 # m
pot_height: 0.16 # m (0 for a pole with no pot)
pot_radius: 0.085 # m
crown_height: 0.95 # m, where the fronds spring from the trunk
fronds: 8 # blades in the crown
frond_length: 0.45 # m, tip to trunk (split over the two segments)
frond_width: 0.10 # m
frond_pitch_deg: 35 # inner segment's rise above horizontal
frond_droop_deg: 45 # extra downward turn of the outer segment
frond_tier: 0.10 # m, height offset between alternating fronds
bunches: # fruit bunches; pos is relative to the trunk base
- pos: [-0.13, 0.02, 0.88]
radius: 0.075
fruits: 9
The trunk, the fronds and the fruit all collide – every one of them is something an arm can hit, and the fronds in particular are the obstacle the experiment is about. The pot collides too (it is a solid object at floor level). Nothing here is decoration, so nothing here is contact-free.
press
Machine: a C-frame press whose ram strokes only behind its closed guard door.
Config:
press:
prefix: press_1_ # MJCF name prefix (distinct per press)
pose: # the press in the world (roqsim.pose); its footprint centre on the floor
position: {x: 0.0, y: 0.0, z: 0.0}
orientation: {yaw: 0.0}
table_height: 0.9 # height of the press table (m)
door_speed: 0.25 # guard door speed (m/s): 2 s each way
approach_speed: 0.2 # ram speed down to contact (m/s)
power_speed: 0.03 # ram speed of the power stroke (m/s)
return_speed: 0.2 # ram speed back up (m/s)
ram_contact: 0.195 # ram travel where the power stroke begins (m, down from home)
ram_bottom: 0.215 # ram travel at the stroke's bottom (m): the punch 5 mm above the die
prop_trajectory
Scene + controller plugin: carry a prop along a prescribed planar path at a fixed speed.
Config:
prop_trajectory:
prefix: "" # MJCF name prefix (distinct prefixes for >1 stage)
path: trajectories/t1.csv # 2-column "x,y" CSV, resolved relative to the world YAML
units: mm # mm | m -- the CSV's units (default mm)
speed: 0.03 # m/s along the path (arc length), constant
origin: [2.0, 1.0, 0.6] # world pose of CSV point (0,0); z is the plate's TOP surface
plate: [0.07, 0.07, 0.006] # carrier plate half-extents (x, y, z)
friction: 1.0 # plate friction (a carried object must not slide off)
loop: false # restart at the path start when the end is reached
start_index: 0 # begin at this CSV row (phase offset within one path)
travel: [0.15, 0.15] # +/- soft limits on each axis (m); the path is clamped into them
The plate is driven, not simulated: its joints have no actuator and are velocity-forced, so the stage is infinitely stiff and its motion is exactly the commanded path regardless of the load it carries. That is the right model for a stepper-driven gantry and the wrong one for a compliant conveyor.
Props carried by the plate need their own free joint – spawn them with
spawn_model: {..., motion: physics} and place them just above the plate’s top surface.
push_button
Scene plugin: a push button on a housing, pressed by whatever pushes it.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
push_button:
pose: <required> # required; the housing's centre, as SpawnEntity states a pose; the button faces its +x
housing: [0.06, 0.16, 0.16] # m; the housing's full extents
radius: 0.02 # m; the button's radius
stroke: 0.012 # m; how far the button goes in
threshold: 0.6 # share of the stroke that is pressed
release: 0.4 # share of the stroke it must come back under to be released (below threshold)
stiffness: 300.0 # N/m; the spring that pushes it back
color: [0.8, 0.1, 0.1, 1.0] # the button's colour
shelf
Scene plugin: a parametric chipboard shelf built from primitive boxes at build time.
Config:
shelf:
prefix: "" # MJCF name prefix (distinct prefixes for >1 shelf)
pose: # world placement, a geometry_msgs/Pose (roqsim.pose); omitted
position: {x: 0.0, y: 0.0, z: 0.0} # components are 0
orientation: {roll: 0.0, pitch: 0.0, yaw: 0.0} # or a quaternion x/y/z/w
layers: 5 # number of boards (int >= 2; default 5)
width: 1.51 # board size along Y, m (default 1.51)
depth: 0.80 # board size along X, m (default 0.80; half-depth => 0.40)
height: 2.00 # overall shelf height, m (default 2.00)
thickness: 0.02 # board thickness, m (default 0.02)
leg: 0.04 # square cross-section of a corner upright, m (default 0.04)
sliding_door
Machine: a sliding door whose leaf runs sideways along its wall, with open and close programs.
Config:
sliding_door:
prefix: sd_1_ # MJCF name prefix (distinct per door)
pose: # opening CENTRE in the world (roqsim.pose); yaw aligns it with its wall
position: {x: 0.0, y: 0.0}
orientation: {yaw: 0.0}
width: 1.2 # opening and leaf width (m)
height: 2.1 # leaf height (m)
thickness: 0.04 # leaf thickness (m)
offset: 0.08 # how far proud of the wall the leaf hangs (m)
slide: 1 # +1 / -1: which way along the wall the leaf runs to open
speed: 0.5 # leaf speed of open and close (m/s)
max_force: 150.0 # the servo's force cap (N): an obstacle is pushed, never crushed
stall_timeout: 2.0 # s blocked before a program gives up
stall_speed: 0.01 # m/s below which a leaf short of its target is blocked
color: [0.75, 0.8, 0.85, 0.6] # the leaf's rgba; a glazed leaf by default
slots
Adds a body’s slots – hand targets and stances – as sites, at build.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
slots:
body: <required> # required; the body the slots are on, as the model names it
slots: <required> # required; slot name -> {kind, at, stand}
strip_light
Scene plugin: a parametric linear ceiling luminaire – the LED batten, optionally lit.
Config:
strip_light:
prefix: "" # MJCF name prefix (distinct prefixes for >1 batten)
pose: # a geometry_msgs/Pose in the world (roqsim.pose), z REQUIRED:
position: {x: 0.0, y: 0.0, z: 3.5} # the centre, z the underside of the ceiling it hangs on
orientation: {yaw: 0.0} # direction of the run, rad; no roll or pitch
length: 2.4 # along yaw, m
width: 0.09 # across it, m
height: 0.06 # how deep the fixture hangs, m
color: [r,g,b,a] # fixture colour (default white)
emission: 0.6 # 0..1 self-illumination, so the batten reads as lit, not just white
emit: false # also add a real light below the fixture
diffuse: [0.25, 0.25, 0.25] # its colour/intensity (only with emit)
cutoff: 80.0 # its spot half-angle in degrees (only with emit)
Keep emit for the few battens that should actually light the scene: MuJoCo caps a model at 100
lights, and every extra one costs render time for a room that is already lit.
tote
Scene plugin: a tote – an open box of five walls – that hands carry by its two ends.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
tote:
pose: <required> # required; where it stands; omit z to stand it on the floor
size: [0.4, 0.3, 0.2] # m; length (between the handles), width, height
mass: 1.5 # kg; the empty tote's mass
color: [0.15, 0.35, 0.7, 1.0] # its colour
contents: false # add look_full / look_empty bodies for a part_state
window
Scene plugin: a parametric fixed window – a glazed pane in a slim frame, built from boxes.
Config:
window:
prefix: "" # MJCF name prefix (distinct prefixes for >1 window)
pose: # opening CENTRE, a geometry_msgs/Pose in the world (roqsim.pose);
position: {x: 0.0, y: 0.0} # omitted components are 0
orientation: {yaw: 0.0} # yaw aligns the pane with its wall
width: 0.94 # opening width along the wall, m (default 0.94)
height: 2.06 # overall height from the floor, m (default 2.06 -- door_frame's outer height)
depth: 0.10 # thickness through the wall, m (default 0.10 -- the default wall thickness)
frame: 0.05 # frame border width, m (default 0.05); glass fills the rest
glass: 0.012 # glass thickness, m (default 0.012)
color: [r,g,b,a] # frame colour (default a neutral grey); alpha optional
glass_color: [r,g,b,a] # glass colour, alpha < 1 to see through it
Both parts collide: the wall around the opening stops a robot, and the glass must too, or a robot would drive through the window.
workbench
Scene plugin: a parametric ESD assembly workbench with an electric lift column.
Config:
workbench:
prefix: "" # MJCF name prefix (distinct prefixes for >1 bench)
pose: # world placement, a geometry_msgs/Pose (roqsim.pose); omitted
position: {x: 0.0, y: 0.0, z: 0.0} # components are 0
orientation: {roll: 0.0, pitch: 0.0, yaw: 0.0} # or a quaternion x/y/z/w
height: 0.695 # worktop height, m -- the lift column's stroke, 0.695 .. 0.995
width: 2.00 # worktop size along X, m (default 2.00)
depth: 0.70 # worktop size along Y, m (default 0.70)
cabinet: left # drawer cabinet side: 'left' | 'right' | 'none'
superstructure: true # uprights + tool panel + monitor arm + overhead light frame
The structure collides – worktop, frame, columns, cabinet, uprights, tool panel and the overhead beams are all things a robot or an arm can hit. The trim does not: adjustable feet pads, drawer fronts and handles, the power strip, the monitor arm and the light bar are visual, so a bench in a navigation scene does not cost contacts for decoration.
roqsim_humanoid
agibot_g2_controller
Controller plugin: whole-upper-body joint-position hold for the AgiBot G2.
Config – a component of the entry that spawns the robot, since ownership is where the entry sits rather than a config key:
agibot_g2_controller:
namespace: "" # transport scope (default: inherited from spawn_robot)
rest: {idx21_arm_l_joint1: 1.6, ...} # {joint: angle} spawn+hold stance (default: manifest)
test_target: {idx31_gripper_l_inner_joint1: -0.6} # optional {joint: pos} held every tick
g1_locomotion
Controller plugin: RL walking policy + PD torque loop for the Unitree G1 (12-DoF legs).
Config – a component of the entry that spawns the robot, since ownership is where the entry sits rather than a config key:
g1_locomotion:
namespace: "" # transport scope (default: inherited from spawn_robot's namespace)
policy: g1_stand # use a spec-driven policy instead of the bundled walk one: names a
# directory under policy/ holding <name>.spec.yaml + its checkpoint
# (roqsim.policy.PolicySpec). The spec carries the observation layout,
# gains and trained envelope, so adding a policy edits no Python.
# Omitted -> the bundled walk policy, unchanged.
policy_path: <bundled> # override the TorchScript policy (default: policy/motion.pt)
config_path: <bundled> # override the deploy config (default: policy/g1.yaml)
gait_period: 0.8 # gait-phase period (s) feeding the sin/cos phase obs
max_linear_vel: 1.0 # |vx| clamp (m/s)
max_lateral_vel: 0.5 # |vy| clamp (m/s)
max_angular_vel: 1.0 # |yaw_rate| clamp (rad/s)
cmd_vel_timeout: 0.0 # s; > 0 stops the robot when no command arrives for this long
test_cmd: [0.4, 0.0, 0.0] # optional [vx, vy, w] applied every tick (standalone demo)
station_keeping: true # hold position when commanded to stop (see below)
station_gain: [2.5, 2.5, 2.0] # P gains on [x, y, yaw] error -> body-frame twist
station_deadband: [0.02, 0.05] # [m, rad] inside which no correction is applied
station_keeping closes a position loop so a zero command means stay here rather than walk at
zero velocity. It is off by default (the policy’s raw behaviour is what a locomotion study wants to
measure), but anything standing still needs it: the policy takes only a velocity command and has no
notion of where it is, so a stationary G1 drifts at roughly 0.06–0.09 m/s – 0.6–0.9 m over ten
seconds, measured on both this model and unitree_g1. That is enough to walk a robot away from the
table it was reaching for, and it also means a navigating robot creeps away after arriving at its goal.
The hold target arms itself whenever the external command returns to (near) zero, capturing the pose
the robot is standing at, and releases the moment a non-zero command arrives – so nav2 drives normally
and only the standstill is corrected. The correction is a P term on the world-frame error rotated into
the body frame, clamped by the same max_* limits as any other command, with a deadband so the robot
is not permanently taking small steps to chase millimetres. A command expired by cmd_vel_timeout
is a zero command, so the hold arms there too.
Measured on unitree_g1_dex1, 10 s at rest – settled offset from the armed pose, and how far the
base still wanders in a subsequent 2 s (the number a manipulation task actually cares about):
station_gain |
settled offset |
further motion / 2 s |
|---|---|---|
off |
0.905 m, rising |
– |
[1.0, 1.0, 1.5] |
0.116 m |
0.0045 m |
[2.5, 2.5, 2.0] |
0.046 m |
0.0049 m |
[5.0, 5.0, 3.0] |
0.026 m |
0.0031 m |
Residual wander is ~5 mm regardless, so the gain only trades settled offset against how hard the policy is pushed; the default is the middle row. A P term leaves a steady-state offset because the policy needs a finite velocity command to step at all – plan in the robot’s own base frame (as MoveIt should here anyway) and a constant offset costs nothing.
This is what the hardware does too: the real G1’s sport mode has a stand state that holds pose rather than integrating a zero velocity.
oli_locomotion
Controller plugin: ONNX whole-body walk policy + PD torque loop for the LimX Oli (HU_D04_01).
Config – a component of the entry that spawns the robot, since ownership is where the entry sits rather than a config key:
oli_locomotion:
namespace: "" # transport scope (default: inherited from spawn_robot)
policy_path: <bundled> # override the ONNX policy (default: policy/oli/policy.onnx)
config_path: <bundled> # override the deploy config (default: policy/oli/walk_param.yaml)
max_linear_vel: 0.5 # |vx| clamp (m/s) -- vendor max_vx
max_lateral_vel: 0.3 # |vy| clamp (m/s) -- vendor max_vy
max_angular_vel: 0.5 # |yaw_rate| clamp (rad/s) -- vendor max_vz
cmd_vel_timeout: 0.0 # s; > 0 stops the robot when no command arrives for this long
test_cmd: [0.3, 0.0, 0.0] # optional [vx, vy, w] applied every tick (standalone demo)
roqsim_manipulation
arm_controller
Controller plugin: joint-position hold for a manipulator + joint-state publishing.
Config – a component of the entry that spawns the arm, since ownership is where the entry sits rather than a config key:
arm_controller:
joints: [shoulder_pan_joint, ...] # optional: the joints this controller owns. Omitted, the
# plugin claims every joint actuator sharing the entity's prefix,
# which is right for a standalone arm and wrong for an arm that
# shares its entity with other actuated parts -- a humanoid's legs,
# a mobile manipulator's wheels. There the scan claims those too
# and this plugin then fights their owner, writing position targets
# into what may be torque actuators. Naming the joints also scopes
# `joint_states` to this arm, so several controllers can share one
# topic without each restating the others' joints.
gripper_actuator: left_gripper # required WITH `joints:` for a gripper, and the ONLY way to
# declare one that is a plain joint actuator (the X-Series arms
# drive their jaws from a `left_finger` slide, which the scan
# below would otherwise claim as a seventh arm joint). Resolved by
# ACTUATOR NAME, so it need not be a tendon -- and a tendon one is
# not inferable anyway once an entity carries two (left/right).
joint_prefix: "" # prepended to every joint name this controller REPORTS in
# `joint_states` and accepts in a trajectory. Empty (the default)
# reports the model's own names. Set it -- conventionally to the
# arm's MJCF prefix -- when two arms must appear in ONE robot
# description: a URDF is a flat namespace, so two `shoulder_pan_joint`
# cannot coexist there, and MoveIt matches states and trajectory
# points to the description by name.
namespace: ur10e # transport scope (default: inherited from spawn_arm's namespace)
topics: {joint_states: /joint_states} # optional: rename an endpoint, here to an absolute
# name that overrides the namespace (see Plugin.topic_override)
controller_name: arm_controller # action at <controller_name>/follow_joint_trajectory
controller_type: joint_trajectory_controller/JointTrajectoryController
# the type list_controllers reports: this, or a scaled one --
# ur_controllers/ScaledJointTrajectoryController (the UR driver's)
# or fanuc_controllers/ScaledJointTrajectoryController (FANUC's) --
# whose trajectory time runs at the speed scaling (see "Speed
# scaling" below)
initial_state: active # active | inactive -- `inactive` is ros2_control's
# `spawner --inactive`: registered, but not holding the arm
joint_state_broadcaster_name: joint_state_broadcaster # the robot's one broadcaster; a
# second arm on the entity extends the one the first registered
goal_tolerance: 0.5 # rad the joints may end from the trajectory's last waypoint before
# the action reports GOAL_TOLERANCE_VIOLATED instead of success.
# A scalar applies to every joint; {joint: rad} sets them apart;
# 0 disables the check. Loose on purpose -- it exists to catch an
# arm that never arrived (blocked, saturated, planned through the
# furniture), not to grade a servo's steady-state error.
goal_time_tolerance: 1.0 # s the joints get, after the last waypoint, to reach that; 0 is
# no limit, ros2_control's convention (the goal waits until the
# joints are inside its tolerance, or it is cancelled or replaced)
path_tolerance: 0.25 # optional: rad a joint may trail the trajectory while it runs before
# the action aborts with PATH_TOLERANCE_VIOLATED, ros2_control's
# `constraints.<joint>.trajectory`. Scalar or {joint: rad}; 0 or
# absent is no check.
allow_partial_joints_goal: true # false: a goal naming fewer than all of this controller's
# joints is rejected, as ros2_control's parameter of that name does
allow_nonzero_velocity_at_trajectory_end: true # false: a goal whose last point has a
# velocity is rejected, as ros2_control's parameter of that name does
state_interfaces: [position, velocity, effort] # which `joint_states` fields carry values; a
# robot whose hardware has no effort interface reports none
joint_state_rate: 50.0 # Hz of `joint_states` (0: every step)
controller_state_rate: 50.0 # Hz of `<controller_name>/controller_state` (0: every step)
command_feedforward: none # none | velocity: add the servo's velocity lag (d * qd / p) to a
# STREAMED position command, qd estimated from successive commands
# (a follow_joint_trajectory goal is fed as such a stream). Needs
# affine position servos. A real drive's own controller does not
# trail its setpoint; this servo does unless told how fast it moves.
forward_command_controller: forward_position_controller # optional: also declare ros2_control's
# forward_command_controller/ForwardCommandController under this
# name, claiming the same joints and listed only once
# `load_controller` names it (a robot that defines it but does not
# spawn it). Active, it takes `<name>/commands`, a
# std_msgs/Float64MultiArray of one position per joint.
dynamic_joint_states: false # also publish control_msgs/DynamicJointState on
# `dynamic_joint_states`: every joint's state interfaces, and those
# a driver interface adds (see "The motion gate" below)
stream_commands: false # also expose <controller_name>/joint_trajectory as a high-rate topic
# input (mirrors ros2_control's JointTrajectoryController): the path
# moveit_servo streams position targets to. Off by default.
velocity_commands: false # also accept JOINT VELOCITIES at <controller_name>/joint_velocity
# (see "Velocity commands" below). Off by default.
velocity_timeout_s: 0.5 # watchdog: a velocity command decays to zero if not refreshed within
# this window, so a dropped stream cannot leave the arm drifting.
max_velocity: 0.4 # optional: the fastest the held target moves toward a commanded
# position, in the joint's unit per second (see "Limited joints"
# below). A scalar applies to every joint; {joint: value} sets
# them apart, and a joint it does not name is not limited.
max_acceleration: 1.0 # optional: the same for the rate of that speed, unit per s^2.
trajectory_feedforward: none # none | velocity | dynamics: what an in-process trajectory
# (``ArmHandle.follow_trajectory``) adds to the position target
# (see "In-process trajectories" below). Needs affine position servos.
gripper_ctrl: 255.0 # ctrl held on any non-joint (tendon) actuator, e.g. the gripper
rest: {joint1: 0.0, ...} # {joint: angle} spawn+hold stance. Seeds BOTH the reset qpos (so the
# arm spawns in the pose) and the held target (so it stays there).
# Needed whenever the arm is carried by `spawn_robot`, which sets
# only the base pose and no joint stance -- see below.
test_target: [...] # optional joint vector held every tick (standalone demo)
gripper_controller_name: gripper_controller # action at <name>/gripper_cmd (see below)
gripper_joint: right_driver_joint # joint whose angle is the reported gripper position
gripper_open: 0.0 # gripper_joint position with the fingers open
gripper_close: 0.8 # gripper_joint position with the fingers closed
To pose the arm by hand with the viewer’s control sliders instead, run roqsim --manual-control
(a run-level switch; see roqsim.context.SimContext.manual_control).
Velocity commands (velocity_commands: true). Reactive whole-body controllers – resolved-rate
or QP redundancy resolution, e.g. Haviland et al.’s holistic mobile manipulation – emit joint
velocities, not positions. This plugin’s actuators are
position servos, so a velocity command is integrated into the held target at the physics rate:
target += qd * dt, clamped to each joint’s range. That is what a real velocity-mode driver does on
top of a position-controlled joint, and it keeps the servo’s gravity-compensated hold – a MuJoCo
<velocity> actuator would sag under gravity whenever the command is zero.
Two consequences worth knowing before using it for a metric:
The achieved profile is shaped by the servo, not only by the command. Integrating and then tracking with a stiff PD adds the actuator’s own dynamics, so end-effector acceleration is not purely the controller’s. Where acceleration is the measured quantity, verify tracking error and report the servo gains as part of the setup.
A stream that stops must stop the arm.
velocity_timeout_szeroes a stale command; without a watchdog an interrupted stream integrates the last velocity forever.
ArmHandle.set_velocities(names, velocities) is the in-process entry point; the transport endpoint is
<controller_name>/joint_velocity.
Limited joints (max_velocity / max_acceleration). Without them a position command is a
step: the servo is handed the new target at once and the joint gets there as fast as its gains and
force range allow. A hydraulic lift handed a step leaps, and a load standing on it is thrown off.
With a limit, a command sets the joint’s goal, and every pre_step moves the held target toward
it no faster than max_velocity, speeding up and slowing down at no more than max_acceleration
and slowing in time to stop exactly on the goal – a trapezoidal profile, which is what a real
drive’s limiter or a proportional valve’s flow limit does to a step. Joints without a limit take
each command at once. Nothing is limited by default: an MJCF declares no velocity limit to take one
from, so the values come from the robot’s source (a URDF’s <limit velocity=>), in its manifest
or the world, and null lifts a limit a manifest set.
The limiter belongs to the drive, not to any one command path, so every way of commanding the arm
goes through it: a follow_joint_trajectory waypoint, a streamed joint_trajectory point,
ArmHandle.set_targets (and with it a Cartesian command source), test_target, and a velocity
command, whose rate is clipped to max_velocity before it is integrated into the goal. The rest
stance and a reset are not commands: they place the arm and leave nothing in motion.
controller_state reports the held target as its reference.
Consequences worth knowing:
A single position is a complete “go there” command, which is what a limit is for.
A goal that keeps moving – an interpolated trajectory, a stream – is trailed by
v**2 / (2 * max_acceleration), the distance the target needs to be able to stop, and the target makes it up once the goal stops. A trajectory faster than the limits arrives late and is graded bygoal_time_tolerancelike any late arm.A cancelled trajectory, which the bridge ends by commanding the measured pose, brakes at
max_accelerationand comes back to that pose rather than stopping dead.A velocity stream that stops leaves the target to brake onto the integrated goal.
In-process trajectories (ArmHandle.follow_trajectory). A plugin that plans a motion – a
time-optimal profile, a strike, a recorded demonstration – hands the whole trajectory over at once:
times, positions and optionally velocities and accelerations, the fields of a
trajectory_msgs/JointTrajectory. Every pre_step samples it on simulated time
(roqsim_manipulation.trajectory.JointTrajectory: quintic between knots that carry
accelerations, cubic with velocities only, linear otherwise, as ros2_control’s controller does) and
commands the sample through the drive’s limiter like any other command. That is deterministic in a
stepped run, where the bridge’s action handler is not: it samples on simulated time too, but from a
ROS thread whose setpoints reach the physics thread through a queue, so which step one lands on
depends on scheduling.
Held after the end: when the last knot is reached, the arm holds it. A new trajectory, a
set_targets, a velocity command or a command source taking the arm ends the current one.Only while active: an inactive controller refuses a trajectory, as ros2_control refuses a goal, and deactivating the controller ends the one it is executing.
A position servo handed only the trajectory’s positions lags it: the servo’s damping acts on the
joint’s absolute velocity, so at speed the joint trails by d * qd / p, and accelerating the arm
needs an error to produce the force. trajectory_feedforward folds the missing terms into the
target (roqsim_manipulation.trajectory.servo_feedforward()):
velocityaddsd * qd / p;dynamicsadds the inverse dynamics as well, less the gravity the model compensates outside the servo.
With dynamics, a joint swept at its speed limit tracks to within a hundredth of a degree. Both
need affine position servos on unit-gear joint transmissions, and configure refuses anything else
rather than adding a wrong term.
Speed scaling (controller_type: ur_controllers/ScaledJointTrajectoryController). The UR
driver’s scaled controller advances a trajectory’s time at the robot’s speed scaling factor rather
than at one second per second, so at a factor of 0.5 the arm passes through the same path in twice
the time. The factor is read from the blackboard under speed_scaling:<entity>, a
() -> float fraction that ur_driver_interface publishes from its speed slider; without one
the factor is 1.0, as the driver’s scaled controller runs unscaled when the hardware has no scaling
interface. The scaling applies to both trajectory paths: the in-process playback above, and the
bridge’s follow_joint_trajectory handler, which reads it through
ArmHandle.trajectory_time_scale. The plain JointTrajectoryController type always runs at 1.0.
A change of factor during a trajectory takes effect from the step it is seen in; the time already
travelled is kept. fanuc_controllers/ScaledJointTrajectoryController reads it the same way, from
fanuc_driver_interface.
The motion gate. A driver interface may close the arm to motion – a robot controller that has
stopped streaming, a contact stop, a STOP request – by publishing motion_gate:<entity> on the
blackboard: a () -> str | None giving the reason while closed. On the step it closes, the arm
holds where it is, the in-process trajectory ends, and every command is ignored until it opens,
as a real robot controller ignores setpoints while motion is not possible; on opening, the arm
holds where it then is. ArmHandle.motion_blocked gives the reason, so the bridge aborts a
trajectory goal with it. The same interface may add state interfaces to dynamic_joint_states
under state_interfaces:<entity>: a () -> list[(name, {interface: value})].
The ``rest`` stance. spawn_arm supplies a per-model home that this plugin seeds its targets from. spawn_robot
does not: a robot spawn sets the base pose only, so an arm carried by a mobile base falls back to
qpos0 – all joints zero. For the Panda that is not a neutral default but an actively bad pose (its
link5 and hand collision geoms overlap by 0.030 m there), so a mobile manipulator must declare
rest in its manifest. It seeds the reset qpos and the held target, by joint name, which is
attach-safe where a model <keyframe> is not (spawn_robot strips keyframes – they cannot merge
into a composed world). Mirrors agibot_g2_controller’s rest.
If the arm has a non-joint (tendon) actuator – a parallel gripper – it also becomes commandable: the
plugin declares a control_msgs/GripperCommand action endpoint at
<gripper_controller_name>/gripper_cmd and publishes a () -> (position, velocity) reader on the
blackboard under gripper:<arm> (the bridge’s GripperCommand handler watches it to report
reached/stalled). The commanded position is the gripper_joint’s position (e.g. 0=open .. 0.8=closed
for a Robotiq 2F-85, 0.057=open .. 0.021=closed for a ViperX 300 finger slide), mapped linearly onto the
actuator’s ctrlrange. Which end of the ctrlrange is open is read from the model – the actuator’s gain
and its signed moment on that joint – so gripper_open/gripper_close are the joint’s positions
with the fingers open and closed, the two positions the ctrlrange’s ends hold it at, whichever way the
actuator runs. A gripper needs its gripper_joint, driven with a constant moment; configure fails
without one.
Grip force. Beside the position the plugin publishes a GripperEffort under
gripper_effort:<arm>, the key the endpoint’s effort_key hint names. It takes GripperCommand’s
max_effort as ros2_control’s gripper action controller does: a clamp on the gripper joint’s
effort, in that joint’s own unit – newtons for a slide jaw, newton-metres for a knuckle, the unit
/joint_states reports – which is what that controller’s effort adapter applies
(gripper_controllers/hardware_interface_adapter.hpp). A goal is never refused for its effort: a
request at or above the model’s own limit saturates there, as a drive does, and max_effort <= 0
and every reset restore the model’s own force range. The clamp reaches the actuator through the
transmission’s constant moment. A gripper actuator without a force limit keeps its range and executes
the position alone, as a position-interface controller does. Its keys are the gripper_* entries
of the Config block above.
cartesian_admittance
Controller plugin: Cartesian end-effector control for an arm, with or without force feedback.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
cartesian_admittance:
controller_type: cartesian_compliance_controller # which controller this is, and so which terms of the law are live
controller_name: "" # name its topics sit under; empty: controller_type
initial_state: active # inactive: registered holding nothing, as `spawner --inactive` leaves one
arm_controller: "" # `controller_name` of the arm_controller it commands through; needed where that controller names its `joints:`, which keys its handle by it. Empty: the arm's one controller, at `arm:<arm>`
site: tool_site # controlled site, with the arm's prefix
ft: ft # force_torque sensor key (`ft:<key>`); required by the force and compliance types
rate_hz: 100.0 # Hz; control rate, > 0
pose_rate_hz: 50.0 # Hz; publish rate of current_pose and tracking_error
target_wrench: [0, 0, -10, 0, 0, 0] # N, N m; w_d, what the TOOL applies: -10 on z presses down
mass: [1, 1, 1, 0.6, 0.6, 0.6] # kg, kg m^2; M, diagonal; every entry > 0
damping: [80, 80, 80, 160, 160, 160] # N s/m, N m s/rad; D, diagonal
stiffness: [0, 0, 0, 0, 0, 0] # N/m, N m/rad; C, diagonal; a zero axis is pure force control
axes: [1, 1, 1, 1, 1, 1] # per-axis enable mask
kp: [2, 2, 2, 2, 2, 2] # 1/s; motion type: gain on the pose error; a goal moving at v trails v / kp without feedforward
feedforward: auto # goal velocity commanded alongside the correction: auto (supplied, else estimated from the goal stream), supplied, or off
feedforward_window_s: 0.2 # s; goals further apart than this are not a stream; > 0
max_linear_vel: 0.1 # m/s; clamp on the twist's magnitude
max_angular_vel: 1.0 # rad/s; clamp on the twist's magnitude
ik_damping: 0.01 # damped-least-squares lambda
fanuc_driver_interface
A FANUC arm under the names FANUC’s ROS 2 driver gives it (fanuc_driver).
Config:
fanuc_driver_interface:
collaborative: false # true for a CRX: embedded force sensing, contact stop, collaborative
# speed scaling, payload compensation (the manifest sets it)
contact_stop_force: 150.0 # N of external force a collaborative arm stops at (FANUC publishes
# no threshold; the manifest states its assumption)
prefix: "" # the driver's prefix, for the frames it names (<prefix>fanuc_flange)
gpio_topic_config: {} # the driver's gpio yaml's block of that name: io_state, io_cmd,
# analog_io_state, analog_io_cmd, num_reg_state, num_reg_cmd
io_rate_hz: 0.0 # Hz of the GPIO and force topics (0: every control period, as the
# driver publishes them)
status_ext_rate_hz: 30.0 # Hz of robot_status_ext (the driver's 33 ms timer)
franka_fci
Plugin: a Franka Research 3 as its controller and its FCI serve it, in lock-step with the physics.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
franka_fci:
collision_behavior: <required> # required; setCollisionBehavior's thresholds; the robot's own are unpublished
bind: "" # address the FCI is served on (empty: in-process only)
port: 1337 # the FCI command port; libfranka always uses 1337
joint_impedance: <unset> # setJointImpedance's K (N m/rad); default: libfranka's examples' values
cartesian_impedance: <unset> # setCartesianImpedance's K; default: libfranka's examples' values
end_effector: <unset> # Desk's end effector: mass, com, inertia, F_T_NE
load: <unset> # an initial setLoad: mass, com, inertia
observer_gain: 200.0 # 1/s; the external-torque observer's gain (a first-order lag of 1/gain)
accel_switch: 1.0 # rad/s^2; |ddq_d| above which the 'acceleration' thresholds apply (unpublished)
tau_J_noise: 0.0 # N m; standard deviation of the joint torque sensors' noise, one or per joint
tau_J_offset: 0.0 # N m; the sensors' offset, one or per joint
client_timeout_s: 30.0 # s; wall time a client may take to answer a state before the run stops
joint_torque_control: # the robot's joint torque controller: what of the motor a torque program meets
mode: link # link: tau_J_d is the link-side torque, the robot's torque loop leaves the values below in front of the program; motor: the command acts at the motor, against the model's own armature, damping and friction loss
armature: <unset> # kg m^2; link: the rotor inertia left, one or per joint (default LINK_ARMATURE)
damping: <unset> # N m s/rad; link: the viscous damping left, one or per joint (default LINK_DAMPING)
friction: <unset> # N m; link: the Coulomb friction left, one or per joint (default LINK_FRICTION)
urdf: "" # the URDF GetRobotModel serves (default: <model>.robot_model.urdf beside the MJCF)
fzi_cartesian_controllers
Plugin: FZI’s Cartesian controllers – motion, force and compliance – with their law and parameters.
Config – a component of the arm, after its arm_controller and the force_torque it reads:
fzi_cartesian_controllers:
ft: force_torque_sensor_broadcaster # force_torque label, for force and compliance
rate_hz: 500.0 # the controller manager's update rate
robot_base_link: {body: base, yaw: 0.0}
end_effector_site: tool0_site
ft_delay_cycles: 1
controllers:
cartesian_motion_controller:
type: motion # motion | force | compliance
solver: {error_scale: 1.0, iterations: 10, forward_dynamics: {link_mass: 0.1}}
pd_gains: {trans_x: {p: 10.0}, trans_y: {p: 10.0}, trans_z: {p: 10.0},
rot_x: {p: 1.5}, rot_y: {p: 1.5}, rot_z: {p: 1.5}}
cartesian_compliance_controller:
type: compliance
compliance_ref: robot_base_link # or end_effector
stiffness: {trans_x: 2000, trans_y: 2000, trans_z: 0, rot_x: 50, rot_y: 50, rot_z: 50}
solver: {...}
pd_gains: {...}
Every controller starts inactive; a stack activates one with switch_controller. They claim the
arm’s position interfaces, so one of them, or the trajectory controller, holds the arm at a time.
spawn_arm
Scene plugin: attach a manipulator MJCF into the world – to the ground, or onto a mobile base.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
spawn_arm:
model: <required> # required; bundled model name, filename, or absolute path
namespace: "" # transport scope the arm's endpoints inherit
prefix: "" # MJCF name prefix; distinct per arm, and non-empty on a mount
base_body: <unset> # body the arm's entity is registered at; default: the model's root body
pose: <unset> # the mount, in the world or the mount body's frame: a geometry_msgs/Pose
home: <unset> # the arm's joint home pose, applied on reset; default: the model's, else its home keyframe
default_plugins: true # inject the model manifest's components, and the tool's
actuators: # the control law and gains the model's actuators run under (roqsim.actuators)
control: <unset> # the command interface this joint runs under, as a robot's driver exposes it
p: <unset> # N*m/rad (N/m on a slide joint or a tendon over slide joints); position-loop proportional gain (control: position)
d: <unset> # N*m*s/rad (N*s/m on a slide joint or a tendon over slide joints); damping/derivative gain (control: position, velocity)
stiffness: <unset> # N*m/rad (N/m on a slide joint); joint stiffness (control: impedance)
damping: <unset> # N*m*s/rad (N*s/m on a slide joint); joint damping (control: impedance)
effort_limit: <unset> # N*m (N on a slide joint); torque magnitude cap; URDF's <limit effort=>. A one-sided forcerange keeps its side
ctrlrange: <unset> # command limits, in the unit `control` commands; needed on a unit change
each: # per actuator, keyed by its name in the model (unprefixed)
<name>: # this actuator's settings, on top of the shared keys
control: <unset> # the command interface this joint runs under, as a robot's driver exposes it
p: <unset> # N*m/rad (N/m on a slide joint or a tendon over slide joints); position-loop proportional gain (control: position)
d: <unset> # N*m*s/rad (N*s/m on a slide joint or a tendon over slide joints); damping/derivative gain (control: position, velocity)
stiffness: <unset> # N*m/rad (N/m on a slide joint); joint stiffness (control: impedance)
damping: <unset> # N*m*s/rad (N*s/m on a slide joint); joint damping (control: impedance)
effort_limit: <unset> # N*m (N on a slide joint); torque magnitude cap; URDF's <limit effort=>. A one-sided forcerange keeps its side
ctrlrange: <unset> # command limits, in the unit `control` commands; needed on a unit change
gravity_compensation: <unset> # whether the drives carry the arm's weight; default: true under position, velocity and impedance, false under effort (roqsim.actuators)
pedestal: false # a static box under the base, floor to mount height; for a mount above z=0
pedestal_half_width: 0.1 # m; half-width of the pedestal's square footprint
adapter_plate: # a round plate under the base, between it and its support
diameter: <required> # required, m; the plate's diameter
height: <required> # required, m; its thickness; its top face is the pose
offset: [0.0, 0.0] # m; the plate's centre from the base origin, in the base frame (x, y)
rgba: [0.06, 0.06, 0.07, 1.0] # its colour
rail: # carry the arm on a linear axis (gantry, track)
axis: [1.0, 0.0, 0.0] # travel direction, in the mount frame (after the pose's orientation); non-zero
range: [-1.0, 1.0] # m; [min, max] travel about the pose
home: 0.0 # m; carriage position at spawn and reset
joint: rail_joint # MJCF joint name, under the arm's prefix
kp: 20000.0 # N/m; position-servo gain of the carriage
damping: 200.0 # N*s/m; carriage joint damping
mount: # weld the arm onto another entity's body, not the world
robot: <required> # required; entity name of a spawn_robot declared before this arm
body: base_link # that robot's body to weld to, under the robot's prefix
end_effector: # weld a gripper onto the arm's tool site
model: <required> # required; a gripper model (robotiq_2f85, robotiq_hande, schunk_pg70)
site: <unset> # arm site to weld it to; default: the arm manifest's end_effector.site, else attachment_site, the Menagerie flange
prefix: "" # MJCF name prefix for the gripper's own names
pose: <unset> # offset in the site's frame, a geometry_msgs/Pose like the arm's
replaces: [] # bodies of the arm model the tool supersedes, deleted first
actuators: # the control law and gains the model's actuators run under (roqsim.actuators)
control: <unset> # the command interface this joint runs under, as a robot's driver exposes it
p: <unset> # N*m/rad (N/m on a slide joint or a tendon over slide joints); position-loop proportional gain (control: position)
d: <unset> # N*m*s/rad (N*s/m on a slide joint or a tendon over slide joints); damping/derivative gain (control: position, velocity)
stiffness: <unset> # N*m/rad (N/m on a slide joint); joint stiffness (control: impedance)
damping: <unset> # N*m*s/rad (N*s/m on a slide joint); joint damping (control: impedance)
effort_limit: <unset> # N*m (N on a slide joint); torque magnitude cap; URDF's <limit effort=>. A one-sided forcerange keeps its side
ctrlrange: <unset> # command limits, in the unit `control` commands; needed on a unit change
each: # per actuator, keyed by its name in the model (unprefixed)
<name>: # this actuator's settings, on top of the shared keys
control: <unset> # the command interface this joint runs under, as a robot's driver exposes it
p: <unset> # N*m/rad (N/m on a slide joint or a tendon over slide joints); position-loop proportional gain (control: position)
d: <unset> # N*m*s/rad (N*s/m on a slide joint or a tendon over slide joints); damping/derivative gain (control: position, velocity)
stiffness: <unset> # N*m/rad (N/m on a slide joint); joint stiffness (control: impedance)
damping: <unset> # N*m*s/rad (N*s/m on a slide joint); joint damping (control: impedance)
effort_limit: <unset> # N*m (N on a slide joint); torque magnitude cap; URDF's <limit effort=>. A one-sided forcerange keeps its side
ctrlrange: <unset> # command limits, in the unit `control` commands; needed on a unit change
ur_driver_interface
Plugin: the parts of ur_robot_driver’s ROS interface a simulated UR arm has no other source for.
Config – a component of the entry that spawns the arm, AFTER the force_torque entry it names:
ur_driver_interface:
ft: force_torque_sensor_broadcaster # REQUIRED: label of the force_torque entry zero_ftsensor tares
rate_hz: 100.0 # speed_scaling publish rate (the driver's default)
ur_rtde
Plugin: a simulated UR arm driven through the ur_rtde client API, in lock-step with the physics.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
ur_rtde:
ft: <required> # required; label of the force_torque entry, reporting in the world frame
ft_site: fts_site # the site that sensor measures at (prefixed)
flange_site: tool0_site # the tool flange: the TCP offset's origin
base: {"body": "base", "yaw": 3.141592653589793} # the controller's base frame: a body (prefixed) turned by yaw (rad) about its z
rate_hz: 500.0 # Hz; the control cycle
command_delay_s: 0.002 # s; how long after the state it was computed from a command acts
tcp_force_measures: environment_on_tool # which force getActualTCPForce reports
ik_damping: 0.01 # damped least-squares lambda
line_gain: 50.0 # 1/s; moveL's closure on its profile
client_timeout_s: 120.0 # s; wall seconds the physics waits for a program that holds the turn
roqsim_mobile
ackermann_drive
Controller plugin: Ackermann (car-like) steering + wheel-encoder odometry.
Config:
ackermann_drive:
wheel_radius: 0.05
wheelbase: 0.32 # front axle to rear axle -- what turns a curvature into an angle
track: 0.24 # driven axle width, for the drive split (and the default below)
steer_track: 0.24 # steering-axis (kingpin) separation, for the steer split
max_linear_vel: 2.0
max_steer_angle: 0.5 # rad; the rack's mechanical limit, and the turning circle with it
steer_rate: 4.0 # rad/s slew on the steering angle (0 = instant)
accel_limit: 2.0 # m/s^2 on the commanded speed (0 = instant)
decel_limit: 2.0 # m/s^2 taking speed off; default accel_limit
steer_actuators: [left_steer_motor, right_steer_motor] # POSITION servos, left then right
steer_joints: [left_steer_joint, right_steer_joint]
drive_actuators: [rear_left_motor, rear_right_motor] # VELOCITY servos, left then right
drive_joints: [rear_left_joint, rear_right_joint]
base_body: "" # body the wheel axes are expressed in (default: the root)
odom_child_frame: base_link # link the odometry TF points at (see below)
stamped_cmd_vel: false # true when the stack publishes TwistStamped (see below)
cmd_vel_timeout: 0.0 # s; > 0 stops the car when no command arrives for this long
test_cmd: [1.0, 0.4] # optional [v, w] applied every tick (standalone demo)
stamped_cmd_vel selects geometry_msgs/TwistStamped instead of geometry_msgs/Twist
for the velocity command. Which of the two a stack publishes is a property of that stack, not of
the kinematics: Nav2 switches with its own enable_stamped_cmd_vel (the TurtleBot 4’s shipped
configuration sets it), and ROS 2 is moving towards the stamped form. A subscription is one type,
so a mismatch is not a degradation but silence – the robot receives no command at all, and the
only symptom is a controller reporting that it cannot make progress.
cmd_vel_timeout is the watchdog every real base driver has, as on diff_drive: a command is
good for this long and then the car stops, so a stack that dies mid-run leaves a stationary car
rather than one driving at its last velocity into a wall. Off (0) by default, because an in-process
driver that sets a twist once and steps expects it to hold. The stop goes through the same
acceleration ramp as any command, and the rack holds its angle, as it does on any stop.
odom_child_frame names the link the odom -> transform points at, and it must be the ROOT of
whatever URDF robot_state_publisher is running beside the simulator: a description rooted at
base_footprint already gives base_link a parent, and a second parent from here leaves that
frame with two, which tf2 cannot resolve.
Endpoints are the ones every base here publishes, so a stack does not know which geometry it is
driving until it tries to turn in place: cmd_vel in (geometry_msgs/Twist), odom out with
TF, and joint_states out carrying the steer joints as well as the driven ones – a car’s
steering angle is state a stack watches, and leaving it out is how a URDF’s front wheels stay
straight in RViz while the robot corners.
Odometry is what the encoders say, as in diff_drive: the driven wheels’ measured speed for
v, and the measured steering angle for the yaw rate through the same bicycle relation
(w = v * tan(delta) / L). Reading back the commanded angle instead would report a car that
corners perfectly while the rack is still slewing.
It is therefore dead reckoning and it drifts, which is deliberate. On a straight run the test
vehicle’s odometry lands within a few percent; cornering, the tyres slip and the bicycle relation
under-reports the turn – measured, a car that came round 1.1 rad believes it came round 0.8. No
scrub factor is offered to hide it: unlike a skid-steer’s, whose scrub is systematic enough for
diff_drive’s slip_factor to correct, a tyre’s slip angle varies with speed and load, so a
single constant would be a fudge that makes the odometry look better than the sensor it stands for.
The true pose (roqsim.entity_pose, and the run’s recording) is what a grader compares
against, and the gap between the two is what a localisation experiment is about.
diff_drive
Controller plugin: differential-drive kinematics + wheel-encoder odometry.
Config – a component of the entry that spawns the base, since ownership is where the entry sits rather than a config key:
diff_drive:
namespace: "" # transport scope (default: inherited from spawn_robot's namespace)
wheel_radius: 0.03575
wheel_separation: 0.233
max_linear_vel: 0.31
max_angular_vel: 1.90
wheel_accel_limit: 0.9 # m/s^2 per wheel; ramps commands (Create 3 default/max 900 mm/s^2)
left_actuator: left_wheel_motor
right_actuator: right_wheel_motor
left_joint: left_wheel_joint
right_joint: right_wheel_joint
left_actuators: [] # skid-steer: every left wheel's actuator, instead of left_actuator
right_actuators: [] # likewise for the right side (see below)
left_joints: [] # skid-steer: every left wheel's joint, instead of left_joint
right_joints: [] # likewise for the right side
slip_factor: 1.0 # skid-steer ICR slip compensation (1.0 = ideal diff-drive)
base_body: "" # body the wheel axes are expressed in (default: the robot's root)
odom_child_frame: base_link # frame the odometry TF points at (see below)
odom_rate_hz: 50.0 # publish rate of odom (and its TF) and joint_states
stamped_cmd_vel: false # true when the stack publishes TwistStamped (see below)
cmd_vel_timeout: 0.0 # s; > 0 stops the base when no command arrives for this long
publish_joint_states: true # false when a joint_state_publisher covers the whole robot
test_cmd: [0.15, 0.4] # optional [v, w] applied every tick (standalone demo)
odom_noise: # optional odometry error (see below); omitted = exact odometry
linear_stddev: 0.0 # m/s, white noise on the reported linear velocity
angular_stddev: 0.0 # rad/s, white noise on the reported yaw rate
linear_scale: 1.0 # multiplicative bias (e.g. a wheel radius off by 1 %)
angular_scale: 1.0 # multiplicative bias on the yaw rate (e.g. an effective track error)
Skid-steer (>1 wheel per side, e.g. Husky A200): give the per-side actuator/joint lists instead of
the singular keys; every left wheel gets the same command, every right wheel the same, and odometry
averages each side’s wheel velocities. slip_factor compensates the lateral scrub of a skid-steer
(see below):
diff_drive:
wheel_radius: 0.17775
wheel_separation: 0.5708 # track width
slip_factor: 4.0 # ICR slip compensation (1.0 = ideal diff-drive)
left_actuators: [front_left_wheel_motor, rear_left_wheel_motor]
right_actuators: [front_right_wheel_motor, rear_right_wheel_motor]
left_joints: [front_left_wheel_joint, rear_left_wheel_joint]
right_joints: [front_right_wheel_joint, rear_right_wheel_joint]
stamped_cmd_vel selects geometry_msgs/TwistStamped instead of geometry_msgs/Twist
for the velocity command. Which of the two a stack publishes is a property of that stack, not of
the kinematics: Nav2 switches with its own enable_stamped_cmd_vel (the TurtleBot 4’s shipped
configuration sets it), and ROS 2 is moving towards the stamped form. A subscription is one type,
so a mismatch would be not a degradation but silence – no command arrives and nothing logs it –
which is why the ROS bridge fails the run when a peer of another type sits on one of its topics,
naming the topic, both types and both sides.
cmd_vel_timeout is the watchdog every real base driver has: a command is good for this long
and then the base stops, so a stack that dies mid-run leaves a stationary robot rather than one
driving at its last velocity into a wall. ros2_control’s diff_drive_controller ships it at
0.5 s and the Create 3’s firmware behaves the same. It is off by default here, because an in-process
driver that sets a twist once and steps expects it to hold; a world that runs a real stack sets it
to that stack’s value. The stop goes through the same acceleration ramp as any command.
publish_joint_states switches this plugin’s own joint_states (the wheel joints) off, for a
robot whose joint_state_publisher publishes every joint in one message – a consumer that needs
a suspension travel in the same message as the wheels must not get two messages on one topic that
each carry half.
odom_child_frame names the link the odom -> transform points at, and it must be the ROOT
of whatever URDF robot_state_publisher is running: a robot_state_publisher rooted at
base_footprint (every published TurtleBot 3 description) already gives base_link a parent,
and a second parent from here leaves the frame with two, which tf2 cannot resolve. Robots whose
description is rooted at base_link (TurtleBot 4) keep the default.
slip_factor exists because a 4-wheel skid-steer turns by scrubbing its wheels sideways: with
MuJoCo point contacts the base yaws at only ~15% of the ideal differential-drive prediction, which
would leave a planner unable to rotate. The factor inflates the yaw term of the wheel command and is
divided back out of odometry, so commanded yaw is achieved and odometry stays consistent with the
base’s real motion. It is a per-robot calibration against the model’s contact/friction setup –
re-measure it (achieved vs commanded yaw rate) if wheel friction, mass, or the timestep change.
odom_noise makes the odometry wrong the way real wheel odometry is wrong, and leaves the robot’s
motion alone. The error is applied to the velocities read off the wheels, before they are integrated,
so the reported pose drifts rather than jitters: a linear_scale of 1.01 is a wheel radius stated
1 % too small and overstates every metre by a centimetre, and the *_stddev terms are zero-mean
white noise on each reading, drawn per physics step. A white velocity error integrates to a random
walk, so the pose spread grows with the square root of the distance driven and shrinks with the
timestep; state the stddev together with the world’s sim.timestep. Everything downstream that
consumes odometry sees it – the odom endpoint, its TF, the RobotHandle – and nothing that
reports the truth does: the body’s pose, the recording’s poses channel and a ground-truth pose plugin are exact.
Draws come from ctx.rng_for (docs/architecture.rst §9.1), so a noisy run needs a seed and
reproduces from it; with the block omitted nothing is drawn and the odometry is exact.
floorplan
Flags: provides_world
Scene plugin: a floorplan as the world – ground plane, light and walls, from a mesh or from wall segments.
Config:
floorplan:
# --- one of these two sources ---
mesh: <path> # floorplan mesh (.stl); absolute, or relative to the process cwd
mesh_scale: 1.0 # mesh only: float or [x, y, z]
mesh_pos: [0, 0, 0] # mesh only: placement offset in the world frame
# ...or the layout instead, in the floorplan JSON's own vocabulary:
floorplan: rooms.json # what `roqsim scenes dxf-to-floorplan` and the sketch window write
lines: # ...or the segments inline
- {id: 0, x0_m: 0.0, y0_m: 0.0, x1_m: 6.0, y1_m: 0.0}
doors: [{line_id: 0, t: 0.5, width_m: 0.9}] # t is 0..1 along that wall
height: 2.5 # segments only: ceiling height (m)
thickness: 0.12 # segments only: wall thickness (m)
opening_height: 2.0 # segments only: door height; the wall above one becomes a lintel
# --- the rest applies to both ---
floor: # ground-plane appearance + physics (all keys optional; default = light gray)
rgb1: [0.85, 0.85, 0.85] # builtin-checker colour A (0..1 RGB)
rgb2: [0.78, 0.78, 0.79] # builtin-checker colour B
reflectance: 0.2 # 0..1; if omitted, a texture's manifest value (else 0.2) is used
texture: null # PNG image; overrides rgb1/rgb2 when set. A package-qualified
# name ('roqsim_assets:Concrete030') or a PNG path
# (absolute / cwd-relative). MuJoCo loads PNG only.
rgba: null # optional multiplicative tint on the texture/checker (like
# Poly Haven's base colour). RGB >1 brightens (not clamped
# to 1); e.g. [2.2, 2.2, 2.2, 1] = much brighter.
physical_size: 1.8 # metres one tile spans (real-world scale); scalar or [x, y].
# If omitted, a texture's manifest value (else 1.0) is used.
friction: [2.0, 0.005, 0.0001] # geom contact friction [sliding, torsional, rolling]
wall: # floorplan-mesh appearance (same keys as 'floor' minus friction; default = gray)
rgb1: [0.8, 0.8, 0.82] # solid colour when rgb1 == rgb2 (the default)
rgb2: [0.8, 0.8, 0.82]
reflectance: 0.0
texture: null # PNG image (see 'floor.texture'), applied to the wall mesh.
rgba: null # optional tint (see 'floor.rgba')
physical_size: 2.4 # metres one tile spans. Honoured for both a UV-less .stl (via
# texuniform) and a UV'd .obj (its UVs are scaled to match).
light: # a single overhead light at the floorplan centre + a global ambient
height: 2.5 # metres above the floor for the light; by default 0.15 m under
# the walls' top when it would be at it (their tops then flicker)
diffuse: [0.35, 0.35, 0.35] # light colour/intensity (flat across the cone)
cutoff: 90.0 # spot half-angle (deg); 90 = hemisphere, no visible cone edge
fill: [0.3, 0.3, 0.3] # uniform global ambient (not a light); [0, 0, 0] disables it
Textures are resolved via roqsim.textures.resolve_texture(): a package-qualified
<package>:<name> (e.g. roqsim_assets:Concrete030, from the shared roqsim_assets)
or a PNG path – no cross-package name search. A texture folder may carry a manifest.yaml (next to
the PNG) with surface properties – reflectance and physical_size – used when the world does
not set the matching <floor|wall> key explicitly. When no manifest exists, the defaults are used.
omni_drive
Controller plugin: holonomic (omnidirectional) base kinematics + odometry.
Config – a component of the entry that spawns the base, since ownership is where the entry sits rather than a config key:
omni_drive:
namespace: "" # transport scope (default: inherited from spawn_robot)
base_joint: base_free # the base's free joint
base_body: "" # body the wheel axes are expressed in (default: the robot's root)
vx_actuator: base_vx # planar drive actuators (see "Planar drive" below)
vy_actuator: base_vy
wz_actuator: base_wz
max_linear_vel: 1.0 # m/s, applies to vx
max_lateral_vel: 1.0 # m/s, applies to vy (defaults to max_linear_vel)
max_combined_linear_vel: 0.7 # m/s, cap on hypot(vx, vy); 0 disables
max_angular_vel: 2.09 # rad/s
accel_limit: 1.0 # m/s^2, ramps vx and vy
angular_accel_limit: 2.09 # rad/s^2, ramps wz
# Mecanum wheels: OBSERVATIONAL only (see "Wheels" below). Omit to skip wheel handling.
wheel_radius: 0.0762
wheel_separation: 0.44715 # lateral, left <-> right
axis_separation: 0.488 # longitudinal, front <-> rear
wheels: [front_left, front_right, rear_left, rear_right] # joint name stems
wheel_actuators: [...] # same order; defaults to <stem>_motor
# SWERVE bases only: give the steer joints and their POSITION actuators, same order as
# `wheels`. Their presence is what selects swerve inverse kinematics over mecanum.
steer_joints: [...]
steer_actuators: [...]
odom_child_frame: base_footprint # link the odometry TF points at (see below)
stamped_cmd_vel: false # true when the stack publishes TwistStamped (see below)
cmd_vel_timeout: 0.0 # s; > 0 stops the base when no command arrives for this long
test_cmd: [0.2, 0.1, 0.0] # optional [vx, vy, wz] applied every tick (standalone demo)
stamped_cmd_vel selects geometry_msgs/TwistStamped instead of geometry_msgs/Twist
for the velocity command. Which of the two a stack publishes is a property of that stack, not of
the kinematics: Nav2 switches with its own enable_stamped_cmd_vel (the TurtleBot 4’s shipped
configuration sets it), and ROS 2 is moving towards the stamped form. A subscription is one type,
so a mismatch would be not a degradation but silence – no command arrives and nothing logs it –
which is why the ROS bridge fails the run when a peer of another type sits on one of its topics,
naming the topic, both types and both sides.
cmd_vel_timeout is the watchdog every real base driver has, as on diff_drive: a command is
good for this long and then the base stops, so a stack that dies mid-run leaves a stationary robot
rather than one driving at its last velocity into a wall. Off (0) by default, because an in-process
driver that sets a twist once and steps expects it to hold. The stop goes through the same
acceleration ramp as any command.
odom_child_frame names the link the odom -> transform points at, and it must be the ROOT of
whatever URDF robot_state_publisher is running beside the simulator: a description rooted at
base_footprint already gives base_link a parent, and a second parent from here leaves that
frame with two, which tf2 cannot resolve.
Planar drive. A real omnidirectional base translates sideways because each mecanum wheel’s passive rollers let the
contact patch slide along one diagonal. Those rollers are not modelled (~9 per wheel would mean
~36 extra bodies and as many contact pairs, and MuJoCo’s cylinder-on-plane contact frame is not
roller-aligned, so anisotropic friction is not a reliable substitute). Instead the commanded twist is
applied to the base’s free joint through three velocity actuators, and the wheels are near-frictionless
load carriers – which is what an omni wheel is, in the directions that matter. This is the approach
PAL themselves sketched: base_x / base_y / base_tau velocity actuators on the floating
base, commented out in omni_base_description/mujoco/mj_tags.xacro.
The drive stays inside MuJoCo’s force path rather than writing qvel directly, so contacts still
win: a wall stops the base, and it cannot be shoved through thin geometry.
Frames. A free joint’s translational DOFs are expressed in the world frame and its rotational
DOFs in the body frame (both verified against MuJoCo 3.11), and gear inherits that. So the
body-frame vx/vy command is rotated by the base yaw before it is written to ctrl, while
wz needs no rotation. Getting this wrong yields a base that drives correctly only while its
heading is zero – which a straight-line test would not catch.
Swerve. A steerable-wheel base is holonomic like a mecanum one, so the planar drive above is
unchanged: what differs is only how the wheels are told to follow. Given steer_joints and
steer_actuators, each corner’s contact velocity is computed from the body twist
(v_k = v + w x r_k), the steer actuator is commanded to atan2 of it and the roll actuator to
its magnitude over the wheel radius. The steer target is resolved to whichever of the two equivalent
headings (theta, theta+pi) is nearer the joint’s current angle, negating the roll rate for the flipped
one – without that a command crossing straight-ahead makes every wheel slew half a turn, which looks
like a violent glitch and is purely an artefact of the branch cut.
Like the mecanum case this is observational: the wheels are not the motive force. The difference is that a swerve base’s steering is visible and physically meaningful, so getting it right matters for anything reading joint_states or watching the robot – but a paper measuring the steer joints themselves (their rate limits, or the reorientation delay at a direction change) needs real steer actuation, which this is not.
Wheels. The wheel velocity servos are driven from the mecanum inverse kinematics purely so that the visual
and joint_states are right (the wheels turn, and turn differently when strafing). They are not
the motive force: at the model’s wheel friction they transmit almost nothing. Each wheel’s roll sign
is derived from its joint axis in the base frame at configure time rather than hardcoded, because
which way “positive” spins depends on how the source URDF mirrored that wheel.
Odometry. Integrated from the base’s achieved twist, in the odom frame – the pose the base
was spawned at, as diff_drive reports it – so a base held against a wall reports no progress.
Note the consequence: with no wheel slip in the model, wheel-encoder odometry and ground truth
coincide by construction. This port therefore cannot be used to study odometry drift – a
skid-steer’s characteristic error source is absent here by design, not by accident.
spawn_robot
Scene plugin: attach a robot MJCF into the world and own its base spawn pose.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
spawn_robot:
model: <required> # required; bundled model name, filename, or absolute path
namespace: "" # transport scope the robot's endpoints inherit
prefix: "" # MJCF name prefix; distinct per robot
pose: <unset> # spawn pose, as SpawnEntity's initial_pose (roqsim.pose)
base_joint: base_free # free joint used to place the base
actuators: # the control law and gains the model's actuators run under (roqsim.actuators)
control: <unset> # the command interface this joint runs under, as a robot's driver exposes it
p: <unset> # N*m/rad (N/m on a slide joint or a tendon over slide joints); position-loop proportional gain (control: position)
d: <unset> # N*m*s/rad (N*s/m on a slide joint or a tendon over slide joints); damping/derivative gain (control: position, velocity)
stiffness: <unset> # N*m/rad (N/m on a slide joint); joint stiffness (control: impedance)
damping: <unset> # N*m*s/rad (N*s/m on a slide joint); joint damping (control: impedance)
effort_limit: <unset> # N*m (N on a slide joint); torque magnitude cap; URDF's <limit effort=>. A one-sided forcerange keeps its side
ctrlrange: <unset> # command limits, in the unit `control` commands; needed on a unit change
each: # per actuator, keyed by its name in the model (unprefixed)
<name>: # this actuator's settings, on top of the shared keys
control: <unset> # the command interface this joint runs under, as a robot's driver exposes it
p: <unset> # N*m/rad (N/m on a slide joint or a tendon over slide joints); position-loop proportional gain (control: position)
d: <unset> # N*m*s/rad (N*s/m on a slide joint or a tendon over slide joints); damping/derivative gain (control: position, velocity)
stiffness: <unset> # N*m/rad (N/m on a slide joint); joint stiffness (control: impedance)
damping: <unset> # N*m*s/rad (N*s/m on a slide joint); joint damping (control: impedance)
effort_limit: <unset> # N*m (N on a slide joint); torque magnitude cap; URDF's <limit effort=>. A one-sided forcerange keeps its side
ctrlrange: <unset> # command limits, in the unit `control` commands; needed on a unit change
gravity_compensation: true # false: no drive supplies a gravity term (roqsim.actuators)
present: true # false: compiled in, absent until spawned
frames: <unset> # fixed links beyond the manifest's own (roqsim.frames)
default_plugins: true # inject the model manifest's components
tricycle_drive
Controller plugin: tricycle kinematics – one steered wheel and a fixed axle – plus odometry.
Config:
tricycle_drive:
drive: axle # axle | steer_wheel -- which wheels the motors turn
steer_offset: -1.39 # m; x of the steering axis from base_link, < 0 = rear
wheel_radius: 0.23 # driven axle wheels (drive: axle)
track: 0.93 # driven axle width (drive: axle)
steer_wheel_radius: 0.18 # the steered wheel (drive: steer_wheel)
max_linear_vel: 2.0 # m/s at base_link
max_wheel_speed: 2.0 # m/s at any driven tread; default max_linear_vel
max_steer_angle: 1.2 # rad, < pi/2; the mechanical lock
steer_rate: 1.5 # rad/s slew on the steering angle (0 = instant)
accel_limit: 1.0 # m/s^2 on the commanded speed (0 = instant)
decel_limit: 1.0 # m/s^2 taking speed off; default accel_limit
steer_actuator: steer_motor # POSITION servo
steer_joint: steer_joint
drive_actuators: [left_motor, right_motor] # VELOCITY servos; left then right for `axle`,
drive_joints: [left_wheel, right_wheel] # the one steered wheel for `steer_wheel`
passive_joints: [steer_wheel_joint] # published in joint_states, never commanded
base_body: "" # body the geometry is read in (default: the robot's root)
odom_child_frame: base_link
odom_rate_hz: 50.0
cmd_vel_timeout: 0.0 # s; > 0 stops the vehicle when no command arrives for this long
publish_joint_states: true
stamped_cmd_vel: false # true when the stack publishes TwistStamped
test_cmd: [1.0, 0.3] # optional [v, w] applied every tick (standalone demo)
steer_offset and track are checked against the model at configure: the steering joint’s
anchor and the two axle wheels’ anchors, expressed in base_body, must agree with them to within a
centimetre, and the steering axis must be vertical. A kinematic model that disagrees with its vehicle
turns about the wrong point, so the disagreement is refused by name.
passive_joints are joints nothing actuates but a URDF names, such as the steered wheel’s roll on
an axle-driven truck. robot_state_publisher publishes a link’s transform only once it has a state
for the joint above it, so a joint left out here leaves that wheel’s frame missing from TF.
Endpoints are the siblings’, declared on typed methods: cmd_vel in (a Twist; the ROS bridge
carries it as geometry_msgs/Twist, or TwistStamped with stamped_cmd_vel), odom out
(an Odometry) with its TF to odom_child_frame, and joint_states out (a JointState,
off with publish_joint_states: false) at odom_rate_hz. joint_states carries the steering
joint first, then the driven joints, then the passive ones.
Odometry is what the encoders say. drive: axle takes the speed from the mean of the two
driven wheels and the yaw rate from the measured steering angle, w = v * tan(delta) / a;
drive: steer_wheel splits the wheel’s own speed s into v = s * cos(delta) and
w = s * sin(delta) / a. It is dead reckoning and drifts where the tyres slip, uncorrected for the
reason ackermann_drive gives: a tyre’s slip angle varies with speed and load, so a constant would
make the estimate look better than the sensor it stands for.
roqsim_motion
humanoid
A humanoid’s moves (see the module docstring).
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
humanoid:
home: <unset> # where an actuator or setpoint stands at the start of a run and after a reset, over the class's HOME
on_error: raise # a program that raises: raise (stop the run, naming it) or report (its error in status())
graspable: [] # entities whose grip sites the hands may hold (fnmatch)
hold: # how hard a hold may pull and how far it may slip
max_force: 300.0 # N; a hold lets go past this
slip: 0.06 # m; a hold lets go when its frames part this far
solref: [0.02, 1.0] # the hold's (timeconst, dampratio)
press: # how hard a press may push
max_force: 40.0 # N; a press's force at most
roqsim_nav
navigator
Controller plugin: move an entity along a route, inside the simulator.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
navigator:
output: auto # auto | drive | mocap | walker | module:Class
speed: <required> # required, m/s; 0: does not move
goals: [] # m; the route: [x, y] or [x, y, yaw] each
dwell: 0.0 # s; pause on reaching a point: s, [lo, hi], or one per route point, start included
route_mode: plan # exact: no planner
tracker: waypoint
lookahead: 0.6 # m; pure_pursuit carrot distance
autostart: true # false: hold at the start until started
loop: false # cycle the route forever
arrival_radius: 0.25 # m; a goal counts as reached
avoidance: # what it does about the unplanned
stop: true # look ahead and hold until the way is clear
steer: none # none | give_way | orca | module:Class: which model gives way
reroute: false # plan around what stopped it; needs stop
params: {} # the steer model's world-level keys
agent_radius: <unset> # m; its disc to the avoidance model; default: its embodiment's, else radius
sidestep: # steer none, stop: steps aside round what stands in its way, and back; default: off, or what its embodiment declares; false: off, whatever that declares
max: 1.0 # m; how far from its route it may go
onset: 2.2 # m; steps aside this far before what is in its way
back: 4.85 # m; is back on its route this far after it
clearance: 0.24 # m; the gap it keeps from what it passes
lookahead: 1.2 # m; clear corridor needed, from the front
width: 0.6 # m; corridor ahead: the body plus its clearance
horizon: 0.0 # s; reach: max(lookahead, horizon x speed); 0: lookahead
decel: 0.0 # m/s^2; speed follows the gap ahead; 0: hold at once
stop_gap: 0.3 # m; with decel: stands this short of what stands or goes along
wait_gap: <unset> # m; with decel: short of a mover crossing; default: stop_gap
tau: 0.0 # s; after a hold, speed rises with this; 0: at once
clear_time: 0.5 # s; the way stays open this long to go on
yield_time: 3.0 # s; a blockage is traffic this long before recovery may run
forget_after: 5.0 # s; a remembered blockage steers the planner this long
blockage_radius: <unset> # m; disc a blockage marks; default: half the corridor width
ignore: [] # entities this mover never stops for
margin: 0.0 # m; with decel: a crosser passes no nearer, as predicted, or it slows to let it go first
perception: # it meets only what it sees; default: everything, or what its embodiment declares; false: everything, whatever that declares
eye_height: 1.6 # m; above its body's bottom
fov: 75.0 # deg; to each side
memory: 4.0 # s; what went out of sight is kept
reaction: 0.4 # s; in sight this long to count
params: {} # this mover's own keys for the steer model
radius: <unset> # m; footprint; default: measured
max_speed: <unset> # m/s; cap for avoidance; default: max(1, 2 * speed)
kinematics: auto # drive: the base's law
heading_gain: 2.0 # 1/s; drive: yaw rate per rad error
max_angular_vel: 1.5 # rad/s; drive: yaw rate cap
turn_in_place: 0.8 # rad; drive, unicycle: pivot above this heading error
min_speed: 0.15 # m/s; drive, ackermann: speed floor
face: travel # drive, holonomic
yaw_rate: 3.0 # rad/s; mocap: re-facing rate; 0 snaps
obstacle_height: [0.1, 1.8] # m; z band a geom spans to be a wall
resolution: 0.05 # m; planner grid cell
planner: # the path between the route's points
inflation_radius: <unset> # m; wall inflation; default: the mover's footprint radius
waypoint_radius: 0.3 # m; a path waypoint counts as reached
recovery: # backing away when wedged
enabled: true # back away and re-plan when wedged
stuck_time: 1.5 # s; window progress is measured over
stuck_eps: 0.1 # m; less progress than this is stuck; for a mover whose speed covers less: half of that
backup_time: 0.5 # s; how long it backs away
backup_speed: 0.4 # m/s; speed it backs away at
max_recovery: 4 # recoveries before it gives up on a goal
update_hz: <unset> # Hz; nav rate; default: the output's, else 20
goal_endpoint: true # false: declares no goal endpoint
actions: <unset> # actions served; default: all
action_names: # the name each action is served under
navigate_to_pose: navigate_to_pose # the action's name
navigate_through_poses: navigate_through_poses # the action's name
start_route: start_route # the action's name
roqsim_quadruped
spot_locomotion
Controller plugin: RL flat-terrain walking policy for the Boston Dynamics Spot (12-DoF quadruped).
Config – a component of the entry that spawns the robot, since ownership is where the entry sits rather than a config key:
spot_locomotion:
namespace: "" # transport scope (default: inherited from spawn_robot's namespace)
policy_path: <fetched> # TorchScript policy (default: $SPOT_POLICY_PATH or policy/spot_policy.pt)
config_path: <bundled> # deploy config (default: policy/spot.yaml)
max_linear_vel: 1.5 # |vx| clamp (m/s)
max_lateral_vel: 0.8 # |vy| clamp (m/s)
max_angular_vel: 1.5 # |yaw_rate| clamp (rad/s)
cmd_vel_timeout: 0.0 # s; > 0 stops the robot when no command arrives for this long
test_cmd: [0.5, 0.0, 0.0] # optional [vx, vy, w] applied every tick (standalone demo)
joint_velocity_limits: {} # rad/s by MJCF joint name: no position target moves faster
joint_names: {} # the name joint_states publishes each joint under, by MJCF name
# ({fl_hx: front_left_hip_x, ...}); unlisted joints keep theirs
joint_velocity_limits bounds the command, not the joint: each physics step the position target
written to a joint’s actuator moves towards the policy’s by at most limit * timestep, so the
plugin never asks a leg for more speed than its motor has. MuJoCo has no joint velocity limit, so a
joint the PD loop or a contact accelerates can still exceed it. The model’s manifest sets the
description’s limits.
joint_names renames the joints where they leave the plugin, nowhere else: the policy, the MJCF
and every other reader keep the MJCF names. It is how a world publishes the names another driver
uses – spot_ros2’s front_left_hip_x … rear_right_knee, for one, as
ros2_ws/src/roqsim_nav2_example/worlds/spot_ros2_interface.yaml does.
roqsim_sensors
fiducial_marker
Scene plugin: add an ArUco / AprilTag fiducial marker to the world or onto a robot body.
Config:
fiducial_marker:
family: apriltag_36h11 # apriltag_36h11 | apriltag_25h9 | aruco_4x4_50 | aruco_5x5_100 | ...
id: 0 # marker id within the family
size: 0.05 # side of the BLACK marker square (m) -- the length a detector estimates
quiet_zone: 0.15 # white margin around the tag, as a fraction of `size` (default 0.15)
emission: 0.0 # material emission; RAISE ONLY FOR VISIBILITY, NOT FOR DETECTION (see below)
thickness: 0.002 # box half-thickness behind the marker face (m)
vflip: false # flip the texture rows / cols if the render comes out mirrored
hflip: false # (a mirrored tag will NOT decode)
pose: # the marker centre, in the world or in the `attach_to` body's frame:
position: {x: 0.0, y: 0.0, z: 0.0} # a geometry_msgs/Pose, omitted components 0
orientation: {roll: 0.0, pitch: 0.0, yaw: 0.0} # or a quaternion; none faces +Z (up)
attach_to: wrist_3_link # OPTIONAL: weld to this body (without prefix) instead of the world
prefix: "ur10e_" # target robot/arm MJCF prefix (matches spawn_robot/spawn_arm `prefix`);
# inherited automatically when this plugin ships in a model manifest
The texture, material and geom this builds are named after the entry’s label (its name:
sibling, else fiducial_marker), so a world carrying several markers gives each entry a label.
force_limit
Observation plugin: stop when a measured wrench exceeds what the task allows.
Config – a component of the entity whose wrench is watched:
force_limit:
ft: ft # blackboard key suffix of the force_torque sensor (`ft:<key>`)
max_force: 40.0 # N; magnitude of the measured force, 0 disables
max_torque: 0.0 # Nm; magnitude of the measured torque, 0 disables
settle_s: 0.0 # ignore the first seconds, while a reset transient decays
latch: true # once tripped, stay tripped until reset (a trial is failed, not un-failed)
stop_run: true # end a standalone `roqsim sim` run, as a real stop ends the motion;
# a scenario ends its own run, on this plugin's `tripped`
release_controllers: true # deactivate the controllers driving the arm, the way a stop does
reports_as: protective_stop # the word this robot's own interface uses
rate_hz: 30.0
Endpoint force_limit (out) reads a LimitReport:
(tripped, reason, at_time, force, torque) – at_time is the simulation time of the first
trip (-1.0 if none) and force/torque are the magnitudes that caused it, so a failure is
attributable rather than merely flagged. ROS carries tripped alone, a std_msgs/Bool on
force_limit. A world compiled to look at it (ctx.preview) reports a trip the same way and
neither releases the controllers nor stops the run.
force_torque
Flags: parallel_safe
Sensor plugin: a six-axis force/torque sensor at a site.
Config – a component of the entry that spawns the arm whose prefix and namespace it inherits, since ownership is where the entry sits rather than a config key:
force_torque:
site: fts_site # REQUIRED: MJCF site to measure at (prefixed with the arm's prefix)
frame: base # sensor | base | world -- the frame the wrench is REPORTED in
invert: true # negate the reading (report the force the ENVIRONMENT applies to the
# tool, the sign convention a real FT sensor and its users assume;
# MuJoCo's site sensor reports the opposite). Whichever is chosen,
# the blackboard reader says which it is in `measures`, so a
# consumer never has to assume.
tare_at_s: null # sim time (s) at which to capture the zero offset, once per
# run; null (default) never tares. The `tare` service and
# `WrenchReader.tare()` are the better doors -- see "Taring"
# below, and note the offset is only valid at the pose it was
# captured at.
noise_force_stddev: 0.0 # N, additive Gaussian white noise on the three force channels
noise_torque_stddev: 0.0 # Nm, likewise on the three torque channels
bias_force: 0.0 # N, bound of a per-run zero offset, uniform per channel
bias_torque: 0.0 # Nm, likewise
drift_force: 0.0 # N/s, bound of a per-run linear drift rate, uniform per channel
drift_torque: 0.0 # Nm/s, likewise
range_force: null # N, the measuring range: each force channel saturates at +-range
range_torque: null # Nm, likewise for torque; null (default) never saturates
rate_hz: 100.0 # endpoint publish rate
namespace: "" # transport scope (default: inherited from the entity)
topics: {wrench: /ft} # optional absolute-topic hardwire
controller_name: ft_broadcaster # name of the broadcaster it registers with the controller
# manager (default: <entry label>_broadcaster)
Endpoint tare (a command) is that zero button, a std_srvs/Trigger service on
<name>/tare over ROS; it takes no argument and its reply is what lets a scenario fail rather
than measure against an offset it only assumed was applied.
Endpoint wrench (out) reads a roqsim.types.Wrench, a geometry_msgs/WrenchStamped on
<name>/wrench over ROS, stamped in the frame frame names. A WrenchReader is published on the blackboard
under ft:<entry label> for in-process consumers — the admittance controller is one — exposing
read() and the resolved frame.
Frames. sensor returns MuJoCo’s raw site-frame reading. base rotates it into the owning
entity’s base body frame, and world into the world frame. The choice is not cosmetic for
metrics that split the wrench into an insertion axis and the plane orthogonal to it: |F_z| and
||F_x, F_y|| are frame-dependent, and a tool that tilts reports a different split in its own
frame than in the world’s. The WrenchStamped header names that frame as TF knows it: the site’s
name without the entity’s MJCF prefix, published with the fixed transform from the body it sits on;
the entity’s root body, likewise unprefixed; or world.
Taring: zeroing the tool’s own load. The sensor reads everything below the cut, which for a loaded flange is mostly the tool’s own weight – so a contact task measuring a 5 N push starts from 20 N of tool.
Zeroing is a command, the way it is on real hardware: an FT driver exposes a service taking no
argument (zero_ftsensor) and this exposes the same thing three ways onto one implementation –
the tare endpoint (std_srvs/Trigger over ROS), WrenchReader.tare() for an in-process
controller, and tare_at_s for a world that wants it done once at a stated time without anything
to press the button. Prefer one of the first two: a time is a number that has to stay in step with
a scenario’s own timing, and if the approach runs long it fires mid-motion and zeroes against a
contact.
All three re-arm on on_reset: an offset carried into the next run is a measurement of the
previous one, and repetitions of a trial would not be repetitions.
A tare is not gravity compensation, and the difference is a trap. The offset is captured in the raw sensor frame and subtracted there, exactly as a real FT sensor’s zero button works – so it is valid at the pose the tool was in when it was captured. Rotate the tool ninety degrees and the weight reappears, up to twice the tool’s load in the worst case, because the tool’s weight is fixed in the WORLD frame while the sensor frame turns with it. Compensating at every pose needs the tool’s mass and centre of mass estimated, which is a calibration, not a tare; roqsim does not do it, and a tare that quietly claimed to would leave a contact controller chasing a bias that grows with the tool’s tilt. Tare at the pose you are about to make contact in, or tare per approach.
The offset is the reading BEFORE noise is added, so what is left after taring is the noise alone
rather than the noise plus one sample’s worth of it – a real tare averages many samples, and this
is that average exactly. Capture happens on the first read at or after tare_at_s, so a sensor
nobody reads is never tared and one read at 100 Hz tares within a step of the time asked for.
A flex’s contacts are added to the reading. MuJoCo’s site force/torque sensor reads the sensed
subtree’s momentum balance against its external forces and leaves a contact with a flex out of them
(roqsim.flex, “the wrench a flex’s contacts put into a subtree”). Measured on MuJoCo 4.0.0
(tests/test_force_torque_flex.py): a rigid probe pressing a flex block read its weight alone, and
a support carrying 1.5 N of a pinned elastic cantilever was absent from the reading. The rest of
what a flex does already reaches the sensor – its weight, its inertia and its elastic forces, which
act on its vertex DOFs as joint forces between each vertex body and the body it hangs from.
So the plugin adds the missing term: every contact that involves a flex and has exactly one side in
the sensed subtree enters with its force and its moment about the site
(roqsim.flex.FlexContactWrench). That covers a soft tool below the sensor touching anything
– an elastic block pinned to a flange pressing a table – and a rigid tool pressing a soft object.
The correction is applied to the raw pair, before the tare and the frame, so the reading is what a
real sensor at that cut measures. A flex lying partly inside the subtree and partly outside is
refused: its contacts cannot be assigned to one side of the cut.
Bias, drift and range are the transducer’s, so they come before the tare. A real sensor’s zero
offset and its slow thermal drift are in what it measures, and its zero button removes whatever of
them has accumulated – which is why a contact task tares at the pose it is about to press in. So
bias_* (a constant per run) and drift_* (a rate per run, the offset growing
linearly from zero at the run’s start) are added to the raw pair, and a tare captures them with
it. Both are drawn once per run and per channel, uniformly within the stated bound, from
ctx.rng_for(..., per_run=True): a function of the run’s seed and its name, so a value at
any sim time is reproducible from that time alone, as the noise is. Linear rather than a random
walk for that reason – a walk’s value depends on every step before it – and because a trial lasts
minutes, over which a thermal drift is close to a line. range_* saturates each raw channel, bias
and drift included, as the transducer’s range does; the noise is added after, in the reported
frame. All default to zero or none.
Noise is per-sensor config, deliberately. There is no generic error-model framework in roqsim (see
docs/architecture.rst §9); a sensor that wants noise declares its own, as the lidar’s
range_stddev does. The default is zero: a noise model that appears without being asked for is a
silent change to every metric derived from the signal.
The draws come from roqsim.context.SimContext.rng_for() – the run’s seed, not a per-sensor one –
for the same reason the lidars use it, plus one specific to a wrench: it is a pure function of
(seed, sim_time, sensor), so two readers in the same step see the same wrench. This sensor has
two by construction (the wrench endpoint and the blackboard WrenchReader an in-process
controller polls), and with a stateful generator each read would have advanced the stream – the
controller and the recorded signal would disagree about the force at one instant, which is
indistinguishable from a controller bug. It also makes the noise reproducible from a recorded state
without replaying the run, and repeats identically after on_reset because sim_time restarts.
gnss
Sensor plugin: a GNSS receiver – local ENU position converted to WGS84, with drift.
Config:
gnss:
datum: {lat: 47.397742, lon: 8.545594, alt: 488.0} # REQUIRED -- world origin on Earth
body: x500 # the body whose position is measured (default: the entity root)
rate: 10.0 # Hz -- real GNSS is slow, and EKF2's behaviour depends on that
horizontal_noise: 0.5 # m, 1-sigma
vertical_noise: 1.0 # m, 1-sigma
velocity_noise: 0.1 # m/s, 1-sigma per axis
bias_time: 60.0 # s, correlation time of the slowly-drifting position bias
satellites: 12
eph: 0.5 # m, reported horizontal accuracy (default: horizontal_noise)
epv: 1.0 # m, reported vertical accuracy (default: vertical_noise)
fix_type: 3 # 3 = 3D fix
denied: false # true -> no fix at all, without removing the plugin
The projection is deliberately the cheap one. dlat = north / R, dlon = east / (R cos
lat) with R = 6378137.0 m (the WGS84 semi-major axis) – an equirectangular tangent-plane
approximation. Its error grows with the square of the offset from the datum, and over the
kilometre-scale extents a MuJoCo world can actually hold it stays well under a metre, i.e. below
this receiver’s own noise floor. It is not a general geodesy routine: it ignores the ellipsoid’s
flattening, uses geodetic altitude as if it were MSL, and would be wrong at continental range. Any
experiment that needs true geodesy needs pyproj and a real projection, not a bigger constant here.
Noise is a drifting bias plus white noise, not white noise alone. A pure-white GNSS is the
input that makes an EKF look best: averaging kills it, so position error shrinks with the filter’s
window and the estimator appears to have solved a problem it has not. Real GNSS error is dominated
by slowly-correlated terms (ionosphere, ephemeris, multipath geometry), and that is what a
navigation experiment is about – how the estimator behaves when its position reference wanders
metres over a minute. The bias here is an Ornstein-Uhlenbeck process with correlation time
bias_time; the white term rides on top.
Randomness comes from ``ctx.rng_for``, like every other stochastic plugin, so the fix is a pure
function of (sim.seed, run, sim_time) and this plugin has no seed key of its own.
The fix is held between updates. At rate Hz the value changes 10 times a second and is
constant in between, because that is what the sensor does – a consumer that interpolated it would
be inventing measurements the receiver never made, and would hide exactly the latency an estimator
has to cope with.
What this does not model: multipath and its geometry-dependent structure, ionospheric and
tropospheric delay, constellation geometry (so satellites and the reported eph/epv are
declared constants, not computed DOP), RTK/carrier-phase modes, receiver clock error, and
acquisition time – the fix is available on the first tick.
imu
Flags: parallel_safe
Sensor plugin: a strap-down IMU – angular rate, proper acceleration, and attitude at a site.
Config:
imu:
# The entity is the one this entry is NESTED UNDER; declaring it at the top of a document is
# refused (`requires_owner`) -- an IMU measures a body's motion, so it belongs to something.
body: "" # body the IMU is bolted to; default: the entity's registered base body
site: "" # measure at an EXISTING site instead (then `body`/`pose` are unused)
pose: # the mount in the body frame, a geometry_msgs/Pose; omitted
position: {x: 0.0, y: 0.0, z: 0.0} # components are 0 (roqsim.pose, relative)
orientation: {roll: 0.0, pitch: 0.0, yaw: 0.0} # or a quaternion x/y/z/w
frame_id: imu_link # the frame the reading is stamped in (default: '<label>_link')
topic: imu/data # the endpoint's RELATIVE topic, so a device can match its driver's
# layout (the D435i's IMU is `camera/imu`); `topics: {imu: /abs}`
# still hardwires an absolute one and wins over this
rate_hz: 100.0 # endpoint publish rate
emit_static_tf: true # publish body -> frame_id; false where a device's frame chain does
orientation: true # publish attitude; false -> orientation_covariance[0] = -1
accel_stddev: 0.0 # m/s^2, additive Gaussian white noise, per axis
gyro_stddev: 0.0 # rad/s, likewise
accel_bias: [0, 0, 0] # m/s^2, systematic -- a real accelerometer's is not zero-mean
gyro_bias: [0, 0, 0] # rad/s, likewise (a rate bias is what makes integrated yaw drift)
orientation_stddev: 0.0 # rad, small-angle noise about each axis
yaw_stddev: 0.0 # rad, EXTRA noise about the vertical axis only (see above)
fault: {gyro_stddev: 0.4} # optional: the values it takes while degraded (its `override`)
Endpoint imu (out) reads a roqsim.types.Imu, a sensor_msgs/Imu on imu/data over
ROS – the topic robot_localization and a standalone IMU driver both use – plus the
static body -> frame_id transform (unless emit_static_tf: false: a device model whose
frames: chain already publishes frame_id, as the D435i’s does, sets it, since a second parent
for one frame leaves whichever a consumer sees last). An ImuReader is published on the blackboard under
imu:<address> for in-process consumers.
Nothing is computed while nothing is listening. The reading is assembled in the endpoint’s
read() rather than in a post_step, and the endpoint is lazy, so a bridge does not even
read it while the transport reports no subscriber (BridgeBase._skip_unsubscribed). That matters
here because an IMU is the fastest sensor on the robot – at 200 Hz, several of them, each drawing
noise from a fresh counter-based generator, is real work to do for nobody – and because a device
whose manifest carries an IMU by default (the D435i does) must cost a world that ignores it nothing.
Two properties make lazy safe for this endpoint, and both are why it is opt-in per endpoint:
the publish has no side effect beyond the message (the mount transform is latched once at bind
time, not derived per read), and an in-process consumer goes through the blackboard reader, which is
not gated by anyone’s subscriptions. Where no transport can report subscribers at all, the
convention is “assume yes”, so the endpoint stays live.
Covariances are the declared noise, squared, and nothing else. The reported variance is
stddev**2 per channel (bias is systematic and deliberately not folded in: a covariance is what a
filter uses to weight the random part, and inflating it to cover a bias tells the filter the bias
will average out). A perfect sensor therefore reports zero variance, which is truthful and which some
filters refuse; a world that wants a filter-friendly floor states the stddev it wants assumed, in the
world, where the run’s provenance records it.
Noise draws come from ctx.rng_for, keyed imu:<address>, like the lidar’s and the FT
sensor’s: reproducible from the run’s seed, identical for two readers in the same step (the endpoint
and the blackboard reader are two by construction), and repeatable across a reset.
lidar
Flags: parallel_safe
Sensor plugin: 2D lidar via batched ray-casting (roqsim.raycast.cast(), no GL).
Config (in addition to lidar_common’s namespace/site/frame_id/
rate_hz/exclude_body/dropout_percent/emit_static_tf/tf_parent/lazy):
lidar:
rays: 360 # samples; the first at angle_min, the last exactly at angle_max
angle_min: 0.0
angle_max: 6.265732015 # default: angle_min + 2*pi*(rays-1)/rays, a full turn
# with no bearing published twice
range_min: 0.164 # published as the header's range_min
max_range: 20.0 # published as the header's range_max
detection_min: 0.164 # nearest distance measured; a nearer hit is too close
# (default: range_min)
detection_max: 20.0 # farthest distance measured; a farther hit is no return
# (default: max_range)
too_close: -inf # published for a too-close hit: -inf, +inf, nan, raw
# (the true distance) or a number
no_return: +inf # published where nothing is measured: +inf, nan or a number
range_stddev: 0.0 # Gaussian range sigma (m)
range_stddev_relative: 0.0 # sigma as a fraction of the distance, at and beyond
# range_stddev_relative_from (0 = constant sigma)
range_stddev_relative_from: 0.0 # m; nearer than this the sigma is range_stddev
range_resolution: 0.0 # quantisation step of a published distance (m); 0 = continuous
What a scan publishes follows ROS REP 117 unless the device says otherwise. A hit nearer than
detection_min is published as too_close (-inf by default) and a ray with nothing within
detection_max as no_return (+inf). A too-close hit is never raised to range_min and
never published as though it were measured. A device model whose real driver publishes something
else declares it, e.g. urg_node publishes a Hokuyo’s too-close error code as 0.004 and its
no-return code as 65.533. A consumer uses a range only where range_min <= r <= range_max and
the value is finite, as REP 117 prescribes.
The header and the physics are separate keys because they differ on real hardware: a driver
publishes a hard-coded range_min/range_max (neo_sick_s300 publishes 0.01/29.0 for a
scanner that measures 0.05 to 30 m), while whether a return exists is the device’s physical limit.
range_min/max_range are what the header says; detection_min/detection_max decide
which rays are too close, measured, or no return. Each defaults to its header counterpart.
Layout. rays samples run from angle_min to angle_max inclusive, angle_increment =
(angle_max - angle_min) / (rays - 1), which is how every 2D scanner driver lays out a
LaserScan. A full turn is written the way its driver writes it: angle_max one increment short
of angle_min + 2*pi where no bearing repeats (the LDS-01’s hls_lfcd_lds_driver), or
-pi .. pi where the first and last ray share a bearing (the RPLIDAR C1’s sllidar_ros2).
Noise is drawn on the true distance of every hit and published on measured and raw
too-close returns; a constant too_close/no_return carries none. A noisy distance is floored at
0 and then quantised to range_resolution. It is not re-classified: a measured return that noise
carries past a header limit is published as the device would publish it, outside
[range_min, range_max].
frame_id defaults to site; set it when the robot’s real description names the frame
differently (the TurtleBot 4’s URDF calls it rplidar_link).
exclude_body defaults to nothing: a scanner skips only its own housing, which a device model names
(exclude_body: mount), and any other robot geometry in the scan plane is a real return.
The static mount TF (emit_static_tf, on by default) is tf_parent -> frame_id, measured from
that body. tf_parent defaults to the root body of the entity carrying the lidar (a robot’s base),
else the resolved exclude_body, else world for a lidar nothing carries. A device model mounted
with spawn_sensor sets emit_static_tf: false: the mount publishes the chain.
livox_mid360
Flags: parallel_safe
Sensor plugin: Livox Mid-360 3D lidar via batched ray-casting (roqsim.raycast.cast(), no GL).
Config (in addition to lidar_common’s shared keys):
livox_mid360:
site: lidar # site the rays are cast from
frame_id: livox_frame # defaults to `site`; Livox's own driver publishes `livox_frame`
horizontal_rays: 360 # azimuth samples across the 360deg FoV (wraps, so none at 2pi)
vertical_rays: 56 # elevation samples across the vertical FoV (inclusive endpoints)
h_fov_min: 0.0
h_fov_max: 6.283185307 # 2*pi (full 360deg)
v_fov_min: -0.122173048 # -7 deg
v_fov_max: 0.907571211 # +52 deg
range_min: 0.1 # blind zone: a nearer hit is too close
max_range: 40.0
too_close: drop # a hit nearer than range_min: drop (not in the cloud) or origin
no_return: drop # nothing within max_range: drop or origin
What a cloud carries follows the device. A measured return is a point at its distance along the
ray. A too-close hit and a ray with no return are left out (drop) unless the device’s driver
publishes them: origin puts a point at (0, 0, 0) of the sensor frame for each such ray, which is
what the Livox Mid-360 and livox_ros_driver2 publish (see mid360.manifest.yaml). A point
cloud is not a fixed-length array, so neither keeps a slot as a LaserScan ray does; with both set
to origin the cloud has one point per ray, in ray order.
oakd_camera
Sensor plugin: OAK-D Pro RGB-D camera, drawn through the render service.
Config (in addition to camera_common.CameraPlugin’s, and depth_camera.DepthCameraPlugin’s
clip_near/clip_far/depth_encoding):
oakd_camera:
camera: oakd_rgb
clip_near: 0.3 # m; depth outside [clip_near, clip_far] reads as "no return" (inf)
clip_far: 100.0 # m
On depth_encoding: 16UC1: this camera’s default 100 m clip_far is further than uint16
millimetres reach, so opting in means also lowering the range to the depth the world actually needs –
which the plugin says at load time rather than saturating at 65.5 m.
object_detector
Flags: parallel_safe
Sensor plugin: named objects detected relative to a robot, from ground truth plus an error model.
Config – a component of the entry that spawns the robot the detections are reported from, since ownership is where the entry sits rather than a config key:
object_detector:
frame: base_footprint # body whose frame the poses are expressed in
rate_hz: 10.0
objects: # body name -> what a detector would call it
- {body: graspable_carton, class_id: parcel, size: [0.040, 0.024, 0.090]}
position_stddev: 0.0 # m, Gaussian, per axis
orientation_stddev: 0.0 # rad, small-angle, applied about each axis
position_bias: [0.0, 0.0, 0.0] # m, systematic -- calibration error is not zero-mean
dropout_percent: 0.0 # this percentage of detections go missing
max_range: 0.0 # 0 = unlimited; else report only within this range
confidence: 1.0 # what the hypothesis score reports
The consumer contract, which a real detector must satisfy to drop in:
topic
detections, typevision_msgs/msg/Detection3DArrayheader.frame_idis a frame reachable through the robot’s own kinematics – nevermapobjects identified by
results[0].hypothesis.class_idlatest-wins; a detection missing from a message means “not detected this cycle”
range_sensor
Flags: parallel_safe
Sensor plugin: a ray-grid range sensor – the ToF / IR proximity / ultrasonic / cliff model.
Config (in addition to lidar’s site/frame_id/rate_hz/range_min/max_range/
detection_min/detection_max/too_close/no_return/noise/emit_static_tf/
tf_parent keys):
range_sensor:
site: ir_front # rays are cast along the site's +x axis
h_rays: 5 # rays across the horizontal field of view (default 1, >= 1)
v_rays: 5 # rays down the vertical field of view (default 1, >= 1)
h_fov: 0.1745 # horizontal field of view, rad (10 deg); 0 with h_rays: 1
v_fov: 0.1745 # vertical field of view, rad; 0 with v_rays: 1
range_min: 0.025 # published as the header's range_min (default 0.01)
max_range: 0.2 # published as the header's range_max (default 2.0)
rate_hz: 62.0
A lidar’s rays/angle_min/angle_max are refused here: the layout is the grid’s, and
a world that wants a fan declares a lidar. The endpoint’s role name is range (so the topic
is renamed with topics: {range: ...}), leaving scan to the robot’s scanner.
Pointing it. The site’s +x is the boresight, as for every ray sensor here; a cliff sensor
is a site pitched towards the floor, a proximity sensor a site facing out through the shell. With
the boresight on the floor at a known standoff, a floor return reads the standoff and a hole reads
no_return (+inf by REP 117), which is exactly the comparison a cliff detector makes.
realsense_d415
Sensor plugin: Intel RealSense D415 colour stream, drawn through the render service.
realsense_d435
Sensor plugin: Intel RealSense D435(i) colour + depth + point cloud, drawn through the render service.
Config (also inherits camera_common.CameraPlugin’s own fields, undocumented here):
realsense_d435:
depth: true # publish the depth image (default: false)
points: true # publish a PointCloud2 -- implies depth (default: false)
clip_near: 0.28 # m; the D435's minimum-Z. Outside [clip_near, clip_far] reads "no return"
clip_far: 3.0 # m; the datasheet's usable range at default settings
depth_camera: d435_depth # the MuJoCo camera depth is rendered from (see depth_camera.py)
depth_frame_id: camera_depth_optical_frame
depth_encoding: 32FC1 # or 16UC1 -- millimetres, 0 for invalid, as realsense-ros publishes it
References:
https://github.com/IntelRealSense/realsense-ros – topic layout, frame names,
CameraInfoshape.https://www.intelrealsense.com/depth-camera-d435i/ – D435i data sheet. Colour FOV 69.4 x 42.5 deg; DEPTH FOV 87 x 58 deg; min-Z ~0.28 m at 848x480; usable range ~0.3-3 m.
Note on FOV. A real D435 images colour and depth through different optics, so the bundled
realsense_d435 model has one MuJoCo camera per stream, each with its data-sheet FOV and
resolution: fovy/width/height size the colour camera and depth_width/depth_height
the depth one. A robot MJCF that carries a single d435_color camera (the OpenMANIPULATOR-X’s
eye-in-hand one, at the depth FOV its experiment consumes) renders depth through it with
depth_camera: d435_color.
realsense_d455
Sensor plugin: Intel RealSense D455 colour + depth + point cloud, drawn through the render service.
segmentation_camera
Sensor plugin: per-pixel class and instance labels, and the 2D boxes that fall out of them.
Config (in addition to camera_common.CameraPlugin’s):
segmentation_camera:
camera: camera # the MJCF <camera> to render through
classes: # REQUIRED: the experiment's vocabulary, in priority order
- {class_id: 1, name: parcel, bodies: ["graspable_*"]}
- {class_id: 2, name: person, entities: [walker_1]} # the whole entity, limbs and all
- {class_id: 3, name: shelf_board, geoms: ["board_*"]} # PARTS of one body
instances: false # also publish the instance-id image (16UC1)
detections: true # publish 2D boxes derived from the mask
min_pixels: 16 # an instance with fewer visible pixels is not reported
color: false # the colour stream, off by default here (see below)
rate_hz: 10.0
frame_id: camera_optical_frame
topics: {} # hardwire absolute topics, e.g. {labels: /seg/class_image}
Endpoints. labels (sensor_msgs/Image, mono8) is the class image: each pixel is the
class_id of the class owning the geom that pixel hit, 0 where nothing labelled was hit.
instances (16UC1, off by default) is the instance-id image. detections
(vision_msgs/Detection2DArray) carries one entry per visible instance, with the class in
results[0].hypothesis.class_id and the instance in Detection2D.id. camera_info comes from
the base and describes all of them, since they are one render through one camera.
Instance ids are body ids, so they are stable across frames, across a reset, and across two runs of the same world – a tracker’s association is then a fact about the world rather than about the order this plugin happened to see things in. They are consequently not contiguous, which is why the detections name them rather than leaving a consumer to infer them from the image.
Class ids are the world’s, and 0 is reserved for “nothing labelled here”: a background class with an id of its own would be indistinguishable from an unlabelled geom, and a mask metric computed over it would score the wall. Classes are matched in declaration order and the first match wins, so a world can put a specific body ahead of the glob that would otherwise swallow it.
The colour stream is off by default here (PUBLISHES_COLOR = False). A label camera normally
shares its MJCF <camera> with the RGB sensor that already publishes those pixels, and a second
colour topic off the same optics is a duplicate that costs a serialisation. color: true turns it
on for the case that wants it: a pixel-aligned image/label pair off one camera, which is what a
training set is.
An absent entity is absent here too, and the pass says so rather than inheriting it.
DeleteEntity hides geoms by moving them to roqsim.presence.ABSENT_GEOM_GROUP and zeroing
their alpha (roqsim.presence). Measured, MuJoCo’s default view options already exclude that
group, so a deleted obstacle contributes no label pixels either way – but “a deleted obstacle is not
in the ground truth” is a contract this sensor owes an experiment, not something to leave resting on
a default in another project that no test of ours would notice changing. So the pass is rendered with
the group explicitly masked, and test_segmentation_camera.py pins the outcome. Alpha is the other
half of hiding and is no help here: it is a colour, and an id pass need not respect it.
sensor_coverage_probe
Scene plugin: report the sensor coverage of a world, enabled/disabled from the world YAML.
Config:
sensor_coverage_probe:
sensors: auto # 'auto' = every MuJoCo camera in the world, less a device's depth
# camera beside its colour one (camera_common.DEPTH_CAMERA_SUFFIX);
# or an explicit list of {type, pose, config, label} placements
# (for lidars, or hypotheticals), e.g.
# - {type: livox_mid360,
# pose: {position: {x: 3, y: 1, z: 2.4},
# orientation: {roll: 3.14159}}}
# `pose` is a world pose with z stated; any other key is refused.
camera_far: 10.0 # detection range assumed for 'auto' cameras (metres; not physics)
target: {k: 1, frac: 0.95}
sample:
volume: true
objects: true
resolution: 0.25
heights: [0.3, 1.0, 1.7]
per_object: 64
out: coverage # output directory (report.json + render); relative to the CWD
render: 3d # 3d | 2d | both | none
palette: coverage # colour encoding: 'coverage' (red 0->green many) | 'density'
# (light 0->dark many, so overlapping-sensor regions read darker)
Rendering needs a GL context, which import roqsim already selected for this machine (set
MUJOCO_GL only to override it). sensors: auto discovers
cameras robustly (their FOV is read straight from the MJCF); include lidars/Livox via the explicit
list form or evaluate them with the CLI.
seyond_robin_w1g
Flags: parallel_safe
Sensor plugin: Seyond Robin W1G forward-facing solid-state 3D lidar via batched ray-casting.
spawn_sensor
Scene plugin: attach a standalone sensor MJCF (mesh + camera/site) into the world at a mount pose.
Config (declared in CONFIG_SCHEMA – unknown keys are refused):
spawn_sensor:
model: <required> # required; bundled model name, filename, or absolute path
namespace: "" # transport scope; a nested mount's is its carrier's
prefix: "" # MJCF name prefix; nested: <attach_prefix><name>_
pose: <unset> # mount pose in its parent, a geometry_msgs/Pose (omitted components: 0)
motion: static # static | driven | physics
attach_to: "" # body of an already-spawned carrier to weld the mount to
attach_prefix: "" # carrier's MJCF prefix for attach_to/parent_frame
parent_frame: "" # carrier body or declared frame to hang from
frame_id: <unset> # the device's scan frame; default: its manifest's frame_id
device_name: <unset> # the vendor macro's name, prefixing its frames; default: its manifest's
show_fov: false # draw the sensor's field of view
fov_alpha: 0.25 # FOV translucency, 0..1
fov_near: <unset> # m; FOV near plane; > 0 truncates the cone; default: model manifest
fov_range: <unset> # m; FOV far plane; default: model manifest
fov_rays: [32, 24] # occlusion-clip ray grid [nu, nv], each 2..256
intrinsics: <unset> # this unit's measured lens: fx, fy, cx, cy, width, height
present: true # false: compiled in, absent until spawned
default_plugins: true # inject the model manifest's components
spot_body_camera
Sensor plugin: one body camera station of a Boston Dynamics Spot, as the spot_ros2 driver publishes it.
Config (in addition to depth_camera.DepthCameraPlugin’s):
spot_body_camera:
station: frontleft # the station's name, which every topic carries (required)
depth_frame_id: <station> # the frame depth is stamped in: the station's own
color_encoding: mono8 # bgr8 for a Spot with colour body cameras (spot_ros2 rgb_cameras: true)
registered_depth: true # depth_registered/<station>/image
compressed: false # spot_ros2's publish_compressed_images default
zivid
Sensor plugin: Zivid 3 XL250 structured-light 3D camera, drawn through the render service.
roqsim_walker
walker
Scene plugin: a kinematic pedestrian, moved by the navigator nested under it.
Config:
walker:
walker: MaleVisitorWalk # blueprint folder under models/people/ (required)
namespace: "" # transport scope of the walker's endpoints and its navigator's
outfit: B # clothing variant: a letter, or {pants: C, jacket: A}
skin: true # false -> capsule visuals instead of the character mesh
hands: false # true -> wrists that turn, five fingers a hand, grip poses, and
# the moves of a nested `humanoid` (roqsim_motion); false is the
# seventeen-body walker, with nothing of the hands built or computed
rgba: [r, g, b, a] # colour of the capsule visuals (default: the humanoid's own)
pose: # where the walker stands at the start and after every reset:
position: {x: 0.0, y: 0.0} # a world pose as SpawnEntity states one, with no z -- a
orientation: {yaw: 0.0} # walker stands on the floor -- and a heading only
motion: {walk: /abs/walk.npz} # a locomotion clip of its own: a clip's name or a .npz
layers: # clips played over the gait from the start (roqsim_walker.layers):
- {clip: wave, joints: [arm_r], loop: true, weight: 1.0, fade: 0.3, speed: 1.0}
body_lag: 0.0 # s: the body follows its nav root as a damped spring of this time
# constant and its turns speed up and slow down over twice it, so
# it starts, turns and stops smoothly (0: on the root, turning at once)
A walker with no nested navigator gets one that is goal-driven only: output: walker,
speed: 1.0, its 0.26 m disc as radius, and avoidance: {stop: false}, since a walker does
not look ahead. A patrol, a pause, avoidance or a goal endpoint’s name is stated on a navigator
nested under it:
- walker: {walker: MaleVisitorWalk, pose: {position: {x: -2.0, y: -2.0}}}
name: pedestrian
components:
- navigator:
output: walker
speed: 1.2
goals: [[2.0, -2.0], [2.0, 2.0], [-2.0, 2.0]]
loop: true
dwell: [[0, 0], [2, 4], [0, 0], [1, 3]] # per route point, the start first
avoidance: {steer: give_way, stop: false}
scenario_execution_roqsim
scenario
A world entry that runs an OpenSCENARIO file: the scenario plugin.
Config:
file: press_cell.osc # relative to the world file
scenario: "" # which scenario of the file; required where it holds several
stop_at_end: true # end a standalone run when the scenario ends
output_dir: "" # where scenario-execution writes its test.xml; none by default
One entry serves a world: scenario-execution keeps a scenario’s flags by its name and one output
directory per process, so a second would read the first’s. Each run parses the file again and
builds a new tree, since a tree holds a run’s state. The tree is ticked once per physics step, after
the plugins listed before this entry, in its post_step. The file is parsed there too, and only in
a run: a world compiled to look at it (SimContext.preview: rendering, replaying, checking, a settled
export) neither needs scenario-execution nor runs the scenario, though roqsim check needs this
package to know the entry.
A scenario that fails stops the run with an error and a non-zero exit. One the run ends before it does
is written to test.xml as failed and reported to the driver (ctx.report_unfinished), so
roqsim sim exits non-zero; a reset that cuts it short logs that as an error, and the next run
runs it again.
The other way to run a scenario is scenario-execution owning the loop (roqsim.scenario_adapter),
for a campaign that runs it as its command, or for scenario parameters this entry does not take.
ROS 2 bridge (roqsim_ros_bridge)¶
The bridge plugins live in the ROS 2 workspace (ros2_ws/), which is built with colcon rather
than pip-installed into the docs venv, so they are listed here by hand; they appear in the generated
catalog above once ROS is sourced and the workspace is on the path.
Plugin |
Purpose and key config |
|---|---|
|
Generic bridge: wires every endpoint declared on |
|
|
Note
A publish rate lands on the physics grid. A gate is tested once per physics step, so the rates
a world can hold are exactly physics_rate / k for integer k. Every rate this bridge gates
on — an endpoint’s own rate_hz, a backend hint, a rates: override, clock_rate_hz, a
merged joint_states — is snapped to the nearest of those when it is bound, and the move is
logged in proportion to its size (silent below 0.1 %, a note below 1 %, a warning naming the nearby
achievable rates above it). Nearest, so a snapped rate may come out slightly FASTER than asked: a
rate meant as a ceiling has to be one the world can hold.
At the common timestep: 0.002 that makes 10 Hz and 25 Hz exact and 30 Hz a 500/17 —
29.41 Hz. Where a result turns on that difference there are two ways to keep the number: ask for a
rate on the grid, or step the world at a whole multiple of the rate you need (30 Hz is exact at
510 Hz, i.e. timestep: 0.0019607843137254902), which is the one to reach for when the rate came
from a paper. Write such a timestep out in full: the step rate is recovered from the float, and a
rounded one is a different grid. Both numbers,
requested and realised, reach a recording’s provenance as endpoint_rates, so a run states what
it published at rather than what it was asked for.
Note
When to set merged_joint_states. A robot with several controllers declares one
joint_states endpoint per controller (arm_controller does), and where those are scoped
apart by namespace nothing publishes the plain topic a robot_state_publisher or MoveIt’s
planning-scene monitor over their combined robot_description subscribes to — so that
description gets no TF and move_group never learns a current state, silently: it still logs
that planning is ready. The bridge closes that with one extra merged publisher per group, carrying
every member endpoint’s names/positions/velocities/efforts in registration order, alongside each
endpoint’s own topic, which is unchanged.
Which endpoints form a group is a fact about the stack — how many robot_descriptions it
runs — that the world cannot answer, so it is declared:
components:
- ros2_bridge: {} # "auto" (default): group by entity
- ros2_bridge: {merged_joint_states: true} # one /joint_states across all entities
- ros2_bridge: {merged_joint_states: false} # never merge
- ros2_bridge: # groups stated outright
merged_joint_states:
- {topic: /cell/joint_states, owners: [ur10e_left, ur10e_right]}
"auto" merges each entity’s controllers into the scope they share (dual/left +
dual/right → /dual/joint_states) and keeps separate robots separate — right without any
declaration, because one entity is one physical robot however the stack is arranged. Two arms that
are two entities but one description (what arm_controller’s joint_prefix exists for) need
true or an explicit group; auto warns when more than one entity publishes joint states here
so that case is not silent. Controllers already sharing one topic get no merged publisher: they
meet on the wire, and both robot_state_publisher and MoveIt accumulate partial joint states.
Note
When to set tf_namespace. By default the bridge publishes TF on the global /tf, which is
right for a single robot owning the tree. But a namespaced Nav2 bringup follows the multi-robot
convention of remapping /tf -> tf, so its TF lives on /<robot>/tf — and tooling that
assumes that convention (notably scenario_execution’s NamespacedTransformListener, which
subscribes <namespace>/tf) then never sees the bridge’s odom -> base_link. The symptom is a
stack that looks healthy while a transform lookup hangs forever, e.g. scenario_execution’s
init_nav2 stuck on “Waiting for transform map -> base_link”.
Set tf_namespace to the robot’s namespace so the bridge joins that tree:
components:
- ros2_bridge: {tf_namespace: a200_0000} # -> /a200_0000/tf, /a200_0000/tf_static
It must match the namespace the consuming stack uses, and it is all or nothing: every publisher
of a link in the chain has to agree on one topic. Note this scopes the TF topics only — frame ids
(odom, base_link) are untouched; namespace those with frame_prefix if needed. The
global frames world and map are never namespaced.
Setting the bridge’s namespace does not do this: tf2_ros’s broadcasters hardwire the
absolute /tf, which is exactly why this option exists.
Transport plugins and the scene-only consumers¶
A bridge publishes what the other plugins built; it adds nothing to the model. Such a plugin sets the
class attribute transport_only = True — BridgeBase does, so every transport inherits it,
including one you write — and every tool that wants the scene rather than a running simulation builds a
preview engine (Engine(cfg, preview=True)), which leaves it out: roqsim render, roqsim scenes
describe, the scene-review window (roqsim_scene_builder), roqsim export web/urdf/srdf/moveit,
scene-to-map and roqsim sensors coverage. The ROS bridges are identified by name where they do
not resolve, so each of these tools builds a ``*_ros`` world without ROS installed. The tools that
only draw or export geometry (skip_unloadable=True) also skip any other plugin whose ref does not
resolve and warn, naming it — geometry is unaffected for a transport, but the other way to get there is
a misspelt ref.
roqsim check leaves the transport out of its load too, but first validates the config of every
plugin the world declares, so it still needs the bridge’s package: on a world whose bridge does not
resolve it fails at the config stage.
roqsim sim keeps both by default: a simulation genuinely needs its transport, so an unresolvable
ros2_bridge there stays the loud failure it should be (source ros2_ws/install/setup.bash).
--no-communication is the deliberate exception, for opening a *_ros world in the viewer on a
machine with no middleware installed:
roqsim sim depot_nav2.yaml --no-communication
It is not the render path’s rule with a flag on it. Two differences, both because this one is a simulation:
Only a plugin that can be identified as transport goes — its class declares
transport_only, or its ref is one of the bridgesroqsimnames for--ros. An unresolvable ref that is neither stays in the world and still fails the build, because there it is a misspelt plugin that would have changed the run.The run then communicates with nothing, and says so on every start: nothing published (no
/clock, no TF, no sensor topics, no odometry), nothing received (no/cmd_vel, no goals, no services). An external stack sees a simulator that was never started, and a robot it would have driven stands still. Use it to look at a world, never to run its experiment.
--no-communication and --ros/--tf-namespace/--sim-control are refused together rather
than silently ordered.
Nothing is required to know the flag exists, either. When a world’s only unresolvable plugins are
its bridges, the failure says so and names both ways out; a bare “unknown plugin ros2_bridge”
sends the reader hunting for a typo that is not there.
Model plugin manifests¶
A robot’s controller and sensors are intrinsic to the model, not the world, so they ship with
the model in a <model>.manifest.yaml manifest next to its MJCF. A spawn plugin pulls them in
automatically, so a world just spawns the robot – and the same applies to a device with more than
one sensor in it: the bundled realsense_d435 is a D435i, so its manifest carries the imu
component at the inertial module’s own frame, and spawn_sensor: {model: realsense_d435} yields
both camera/imu and the colour stream. A world that models the IMU-less D435 sets enabled: false on that
component (which is also how “does this device have an IMU” becomes a campaign factor):
components:
- spawn_robot:
model: turtlebot4
pose: {position: {x: 0, y: 0}} # diff_drive, the RPLIDAR and the OAK-D come with it
- ros2_bridge: {}
An arm’s manifest can also carry an eye-in-hand sensor: a camera among the arm’s components rides
its flange, exactly as one among a mobile base’s components rides the base – there is no per-family
mount key to choose between. The
open_manipulator_x model ships the MJCF d435_color camera at ROBOTIS’s own RealSense mount pose
but deliberately leaves realsense_d435 OUT of its manifest – the arm provides the mount, the world
decides whether anything renders from it, at what rate, and whether it reprojects to a point cloud.
The same applies to spawn_arm (roqsim_manipulation): {model: ur10e} pulls in that
arm’s arm_controller; and to spawn_sensor (roqsim_sensors): {model: realsense_d435}
pulls in its realsense_d435 capture plugin.
Where a spawn puts things is checked at every reset. An arm’s home, a model’s keyframe, a
robot’s or a prop’s pose – once every plugin’s on_reset has applied them, the engine reports
any two bodies that start inside one another deeper than the contact’s tolerance: one WARNING in the
run’s log naming both sides, the entity each belongs to and the depth, and the same finding as a
roqsim check warning. Left alone, the contact solver separates them on the first steps with
forces that fling them, and the run fails later looking like a controller fault. Nothing is refused;
an overlap that is meant is excluded from collision and is then not reported
(architecture §2).
An eye-in-hand camera, or any sensor that rides something that moves, is
spawn_sensor: {attach_to: <body>, attach_prefix: <carrier prefix>} – the same spelling
fiducial_marker uses, welding the mount to a body of a robot or arm declared earlier in the
document, with pose then read relative to that body – which is what a datasheet or a
CAD drawing states, and what a world-frame pose cannot be once the carrier moves. An arm whose own
MODEL ships a camera needs none of this (three do, and their manifests offer the capture plugin);
this is how every other arm gets one, without a per-trial MJCF edit that travels badly and is
invisible to anyone reading the world. It is mutually exclusive with motion:: a mount that
rides a body has its pose from that body, so moving the sensor means moving what carries it.
A device a robot ships with is a spawn_sensor nested among the robot’s components, usually
in the robot’s own manifest. It hangs from a real frame of the robot, the link the vendor
description attaches it to: parent_frame names a body of the robot or an entry of its manifest’s
frames: block, and pose is the origin the robot description passes the device’s vendor
macro, verbatim. A device model’s mount body is the frame that origin places, so the device sits
where robot_state_publisher would put it, and its chain is published from that frame, as the
description’s is. A parent_frame that is neither a body nor a frame of the robot is refused when
the document expands, with a did-you-mean and the robot’s frames listed; roqsim catalog model
<robot> lists the frames too.
The pose is an offset from parent_frame: a geometry_msgs/Pose in the shape
roqsim.pose reads everywhere, whose omitted components are zero – there is no resting
height to fall back on as there is for a world spawn of a robot, and no pose puts the device
at the frame itself. That is also how a world or a campaign moves a device: it overrides the
device’s pose (robot.rplidar.pose.position.z=0.1), and the record states the frame and the
offset. pos/rpy keys are refused with the pose: they mean.
A mounted device inherits the robot’s prefix (its own is <robot prefix><name>_) and namespace.
Its components are addressed <robot>.<name>.<plugin>, and a robot manifest overrides one by
nesting it under the device. The device publishes its frame chain as static TF. Its scan frame is
the mount’s frame_id, else the vendor default the device manifest declares as frame_id:; a
device whose vendor names none needs one on every mount. A device whose vendor macro prefixes its
links with a name parameter declares that default as device_name:, and a second mount of it
on one robot sets its own, as a second instance of the macro would: two mounts that would publish
any one frame name are refused. A device that declares no frames: chain has no vendor frame to
hang from, and a robot mount of it is refused naming the device. The spawn_sensor and
spawn_robot entries below have the keys.
A world puts another device on a spawned robot’s frame the way the robot’s manifest does, by
nesting it in that robot’s components: – in the document, or added under the robot’s address
from an override – with parent_frame naming the frame and pose the origin on it. To
replace the robot’s own device there rather than add beside it, switch that one off by its label:
- spawn_robot: {model: turtlebot4}
name: tb4
components:
- spawn_sensor: {model: realsense_d435, parent_frame: oakd_camera_bracket,
pose: {position: {x: 0.0584, z: 0.09676}}}
name: d435
- spawn_sensor: {}
name: oakd
enabled: false
A standalone mount takes the same motion: key a prop does, with the same three answers, and it
is what a trial needs to place a sensor at run time – a viewpoint the campaign varies, a camera a
scenario repositions between phases. static is the default and welds the mount into the model,
so nothing can move it and a placement naming it is refused rather than ignored. driven makes
it a mocap body: it holds the pose it is given, nothing that touches it shoves it off, and – the
part a free joint gets wrong – it does not fall. That is what a sensor on a mast or a ceiling is.
physics hands the pose to the solver, which for an overhead camera means the camera drops to
the floor; ask for it only when the mount is meant to fall, be pushed or be carried.
Override a default: declare the same plugin inside that robot’s/arm’s
components:block — your entry wins (e.g. addtest_cmd/test_target, or changelidarrays). Nothing is duplicated. Matching is on the label: the entry’sname:, else its plugin ref, among that owner’s components. There is no entity key to name — an entry belongs to the entity whose block it sits in — which is what makes an override an override: a controller that named its robot instead could sit anywhere, and one declared outside the block would run alongside the manifest default rather than replacing it, leaving two controllers on the same actuators and a config with no visible effect. The override is partial: keys you do not mention keep the model’s manifest values, so adding atest_cmddoes not cost you the model’s wheel geometry or actuator names. Per key, what the world says wins; nested values (e.g.topics:) replace the manifest’s mapping outright rather than being deep-merged. To start from the plugin’s own defaults instead of the model’s, opt out withdefault_plugins: falseand declare the plugin fully.Switch one off with
enabled: false– as a sibling in the document, or from an override:roqsim sim world.yaml --set components.robot.oakd.oakd_camera.enabled=false
The component is not deleted: it stays addressable, stays in the run’s record saying it was turned off, and a later override can turn it back on. Disabling an entry disables everything it owns.
Opt out entirely: set
default_plugins: falseon thespawn_*config.Derive one manifest from another with
extends:.unitree_g1_dex1is aunitree_g1plus hands, and says exactly that – rather than repeating the base’s locomotion and lidar blocks as a second copy for someone to keep in step by hand:extends: unitree_g1 # a roqsim.models ref, or a path beside this manifest components: - arm_controller: {...} name: left_arm_controller
What is inherited is components, not geometry: a derived model keeps its own MJCF. The base’s components come first, so a derived entry with the same label is the one that runs. Cycles raise. A manifest may not carry
sim:at all – and neither may anything it extends – because a model is a component of a world, and the run’s seed, pacing and contact overrides belong to the world being run rather than to something included in it.Add a manifest for your own model: drop a
<model>.manifest.yamlbeside the MJCF listing the plugins (same shape as a world’scomponents:). Its top level takescomponents,extends,assets,fov,frames,frame_id,device_name,licenseand, on an arm,end_effector(wherespawn_armmounts a tool) and nothing else: a key outside that set is refused with the nearest known one named, since nothing reads it and a manifest loaded without it would look configured. The entity name is filled in for you, and each injected plugin also inherits the spawn’sprefix— so a build-time plugin that welds geometry onto a spawned body (e.g.fiducial_markerwithattach_to: wrist_3_link) resolves the prefixed body name without the world having to know it. A downstreamur10e_custom.manifest.yamlcould, for instance, ship anarm_controller, an eye-in-handrealsense_d415, and afiducial_markeron the wrist (Architecture & porting playbook §4, Model discovery).
A model: name is resolved across all installed packages, so a world can spawn a model that
lives in a different package from the spawn plugin. Register a package’s models once:
# pyproject.toml
[project.entry-points."roqsim.models"]
roqsim_assets = "roqsim_assets.models" # module exposing MODELS_DIR
Then {model: conveyor} finds it by bare name (or {model: roqsim_assets:conveyor}
to be explicit). A model that reuses another package’s meshes need not copy them — add an
assets: <provider> key to its <model>.manifest.yaml to borrow that provider’s mesh/texture
dirs (e.g. assets: roqsim_manipulation_assets for a custom arm variant that keeps the stock meshes).
# turtlebot4.manifest.yaml — shipped next to turtlebot4.xml (abridged)
frames:
# vendor fixed links this MJCF flattens into base_link, published as static TF
- {name: shell_link, parent: base_link, pose: {position: {z: 0.0942}}}
- {name: oakd_camera_bracket, parent: shell_link, pose: {position: {x: -0.118, z: 0.05257}}}
components:
- diff_drive: {max_linear_vel: 0.46, max_angular_vel: 1.9, wheel_accel_limit: 0.9,
cmd_vel_timeout: 0.5, odom_rate_hz: 62.0, publish_joint_states: false}
- joint_state_publisher: {rate_hz: 62} # every joint, wheels and suspension, in one message
- spawn_sensor: # the RPLIDAR A1 device model, at its vendor joint
model: rplidar_a1
parent_frame: shell_link
pose: {position: {x: -0.04, z: 0.098715}, orientation: {yaw: 1.5707963267948966}}
frame_id: rplidar_link
name: rplidar
- spawn_sensor: # the OAK-D Pro device model, at its vendor joint
model: oakd_pro
parent_frame: oakd_camera_bracket
pose: {position: {x: 0.0584, z: 0.09676}}
name: oakd
components:
- oakd_camera: # renders: needs a GL backend (roqsim selects one on import)
topics: {image: oakd/rgb/preview/image_raw, ...} # the TurtleBot 4's names
- bumper: {geoms: [body_collision], zones: {bump_front_center: [-0.314, 0.314], ...}}
- range_sensor: {site: cliff_front_left, max_range: 0.15, lazy: true, ...} # x4 cliff, x7 IR
name: cliff_front_left
- imu: {pose: {position: {x: 0.050613, y: 0.043673, z: 0.0844}}, topic: imu, rate_hz: 62}
- pose_publisher: # the base in the world, its mouse and IR receiver on it
poses: [{frame: ., child: turtlebot4}, {frame: mouse, relative_to: base_link}, ...]
rate_hz: 62
topics: {poses: _internal/sim_ground_truth_pose}
name: gt
The second half is the Create 3 base’s own sensor surface – bumper zones, cliff and IR proximity
sensors, IMU, and the ground-truth streams its vendor’s simulator adapter reads – declared on the
model because the reference robot carries them, on the topic names that adapter’s shipped parameter
files expect, and lazy so a world that never launches that stack publishes none of it. See
The Create 3 / TurtleBot 4 stack.
Selecting a policy¶
A policy-driven controller can be pointed at a different checkpoint with policy::
- spawn_robot: {model: unitree_g1}
name: robot
components:
- g1_locomotion: {policy: g1_stand, station_keeping: true}
policy: names a directory under the family’s policy/ holding <name>.spec.yaml and its
checkpoint (an absolute or relative path to a spec also works, for an out-of-tree policy). The spec
declares the observation layout, the joints the policy commands, the joints it merely observes, the
control gains, and the envelope it was trained for – so adding a policy is dropping in a directory, not
editing Python. Omit the key and the controller uses its bundled default, unchanged.
Note the envelope is recorded, not enforced: outside it a policy does not fail, it balances worse.
Check it against what a world actually contains (spec.envelope.check_payload(mass)) rather than
trusting prose to be read.
What a robot carries¶
payload adds a carried mass to one body of an entity – a load is a property of the trial, not
of a robot family, so it is stated in the world and swept like any other factor:
- spawn_robot: {model: turtlebot4}
name: robot
components:
- payload: {mass: 2.5} # kg, on the entity's root body
It is a point mass at the body’s centre of mass: mass adds, and a point mass contributes no
inertia about its own centre. An offset is refused rather than approximated – an offset payload
shifts the centre of mass and adds a parallel-axis term, which is a different body, not a heavier
one. mass: 0 leaves the model untouched, so the unloaded cell of a sweep is identical to a world
that never declared a payload. Load a body other than the root with body: (the entity’s spawn
prefix is applied for you); which robot is loaded is the entry this one sits in, so there is nothing
to point with.
Where thrust is bounded this is the flight envelope rather than a detail: see
roqsim_aerial/README.md, which measures a quadrotor’s hover collapsing at a thrust-to-weight
ratio of 1.
A range sensor that is not a scanner¶
The small range sensors a base carries – IR proximity, ToF, ultrasonic, a downward cliff sensor –
illuminate a narrow cone, and range_sensor models that cone as a small grid of rays from a
site, published as one LaserScan with the rows concatenated:
- spawn_robot: {model: turtlebot4}
name: robot
components:
- range_sensor: {site: cliff_front_left, range_min: 0.0001, max_range: 0.15, rate_hz: 62}
name: cliff_front_left # 1 ray: a cliff sensor
- range_sensor: {site: ir_front, h_rays: 5, v_rays: 5, h_fov: 0.1745, v_fov: 0.1745,
range_min: 0.025, max_range: 0.2, rate_hz: 62}
name: ir_front # 5x5 rays: an IR proximity sensor
It publishes returns, not verdicts. A cliff detector asks whether the nearest return is farther than the floor should be; a proximity sensor turns the nearest return into an intensity. Both are the consumer’s rule, applied to the grid this publishes, so a single sensor plugin serves every such device and nothing in the simulator encodes what a cliff is.
The site’s
+xis the boresight, as for every ray sensor here. A cliff sensor is a site pitched at the floor: with its boresight on the floor at a known standoff, a floor return reads the standoff and a hole reads+inf(REP 117’s no return), which is exactly the comparison a cliff detector makes.The rest is
lidar‘s. Detection limits,too_close/no_return, the noise model, the fault switch and the static mount TF are inherited rather than restated; a fan’srays/angle_*keys are refused, because the layout is the grid’s. The endpoint’s role isrange(renamed withtopics: {range: ...}), leavingscanto the robot’s scanner.
Injecting a physical fault¶
Some trials need something to go wrong at a chosen instant: a gripper that stops holding halfway
through a carry, a wheel that loses traction, a payload that changes under load. model_override
makes that a property of the world rather than something scripted into whatever drives the robot —
name a model field, name the objects, name the target value, and let the scenario switch it on:
- model_override:
overrides:
- field: geom_friction
select: [gripper_right_left_pad1, gripper_right_left_pad2,
gripper_right_right_pad1, gripper_right_right_pad2]
to: 0.0
name: grip_fault
and, for a wheel that keeps its grip only until it does not:
- model_override:
overrides: [{field: geom_friction, select: [wheel_left_tyre, wheel_right_tyre], to: 0.02}]
name: traction_fault
A geom field’s objects may also be named as bodies: [...] (every geom of each body’s subtree)
or entity: <name>, every geom of that entity taken whole – a walker’s limbs with its pelvis.
The plugin is inert until fired, so adding it changes nothing about a nominal run.
Firing it is a service call, and the reply is the point. Over ROS 2 the inbound endpoint is a
std_srvs/SetBool, so a scenario does:
service_call(service_name: '/grip_fault/override', service_type: 'std_srvs.srv.SetBool',
data: '{\"data\": true}', response_variable: 'fault')
and can fail the trial when the reply says the fault did not land — a topic publish could only be
followed by hoping. In a ROS-free stepped run the same switch is
ctx.blackboard.require("model_override:grip_fault").set_active(True), which is what an .osc
action calls. Severity is not on the wire: it is the configured to: value, so sweeping how
slippery the pads get is an ordinary experiment factor rather than a runtime message.
Three things to know before writing one:
Which side of a contact you select decides whether anything happens. MuJoCo takes a contact’s friction from the geom with the higher
priority, and at equal priority the element-wise maximum of the two. So a default-priority wheel written to0.0against a floor declaring1.0changes nothing, and overriding a carton held by pads that carrypriority="1"changes nothing either — select the geoms that own the contact, or select both sides. Useroqsim scenes describe <world> --overridable 'gripper_right*'to see the names, their current friction and their priority, rather than guessing.A fault that did nothing says so. One step after the change — or after a trial begins, for an override configured
active: true— the plugin compares the applied contact against what it asked for and reportslanded,no_effect(a warning, and a failed service reply) oruntested— the last meaning nothing was touching the selected geoms, which is not a failure. It is published asoverride_verifiedtoo, because a service call leaves no trace in a rosbag andmjModelis in neither the bag nor the state recording.A reset returns the world to the configured state, exactly, from the values read when the override was applied. Without that, repetition 2 of a sweep cell would start already faulted and report a plausible wrong number —
Engine.resetresetsMjDataand never touchesMjModel. An override the trial left as configured writes nothing, so a value another plugin set on the same rows (apayload’s mass) is kept.
Not every model value can be written at runtime; geom_size and the opt.* globals are refused
by name, with the reason and with what to use instead (for the globals, sim.contact_override,
which is global and applies before compile — a different tool for a different job). The full
allowlist, with what each field does and how it can silently do nothing, is in the plugin’s own
Config:: block above and in roqsim scenes describe’s overridable.fields. Details and the
measurements behind each row: architecture §9.2. A flex’s
flex_damping, flex_friction, flex_solref and flex_solimp are rows too, selected by
flex name; its Young’s modulus is not, for the reason in
its material, as a world key.
Deformable bodies¶
A soft block, a sheet, a cable or a compliant pad is a MuJoCo flex, and roqsim has no format of
its own for one: it is written as MuJoCo’s <flexcomp> in whichever MJCF owns it, and roqsim
reads what that compiled into. This topic says where a flex can be written, what roqsim does for
it, and what MuJoCo does with it that a world author has to know. Its snippets are two small
models – a soft block as a prop, and a pad as an arm’s tool – and a world that places both.
Writing one¶
A 50 mm block of soft silicone is one <flexcomp>, here in a model file block.xml of its
own:
<mujoco>
<worldbody>
<body name="block">
<flexcomp name="block" type="grid" dim="3" count="5 5 5"
spacing="0.0125 0.0125 0.0125" pos="0 0 0.027" mass="0.14" radius="0.002">
<edge equality="false"/>
<elasticity young="1e5" poisson="0.45" damping="0.001"/>
<contact solref="0.004 1" solimp="0.95 0.99 0.001 0.5 2" friction="0.9" priority="1"
selfcollide="none"/>
</flexcomp>
</body>
</worldbody>
</mujoco>
What each value does, with the reason for the choice, is in the rest of this topic: a 5 x 5 x 5
grid is 125 vertices; young and poisson are the material, which a world can restate
(flex_material, below); damping is sized for a 1 ms step (numerical damping, below); the
contact is stiffer than MuJoCo’s default and carries a priority so that it is the one that runs
(light vertices sink, and contact parameters mix, below); radius is the collision shell around
each vertex, and the grid is raised by it so that the shell’s bottom rests at the model’s origin.
A flex can be written in four places, and roqsim treats all four alike:
an asset placed with
spawn_model– a prop, like the block;an end effector mounted with
spawn_arm’send_effector:– a tool, its vertices pinned (<pin>) to a body of the tool model, like the pad below;the world MJCF that
sim.worldnames, compiled before any plugin builds;a plugin’s
build, which adds it to the spec like any other element.
MuJoCo expands a <flexcomp> into bodies on three slide joints each, which carry the vertices,
and the dof attribute decides how many there are:
full(the default): every vertex is a body – 375 degrees of freedom for the block;trilinear: 8 nodes carry the flex and every vertex is interpolated from them (24);quadratic: 27 nodes (81).
The two reduced modes collide a flex with itself only between elements that are neither in the
same grid cell nor in neighbouring ones. A solid block cannot fold onto itself anyway, so the
examples state selfcollide="none", which spares those tests. roqsim check computes a flex’s
modes up to 2400 degrees of freedom and suggests a reduced mode above that; the web replay draws a quadratic flex approximately (below).
Elasticity is integrated on a solid, a rope and an elastic shell. young acts on a dim=3
flex, on a dim=1 rope, which it makes bend and, through poisson (or shear), twist, and on
a dim=2 flex whose elastic2d is not none. On a shell left at elastic2d="none" (the
default) it changes nothing, and flex_material refuses a modulus it would not read. An elastic
rope gets a twist body and hinge joint per edge (<name>_twist_<i>) while MuJoCo parses the
<flexcomp>, which adds to nq and nv; so a rope is made elastic in its MJCF, and
flex_material only restates its modulus. Its bending is integrated by discrete, euler
and rk4, never implicitfast. A rope can be made stiff along its length with <edge
stiffness> instead, which every integrator but discrete runs (roqsim.flex, rule 2).
A mesh or gmsh <flexcomp> reads its file while MuJoCo parses the model, relative to the
model’s own folder and <compiler meshdir>; keep that file beside the model, since the
directories a manifest borrows through assets: are not searched for it.
What roqsim does for it¶
The integrator, and what it refuses. sim.integrator: auto (the default) resolves after
every plugin has built, so it sees a flex from any of the four places: to discrete for a flex
whose elasticity MuJoCo integrates or that has passive contact, and to implicitfast otherwise.
Before compile, roqsim refuses what such a flex cannot run under, naming the key to change:
a stated
implicitorimplicitfast(and, for passive contact, anything butdiscrete);sim.solver: pgsorsim.noslip_iterationsabove 0 – MuJoCo supports neither with such a flex underdiscrete;newton(the default) andcgwork;a flex declared in a mocap body. A mocap body moves by having its frame replaced, which applies no acceleration, so the flex would be carried rigidly and never deform. Declare it in a body that follows the target through a weld, or on an arm’s end effector.
The rules, and the MuJoCo version they were measured on, are roqsim.flex’s; where they sit
among the solver options is in Architecture & porting playbook (§4, “Solver options”).
A prop. spawn_model places a model with a <flexcomp> like any other, and adds what the
prop needs around it:
Who owns the pose. A model whose root body holds nothing but free flexes is its vertices:
motion: physicsadds no free joint, since every vertex already has its own, and a reset puts each back where the model declared it (soSetEntityStatehas nobase_jointto re-seat).staticanddrivenare refused for a flex nothing is pinned to – welding the root would hold none of it;<pin>the vertices that should be held. A flex pinned to a rigid body rides that body’s pose, whichevermotionit has: the pad below, spawnedstatic, is a mat welded where it is placed.A
<flexcomp>under<worldbody>is moved into a body named after the file, so the prop has a root, and a vertex it pins to the world is pinned there (MuJoCo’s attach would leave it pinned to the world, wherever the prop is placed).scale, mass, friction reach the flex: its vertices and collision radius scale with the prop,
masssets the total over the root’s geoms and the vertex bodies, andfrictionis written to the flex, where its contacts combine it with the other side’s by priority (below).Presence hides a flex with its entity – no contacts, not drawn, held still – and the entity lists its flexes in
meta["flexes"].
A tool. spawn_arm’s end_effector: mounts a model with a <flexcomp> pinned to one of
its bodies, or written under its <worldbody> (moved into a body named after the file, so its
pins hold on the mount). A 40 x 40 x 12 mm rubber pad on a rigid backing plate, pad.xml, whose
bottom vertex layer is pinned to the plate:
<mujoco>
<worldbody>
<body name="pad">
<geom name="plate" type="box" size="0.025 0.025 0.004" pos="0 0 0.004" mass="0.05"/>
<flexcomp name="pad" type="grid" dim="3" count="5 5 3" spacing="0.01 0.01 0.006"
pos="0 0 0.0155" mass="0.02" radius="0.001">
<pin gridrange="0 0 0 4 4 0"/>
<edge equality="false"/>
<elasticity young="2e5" poisson="0.4" damping="0.001"/>
<contact solref="0.004 1" solimp="0.95 0.99 0.001 0.5 2" friction="0.9" priority="1"
selfcollide="none"/>
</flexcomp>
</body>
</worldbody>
</mujoco>
The plate is the model’s root, so it is what the mount welds, and the pad faces away from the
mounting site along its +z. The pinned layer sits half a millimetre more than the radius clear of
the plate: an element holding a pinned vertex has that radius as its collision shell, and at
exactly one radius it grazes the plate as the pad deforms. The vertices are not
gravity-compensated: the arm holds its pose and the pad hangs under its own weight, as a real one on
a still arm does. The tool is welded at the site the arm’s manifest declares for one
(end_effector: {site: ...}), and a world’s own end_effector.site wins over it. Where the arm
has a force/torque cut, that site is below it: the UR5e declares tool_site, the outer face of
its adapter stack below fts_site, while its bare attachment_site is on the flange beside the
stack, where a sensor at fts_site reads none of the tool. force_torque refuses a sensor on an
arm whose mounted tool is outside the subtree it reads.
Its material, as a world key. What an experiment on a flex varies is its material, and a value
that lives only in the MJCF that declares the flex cannot be a campaign factor. flex_material
states it in the world instead. A world that mounts the pad on a UR5e and drops the block in front
of it, with the block’s modulus a world key (model paths resolve beside the world file):
sim:
timestep: 0.001
components:
- spawn_arm:
model: ur5e
prefix: ur5e_
pose: {position: {x: -0.25}, orientation: {yaw: 3.14159265}}
home: [-0.0671, -1.3800, 2.0314, -2.2222, -1.5708, -0.0671]
end_effector: {model: pad.xml}
name: ur5e
- spawn_model:
model: block.xml
pose: {position: {x: 0.25, y: 0.1, z: 0.05}}
motion: physics
name: block
- flex_material:
flex: block
young: 1.0e+5
poisson: 0.45
name: block_material
Each key is then a sweep axis: --set components.block_material.young=2.0e+5, or a campaign’s
parameter variation over components.block_material.young. Four things to know:
It works on the spec, before compile, because it has to. MuJoCo bakes
youngandpoissoninto the compiled element stiffness and keeps neither, so there is no model field a run-time write could reach – which is why the modulus is a build-time component and not amodel_overriderow. The contact values and the damping are compiled fields; setting them here keeps one material in one block, andmodel_overridecan still change the four live ones (flex_damping,flex_friction,flex_solref,flex_solimp) during a run.The flex is named as it compiles, with the prefix of the model that brought it in – the pad on the arm above is
ur5e_pad. A name that matches nothing is refused with the list of the model’s flexes, so the first run tells you the right one. Plugins build in YAML order, so it is declared after the component that brings the flex in – the spawn, or the arm whoseend_effectorcarries it.A key the flex would not read is refused: a modulus on a shell left at
elastic2d: noneor on a rigid flex would run exactly as without it, and one on a rope its MJCF leaves inelastic would bend it but never twist it (the rope gets its twist joints while MuJoCo parses it, above).elastic2dandthicknesscan be set in the same block, so a shell can be made elastic here, and a flex made elastic here is integrated underdiscretewhensim.integratorisauto.Write an exponent as
5.0e+5: the world is YAML 1.1, which reads5e5as a string – refused, with that fix.
The material’s rules, and the MuJoCo version they were measured on, are in
roqsim.plugins._flex_material.
Contacts are the flex’s. A contact with a flex carries geom = -1 on the flex’s side and the
flex in contact.flex. contact_monitor, contact_impulse and contact_location read that
side as the flex and attribute it to the entity that owns it (see Navigation: detecting a
collision); roqsim check’s interpenetration findings name it as flex '<name>'.
contact_pair_override refuses a flex side, because a <pair> names two geoms and MuJoCo has
none for a flex: a flex’s contact is set on the flex (below). force_torque adds every flex contact
with one side inside the subtree it senses to its reading (roqsim.flex.FlexContactWrench),
so a sensor at fts_site on the arm above reads what the pad touches as well as the pad’s
weight.
roqsim check explains each flex, from the compiled model and before any step. On the world above, its flex lines:
WARN [flex-timestep] flex 'ur5e_pad': mode 1 (134 Hz) is under-resolved by the timestep (omega * timestep = 0.85, above 0.3), and so are modes 2 and 3; the damping ratio and frequency reported for them are not the ones that run: the discrete integrator distorts their dynamics, damping them less and ringing them slower than stated
hint: set sim.timestep <= 0.000331 s to bring omega * timestep to 0.3 or below for every reported mode, or lower the frequencies with a softer material (omega scales with the square root of <elasticity young>)
WARN [flex-timestep] flex 'block': mode 3 (54.9 Hz) is under-resolved by the timestep (omega * timestep = 0.34, above 0.3); the damping ratio and frequency reported for it are not the ones that run: the discrete integrator distorts its dynamics, damping it less and ringing it slower than stated
hint: set sim.timestep <= 0.000869 s to bring omega * timestep to 0.3 or below for every reported mode, or lower the frequencies with a softer material (omega scales with the square root of <elasticity young>)
model: 186 bodies, 38 geoms, 531 joints, 6 actuators, 0 sensors, 1 cameras
timestep 0.001s, integrator discrete (auto: flex 'ur5e_pad' (elasticity), flex 'block' (elasticity))
flexes (2):
ur5e_pad dim 3, 75 vertices, 192 elements, dof full, 25 pinned, on ur5e_pad (entity ur5e); elastic, no passive contact
modes 134*, 139*, 144* Hz; damping ratio 0.845*, 0.874*, 0.906* at damping 0.001 s (numerical share 50% at timestep 0.001 s)
* under-resolved (omega * timestep above 0.3): a run damps and rings a starred mode differently -- see the flex-timestep warning
contact solref 0.004 1 (flex), floor 0.00100504 s
block dim 3, 125 vertices, 384 elements, dof full, 0 pinned, on block (entity block); elastic, no passive contact
modes 41.7, 41.7, 54.9* Hz; damping ratio 0.262, 0.262, 0.345* at damping 0.001 s (numerical share 50% at timestep 0.001 s)
* under-resolved (omega * timestep above 0.3): a run damps and rings a starred mode differently -- see the flex-timestep warning
contact solref 0.004 1 (flex), floor 0.00100504 s
The integrator line says auto chose discrete and which flexes decided it. Each flex’s first
line is what it compiled into – its pinned vertices, the body it is declared in and the entity that
owns it; the second is its lowest elastic modes with everything else held, and the damping ratio
each rings down with (the numerical-damping rule below); the last is its own contact solref
against the floor MuJoCo holds it to under this integrator (the solref floor, below: here
0.001 * sqrt(0.99) / 0.99 at the flexes’ solimp of 0.95 0.99 and damping ratio 1). A starred
mode is one the timestep under-resolves (omega * timestep above 0.3, the resolution limit
below): its frequency and damping ratio are not the ones that run, the footnote line under the modes
says so, and flex-timestep warns, with the sim.timestep that resolves every reported mode as
its hint. Here the pad’s three modes and the block’s third are starred at the 1 ms step. At the
default 2 ms step the same world also warns flex-damping, because the integrator’s share of the
damping passes half:
WARN [flex-damping] flex 'block': numerical damping is 67% of its damping (zeta_1 = 0.393, of which 0.262 is the discrete integrator's timestep * omega / 2), so its ringing changes with sim.timestep
hint: set sim.timestep <= 0.001 s (the flex's damping) to keep the integrator's share at most half, or raise <elasticity damping>
(and the same for the pad, with every mode of both starred). The three flex warnings are
flex-damping, flex-timestep and flex-solref (a contact time constant below the floor);
none makes the check fail. In --json each mode carries omega_dt and resolved, and each
flex its max_timestep_resolved; Quickstart describes the report and its --json form.
Replay and recording. roqsim export web draws each flex as a skin whose bones are the
bodies its vertices follow (roqsim.flex_skin), so a replay deforms it from the run capture’s
pose tracks with no flex-specific code. A quadratic flex is drawn from the four nodes that weigh
most for each vertex, where MuJoCo uses nine: exact at rest and under affine deformation,
approximate where the flex curves between nodes, and the export warns. sim_poses.csv leaves out
the vertex bodies (the run log names each flex left out); the recording and the run capture keep
them.
What MuJoCo does with it¶
Each of these was measured on MuJoCo 4.0.0, the version range the packages pin, and “the block” and “the pad” are the two models above.
Numerical damping under discrete. The integrator damps each elastic mode as if the stated
<elasticity damping> were one timestep larger: mode i rings down with damping ratio (damping
+ timestep) * omega_i / 2, of which timestep * omega_i / 2 is the integrator’s. With no stated
damping all of it is numerical, and changes with sim.timestep; the integrator’s share is at most
half exactly when sim.timestep is at or below the damping. The relation, and the frequency the
check reports, hold while the timestep resolves the mode. As omega * timestep grows, the
integrator damps the mode less and rings it slower than reported. Measured on a pinned block’s first
mode, read from its ring-down with the damping one timestep, the damping ratio falls short by 0.5 %
at omega * timestep 0.1, 2 % at 0.2, 4.4 % at 0.3, 11 % at 0.5 and 23 % at 0.85, and the
frequency by 0.5 %, 1.8 %, 3.8 %, 9 % and 20 %; at a fixed omega * timestep the shortfall grows
with the damping ratio. On the block’s first mode, at its own damping, the reported ratio held
within 1 % at omega * timestep 0.13 and 3 % at 0.26, and 0.9 of it rang at 0.52. The pad’s first
mode is 134 Hz, so at a 1 ms step omega * timestep is 0.85: roqsim check reports a damping
ratio of 0.85, and a ring-down measures 0.65: a stiff, light flex at a coarse step is less damped
than reported. roqsim check therefore takes 0.3 as the resolution limit – at or below it, a
mode damped at a ratio up to 0.3 rings within 5 % of both figures – and stars and warns about
(flex-timestep) every reported mode above it. Only the reported modes are judged; a flex’s
higher modes ring faster still. A coarser grid does not lower the lowest modes; a softer material
does, omega scaling with the square root of young.
The solref floor. With refsafe enabled (MuJoCo’s default) a contact whose time
constant is shorter than the step can resolve is silently held to a floor, and the integrator
decides how. Under euler, rk4, implicit and implicitfast the time constant itself is
raised to two timesteps: measured with a sphere resting on a plane at a 1 ms step, 0.5, 1 and 2
ms rest identically. Under discrete the time constant is left alone and the contact’s
stiffness is capped at what the step can resolve, damping ratio kept – as a time constant,
timestep * sqrt(I) / (solimp[1] * dampratio) with I the impedance at the contact’s depth,
which is about 1.03 timesteps at MuJoCo’s default solimp and a damping ratio of 1, and
halves when the damping ratio doubles: measured the same way, 0.5 and 1 ms rest at the same depth
and 2 ms deeper. With refsafe disabled there is no floor. roqsim.solref.solref_floor() is
the one statement of the rule; roqsim check prints each flex’s floor beside its solref and
warns (flex-solref) when the solref is below it, and sim.contact_override refuses a time
constant below the same floor.
Light vertices sink. MuJoCo scales a contact’s softness to the mass of the body it acts on: the
depth at rest depends on the load the contact carries relative to that mass, not on the load
alone. A flex’s bottom vertex is a light body carrying the weight of the column above it. Measured:
the block at MuJoCo’s default contact (solref 0.02 s, solimp 0.9 0.95) sinks its bottom
vertices 0.8 mm into a plane, seven times as deep as a rigid box of the same weight; the depth grew
with the vertex layers stacked above (0.6, 0.7, 1.0 and 1.8 mm for 2, 3, 5 and 9 layers of a
50 mm block) and did not change with the block’s total mass (0.15 kg and 1.5 kg sank alike). The
block’s own stiffer solref/solimp, made the contact’s own by priority (next), brings it
to 0.03 mm.
Contact parameters mix, unless a priority decides. At equal priority MuJoCo averages the
two sides’ solref and solimp (weighted by solmix, equal by default) and takes the larger
friction; the side with the higher priority gives all three outright. Measured with the block on
a plane left at the defaults: at equal priority its 0.004 s ran as 0.012 s and its friction 0.3 as
the plane’s 0.9; at priority="1" both were its own. Two flexes of equal priority, such as the
block and the pad, average each other’s. No <pair> can name a flex, so the flex’s own
<contact> with a priority is the one place to set a flex’s contact. roqsim check’s
contact solref line and floor check read the flex’s own value, not the mixed one.
Friction is soft, so a sustained load creeps. MuJoCo’s friction is a soft constraint: a
tangential load held below the Coulomb limit slides slowly rather than not at all, and a flex’s many
light contacts show it. Measured with the block on a plane tilted below its friction angle
(friction 0.9): at 15 degrees it crept 2.3 mm/s, at 30 degrees 9 mm/s, at MuJoCo’s defaults
(impratio 1, pyramidal cone). sim.impratio: 10 cut both tenfold, and an elliptic cone
(sim.cone: elliptic) with it by another factor of two. A press is enough to show it: the block
on a table, pressed from above by the pad on a UR5e whose stalled position servos are not exactly
vertical, is loaded sideways at 2 to 9 % of the normal load, and at the defaults it walks 24 mm
across the table in three seconds; with both settings, 3.5 mm, at about three times the cost of a
step, and either alone leaves 16 to 17 mm. A world that holds a flex under a sustained load should
state both. noslip_iterations, the solver’s own slip removal, is refused with such a flex under
discrete.
MuJoCo’s site force sensor sees a flex’s weight but none of its contacts. A contact with a flex acts
on its vertices and is not among the external forces MuJoCo’s site force/torque sensor accounts
for. Measured: a rigid probe pressed into a block reads its weight minus the contact force against
a rigid block, and its weight alone against a flex block that pushes back with 4.8 N. Everything
else a flex does reaches the sensor – its weight, its elastic reaction at rest and in motion, a
force applied to a vertex. That is the measurement behind force_torque’s correction
(roqsim_sensors.plugins.force_torque, “A flex’s contacts are added to the reading”).
Where a flex touches. A contact names the flex’s side by contact.flex and then either a
vertex (contact.vert) or an element (contact.elem), never both. Measured on the block:
against a plane every contact names a vertex (vert >= 0, elem == -1); against a box, such as
a table top, and against another flex every contact names an element (vert == -1,
elem >= 0) – a tetrahedron, whose four vertices include interior ones. So “which vertices are in
contact” is not read off the contact list: take the flex’s surface vertices within its collision
radius (plus the contact’s margin) of the other body, or near each contact.pos.
model.flex_elem lists an element’s vertices.
A stiff flex can leave the solve under-converged, and MuJoCo says so. When a stiff flex meets a
contact, MuJoCo may print Flex stiffness is too ill-conditioned for the effective-metric block
preconditioner and Inertia matrix is too close to singular, and carries on; roqsim does not
intercept either. With the pad pressing the block, the block prints them as the pad lands from
young: 2.0e+5 at a 1 ms step, and from 5.0e+5 even at 0.5 ms. A warned run at 2e5 Pa and
1 ms matched the same run at 0.5 ms, which printed nothing, within 1 % in the block’s deflection and
2 % in the contact force. To trust a run that printed it, halve sim.timestep and compare.
How a world looks: baked lighting¶
baked_lighting (core) draws a world’s static geometry with light path-traced once by Blender’s
Cycles – bounced light, soft contact shadows, ambient occlusion – where the classic renderer alone
gives flat walls and hard shadows. Turn it on with - baked_lighting: {} and bake once with roqsim
bake <world>; a world whose bake is missing or stale loads unbaked and says so, recorded with the run.
It acts in build_late, so it sees the world however it was built. Baked lighting has the
keys, the costs and what is baked.
Perception ground truth¶
Two plugins answer two different questions about the same objects, and an experiment usually wants
one of them, not both. object_detector reports an object’s POSE in the robot’s frame – what a
manipulation stack consumes, and what a real pose estimator would output. segmentation_camera
reports which PIXELS an object covers – what an IoU, a mask AP or a training set is computed from:
components:
- spawn_robot: {model: turtlebot4}
name: robot
components:
- segmentation_camera:
camera: oakd_oakd_rgb # the OAK-D's camera, behind its mount's `oakd_` prefix
classes:
- {class_id: 1, name: parcel, bodies: ["graspable_*"]}
- {class_id: 2, name: person, entities: [walker_1]}
- {class_id: 3, name: shelf_board, geoms: ["board_*"]}
instances: true
That publishes a mono8 class image, a 16UC1 instance image and a
vision_msgs/Detection2DArray of tight boxes, all off one render through the named MJCF camera.
Three selectors, because a label does not always follow a body. bodies labels everything a
body carries, and entities everything an entity is – each of its root bodies with its subtree,
so a walker’s limbs are labelled with its pelvis, as one instance – what a parcel or a pedestrian
is.
geoms labels named geoms directly, which is what the parts of a procedural prop are: a
shelf compiles to one body carrying its boards and its legs as separate geoms, and a
workbench its top and its frame, so a body-granular vocabulary can only call the whole thing
one class. An experiment measuring whether a mapper separates a surface from its support needs
them named apart. roqsim scenes describe <world> --overridable '*' lists the geom names a
world carries, which is where a prop’s parts appear — the same listing model_override’s
select: is written against, so this is not a second naming scheme to learn. Selectors compose
within a class and across classes, first match wins in declaration order, and a geom takes the
instance of the body it sits in — so two boards of one rack are one instance of shelf_board,
which is what an instance image of a rack should say.
Three properties are worth knowing before a metric is built on it. Boxes measure the visible
extent, because that is the only extent derivable from a mask and the only one a detector could have
produced – an occluded object shrinks and, below min_pixels, is not reported at all. Instance ids
are body ids, so they are stable across frames and runs rather than depending on the order things
were seen in; they are correspondingly not contiguous, which is why the detections name them.
And class id 0 is background: a declared class with id 0 would be indistinguishable from an
unlabelled geom, so it is refused at load.
Paths: endpoints and frames¶
Everything a world offers by name is addressed by one grammar, a path <component>/<name>
(roqsim.paths). The leading segments are the address of a component – its world entry’s
dotted address, dots as slashes, so tb4.oakd is tb4/oakd – as deep as they name one; the
last segment, or the rest, is a name that component offers:
An endpoint of the plugin it names:
tb4/diff_drive/cmd_vel,ur5e/force_torque/tare(Talking to a running simulation). An endpoint is also named by the entity that owns it and its name (entity_call(entity: 'ur5e', command: 'force_torque/tare')) where that entity has one of that name.A frame of the entity it names: one of its bodies, its sites, the frames its
frames:block declares, or a device’s frame chain, each named as TF shows it, without the model prefix:tb4/base_link,tb4/mouse,tb4/oakd_camera_bracket,tb4/oakd/oakd_rgb_camera_optical_frame,ur5e/tool_site. The entity’s path alone,tb4, is its root: the pose of the entity itself. Its cameras are frames too (tb4/oakd/oakd_rgb), and aroqsim.frames.Framesays it is one (is_camera), so a consumer can read its intrinsics. A camera’s frame is MuJoCo’s: it looks along -z with +y up, not along +z with +y down as an optical frame does.A frame no entity owns: a named body, site or camera of the world’s own MJCF, by its MuJoCo name alone:
gantry,gantry_cam. Its pose is always there, read from the physics state.
The caller says which kind it wants, so an endpoint and a frame of one name never collide. Within a
kind, a path that names two things – a body and a site of one name, or an unowned body spelt as an
entity’s path – is refused naming both, and an unknown path is refused with the nearest known one
and what its component offers. In a plugin nested under an entity, a frame path is relative to that
entity: . is the entity itself, and a leading / starts at the top of the world, where an
unowned frame is (/gantry). A plugin resolves one with
roqsim.frames.resolve_frame() and reads its pose with roqsim.frames.frame_pose(), which
takes both from the core pose data: an entity’s root from its pose endpoint
sim/entities/<name>/pose, a body from data.xpos/xquat, a site from
site_xpos/xmat, a camera from cam_xpos/cam_xmat. roqsim scenes describe
--body-tree shows each body’s, site’s and camera’s path as its frame.
Publishing true poses (pose_publisher)¶
A ROS stack that reads simulator ground truth off a topic – a vendor simulator’s adapter that turns
true poses into an optical-flow reading or a dock’s infrared field – gets it from pose_publisher,
the counterpart of Gazebo’s PosePublisher. Each entry names a frame by its path, and optionally
the frame it is relative to and the child name it goes out under:
components:
- spawn_robot: {model: turtlebot3_waffle}
name: robot
- pose_publisher:
poses:
- {frame: robot} # map -> robot
- {frame: robot/lds01/base_scan, relative_to: robot/base_link, child: lidar}
rate_hz: 30
topics: {poses: ground_truth}
Every pose is one endpoint, poses/<child>, carrying a Transform from the
relative_to frame’s TF name (world_frame, default map, for the world) to the child; all
go out on the one topic, and ROS carries each as a one-transform tf2_msgs/TFMessage. lazy:
true skips the reads while nobody subscribes. The TurtleBot 4’s manifest and the Create 3 world’s
dock carry one each for the Create 3 stack (The Create 3 / TurtleBot 4 stack). An analysis does not need it: the
recording holds every body’s true pose (Ground truth).
What a run cost¶
energy_monitor is the observation plugin that watches effort rather than geometry: it meters the
actuators that move a robot and integrates their mechanical power, so “energy per metre”, “how far on
a charge” and “which planner is cheaper” become numbers a run produces rather than numbers an
analysis fits:
components:
- spawn_robot: {model: turtlebot4}
name: robot
components:
- energy_monitor: {efficiency: 0.72, idle_w: 8.0, capacity_wh: 26.0, voltage: 14.4}
The split between measurement and assumption is explicit, and the defaults assume nothing.
force * velocity per actuator is measured, every step, at the physics rate – reconstructed from
a recording afterwards it would be sampled at the recording’s rate and need a drivetrain model to
turn poses back into effort, which is a fitted constant between the simulator and the result.
efficiency, idle_w, resistive_w_per_nm2 and regenerative are the platform’s own
numbers; unset, the plugin reports mechanical work and nothing else. A state of charge exists only
where a capacity_wh was given – without one the fraction is reported as unknown rather than as
a full battery. Every one of those defaults is what an absent key means, so a misspelt one would
report an energy figure that looks measured and assumes nothing: the plugin’s keys are declared in
its schema, so resistive_w_per_nm is refused with the key it meant.
The per-actuator split is what makes the number usable on an arm. Each actuator’s force *
velocity is sorted into driving and driven before the sum, so one joint descending under gravity
cannot pay for another one lifting – netted first, an arm changing pose reports as free. Negative
mechanical power is dropped rather than billed, because a non-regenerative drive dissipates the
load’s energy instead of drawing it from the pack:
components:
- spawn_arm: {model: ur5e}
name: arm
components:
- energy_monitor: {efficiency: 0.85, idle_w: 35.0, resistive_w_per_nm2: 0.012}
The torque metered is the one a real drive supplies: the actuator’s own force plus its share of
the gravity-compensation force. MuJoCo adds a compensated joint’s gravity term to
qfrc_actuator after the actuator’s own force is computed, so actuator_force reads exactly zero
on a joint holding a payload against gravity – and since every
position- and impedance-driven arm is compensated, metering it alone would report an arm that is free
to hold a load up and free to lift one. It is the same quantity arm_controller reports as a
joint’s effort, and for the same reason. Under control: effort, where nothing is compensated
because supplying the gravity term is the controller’s job, the share is zero and nothing changes.
resistive_w_per_nm2 is the term a manipulator needs and a mobile base can usually ignore: the
k in k * tau^2, the winding loss. A motor torque is a motor current, so it is the one term
that survives a standstill – an arm holding a payload against gravity has exactly zero mechanical
power and still dissipates I^2 R, which on a slow trial is often the larger part of the bill. One
number covers a machine whose motors are one class; a mapping of actuator name to coefficient gives a
shoulder and a wrist their own, and an actuator the mapping omits contributes nothing. Beside the
joules the report carries torque_integral_nms, the integral of the summed absolute actuator
forces – the effort metric a paper falls back on where its platform’s electrical constants are not
published, accumulated here at the physics rate rather than at whatever rate /joint_states was
published at.
Which actuators count is derived by default (actuators: narrows it to named ones): every
actuator driving a body of the robot’s kinematic subtree, so a world’s other machines are not on
this robot’s bill and a model that gains a joint does not need the world edited. An entity with no
actuators is an error, because a meter reading zero forever looks exactly like a robot that costs
nothing to drive.
It reports; it does not intervene. A depleted battery latches and is published; the robot keeps
driving. Ending a trial is the experiment’s decision, the same line contact_monitor draws about a
collision – a scenario reads the endpoint and stops the run itself.
Where a step’s time goes¶
roqsim sim --profile reports what the physics step costs as a whole, beside each plugin’s hooks.
step_timers splits that step into MuJoCo’s own stages – POSITION (kinematics, inertia,
collision broad and narrow phase, constraint assembly and projection), VELOCITY, ACTUATION,
CONSTRAINT (the solver) and ADVANCE (the integrator) – which is what tells a contact-heavy
scene, a flex and a long chain apart when each is slow for its own reason. MuJoCo keeps that split
in mjData.timer but fills it only while a time callback is installed; the plugin installs one at
configure and removes it at shutdown, and refuses to start if something else in the process
already installed one. The callback only reads a clock, so the trajectory is the same with or
without it.
It is a measurement mode, so a world carries it switched off with the entry-level enabled: false
sibling and a run that wants the split turns it on (--set components.step_timers.enabled=true,
or an override):
components:
- step_timers: {every_s: 0.05, path: step_timers.csv}
name: step_timers
enabled: false
Every every_s of simulated time it appends a row: t, run, wall_s (since
configure), then each timer’s cumulative <timer>_us and <timer>_n (step_us,
forward_us, pos_collision_us, …), with a final row at shutdown. A relative path lands
in the run’s output directory (RUN_OUTPUT_DIR, then OUTPUT_DIR, then the working directory),
the way roqsim sim anchors its recording. Values are cumulative and a reset zeroes them, so a
window’s share is the difference of two rows of one run. Forward dynamics outside the timed
sub-stages – for a flex under a discrete integrator, the smooth-acceleration solve – shows as
FORWARD minus its children; a step taken in two halves (a mechanism whose weight the engine
routes through a moving base) records no FORWARD. wall_s minus step_us is the time no
MuJoCo timer covers: the plugins, the recorder and the loop.
Ground that is not flat¶
Without it everything a robot can stand on here is a plane, while four of the ported platforms –
Spot, the Husky, the Jackal, the Warthog – are outdoor machines whose papers are about what happens
when it is not. heightfield is MuJoCo’s own height field wired into a world:
components:
- heightfield: {size: [40, 40], height: 2.5, resolution: 128, seed: 3}
- spawn_robot: {model: husky_a200, pose: {position: {x: 0, y: 0}}}
name: robot
It provides the ground (provides_world), so sim.world is not also built underneath it – a
floor through the hills is what that would mean. Elevation comes from one of three places and is
normalised the same way regardless: generated fractal noise (reproducible from seed, so two cells
of a campaign share their hills), a .npy array, or a greyscale .png/.tif read at its own
bit depth. A GeoTIFF is converted by the tools that own reprojection –
gdal_translate -ot UInt16 -scale dem.tif dem.png – rather than by a simulator pretending to know
about coordinate systems.
The vertical scale is stated in metres (height:), never inferred from the file: an image has no
unit, and a guessed one would put a made-up gradient under every result. It is also the natural
campaign factor – “the same hills, half as steep” is one number.
roqsim sim roqsim_mobile:warthog_terrain_demo is this with a robot on it: 2.5 m of relief over
24 m, which the skid-steer climbs at up to 23 deg of pitch. It also shows the one coupling a terrain
world has to get right – spawn_robot keeps the model’s rest height, measured against flat ground
at z=0, so the spawn belongs at the terrain’s lowest sample or the robot starts inside a hill. The
demo picks a seed whose minimum is the grid centre and pins that in a test, because a seed changed
without moving the spawn looks like a world that simply throws its robot.
Contact is against the field’s triangles, so the sample spacing is the resolution of every wheel and
foot interaction: 128 samples over 40 m is a 31 cm grid, which a 10 cm wheel rides as facets. Raise
resolution for a small rough patch rather than a large smooth one; the cost is quadratic and buys
nothing where the ground is flat.
Documenting a plugin’s config¶
A plugin’s keys are written in a Config:: block in its module docstring. Two readers parse
that block and nothing else: roqsim plugins describe (and the MCP tool over it), and the page
you are reading – every plugin listed above renders from it. A block written in a shape they do
not read is a plugin that publicly takes no configuration:
"""Sensor plugin: 2D lidar via batched ray-casting.
Config::
lidar:
rays: 360
angle_min: 0.0 # trailing text after # is the key's doc, and may
# wrap onto a bare comment line like this one
sample:
resolution: 0.25 # nested keys are published as sample.resolution
"""
The things the readers rely on:
The block opens with a line beginning
Configand ending::. Qualify it freely (“Config (in addition tolidar_common’s …)::”) and let the qualifier wrap over up to three lines – but the::must arrive, or there is no block.One key per line, as
name: example. The example is documentation, not a parsed value.Nest as the world YAML nests. A key opening a mapping is published under the dotted path a world writes it at, so the block and the YAML have one shape rather than two.
A list is an example, not a block’s end. Under a key holding a list,
- [4.0, 3.0]is an example value, and- field: geom_frictionpublishes the item’s keys under the list’s key (overrides.field). A blank line between groups of keys stays in the block; the block ends at a line written left of its keys, which is where the prose after it sits.Put it on the MODULE, not the class. A class docstring that merely points at the module (“See the module docstring.”) is ignored in favour of the module’s, but a class that documents different keys than its module will publish its own.
Inherited keys are documented once, on the base. A device built on shared machinery – a scanner on
lidar_common, a depth camera oncamera_common– documents what distinguishes it, androqsim plugins describepublishes its block followed by each base plugin’s.Every key the plugin reads is in it. A guard test reads every shipped plugin’s source and fails on a literal key that neither the block nor the schema publishes, since a caller that checks a world against the catalog would refuse that key in a valid world. A key read only to be refused with a reason (
seedon a sensor that draws from the run’s seed) is not a setting and stays out. The scan is public,roqsim.introspection.undeclared_config_reads(cls): it returns the keys a plugin class reads and does not publish, so a package that registers plugins of its own can hold them to the same rule in its tests.
Prefer the declaration below wherever the keys have types, bounds or units worth checking: prose cannot be validated, so it drifts, and this block is read by a caller writing a world.
Declaring a plugin’s config¶
Every plugin validates its own config. A plugin may also declare that config, so the checks and the published description come from one place:
from roqsim.schema import Field
class PayloadPlugin(Plugin):
CONFIG_SCHEMA = {
"mass": Field(float, required=True, minimum=0.0, unit="kg", doc="added to the body's own"),
"body": Field(str, default="", static=True, doc="body to load (default: the root body)"),
}
def configure(self, ctx):
mass = self.settings.mass # the configured value, or the default
def validate_config(self, config):
return [...] # whatever only this plugin knows
Declaring it is what enforces it. The types, ranges, required keys and unknown keys are checked
when the world’s plugins are built, beside whatever validate_config
adds; there is no call to remember. A schema the catalog publishes and nothing checks would be
prose with a type annotation.
roqsim plugins describe payload then carries a schema block: the keys with their types,
defaults, units and bounds. That is what a caller generating a world needs and what prose cannot
give it – and unlike a comment it cannot drift from behaviour, because validation runs on it. The
parameters list every plugin publishes, and this page’s Config:: block for the plugin, are
derived from the same declaration, so a plugin with a schema writes no Config:: block of its
own: a second copy of its keys in prose is the one that drifts, and a test refuses it.
It is also how the plugin reads its config. self.settings is the config seen through the
schema: self.settings.mass is the configured value, or the declared default where the world left
the key out, so a default is written once rather than again in __init__ and validate_config.
A name the schema does not declare raises AttributeError (a config.get of a misspelt key
returns None and runs on it), and nothing can be assigned to it. validate_config reads the
config it is handed with self.settings_for(config). Nothing is converted beyond an int read as
a float, so a plugin takes values as they are rather than calling float() in __init__,
where a wrong type would raise before the check that names it. Keys another owner injects
(namespace, topics) stay on self.config, as does a plugin without a schema.
It is opt-in: a plugin without a declaration is unchecked by it, and one with a declaration still
owns validate_config. The schema covers what is the same everywhere; a rule only one plugin has
(two lists the same length, a file that must exist, a cut that must be finite) stays where it
belongs rather than growing the shared vocabulary.
A key that takes more than one shape declares a tuple of types, as isinstance does:
Field((float, dict), minimum=0.0) is one coefficient or one per actuator, and is published as
"type": ["float", "dict"]. The bound applies to the number; a mapping’s entries stay with
validate_config, which is the rule a schema cannot state for a shape it does not look inside.
A block of fixed keys declares them as a schema of its own, on the field that holds it:
PLANNER = {
"inflation_radius": Field(float, default=None, unit="m", doc="default: the footprint"),
"waypoint_radius": Field(float, default=0.3, unit="m", doc="a waypoint counts as reached"),
}
CONFIG_SCHEMA = {"planner": Field(dict, schema=PLANNER, doc="the path between points")}
Its keys are checked like the top level’s and named by their path ('planner.waypoint_radius' must
be float), and an unknown one is refused with a suggestion, whatever STRICT_KEYS says: nothing
is injected into a block, so its schema is complete. self.settings.planner.waypoint_radius reads
0.3 whether the world wrote the block or not – a block’s default is its keys’ defaults, so it
declares none of its own. describe publishes the keys under the block’s fields, and the
Config:: block on this page nests them as a world writes them. A block whose keys are open (a
model’s parameters, passed through) stays a plain Field(dict).
A mapping from names the world chooses – one entry per actuator of a model – declares what each value is, as a field of its own:
CONFIG_SCHEMA = {"each": Field(dict, values=Field(dict, schema=GAINS), doc="by actuator name")}
Every value is checked against it and named by its path ('each.wrist_3.p' must be >= 0.0), a
value declared as a block strictly. self.settings.each is a read-only mapping of the names the
world wrote, each read through the field – self.settings.each["wrist_3"].p, with the block’s
defaults filled. describe publishes the value’s field under values, and the Config::
block shows it as one <name>: entry. roqsim.actuators.ACTUATORS is declared this way.
A word from another vocabulary – MuJoCo’s kp where a gain block says p, its actuator
type motor where a choice says effort – is declared as a hint on the field that refuses
it: Field(dict, schema=GAINS, hints={"kp": "use 'p'"}) for a key of a block,
Field(str, choices=..., hints={"motor": "use effort"}) for a value. It is refused like any other
unknown key or value, in one error that carries the hint in place of the nearest-name suggestion,
and nothing reads it. A word at the top level – a key the plugin no longer reads, under its new
name – goes into the class’s CONFIG_HINTS: {"press_force": "press: {max_force: <N>}"}.
A plugin with a schema reads only the keys it declares, plus the ones another owner puts there
(roqsim.schema.INJECTED_KEYS: a manifest’s prefix, the transport keys, a sensor’s fault
block, and present, which the base class checks for every plugin). The same guard test holds
every shipped schema to it.
An unknown key is refused. That is the check nothing else can do – an unknown key is a typo,
and above_Z silently leaving the ceiling standing looks exactly like the plugin not working. The
keys a component carries without the world’s author writing them are known centrally, so a schema
lists only its own. A plugin whose schema cannot be complete – one that passes keys on to something
it does not own – opts out and says why:
STRICT_KEYS = False
OPEN_KEYS = "the rest is handed to the policy, which checks it"
describe publishes the reason beside strict_keys: false, and the guard test refuses an open
schema without one.
Declaring a plugin’s endpoints¶
A plugin marks the methods that are its I/O ports (see Interfaces for what an endpoint is).
The method is the endpoint: its name is the endpoint’s name, its docstring’s first line the
endpoint’s documentation, its signature the endpoint’s schema, and its payload one of the neutral
types of roqsim.types or a dataclass of the plugin’s own. A complete plugin:
import numpy as np
from roqsim import endpoint
from roqsim.plugin import Plugin
from roqsim.types import AngularSpeed, JointState, Odometry, Speed, Twist
class Base(Plugin):
requires_owner = True
def __init__(self, config=None, **kw):
super().__init__(config, **kw)
self.odom_rate_hz = float(self.config.get("odom_rate_hz", 50.0))
self.publish_joint_states = bool(self.config.get("publish_joint_states", True))
self.pose = [0.0, 0.0, 0.0]
self.twist = (0.0, 0.0)
@endpoint.stream(Twist)
def cmd_vel(self, vx: Speed, vy: Speed = 0.0, wz: AngularSpeed = 0.0) -> None:
"""Body-frame velocity command, applied once per step.
Args:
vx: forward speed
vy: sideways speed; this base drops it
wz: yaw rate
"""
self.twist = (vx, wz)
@endpoint.out(rate="odom_rate_hz", ros2={"emit_tf": True})
def odom(self) -> Odometry:
"""Odometry of the base."""
x, y, yaw = self.pose
return Odometry.planar(x, y, yaw, vx=self.twist[0], wz=self.twist[1])
@endpoint.out(rate="odom_rate_hz", when="publish_joint_states")
def joint_states(self) -> JointState:
"""The wheels' positions and velocities."""
return JointState(["left", "right"], np.zeros(2), np.zeros(2))
@endpoint.command
def stop(self) -> None:
"""Stop the base now."""
self.twist = (0.0, 0.0)
Over ROS this is geometry_msgs/Twist on cmd_vel, nav_msgs/Odometry on odom with its
odom -> base_link transform, sensor_msgs/JointState on joint_states and a
std_srvs/Trigger service stop, each under the namespace of the entity the plugin is nested
in. The plugin names no ROS type: the bridge maps each payload type to its message.
Kinds.
endpoint.out– the method takes no parameters and returns the payload, on the physics thread when a bridge reads it. The return annotation is the payload’s type.endpoint.command– a request with an outcome.writecan be called from any thread and returns a future holding what the method returned or raised; the method runs on the physics thread. A command without parameters is aTriggerservice over ROS.endpoint.stream– an inbound stream.writekeeps the latest parameters, and the method is called with the newest once per step; values superseded within a step are never applied.
Payloads. A stream or command names its payload type as the decorator’s argument
(@endpoint.stream(Twist)), and its parameters are the fields of that type it uses, by name and
unit – a parameter that is not a field, or is in another unit, is refused when the class is read.
Or it takes one parameter annotated with the type, which receives the whole value. An out
returns the type. Payloads are dataclasses, never positional tuples.
Parameters and fields. Annotate with the unit aliases of roqsim.types (Speed,
AngularSpeed, Angle, Degrees, Length, Force, Torque, Mass, Duration,
Frequency, Acceleration; Point3, Quaternion, Velocity3, AngularVelocity3,
Force3, Torque3, Acceleration3 for vectors), or Annotated[float, Unit("...")] with
a unit spelled as a config Field’s. Document a parameter in the docstring’s Args: section and
a dataclass field in its Attributes: section; a doc string inside Annotated is refused, as is
an Args: entry naming no parameter. A parameter without a default is required. A bridge passes
parameters by name, as a mapping. A bare value (not a mapping) is shorthand for an endpoint with
exactly one parameter: it binds to that one. An endpoint with no parameters refuses it, and one with
several refuses it naming them, never guessing:
override.write(True) # def override(self, data: bool) -> data=True
override.write({"data": True}) # the same, spelled out
A mapping always names parameters, so a single dict parameter is still passed wrapped.
write refuses a missing, unknown or mistyped parameter before anything is queued, naming each
(ParameterError). roqsim plugins describe <name> publishes all of
it, and how each installed transport carries the endpoint, without building a world. Annotations
must resolve at run time: import a type used in one at module level, not under TYPE_CHECKING.
Options name attributes or config keys rather than wrapping them in lambdas:
rate="odom_rate_hz"– anout’s publish rate, from the plugin attribute of that name, else the config key; a number is a fixed rate.when="publish_joint_states"– the endpoint exists only when that attribute (else config key) is true.name=– where the endpoint’s name is not the method’s.each="joint_names"– a family, one endpoint per item, named<name>/<item>(ornamewith{item}substituted); the method gets the item as its first argument.owner=/namespace=– an endpoint that belongs to another entity than the one the plugin is nested under (endpoint_owner,endpoint_namespace).lazy=True– anoutwhose read is skipped while nobody subscribes;lazy="lazy"reads it per instance from that attribute (else config key), and describe names the key.confirm="report"– acommandwhose effect is only known after a step (a fault that landed or did not) names anoutendpoint of the same plugin whose value, recorded in thepost_stepof the step that applied the command, confirms it: a caller over the control socket (Talking to a running simulation) gets that value in the reply.
Each also takes a callable of the plugin ((plugin, item) in a family) for a value that has to be
computed.
Transport hints are deviations. ros2= gives only what the type’s mapping does not: a frame
id (frame_id, child_frame_id), stamped (TwistStamped for a Twist, Pose
rather than PoseStamped), emit_tf, a static_tf, static, a topic other than the
endpoint’s name, a qos, a field of a structure to publish alone, or type naming a message the type
maps to by field name (see below). A dict, a callable of the plugin returning one – for a value
configure resolves – or None to keep the endpoint off ROS. The control socket
(Talking to a running simulation) serves every endpoint as its payload type, with no hint; ipc=None keeps one off
it.
A topic derived from another endpoint’s. A hint’s topic (a service’s name) may name
another endpoint of the same plugin in braces: it is rendered when the plugin registers, from the
topic that endpoint is carried on after the world’s topics:, so renaming the one moves the other
with it. .. steps out of that topic’s last segment, as in a path. A name the plugin does not
register fails the world:
@endpoint.out(ros2={"type": "sensor_msgs.msg.CompressedImage", "topic": "{image}/compressed"})
def image_compressed(self) -> Image: ... # topics: {image: /cam/rgb} -> /cam/rgb/compressed
@endpoint.out(ros2={"topic": "{depth}/../camera_info"})
def depth_camera_info(self) -> CameraInfo: ... # beside the depth image
Transforms. An endpoint returning a Transform (parent, child, translation in m,
rotation as (w, x, y, z)) or a Transforms (a list of them) publishes a
tf2_msgs/TFMessage stamped with sim time: the parent is the value’s, or the frame_id hint
(default map) where the value leaves it empty, namespaced as every frame id is; the child is
published as given. On /tf it takes topic: /tf. With static: true the endpoint’s first
value is sent once on the latched /tf_static instead, parent and child namespaced, as a
static_tf hint’s transforms are:
@endpoint.out(ros2={"static": True, "frame_id": "base_link"})
def mounts(self) -> Transforms:
"""The fixed links of the sensor mount."""
Registration is the engine’s. After a plugin’s configure returns, the engine registers its
endpoints (Plugin.register_endpoints), so an option may read what configure resolved, and a
bridge listed later binds them. A test that calls configure itself calls
plugin.register_endpoints(ctx) after it. A port whose name or number is only known during the run
is added with ctx.interface.add(Endpoint(...)). The method never posts to the physics thread
itself: marshalling is the framework’s.
The world renames and tunes. A plugin’s topics: renames an endpoint (absolute with a leading
/, else under its namespace) and its qos: sets its quality of service; both are keyed by
endpoint name and applied by the bridge, so no plugin reads them:
diff_drive:
topics: {cmd_vel: /teleop/cmd_vel}
qos: {odom: sensor_data, cmd_vel: {reliability: best_effort, depth: 1}}
Custom types and QoS¶
Any dataclass is a payload. Fields annotated with unit aliases, nested dataclasses, and numpy
arrays with a Shape (Annotated[NDArray[np.float64], Shape(None, 3), Unit("m")]) are
described, documented and checked like a core type’s – a command taking one checks a mapping
of its fields, nested ones included. On ROS it travels one of three ways:
By field name, onto the message its hint names:
@dataclass class Push: linear: Vec # a dataclass with x, y, z angular: Vec @endpoint.out(ros2={"type": "geometry_msgs.msg.Accel"}) def push(self) -> Push: ...
Each field must be a field of the message of a fitting kind – a float to a float or integer, a sequence to a sequence or array, a nested dataclass to a nested message. A message’s
headerthe payload does not carry is stamped by the bridge. When the bridge binds the endpoint it refuses a field that does not fit, naming it and the message’s fields; nothing is dropped silently. Aninendpoint with plain parameters maps its parameters the same way.By a converter its package registers once: an entry in the
roqsim.ros2_typesentry-point group loading aroqsim_ros_bridge.typemap.RosType(or several) – the type, the messages it travels as, and afill/decodepair for each. Every endpoint of that type is then on ROS with no hint.roqsim_sensors.ros2_typesis one: a GNSS fix, 3D object detections and 2D boxes asNavSatFix,Detection3DArrayandDetection2DArray.Not at all: with neither, the endpoint is not on ROS.
roqsim plugins describesays so and why, and the bridge logs it; an endpoint that gave ROS hints and still has no mapping fails the bridge instead.
QoS. Every topic defaults to default (reliable, volatile, keep last 10); TF keeps its own. A qos hint or a world’s qos: entry is a preset – default,
sensor_data (best effort, depth 5), services_default, latched (transient local, depth 1)
– or a mapping of reliability (reliable/best_effort), durability
(volatile/transient_local), history (keep_last/keep_all) and depth over
default. The world’s wins over the hint. A qos: naming an endpoint the plugin does not
register fails the world, naming the ones it has. roqsim plugins describe shows each endpoint’s
QoS, and roqsim describe on a running simulation the effective one the ROS bridge used.
Converting a plugin¶
A plugin that still builds Endpoint(...) in configure is converted one endpoint at a time,
and its ROS interface – topic, type, service, action, frames, rate, QoS – stays exactly as it was:
The method. The
readorwritebecomes the decorated method, named as the endpoint. A method the plugin also calls in process under its old name (aRobotHandle’sread_odom) stays beside it, plain.The payload. A positional tuple becomes a type of
roqsim.types(Odometry.planar(...)for a planar odometry,Wrench(force, torque),JointState(names, positions, velocities)) or a dataclass of the plugin’s. Aninendpoint’s parameters become that type’s fields by name (vx,vy,wzof aTwist).The hints. Delete
type(the payload’s mapping gives it),topicwhere it is the endpoint’s name,self.topic_override(...)(the framework appliestopics:; a topic built from another endpoint’s becomes a{name}template), and any value the mapping defaults to (frame_id: odomon odometry). What stays is a real deviation. Arate_hz=lambda self: self.xbecomesrate="x", a surroundingifbecomeswhen="x", and a per-instancelazybecomeslazy="x".Owner and namespace. Delete them where they are the entity the plugin is nested under; otherwise override
endpoint_owneror passowner=/namespace=.The kind. A setpoint topic is a
stream, a service acommand, and an input that must see every value in order (a trajectory, a queue of goals) acommandtoo, since a stream keeps only the latest. Anyctx.postin the write goes: the framework queues it. A loop becomes a family (each=).Prove it. Record every endpoint (owner, namespace, name, direction, rate, lazy) and what the bridge resolves for it (
roqsim_ros_bridge.typemap.resolve: type, topic, QoS, frames) across the worlds that use the plugin, before and after, together with the messages its outputs fill; both must be equal. A test that calledwrite(payload)passes the mapping of parameters.
An endpoint that only carries a model’s fixed frames returns them with static: true
(roqsim.frames.static_transforms_of turns the frame dicts into Transforms); a plugin that
still builds its endpoints by hand adds roqsim.frames.static_tf_endpoint, which does the same.
Where a static_tf hint on an endpoint with nothing else to publish becomes such an endpoint, its
transforms are unchanged: they are sent once on the latched /tf_static on the first step, and the
idle tf publisher the hint’s endpoint held goes.
What stays hand-built: a port whose name or number is only known during the run, and a plugin’s
own transport thread (px4_sitl’s socket reader posts what it received; that is not an endpoint).
The follow-ups. One pull request per package, each leaving every ROS interface unchanged:
Package |
Plugins (endpoints) |
Needs |
|---|---|---|
|
|
– |
|
|
families: |
|
the action handlers ( |
– |
A last pull request removes the old way: no installed plugin calls ctx.interface.add(Endpoint(...))
or posts from an endpoint’s write, a test enforces it over every entry point in roqsim.plugins,
and payload_for’s positional form for an untyped endpoint goes.
Degrading a sensor mid-run¶
model_override changes the physics. Its counterpart changes what a sensor reports — a lidar
that starts dropping returns halfway down a corridor, a scanner whose noise triples when it fogs up.
That perturbation belongs in the sensor’s own config (§9.1), not in a model field, so it is written
there and needs no plugin of its own:
components:
- spawn_robot: {model: turtlebot4}
name: robot
components:
- spawn_sensor: {} # the manifest's RPLIDAR mount, by its label
name: rplidar
components:
- lidar:
range_stddev: 0.01
dropout_percent: 2.0
fault: {dropout_percent: 60.0, range_stddev: 0.35} # held while active
The sensor is nominal until the fault is switched on, so adding a fault: block changes nothing
about a run that never fires it. A scenario switches it through the override command of the
sensor’s address:
entity_call(entity: 'robot.rplidar.lidar', command: 'override', value: 'true')
wait elapsed(8s)
entity_call(entity: 'robot.rplidar.lidar', command: 'override', value: 'false')
which the control socket serves as robot/rplidar/lidar/override (confirmed by its
override_verified report), and over ROS 2 the same switch is a std_srvs/SetBool at robot/rplidar/lidar/override, with
robot/rplidar/lidar/override_state and .../override_verified reporting back. The address is the dotted
path of labels with dots as slashes, because a dot is not legal in a ROS name; a bare lidar would
name neither of a robot’s two lidars.
It mirrors model_override in the three ways that matter, rather than re-deciding them:
Severity is configured, not sent. The
fault:values are ordinary config, so sweeping how bad the fault gets iscomponents.robot.rplidar.lidar.fault.dropout_percent— an experiment factor, deterministic per cell and in the run’s provenance. One bit crosses the wire.The world never decides when. No time trigger, no condition trigger; a fault’s timing is the experiment’s independent variable.
A fault that changed nothing is reported as such. Applying a block whose values already equal the nominal reports
no_effect, andentity_call’srequire_verifiedfails the trial on it — an unfaulted outcome wearing a faulted label is worse than a failed run. A restore has nothing to verify and reportsuntested.
Only keys the sensor reads per frame may be written. Each sensor declares its own allowlist; on
the ray-casting sensors that is range_stddev, range_stddev_relative,
range_stddev_relative_from, range_resolution, dropout_percent, max_range, range_min
and rate_hz, plus detection_min and detection_max on the 2D lidar, and on the imu it is the noise, the biases and orientation – so a trial can
drop the attitude channel or triple the rate noise partway through, which is what an IMU failure
looks like to a localisation filter. Everything else is refused at load, by name, with the reason — rays,
angle_min and angle_max because they change a LaserScan’s length or the bearing its
indices mean, and site/frame_id/exclude_body because they are consumed once at
configure. This is the geom_size rule from the physics channel: a value that writes fine,
takes effect nowhere, and reads back as though it had is worse than one that is refused.
A fault does not survive reset: one process serves several trials, and a fault leaking into the
next would quietly turn a nominal control cell into a degraded one.
Bases: four geometries, one interface¶
diff_drive, omni_drive, ackermann_drive and tricycle_drive publish the same
endpoints – cmd_vel in, odom and joint_states out – so a stack does not know which it
is driving until it asks for something the geometry cannot do. That is the point of the last two: a
car, and a tricycle whose steered wheel stops short of 90 degrees, cannot turn in place, and
cmd_vel with v = 0 and a yaw rate moves either nowhere at all. A planner that emits that
command is a planner that would not move the real vehicle, and approximating a car with a
differential base and a small angular limit hides exactly the failure the experiment is looking for.
What a real base offers its stack. Three keys on diff_drive are the base driver’s
behaviour rather than the kinematics’, and a model that states its robot’s interface states them in
its manifest – the TurtleBot 4’s does. cmd_vel_timeout is on every plugin that takes a
cmd_vel (see A velocity command: odometry and the watchdog); the other two are
diff_drive’s alone:
- diff_drive:
cmd_vel_timeout: 0.5 # the watchdog every base driver has; 0 (default) holds a command
odom_rate_hz: 62.0 # the rate odom (with its TF) and joint_states are published at
publish_joint_states: false # when a joint_state_publisher covers the whole robot
cmd_vel_timeout is off by the plugin’s default because an in-process driver sets a twist once
and steps; a stack republishes at a rate and expects a dead publisher to leave a stationary robot,
and the stop goes through the same acceleration ramp as any command. publish_joint_states
exists for the consumer that needs a passive joint – a suspension travel, a caster swivel – in
the same message as the wheels: the core joint_state_publisher publishes every hinge and
slide joint of the entity in one message, the way ros2_control’s joint_state_broadcaster
does, and the base’s own two-joint message is then switched off rather than left to interleave
with it:
- spawn_robot: {model: turtlebot4}
name: robot
components:
- diff_drive: {publish_joint_states: false}
- joint_state_publisher: {rate_hz: 62} # every joint, names without the spawn prefix
The command’s message type is the stack’s choice, not the base’s, so it stays a world key:
stamped_cmd_vel: true where the stack publishes a TwistStamped – a TurtleBot 4’s own nav2
configuration does, and with the Create 3 nodes the base listens where motion_control
republishes (topics: {cmd_vel: diffdrive_controller/cmd_vel}). Getting it wrong is not silent:
the ROS bridge asks the graph once a second and fails the run when a peer of another type sits on
one of its topics, naming the topic, both types and both sides.
ackermann_drive needs the model’s four names – two steered joints and two driven ones, left then
right – plus the wheelbase and the widths its geometry comes from:
components:
- spawn_robot: {model: my_car}
name: robot
components:
- ackermann_drive:
wheelbase: 0.32
track: 0.24
steer_track: 0.20
max_steer_angle: 0.5
steer_actuators: [left_steer_motor, right_steer_motor]
steer_joints: [left_steer_joint, right_steer_joint]
drive_actuators: [rear_left_motor, rear_right_motor]
drive_joints: [rear_left_joint, rear_right_joint]
The two front wheels are steered by different angles and the two rear wheels driven at different speeds, both derived from the same curve – the inner wheel of a turn follows a tighter radius, and a shared value would scrub the tyres. Both splits vanish as the curve straightens.
Which width is which. A real car has three and they are not interchangeable: the separation of
the two steering axes, the separation of the front wheel centres, and the driven axle’s track. The
two splits are measured across different ones, so there are two keys. steer_track is the width
the steer split pivots about – the steering axes, which on most vehicles are inboard of the wheels
since a kingpin sits inside the hub – and track is the driven axle the drive split is measured
across. steer_track defaults to track, which is exact for a design whose steering axes sit at
its wheel centres; anywhere else, leaving it out overstates the steer split at every radius, and the
front wheel centres (neither of the two) overstate it whichever key they are passed as.
It also accepts the message a car-like stack already speaks. ackermann_cmd takes an
ackermann_msgs/AckermannDriveStamped on drive, beside the cmd_vel every base here
publishes:
ros2 topic pub /drive ackermann_msgs/msg/AckermannDriveStamped \
'{drive: {steering_angle: 0.3, speed: 0.6}}'
The message’s steering_angle is defined as the yaw of a virtual wheel located at the center of
the front axle, which is exactly the centre angle this plugin splits into two, so nothing is
converted on the way in. That is what makes it more than an alias for a twist: a twist states a
curvature, w / v, which says nothing at rest – so through cmd_vel a stopped car’s rack can
only hold the angle it has. Through ackermann_cmd a stopped car can turn its wheels, which is
what a real one does while parking, and what a car-like stack sends when lining up before it moves
off. Whichever of the two commands arrived last owns the angle; they are never merged, because a
stated angle and a curvature are two ways of saying the same thing and averaging them obeys neither.
Both interfaces are kept because their consumers differ. Nav2 plans for car-like vehicles perfectly
well – Smac Hybrid-A* and the state-lattice planner both take a minimum turning radius – but its
controller commands a twist (Twist, or TwistStamped with enable_stamped_cmd_vel), so a
car driven by Nav2 needs cmd_vel (Choosing a drive for a new robot has the configuration). A
stack built around ackermann_msgs needs the other. Neither is a superset of the other.
Its odometry is dead reckoning like the others’, and it drifts on a curve where the tyres slip. That
is left visible rather than corrected by a scrub factor: a skid-steer’s scrub is systematic enough
for diff_drive’s slip_factor, while a tyre’s slip angle varies with speed and load, so a
constant would only make the estimate look better than the sensor it stands for.
tricycle_drive is the other car-like base: one steered wheel on the centre line and a fixed
axle, which is how three-wheel counterbalance forklifts, tuggers, pallet trucks and many AGVs are
built. base_link must be the centre of the fixed axle, since that is the point such a vehicle
always turns about, and steer_offset is the signed distance to the steering axis – negative for
a rear-steered forklift, positive for a front-steered tugger:
- tricycle_drive:
drive: axle # the fixed axle's two wheels are driven; or steer_wheel
steer_offset: -1.393 # rear wheel, 1.393 m behind the axle
wheel_radius: 0.229
track: 0.930
max_steer_angle: 1.396 # must be < pi/2
steer_actuator: steer_motor
steer_joint: steer_joint
drive_actuators: [drive_wheel_left_motor, drive_wheel_right_motor]
drive_joints: [drive_wheel_left_joint, drive_wheel_right_joint]
passive_joints: [steer_wheel_joint] # published in joint_states, never commanded
A twist (v, w) moves the steered wheel’s point at (v, w * steer_offset), so the wheel is
pointed along it, atan(w * steer_offset / v), and clamped to its lock – a rear wheel therefore
steers right for a left turn going forward. With drive: axle the two fixed wheels are split
like a differential across track, using the measured steering angle so that neither scrubs
while the wheel is still slewing; near full lock the inner wheel runs backwards, as on the real
truck, and max_wheel_speed caps the outer one. With drive: steer_wheel the steered wheel is
driven at v / cos(delta). steer_offset and track are checked against the model’s own
joint positions at configure and a disagreement over a centimetre is refused.
A zero-speed twist moves nothing and leaves the steered wheel where it is, for the reason given for
ackermann_drive: a lock short of 90 degrees cannot pivot the vehicle about its axle centre, and
at full lock it still turns about a point |steer_offset| / tan(max_steer_angle) to the side. The
plugin therefore declares kinematics="ackermann" on its RobotHandle. Its odometry takes the
speed from the driven wheels and the yaw rate from the measured steering angle; passive_joints
exist because robot_state_publisher leaves a link out of TF until every movable joint above it
has a state. Like diff_drive it takes odom_rate_hz and publish_joint_states.
Both car-like drives ramp the commanded speed at two rates: accel_limit while gaining speed and
decel_limit while losing it – towards a slower target, to a stop, or on a reversal down to rest,
after which the new direction is gained at accel_limit. decel_limit defaults to
accel_limit; either at 0 is instant.
Choosing a drive for a new robot¶
Pick the plugin by how the robot’s wheels are steered, start from the roqsim_mobile model or
section named beside it (a bundled model has a demo world and a tests/test_<model>_scene.py), and
give Nav2 the configuration in the last column (ros2_ws/src/roqsim_nav2_example):
wheels |
plugin |
start from |
Nav2 configuration |
|---|---|---|---|
two driven wheels and casters (differential) |
|
|
|
four or more driven wheels, none steered (skid-steer) |
|
|
|
mecanum or omni wheels |
|
|
|
independently steered wheels (swerve) |
|
|
as for mecanum |
two steered front wheels, a fixed rear axle (a car) |
|
|
|
one steered wheel, a fixed axle (a tugger, pallet truck, three-wheel forklift) |
|
its section above; no model is bundled |
|
The last two cannot turn in place, and nav2_params.yaml’s rotate-to-heading controller leaves
them standing still. nav2_params_carlike.yaml is the stack that drives them – Smac Hybrid-A*
over Reeds-Shepp motions and Regulated Pure Pursuit that reverses and never rotates on the spot –
and a small per-robot file beside it holds what depends on the robot: the footprint about
base_link and the minimum_turning_radius. The physical minimum comes from the geometry,
wheelbase / tan(max_steer_angle) or |steer_offset| / tan(max_steer_angle); the planning value
is chosen above it, so the controller keeps some lock in hand. nav2_carlike.launch.py
robot:=<model> brings one up, and test/test_nav2_carlike_goals.py drives the PiRacer to a goal
that needs a turn and one that needs reversing (nav2 example).
A velocity command: odometry and the watchdog¶
Every plugin that takes a body-frame twist keeps the same two promises to the stack driving it –
diff_drive, omni_drive, ackermann_drive, tricycle_drive, spot_locomotion,
g1_locomotion, oli_locomotion, and quadrotor_controller for its velocity command. Both are in
roqsim.odometry, for a plugin of your own to keep too.
Odometry starts at zero where the robot was spawned. The odom frame is the spawn pose: the
first odom message reads (0, 0, 0) whatever the world’s pose:, and driving forward reads
as +x whatever the spawn heading. A wheeled base integrates its wheels from zero, so its
odometry drifts as wheel odometry does. A legged controller reads its base pose from the simulator
and states it relative to the spawn pose, so its odometry is exact, and its z stays the base
height, so base_link stands where the robot does. The true pose is not in odom: it is the
core pose endpoint sim/entities/<name>/pose and the run’s recording (Ground truth). A map -> odom identity is therefore right
only for a robot spawned at the map origin facing +x.
A command expires. cmd_vel_timeout (seconds of sim time) is how long a command holds; once
the last one is older, the robot stops, through the same limits as any command to zero; a
locomotion policy is given a zero command and walks to a stop. 0, the default, holds a command
until the next one, because an in-process driver sets a twist once and steps; a world that runs a
real stack sets the stack’s value (ros2_control’s diff_drive_controller ships 0.5 s). Reset
clears the command and its stamp, so no trial starts with the last one’s.
A quadrotor, in three dimensions. quadrotor_controller’s odom is 6-DOF in the same frame:
x and y from the spawn point along the spawn heading, z the altitude, tilt kept, and the twist
in the body frame. A stale velocity command brakes the drone at its altitude setpoint and then holds
where it stopped: a hover. A position setpoint (target, cmd_pos) does not expire, since
holding one already is a hover. cmd_pos is read in the frame its header names: odom is this
spawn frame, world or map (or no frame) the world, and any other frame is refused. The
configured target is a world position.
Manipulation: an arm on a linear axis¶
A gantry, a ceiling track or a seventh-axis floor rail is a prismatic joint carrying the arm base.
spawn_arm’s rail: expresses it, and it is the one thing mount: cannot: mount welds the
arm to a body that already exists, while a rail has to introduce the moving carriage itself:
components:
- spawn_arm:
model: ur10e
prefix: "ur10e_"
pose: # where the axis sits, rolled 180 deg: the arm
position: {z: 2.6} # hangs from the ceiling
orientation: {roll: 3.14159265}
rail: {axis: [1, 0, 0], range: [-2.0, 2.0], home: 0.0}
name: ur10e
What this buys is kinematic redundancy: a 6-DOF arm on a rail is a 7-DOF system, so a task pose has a one-parameter family of solutions and a planner can trade base travel against arm posture.
Three facts other code depends on:
The rail is joint 0. Its MJCF joint and actuator are declared before the arm’s, so
arm_controllerpublishes and commands[rail_joint, <arm joints...>]— matching a URDF with the prismatic joint at the root of the chain, which is what MoveIt plans against.``home`` stays the arm’s joint vector; the carriage’s start is
rail.home. Folding the rail intohomewould invalidate every per-model default (a 6-valueur10ehome would land on[rail, j1..j5]and leavewrist_3unset).The carriage and track geoms are visual only. A ceiling track that collides traps the arm against its own support from the first step, and the collision model a planner reasons about comes from the URDF/planning scene, not from these geoms. Model real structure as scene geometry.
roqsim export urdf handles such a robot: a jointed root is emitted below a synthetic fixed world
link (--world-link), which is the standard URDF spelling for a rail and keeps the fixed root MoveIt
requires. A root body with a free joint still becomes a fixed root — a floating base belongs in TF
(odom -> base_link), not in the description.
The SRDF is where that base reappears, and roqsim export srdf reads it off the model rather than
assuming it: a base riding a MuJoCo free joint gets a planar virtual_joint (--base-joint
floating for a full 6-DOF one), while a base welded to the world — an arm on a pedestal, or a rail
whose DOF is already a URDF joint — gets none, which is how MoveIt spells a bolted-down robot. Declaring
a virtual joint nothing publishes does not fail loudly; move_group logs Missing virtual_joint and
never assembles a complete robot state, so --base-joint planar on a welded model is refused.
Manipulation: the whole MoveIt configuration¶
move_group needs six files, and the two above are the two a human would call the robot
description. roqsim export moveit writes all six:
roqsim export moveit --world cell.yaml --out cfg/ --tip-site pinch --check
cfg/
<arm>.urdf meshes/ the kinematics, FK-checked against the MJCF
<arm>.srdf groups, named states, a sampled collision matrix
kinematics.yaml a solver over the chain the SRDF names
joint_limits.yaml the kinematic limits that time a geometric path
moveit_controllers.yaml which action a trajectory is executed against
ompl_planning.yaml the planner -- a starting point, meant to be overridden
The invariant is the same one the URDF export exists for, extended to the rest: the configuration
MoveIt plans against is derived from the model the simulator loads, and --check fails the export
when the two disagree by more than a micrometre.
Where the meshes are referenced from is a separate question, and ``–check`` does not answer it.
The default URI is file:// plus the path the export wrote to, which is right where the URDF is read
out of the tree it was generated in and wrong everywhere else: an ament package installs to another
prefix, and a campaign generates the description in one container and plans in another.
--mesh-package and --mesh-prefix name the consumer’s path instead — where the meshes will be
READ — and both exports take them, as alternatives to each other. move_group does not fail on a
mesh it cannot fetch; it logs the failure, keeps the links without their collision geometry and plans
through them. So an export whose URIs land under a temporary directory warns about it, and --check,
which resolves the meshes in the export’s own mesh directory whatever the URIs say, reports that it
measured the geometry rather than the reference.
That matters most for the file that looks least interesting. moveit_controllers.yaml maps MoveIt’s
controller names onto the actions this substrate’s bridge serves and onto the joint list
arm_controller publishes — so it is read from the Endpoint objects the controller declared,
not restated. A name written by hand there can be right on the day and wrong after a world renames a
controller, and the failure is that a trajectory is executed against nothing.
Four more answers come off the model rather than from flags, each because getting it wrong is quiet:
the joint list and its order — the
ArmHandlethe controller published, i.e. the names that reach/joint_states.robot_state_publishermatches by name, so a list that is right about the robot and wrong about the order leaves MoveIt planning from a pose the arm is not in. The controller’sjoint_prefixis part of those names, so the URDF’s joints, the SRDF andmoveit_controllers.yamlcarry it too.the home posture —
data.qposafter setup, not the world’shome:key. The controller applies that key itself and areststance may overlay it, while MoveIt’s start-state bounds check runs against the posture the arm is really in.the collapse root — the lowest common ancestor of every body a
connectorweldequality touches. A closed linkage is exactly what URDF cannot express, and MuJoCo says where one is; collapse it and the loop is gone, miss it and the URDF keeps revolute DOFs nothing publishes. Ajointequality closes no loop: it couples two fingers of an open chain, and the URDF carries it as a<mimic>on the joint that is not commanded.``fix_start_state`` — emitted only for an arm that has a continuous joint.
CheckStartStateBoundsnormalizes such a joint onto [-pi, pi], and with this false (its default) it reportsSTART_STATE_INVALIDprecisely because it had to normalize. A start state that drifted a hair past pi is therefore refused rather than wrapped, which surfaces as a phase failing instantly right after a phase that succeeded — at a different phase each run. True writes the normalized state back into the request; a joint genuinely outside its limits is still refused, by a separate bounds check this flag does not relax. A range-limited arm has no such problem and gets no such setting.
The IK answer is not one of them. kinematics.yaml configures MoveIt’s KDL plugin, and that is
the one generated file whose content is not a reading of the model: the plugin solves from the seed
state on its first attempt and from a configuration drawn uniformly inside the joint limits on every
attempt after that, until kinematics_solver_timeout is spent, and takes the first attempt that
converges. The draw is seeded per process from the clock and the number of attempts that fit in the
budget follows the machine, so one pose is answered by a different arm branch from run to run –
the elbow the other way, or a joint turned a full revolution where the limits hold that posture twice
– while everything else the export writes is the same file every time. Each branch is a correct
answer: the tool frame lands where it was asked for, the plan succeeds, and the arm took another
route and stands in another posture. No parameter of the solver constrains it to one branch (its own
are joint weights, max_solver_iterations, epsilon, orientation_vs_position and
position_only_ik), so the export states the fact in the file’s header, names there the joints
whose exported limits hold one posture at more than one value, and warns when it writes it. A trial
whose repeatability rests on a pose therefore solves that pose’s joint vector once, against this
description, commands it in joint space, and reaches further poses by a Cartesian path from the one
the arm is in – which follows the branch it is already in instead of choosing one. Where a query at
run time cannot be avoided, check the joint vector that comes back against the posture expected
before executing it: a plan that succeeds is not evidence that the answer was the intended one.
Pass ``–tip-site``. Without it the arm chain ends at the tool flange, and a goal for the
fingertips has to be written as an offset from there — which multiplies every orientation tolerance by
that lever arm, so 0.15 rad of permitted tilt becomes ±33 mm at the fingers. One cell measured 61 mm of
lateral error against 12.2 mm of jaw clearance: MoveIt had satisfied the goal exactly, and the goal was
about the wrong point. --tip-site pinch emits a frame link at the gripper’s own grasp site (through
a collapsed parent, where such a site usually sits), so a 3 mm position tolerance means 3 mm at the pads.
Two arms that must move at once. --arm left,right describes both as one robot: one URDF with
both chains under a common root, one group per arm, and a group spanning all of them. That last group
is the point of it — a plan for it is a single trajectory through both arms’ joint space, so each
arm’s motion is checked against where the other is at that instant rather than against where it was
before it started. It deliberately gets no IK solver: KDL solves a single serial chain and this
group is several, so a solver there would load and then fail every pose request; reach a pose through
one arm’s own group, and use the combined group for joint-space planning. One flat namespace has to
hold both arms, so their links and joints keep each arm’s MJCF prefix — and since joint names are the
controller’s, not the description’s, each arm’s arm_controller needs joint_prefix: set to that
same prefix. An arm publishing unprefixed names is refused rather than renamed, because those names
are what reaches /joint_states and what a trajectory point carries. Every check above runs per arm:
a second arm whose chain is short by a joint, or whose home disagrees with the simulator, fails as
loudly as the first.
More than one planning pipeline. --pipelines ompl,chomp writes a planning_pipelines.yaml
naming them for move_group and saying which one a request that names none gets; with the default
single pipeline neither that file nor the selector is written, because there is nothing to select. Any
name MoveIt can load is allowed — the list is open, so a pipeline this exporter has never heard of
costs nothing — but each one’s planner package has to be installed where move_group runs, or the
pipeline fails to load at start-up rather than failing the request that uses it.
Only ompl_planning.yaml is written. Its projection_evaluator names joints this model has,
which is what makes it derivable; an optimizer’s cost weights are not — they are the operating point
of a minimisation, which is the experiment’s decision, and a table of them emitted here would be the
exporter making it. Every other pipeline therefore takes MoveIt’s own packaged config (the config
builder falls back to moveit_configs_utils/default_configs/<name>_planning.yaml) until the
experiment puts a file of that name on the config path it reads.
Use this for a comparison across pipelines, where the planners are different plugins with
unrelated parameter files and a trial picks one per request through MotionPlanRequest.pipeline_id;
comparing planners inside OMPL is another entry in ompl_planning.yaml and needs none of it. One
thing to settle before designing such a comparison: CHOMP accepts joint-space goals only. It
rejects a goal with no joint constraints, or with any position or orientation constraint, as
INVALID_GOAL_CONSTRAINTS, so a trial that sets a pose target fails every CHOMP request outright —
which reads like a planner performing badly rather than one that was never given a goal it could take.
Solve the IK and send joint goals, or leave that pipeline out of a pose-goal comparison. The export
warns about it, and planning_pipelines.yaml says so in a comment.
What it does not write is a planning.yaml. The planning frame, the group name and the gripper’s
units belong to whatever node drives the trial, and that is the experiment’s file, not the substrate’s.
Manipulation: the world the arm stands in¶
Those six files describe the robot and nothing else, so the world the simulator loads and the
world the planner reasons about are disjoint: the bench the arm is bolted to, the cabinet it opens
and the wall beside it are invisible to move_group, which plans straight through them, and the
simulator resolves the contact afterwards. There is no error and no warning — the symptom is a plan
that looks fine and an arm that drives into furniture.
--scene writes the other half from the same compiled world, as a seventh file:
roqsim export moveit --world cell.yaml --out cfg/ --tip-site pinch --scene
# cfg/planning_scene.yaml
It is a moveit_msgs/PlanningScene, in YAML a bring-up node fills the message from directly, and
it is a diff: applying it (/apply_planning_scene, or a PlanningScene publisher) adds the
world’s objects and states nothing about the robot. A non-diff scene replaces everything in it, the
robot state included, so applying one would hand the planner a robot at all-zero joints.
One object per static body, at that body’s pose, carrying the primitives it is built from. An
industrial_table is one object called industrial_table holding its top and four legs, so a
trial allows, pads or removes the bench rather than five unrelated shapes. Geoms hanging directly
off the world body — the room’s walls — are each their own object, because one object holding every
wall could not be padded a wall at a time. Poses are written in the frame move_group plans in:
the URDF’s root link, which is the arm’s own base and not the world origin.
What it leaves out is reported by name, in the log and in the file itself, because a missing obstacle is exactly the silent failure the flag exists to end:
Anything with a degree of freedom — a
motion: physicsprop, amotion: drivenobstacle, a pedestrian, another robot’s links. Its pose at export time is not where it will be. Note the default:spawn_modelgives a prop a free joint unless toldmotion: static, so scenery meant for the planner has to say so.Visual-only geometry (
contype/conaffinityboth zero). The simulator does not collide it, so a planner that did would refuse motions the robot can make.Mesh geoms. MoveIt takes a mesh as explicit triangles and MuJoCo collides one as its convex hull, so neither is a shape the two engines agree on — and they disagree most exactly where a hull fills the span a trestle or a shelf exists to leave open. A prop for a planning scene carries primitive collision geoms behind its visual mesh, which is what
roqsim assets collisionmeasures.Plane geoms. A MuJoCo plane is infinite and the robot stands on it, so a half-space in the scene puts the start state in collision and every request is refused before it is planned.
Ellipsoid, height-field and SDF geoms —
shape_msgs/SolidPrimitivehas a box, a sphere, a cylinder and a cone, and none of those is any of these. A capsule is not in this list: it is exactly a cylinder and two spheres, and one object holds all three.
A robot that is not welded down is refused rather than written: its base rides a free joint, so MoveIt plans in a frame TF provides, a prop’s pose is fixed in the world, and the offset between the two is a run-time quantity. Publish that scene from the stack, against the frame TF gives it.
The export also says which objects touch the robot at the posture the simulator starts in.
CheckStartStateCollision refuses a request whose start state is in collision, so an arm bolted to
a bench that is also a collision object plans nothing at all — which reads like a planner that will
not work rather than like a scene saying the arm is inside its own furniture. Allow the pair, pad the
object back by more than the approach clearance, or leave it out; the export names the pair and
leaves the choice where it belongs. MuJoCo reports no contact for it, since both are welded to the
world, so only a distance query finds it.
This is the named-object route, not the only one. A depth sensor feeding MoveIt’s octomap updater
already carries what is in view to the planner as occupied voxels — realsense_d435 with
points: true is that path, and it sees whatever shape a thing has and follows it as it moves.
What voxels cannot be is named: attached to the gripper, allowed against a link, padded, or removed
when the trial picks the part up. The two compose. MoveIt’s sensor filter removes the robot’s own
links and what is attached to them from the incoming cloud, not the world’s collision objects, so a
prop that is both declared and in view is carried twice — conservative, and not wrong.
Manipulation: what a contact task needs¶
Driving one from outside. A Cartesian controller takes its setpoints as topics, named the way
the controllers that do this job on a real arm name theirs – <controller>/target_wrench and
<controller>/target_frame, with <controller>/current_pose coming back. Its identity is
what decides its law, as it is under ros2_control, where what a controller does is settled by which
one is loaded rather than by a mode key:
|
what runs |
|---|---|
|
pose tracking only, blind to contact |
|
the wrench loop, no stiffness and so no equilibrium |
|
both, with per-axis stiffness |
An axis given zero stiffness stays under pure force control while the others track the commanded
frame. That superposition is the point: it is how a task-space motion is layered on a running force
loop on real hardware, which means the thing driving that motion is an ordinary publisher rather
than a second controller. Two controllers cannot claim the same joints, so an experiment that ships
its search or its scan as a “controller” is writing something that cannot run on the arm – ship a
node that publishes target_frame instead.
A streamed frame is tracked, not trailed. A node that publishes target_frame as a moving
setpoint – a path sent one pose at a time – is driving a goal with a velocity, and a law that only
closes on the pose error follows it a steady distance behind: v / kp for the motion controller
(25 mm at 50 mm/s and the default kp of 2 /s), D v / C on a stiff axis of the compliance
controller. feedforward (default auto) commands the goal’s own velocity alongside the
correction, twist = v_goal + kp (x_goal - x), and damps the compliance law on velocity relative
to the goal’s; a zero-stiffness axis is under force control and is given nothing to follow.
- cartesian_admittance:
controller_type: cartesian_motion_controller
feedforward: auto # auto | supplied | off
feedforward_window_s: 0.2 # goals further apart than this are not a stream
v_goal comes from one of two places, and which one is a choice about the caller:
Supplied with the goal, by an in-process caller that knows it:
CartesianHandle.set_goal(pos, quat, twist=[vx, vy, vz, wx, wy, wz]), world frame. Used underautoandsupplied.target_frameis aPoseStamped, as on the real controller, so a ROS client cannot supply one.Estimated from the stream, under
auto, by differencing successive goals over sim time. Per axis it takes the smaller of the last two arrival-to-arrival velocities where they agree in sign, and zero where they do not, so a goal that jumps – a new stationary goal, or one displaced goal in a stream – feeds nothing forward while a steady stream is fed forward in full. Goals further apart thanfeedforward_window_sare waypoints rather than a stream and feed nothing forward; a feedforward lapses once the next goal is half an interval overdue, so a stream that stops leaves the arm to settle on its last goal.
A goal commanded once, or re-sent unchanged, commands exactly what it did without a feedforward;
feedforward: off is the proportional-only law for a stream too. The twist is clamped to
max_linear_vel / max_angular_vel either way.
The lag is observable. <controller>/tracking_error (std_msgs/Float64, metres) is how far
the controlled site is from the pose it tracks – the commanded target_frame or, before one, the
pose the controller took the arm at. An in-process caller reads the full error, rotation included,
and the feedforward in use through CartesianHandle.read_tracking_error().
Zeroing is not optional. The sensor reads everything below the cut, so an arm starts from the weight of its own wrist – and a force controller has no stiffness and therefore no equilibrium anywhere, so an untared tool sinks at that force over the damping for as long as the trial runs. Tare through the service (see “Gravity and tool mass” below) before commanding anything.
A limit that stops the trial is force_limit: a measured wrench magnitude above a threshold
latches, reports, releases whatever was driving the arm and asks the driver to stop. Named for the
capability rather than for one vendor’s word for it, with that word supplied by reports_as. It
is not a controller and does not pretend to be one – on a real arm a stop of this kind comes from
the controller box and is surfaced through the vendor’s status interface, so reporting it as a
controller switch would put a fiction in a results table’s failure-mode column.
contact_monitor (above) treats contact as the failure, and model_override (above) can take a
contact away on command. A contact-rich manipulation task inverts both: contact is the task, and the
measurement is the wrench, not the trajectory. Five plugins make
that chain, and they are listed in a world in this order because each needs the previous one’s
blackboard handle. The sensor and the control law belong to the arm, so they sit in its
components: and need no key naming it:
- spawn_arm: {model: ur5e, prefix: "ur5e_"}
name: ur5e
components:
- force_torque: {site: fts_site, frame: world}
name: ft
- cartesian_admittance: {ft: ft, controller_type: cartesian_force_controller, site: tool_site}
- peg_in_hole.py:PegInHolePlugin: {arm: ur5e, clearance: 0.001, hole_pos: [-0.49, -0.13, 0.0]}
- insertion_task.py:InsertionTaskPlugin: {arm: ur5e, ft: ft, target_pos: [...]}
Read the refs, not the order. Three are named — spawn_arm and cartesian_admittance from
roqsim_manipulation, force_torque from roqsim_sensors — and resolve through entry points because
they are substrate: an arm, a sensor, a control law. Two are paths, and ship with the experiment: the
bored block whose clearance is the experimental variable, and the trial protocol built around it.
That division is the general one. The substrate owes a cell the mechanism — mount an arm, measure a wrench, close a Cartesian loop. What is being inserted into what, and what counts as having inserted it, is the experiment’s to state.
Four things decide whether such a world measures anything at all:
Where the sensor cuts. A site force sensor reads the wrench the site’s body receives from its parent – that body and everything below it – so the tool must hang below it. A tool on any other branch contributes nothing: no weight, no push, no contact, which looks like a well-behaved controller, not like a broken world. The
ur5emodel shipsfts_site(the cut, on its sensor stacktool0) andtool_site(the stack’s outer face, further out), and its manifest declarestool_siteas wherespawn_arm’send_effector:mounts a tool by default – its bareattachment_siteis on the flange beside the stack, where a tool reads as 0 N atfts_site. Every arm model with a free mount declares its site the same way (end_effector: {site: ...}in its manifest), andforce_torquerefuses a sensor on an arm whose mounted tool is outside the subtree it reads – see that plugin’s docstring.Gravity and tool mass. With gravity on and a realistically-massed tool, any metric that integrates force is dominated by the tool’s own weight. Zeroing is a command, as it is on real hardware:
force_torqueexposes atareservice (std_srvs/Trigger, the analogue of a driver’szero_ftsensor),WrenchReader.tare()for an in-process controller, andtare_at_sfor a world that wants it done once at a stated time. Prefer a command – a time has to stay in step with the scenario’s own timing, and fires mid-approach if that slips. All three forget the offset onreset, so a repetition really is one.A tare is not gravity compensation. It cancels the load at the pose it was captured at, exactly as the zero button on a real sensor does: the tool’s weight is fixed in the world frame while the sensor frame turns with the tool, so rotating after taring brings the weight back. Tare per approach on a tool that turns. Where an experiment needs a wrench that is clean at every pose,
sim.gravity: [0, 0, 0]or a near-massless tool remain the honest answers.The controller’s plant, not its gains.
cartesian_admittancecloses a loop aroundarm_controller’s position servo, which is stiff. Admittance gains taken from a system with a soft joint controller will oscillate and diverge on contact. Tune against a stability criterion fixed in advance, and record the result as a calibration — theur5emodel is the worked example, including the sweeps. Where the plant itself is what a reconstruction has to match, the spawn’sactuators:block states it:control: impedancewith the joint stiffness and damping the reference used, in place of the model’s own servo. That is a property of the experiment rather than of the arm, so it belongs in the world and not in the shared MJCF — see Architecture & porting playbook, “Actuator overrides”, and note that a cell running at zero gravity gets identical physics fromimpedanceandposition.Whether a flex is in the contact. MuJoCo’s site sensor does not see a contact with a flex: a probe pressed into a soft block reads its own weight, however hard it presses, and a soft pad on the tool loses every contact it makes, while the flex’s weight and elastic reaction still arrive.
force_torqueadds those contacts back (roqsim.flex.FlexContactWrench), so a soft tool pressing a table and a rigid tool pressing a soft object read what a sensor at that cut measures. A flex lying partly inside the sensed subtree is refused, since its contacts cannot be split across the cut – the measurement is in the plugin’s docstring.
A trial plugin of this shape — approach → act → succeed/timeout/abort → write — publishes its
outcome when it resolves, and the scenario, which owns the end of the run, conditions on it; run
standalone under roqsim sim it also calls ctx.request_stop(), so a hand-run trial ends when
it resolves instead of being padded to a guessed --seconds (see Architecture & porting playbook, “Who ends a
run”). Two rules are worth copying from a trial-protocol plugin: give it
an explicit failure condition as well as a success one (a trial that can only succeed cannot produce a
success rate, it can only hang), and write the raw observable rather than the metric, because a
force-energy definition belongs to the analysis where it can still be argued with.
Publish the outcome as an out endpoint on the entity the trial is about, and the scenario
keeps it in a variable with entity_monitor(entity: 'ur5e', value: 'trial.resolved',
target_variable: resolved) and waits on it (wait resolved == true, then emit end), with
a timeout as the bound. Give the endpoint a ros2 hint whose field is the outcome, as
force_limit does with tripped: that field is what travels over ROS and what a bare
value: 'trial' reads, on both transports.
Manipulation: what a grasping world needs¶
Four things have to line up before an object can be picked up, and three of them are opt-in because they cost something a navigation world should not pay:
A movable object.
motion: physics— the default — adds a<freejoint/>, registers the joint as the entity’sbase_joint(which is whatsimulation_interfaces’SetEntityStaterequires to re-seat it), and re-seats it onresetso repetitions of a trial really are repetitions. Pair it withpublish_tf: dynamic— nothing else publishes a movable body’s pose.graspable_boxis the reference prop, sized and contact-tuned for a parallel gripper.Solver effort.
sim: {noslip_iterations: 10}. Without it a firmly held object creeps out of the jaws; see “Solver options” inarchitecture.rstfor the measurements. A world with a flex that has elasticity or passive contact cannot have it: such a flex runs under thediscreteintegrator, where MuJoCo supports no noslip pass, so roqsim refuses the combination before compile (same section).Scoped actuator ownership, if the arm shares its entity with anything else.
arm_controllerclaims every joint actuator matching the entity prefix by default, which is right for a standalone arm and wrong for a humanoid or a mobile manipulator — it then also claims the legs or the wheels and fights their owner, writing position targets into what may be torque actuators. Give itjoints:(andgripper_actuator:, which cannot be inferred once one entity carries two grippers), and each controller also reports only its own joints, so several can share one/joint_statestopic.``mass`` / ``friction`` on the spawn, if either is a factor you want to vary — they are ordinary world-YAML keys, so an ordinary parameter sweep varies them and needs no new variation plugin.
massworks whichever way the prop’s MJCF states its mass: geoms with amass, geoms with only adensity(MuJoCo’s 1000 kg/m³ when neither is given), or an<inertial>on the root body. It scales them all by one factor, so the split between geoms stays, and a visual geom withmass="0"ordensity="0"stays massless. The rescaled prop is compiled and must weigh what was asked, or the spawn is refused; so is a prop that weighs nothing. What is scaled is the root body (plus any flex it owns), not bodies hinged below it.
unitree_g1_dex1’s manifest is a worked example of (3): three arm_controller instances on one
entity – one per arm, each owning its seven arm joints and its own Dex1 gripper, and a
waist_controller on the three waist joints – alongside g1_locomotion on the twelve leg
motors.
Two more if the target moves (dynamic grasping):
A conveyance, not a mover.
prop_trajectory(inroqsim_assets) carries the object along a prescribed 2-D path by friction, on force-driven slide joints. Reach for it rather thanmoving_boxorwalker: both are mocap, and a mocap body has no velocity in MuJoCo’s dynamics, so friction against it transfers no tangential force — it will slide out from under the object it is supposed to be carrying while staying in contact. Mocap blocks; a driven joint carries.A velocity command path, if the controller is reactive. Resolved-rate and QP whole-body controllers emit joint velocities, and this plugin’s actuators are position servos, so
arm_controller’svelocity_commands: trueintegratestarget += qd·dtinto the held target (clamped to the joint range, with avelocity_timeout_swatchdog so a dropped stream cannot leave the arm drifting). Position servos are kept deliberately — a MuJoCo<velocity>actuator sags under gravity at zero command. Be aware of what that costs a metric: the achieved profile carries the servo’s own dynamics, so where end-effector acceleration is the measured quantity, check the tracking error and report the gains as part of the setup.
An arm carried by spawn_robot also needs arm_controller’s rest stance: a robot spawn sets
the base pose and no joint stance, so the arm falls back to qpos0. For the Panda that is not neutral
but an actively bad pose — its link5 and hand collision geoms overlap by 0.030 m at all-zeros.
rest seeds the spawn qpos and the held target by joint name, and re-seats on reset so repeated
trials start identically. frankie’s manifest is the worked example of (6) and rest.
Motion limits. arm_controller’s max_velocity and max_acceleration (a scalar, or
{joint: value}) turn every position command into a trapezoidal ramp of the held target instead
of a step the servo takes as fast as its force range allows. Set them where a step is wrong: a lift,
a gantry, a mast, a joint carrying a load that must not be thrown. They are off unless set, and no
bundled model sets them, because an MJCF declares no joint velocity limit to default from; take the
values from the source – the URDF’s <limit velocity=> and the vendor’s joint_limits.yaml.
A robot whose drives always limit carries them in its manifest’s arm_controller entry; a world
overrides them per key there, and max_velocity: null lifts one. Give the planner the same
numbers (roqsim export moveit --max-velocity … --max-acceleration …): a trajectory faster than
the limits arrives late and is graded by goal_time_tolerance. The module docstring of
roqsim_manipulation.plugins.arm_controller has the profile and what each command path does.
A planned trajectory, in-process. A plugin that plans a whole motion – a time-optimal profile, a
strike, a replayed demonstration – hands it to ArmHandle.follow_trajectory(names, times, positions,
velocities, accelerations). The controller samples it on simulated time every step (quintic between
knots carrying accelerations, as ros2_control’s controller does), holds the last knot, and gives way
to any other command. Unlike the bridge’s follow_joint_trajectory handler, which samples the
trajectory on simulated time but from a ROS thread whose setpoints reach the physics thread through a
queue, so that which step a setpoint lands on depends on scheduling, this is deterministic in a
stepped run. A position servo handed only the positions
trails them at speed by d·qd/p; trajectory_feedforward: velocity cancels that, and dynamics
also adds the inverse dynamics, so a joint swept at a real arm’s speed limit tracks to a hundredth of
a degree. Where tracking is part of what a trial measures, still report the gains and the feed-forward
with the setup. The same handle commands a gripper in process, as a GripperCommand would:
ArmHandle.set_gripper(position) and set_gripper_max_effort(newtons).
Planning in process, without ROS (roqsim_manipulation.planning). For a fixed arm in a cell,
the planning can run on the world itself rather than on a planning scene described a second time:
ArmKinematics– forward kinematics, the Jacobian and damped-least-squares IK of a site, seeded and staying on the branch nearest the seed; an unreachable target raisesIKError.CollisionChecker– a copy of the model and data as they stand now (doors where they are, parts where they lie), the arm and the parts it holds (hold(body, data);release(body, data)leaves a part where the world has it) checked against everything within a clearance, with allowed pairs for a grip or a support. IK’s restarts draw from thernga call passes.plan_path– RRT-Connect then shortcutting, every segment checked;cartesian_path– a straight line of the site, for an approach into a fixture.time_parameterize– time-optimal timing along the path under per-joint velocity and acceleration limits (reachability analysis, as TOPP-RA), retimed slower when the torques it needs, by inverse dynamics with the payload (ArmDynamics), exceed a fraction of the drives’ limits. Its knots go straight tofollow_trajectory.pose_margins– a pose’s distance to each joint limit, its singularity measures (the wrist, elbow and shoulder by name for an arm of the UR kind) and its static torques against the limits;roqsim arm margins RECORDING --arm … --site … --at …reports them for a recorded run with the peak torques over it.HoldMonitor– whether a part is held, by its pads’ contacts and its drift relative to the site.
Everything random draws from the generator it is given, so a seeded run plans the same paths.
Scoring the trial, not self-reporting it¶
A trial’s verdict belongs to the experiment, not to the substrate — deciding what counts as
success is the thing the experiment is for. tiago_pick’s pick_place_metrics is the
reference implementation, and the pattern generalises even though the plugin is not shipped here:
- pick_place_metrics:
target: parcel
grasp_links: [gripper_fingertip_left_link, gripper_fingertip_right_link]
container: dropbox # omit to score a pick alone
lift_check: 0.05 # m the object must rise ...
hold_s: 5.0 # ... and stay held, both pads on it
metrics_out: metrics.csv
It reports picked (lifted and stayed held through a dwell, with a
contact_debounce_s tolerance so a momentary loss of one pad is not a slip), placed (came to
rest inside the container and supported by it), and success. Nothing in it knows what arm,
gripper or base it is watching — the gripping links are named in config — so the same rule scores
different platforms.
What matters structurally is not which package holds it but which side it sits on: the verdict must be on the SIM side, out of reach of whatever is driving. Two reasons:
Comparability. When an in-process phase machine and an external MoveIt node solve the same trial, each scoring itself makes the comparison partly a comparison of two verdicts.
Observability. Contact state is not on the ROS graph, and neither is “resting inside the box”: a client can see the object’s TF, but a parcel balanced on the rim looks identical to one on the floor of the container.
A driver that wants to react to a slip reads held() and decides for itself — the observer
reports and never terminates. Keep the rule platform-agnostic anyway (name the gripping links in
config rather than hard-coding them): that is what would let it move up into the substrate the day a
second experiment scores a pick.
Manipulation: where a workpiece lives¶
The substrate ships robots, not the things they work on. A bored block whose clearance is swept at 0.1 mm, or an intersecting-pipe weldment whose dimensions were chosen because the paper never stated its own, is one experiment’s geometry: reused by nothing, and installed by everyone if it sits in a family package. So a workpiece ships with the experiment that defines it, and there is no special mechanism for that — it uses the two doors any downstream package uses:
an
roqsim.modelsentry point naming a module withMODELS_DIR, after whichspawn_model: {model: my_workpiece}resolves by bare name;a path-loaded plugin (
my_workpiece.py:MyWorkpiecePlugin, relative to the world file), for a workpiece whose geometry does not exist until the world configures it — a fit expressed as a number, or goal poses derived from the same definition as the shape they lie on. No entry point, no install, no wheel: the world and the plugin travel together.
What the substrate owes such a cell is the arm, the sensing, the control law and the trial machinery — all of which are addressed by name and none of which know what is being welded or inserted.
Machines: one interface for what does something¶
A machine is one entity’s own procedures – a press’s stroke, a door’s opening, a belt’s run – and
every machine looks the same from outside, so a cell, a scenario, the control socket or a client
drives any of them the same way: through the handle under machine:<name>. What a machine is, and
where the line to a scenario runs, is Machines and scenarios in the architecture.
press = ctx.blackboard.require("machine:press_1")
seq = press.start("stroke", show="hole") # refused at once while busy
... # one step later it runs
status = press.status() # MachineStatus(seq, program, finished, error)
if status.seq == seq and status.finished:
assert status.error == "" # "" done; else the failure or "cancelled"
elif status.seq > seq:
... # another start followed this one
press.cancel(seq) # this start only; 0 once it has ended
press.start("stroke", token="mine") # a token of the caller's own ...
press.cancel(token="mine") # ... cancels it before its number is known
roqsim plugins describe <machine> lists its programs with their parameters, and the handle’s
start, status and cancel are endpoints of the machine’s entity: roqsim call
press_1/start '{"program": "stroke", "args": {"show": "hole"}}' over the control socket, and
roqsim call press_1/cancel '{"seq": 3}' (or '{"token": "mine"}') cancels that start and no
other; with neither, whatever is pending or runs. A program cannot take an argument named
token: that is the start’s own. Every program run is an event timeline on the run’s events
(program_start, the program’s steps, program_end).
roqsim_assets ships the machines door and conveyor, and two examples of a machine
package, press (a guard door interlocked with a three-phase stroke) and sliding_door. Three
example worlds in roqsim_assets/src/roqsim_assets/worlds/ – press_demo, sliding_door_demo and
light_barrier_demo (the conveyor stopped by a zone_trigger) – each run one cycle of a
scenario from roqsim_assets.scenarios. DoorForWhoComes watches the zone while the door
closes: someone entering it, or the close ending in a stall, cancels the close and opens the door
again, and it closes once the zone is empty. StopAtBarrier reads the belt’s speed each time it
stops the belt and runs it again at that speed once the part is gone.
A controllable door is driven over ROS too: its openness topic and its openness_goal
action (control_msgs/GripperCommand) each replace what the door is doing with move_to, and
openness_state publishes where it stands; every endpoint of a door is named for its openness, as
a conveyor’s speed stream is for its speed. An openness
equal to the openness last commanded – through a port, or through a handle’s start the physics
thread has not applied yet – changes nothing while the door moves there or stands there. The action
is the bridge’s generic 1-DOF handler (roqsim_ros_bridge.actions.gripper_command), which asks
its producer, through the endpoint’s hints, how to grade a goal and does not look at what the
producer is: reach_tolerance is how near counts as reached_goal (0.005 unless stated; a door
states 0.02, the band its programs end in, so ROS and status() agree), and on_timeout is what
a goal still moving at its timeout ends as – succeed, with neither reached_goal nor
stalled set, unless stated (an arm’s gripper), abort for a door, whose timeout is a full
swing at its speed, stall_timeout and 5 s. The decision is
roqsim_ros_bridge.gripper_policy, free of ROS imports.
Writing a machine¶
Subclass roqsim.machine.MachinePlugin, declare what it drives, and write each program as a
generator method marked @program. Each yield is one physics step:
from roqsim.machine import MachinePlugin, program
class GatePlugin(MachinePlugin):
"""Machine: a gate on a slide that opens and closes."""
ACTUATORS = ("leaf",) # position actuators, after the machine's prefix
HOME = {"leaf": 0.0} # a world's `home:` overrides
def build(self, spec, ctx): ... # the model, from the config
def configure(self, ctx):
self.register_entity(ctx, body=self.config.get("prefix", "") + "gate")
super().configure(ctx) # resolves ACTUATORS and home, publishes the handle
@program
def open(self, speed: float = 0.3):
"""Slide the leaf open."""
yield from self.move("leaf", 1.2, speed=speed, event="opening")
yield from self.until_stopped("leaf")
What a program has:
self.set(name, value)andself.ramp(name, value, speed)– at once, or atspeedin the joint’s unit per second; a target outside the actuator’s range fails the program, naming the machine, the actuator and the range;yield from self.move(name, value, speed=None, event=None, timeout=None)does either and waits until reached;yield from self.until(cond, timeout=None),self.until_reached(*names, timeout=None),self.until_stopped(*names, timeout=None)(reached and at rest: what an interlock waits for),self.wait(seconds). A joint that has not arrivedtimeoutseconds after its target did – by default the machine’sMOVE_TIMEOUT, 5 s unless the class sets another – fails the program, naming the machine and the actuator, so an obstructed joint never hangs a program silently. A loaded joint has arrived when it settles short of its target by its servo’s standing offset. That offset covers gravity and springs on the joint’s own bodies, not a load carried through a contact, such as a part resting on a lift, nor joint friction: such a machine’sREACHEDor stiffness has to allow for it;a program yields nothing and waits on a helper with
yield from; a bareyield self.move(...)stops the run, as a defect does;self.step(name, **fields), an event for a named step;self.fail(reason), the program’s own failure, reported instatus(). A failed or cancelled program stops the machine where it is: each actuator is held where its joint stands (its servo’s standing offset under load kept), and each setpoint keeps its value;self.value(name),self.goal(name),self.position(name),self.reached(name),self.at_home(*names).
SETPOINTS = {"speed": "m/s"} declares a quantity the plugin applies itself – read
self.value("speed") in its pre_step after super().pre_step(ctx) – that ramps, homes and
is waited on like an actuator. NEEDS = {"feeder": "machine:feeder_1"} names a handle the
machine requires; it is resolved at every reset and refused naming the key when nothing published it.
ready_when() states a precondition beyond “not busy” (a press ready only with its ram up).
An actuator a machine drives is a plain <position> servo with a unit gear; a motor, a velocity
servo, an <intvelocity> or a geared servo is refused at configure, naming the machine and the
actuator. A program’s arguments are checked against its annotations, whether they are strings
(from __future__ import annotations) or types, unions with None included.
A machine whose model is an MJCF file of its own is placed with spawn_model and its controller
nested under that entry, a MachinePlugin without build that sets registers_entity = False:
it drives the spawned model’s actuators under the spawn’s prefix and publishes its handle as
machine:<spawned entity> (Machines and scenarios).
Each machine takes home: and on_error: in its config besides its own keys. home: is
the only place a world states where a machine stands at the start: a belt’s start speed is
home: {speed: 0.2}, a door’s start openness home: {openness: 0.5}; a speed key is only
ever a rate (a door’s hinge speed, a sliding door’s leaf speed). A machine whose start state is a
quantity of its own rather than an actuator declares it in HOME_KEYS = {"openness":
"fraction"} and maps it onto what it drives in home_targets(home); its home: then names
only those. A key that stated a start state outside home: goes into START_KEYS (old key ->
new form), and the world is refused when it loads, naming the new form. A transport
endpoint of the machine’s own whose command means “this is the target now” calls
self.preempt(program, **args), which cancels whatever runs; the handle’s start never does.
A machine that compares such a command with what it was commanded last records each start in
start_accepted(program, args): the base calls it, with its lock held, when a start is accepted,
on the thread that made it, a step before the physics thread applies a handle’s start. It touches
neither the model nor the handle. The door records its target there, so an openness back to where
it stood, sent right after a handle’s start("open"), is not taken for a repeat.
Writing a scenario¶
The scene around the machines – who acts when, who waits for whom, what a presence leads to – is a
scenario, in OpenSCENARIO or in Python. A Python scenario subclasses
roqsim.scenario.ScenarioPlugin:
from roqsim.scenario import ScenarioPlugin
class PressDemo(ScenarioPlugin):
"""Scenario: place a strip in the press and punch it."""
NEEDS = {"press": "machine:press_1"}
def program(self):
yield from self.set_entity_state("strip_1", {"position": {"x": 0.0, "y": 0.0, "z": 0.8}})
yield from self.run(self.press, "stroke", show="hole", hide="plain")
self.event("punched", part="strip_1")
and is placed after the machines it drives:
components:
- press: {...}
name: press_1
- "my_cell.scenes:PressDemo": {stop_at_end: true}
name: demo
The helper: run, start, spawn, join, first, navigate, until, wait,
entered, left, dwelled, set_entity_state, event (roqsim.scenario). entered,
left and dwelled wait on a zone_trigger’s handle and take a timeout as until
does. They read who is inside now, so a scenario goes after the zones it waits on; entered and
dwelled with since (a sim time) also count an entity that has come and gone since then.
dwelled on a zone whose dwell is 0, which reports no dwelling, is refused. set_entity_state takes a
pose as a world file writes one:
x and y required, a missing z the floor (0.0, as spawn_model places a pose without
one), the orientation as a quaternion or roll/pitch/yaw; anything else raises
roqsim.pose.PoseError naming what is wrong, a NaN or an infinity included. A start’s error
reaches whoever waits on its task with join or first, so a try around the join catches
it as around run; join raises as soon as one task fails, and the others go on. The scene does
not end before a task has, unless it was spawned with background=True, for one that never ends by
itself, and a start’s error nobody joined then stops the run. A failed start emits start_failed in the step its task sees it. A reset or a run that ends
before the scene does logs a start’s error that reached no one. A run that ends before a scene that
has taken a step did – at --seconds or --steps, on a signal, by the window closing – says
so as an error, and roqsim sim exits 6 (Exit status); a reset only starts the scene
again. Cancelling a
task, as first() does to the loser, cancels the machine start it waits on, by its number, or stops the route. A scene yields
nothing and waits on a helper with yield from; a bare yield self.run(...) is refused. navigate(check=False),
like run(check=False), returns the status where another route overtook its own. A program’s own
exception stops the run with its own type, the scenario named in a note, and the scene never
reports done. Every scenario takes needs: (rename a handle) and
stop_at_end:; its done endpoint says when the scene ended.
The same scene in OpenSCENARIO¶
A scene is written in Python or in OpenSCENARIO (osc.roqsim), in the same words and with the same
outcome, so it moves from one to the other line by line:
Python scenario |
OpenSCENARIO |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
An abandoned machine_run or entity_navigate stops what it started, as a cancelled task does.
machine_run gives each start a token of its own and cancels by it, at once and right behind the
start, so the next machine_run finds the machine free and a start another client made is left
alone; a cancel that is refused or gets no answer is logged as an error.
A world names an OpenSCENARIO file as it names a Python scenario, and roqsim sim runs it through
scenario-execution, in its own loop, with its recording, viewer and control socket:
- scenario: {file: press_cell.osc} # relative to the world file
name: scene
scenario: says which one of a file holding several, stop_at_end (default true) ends the run with
the scenario, and output_dir, relative to the world file, is where its test.xml goes. A scenario
that fails stops the run with a non-zero exit, and one the run ends before is written to test.xml
as failed and makes roqsim sim exit 6, as for a Python scenario. done and scenario_end are as for a Python
scenario. One entry serves a world. scenario-execution is needed only to run: rendering, replaying,
checking or exporting the world runs nothing and parses nothing, though roqsim check needs
scenario_execution_roqsim to know the entry. scenario_execution --simulation roqsim.scenario_adapter:MujocoSim remains the
way to let scenario-execution own the loop, for a campaign or for scenario parameters.
scenario_execution_roqsim/tests holds one scene written both ways, and a test holds their
timelines equal.
An entity’s states: part_state¶
What a machine does to a part shows on the part: a strip punched, bent or labelled; a machine’s own
lamp on. Each such state is a look_<name> body under the entity’s root body, compiled in and
shown or hidden at run time through roqsim.presence, so a recording replays it:
<body name="strip">
<geom type="box" size="0.15 0.02 0.001" mass="0.19"/>
<body name="look_plain">
<geom type="box" size="0.15 0.02 0.0001" pos="0 0 0.0011" contype="0" conaffinity="0" mass="0"/>
</body>
<body name="look_hole">
<geom type="cylinder" size="0.005 0.0001" pos="0 0 0.0011" contype="0" conaffinity="0" mass="0"/>
</body>
</body>
One part_state entry serves the world. Its handle, part_state, shows and hides a state by
entity and name (show, hide, set for one of an exclusive group), and each change is a
shown/hidden event:
- part_state:
shown: {strip_*: [plain]} # at the start of every run, by name or pattern
exclusive: {strip_*: [[plain, hole]]}
A state’s bodies are massless: one with mass is refused, naming the body, because showing a state
must change how the part looks and collides, never what it weighs. A state that moves the centre of
mass – a strip bent into an L – names the root body’s inertia while it is shown, as a custom
numeric look_<name>_inertia of ten values (pos, quat, diaginertia); two shown states
that both name one are refused before anything changes, by show and by set alike. A pattern
that matches no entity with states, an unknown entity or an unknown state is refused by name. Of an
exclusive group at most one state is shown: show of a member while another is shown is refused
(set swaps them), and so is a shown: naming two. The plugin decides nothing: when a part
changes is the machine’s or the scenario’s.
A state is registered as an entity (kind look), so a recording carries and replays its presence,
but it is not listed: GetEntities, GetSpawnables and the per-entity pose endpoints leave it
out, and spawning, deleting or placing it is refused – only part_state changes a state. A replay
draws the shown states; it does not restore the inertia one names, which the picture does not need.
Presence composes, so a state’s own presence and its owner’s are independent: while the owner is absent a state shows nothing, and a state changed meanwhile is as it was left when the owner returns.
Limits. A state body nested in another state body is refused. A shown state’s inertia moves the
physics but not the compiled invweight0 values, so a part held by a weld is slightly softer or
stiffer while it is shown. A state belongs to the nearest entity around it: list part_state after
an entity nested in another whose states it serves.
Presence in a region: zone_trigger¶
A light barrier at a belt’s end, the space before an automatic door, the die of a press: a box in
which a scene needs to know who is there. zone_trigger reports it and decides nothing – what a
presence leads to is a scenario’s:
- zone_trigger:
pose: {position: {x: -0.9, y: 0.6, z: 1.0}} # the box's centre, world or `body` frame
size: [0.24, 0.4, 0.16] # full extents (m), as a box's
entities: [package] # name patterns that count; default all
point: com # com (default) | origin
dwell: 1.0 # s inside before `dwelled`; 0 never
name: belt_end
It emits entered, dwelled (with after, its seconds inside) and left (with
inside_s) events, keeps a handle under zone:<address> (zone:<name>, or
zone:<entity>.<name> when nested; inside(), entered_at(), dwelling(),
entered_since(), dwelled_since(), occupied, counts, dwell) and publishes
occupied (a bool, std_msgs/Bool on ROS, under <zone>/occupied, in the namespace of
the entity it is nested under) and occupancy, both the zone’s own endpoints, so an entity may
carry several zones. With body: the box rides on that body; nested under an entity, body is
named after the entity’s prefix, the entity it is nested under is never counted, and while that
entity or the ridden body is absent the zone reports no one – a zone that only rides another
entity’s body still counts that entity. point: com reads the root body’s centre of mass, which a
part_state state that names an inertia moves; point: origin reads its frame, for a mocap
body.
Slots: where to stand, where the hand goes¶
A slot is what a prop says about working at it: where a worker stands, which way it faces, and where its hand goes. It is sites, by a naming convention:
the hand target, named for the slot: a grip site
<x>/<slot>/grip(the grip frame above), whichgrasptakes; a place frame<x>/<slot>(+z up, its yaw the heading what is set down there is set at), whichplacesets down on; or a press face<x>/<slot>(+x out of the face), whichpresspushes;its stances,
<x>/<slot>/stand, or<x>/<slot>/stand_<k>for several: +x the way to face. What a stance says is where it stands on the floor and its heading; the site itself is at the height of its body’s origin.
approach and carry of roqsim_motion to a target that states stances – <x>/<slot>
itself, or its <x>/<slot>/grip – walk to the nearest of them and face as it says, unless they
are given a standoff or a facing; without one they stand standoff (0.6 m left out) in
front of the target. arrived carries stance: the stance’s site, or the stand-off it used.
A prop’s own plugin can state its slots; the slots component states them on any other body – a
primitive standing in for a rack, a mesh model, a body of a baked scene – nested under the entry
whose body it is, in that body’s frame, its sites named for the entry:
- box: {prefix: rack_, pose: {position: {x: 2.0, y: 0.0}}, size: [0.6, 1.2, 0.9], motion: static}
name: rack
components:
- slots:
body: rack_box # as the model names it
slots:
bin_0: {kind: grip, at: [0.1, 0.0, 0.5, 3.14159], stand: [[0.6, 0.0, 3.14159]]}
tray: {kind: place, at: [0.0, 0.2, 0.46]}
which states rack/bin_0/grip, rack/bin_0/stand and rack/tray. A slot’s name has no
/ and does not begin with stand (nor with grip, but for a grip slot), and a kind
comes with its at.
Writing your own¶
Subclass roqsim.plugin.Plugin, implement the hooks you need, add validate_config, and
either register a roqsim.plugins entry-point or reference the class directly from the world
YAML. Referenced directly, the ref (my_pkg.mod:MyPlugin or ./plugins/x.py:Foo) contains a
colon and is the plugins-list entry’s key, so quote it — - "my_pkg.mod:MyPlugin": {...} —
to keep the colon from splitting the key.
A world compiled to look at it acts on nothing. A render, a replay (Recording.build,
roqsim state --sensor), roqsim check, a settled export, the scene builder and a map compile
the world with Engine(preview=True), and ctx.preview is then true. Such a world still steps
and calls every hook, a replay on each restored sample, so a plugin computes its outputs as in a
run: a replay reads them. What it must not do then is act: write a file a run owns, start or command
anything (a machine’s program, a controller switch), or stop the run
(ctx.request_stop). Ask ctx.preview in the hook that acts and skip that part only.
If your config names a file, implement ``sources``. roqsim.config.world_sources — what
roqsim scenes inputs and the exporters’ --manifest report, and what a run harness
stages a world by — walks the YAML’s extends chain and the MJCF’s assets. It cannot see
into a plugin’s config, so a mesh or a CSV named there is invisible to every caller asking
“what does this world need?” unless the plugin says so. Return absolute paths; entries that do
not exist are dropped, and the hook must never raise (callers treat it as best-effort). It is
the same rule as transport_only: a capability is declared by the plugin, never listed in
the core.
If your plugin renders an image, implement ``scene_cameras``. It returns a
roqsim.scene_content.SensorCamera per image – the plugin’s address, the MuJoCo camera it renders
through, rgb or depth, and the published size and focal lengths – and the scene exporters
place each as a camera on the body that camera is mounted on, so a viewer of the exported scene can
look through the sensor. CameraPlugin implements it for every camera in roqsim_sensors. As
with sources, the plugin declares it; the exporters never guess a sensor from the model’s
<camera> list.
And resolve it against ``self.base_dir``, not the CWD. That attribute is the directory of the
world document the entry was declared in, so a path written beside the world resolves the same
wherever the world is opened from. That matters more than it sounds: the working directory is not
the document’s directory in general, and need not be the same twice. A world may be opened by
absolute path from somewhere unrelated, or copied under a different root by a tool that stages its
inputs — and a CWD-relative path then names a different file, or none. resolve_model and
load_manifest both take a base_dir for this; pass self.base_dir. A bundled model name
is a provider lookup and is unaffected.
A spawn plugin can bundle a model’s default plugins by implementing expand via
roqsim.manifest.expand_manifest (see the manifest mechanism in the Developer guide /
architecture reference). See the porting playbook in the Developer guide.