Interfaces¶
The public surfaces you use to configure and extend roqsim.
The world YAML¶
A single file defines the world and the plugin pipeline. Plugin order is execution order.
sim:
timestep: 0.004 # optional; else taken from the model
pacing: realtime # realtime | asap | {factor: 4.0} (standalone only)
integrator: auto # auto (default) | euler | rk4 | implicit | implicitfast | discrete
dedup_assets: true # default; merge identical attached prop assets before compile
components:
- floorplan: # (1) entry-point short name -- the ref *is* the key
mesh: envs/x.stl
name: ground # optional instance name (reserved sibling key)
- "my_pkg.mod:MyPlugin": { ... } # (2) importable module:Class (PYTHONPATH)
- "./plugins/x.py:Foo": { ... } # (3) path to a .py file (relative to this YAML)
Each entry is a mapping with exactly one plugin-ref key (whose value is the plugin’s config map)
plus an optional reserved name: sibling, which defaults to the ref. Writing name: inside the
config map is refused with the corrected spelling: no plugin reads it there, and a document that
placed it there would load with every entry answering to the plugin’s ref. The plugin ref has three
resolution forms:
short name — a registered
roqsim.pluginsentry-point.module.path:Class — imported off
PYTHONPATH.path/to/file.py:Class — loaded directly from a file (relative to the YAML).
Because forms 2 and 3 contain a colon and the ref is the entry’s key, quote it
(- "my_pkg.mod:MyPlugin": {...}): unquoted it parses only while no space follows the colon, so a
stray key: value space would silently truncate the ref. Short names have no colon and need no
quotes.
Each plugin validates its own config: section; the engine aggregates all errors and fails fast
before the scene is built.
A world may state its document version with a top-level version: 1; absent means 1. A version
newer than the running roqsim reads is refused, naming both, for the world and for every world it
extends: loading it with the keys that happen to overlap would run a different experiment while
looking correct.
Stating a joint’s gains (actuators:)¶
A spawn plugin’s actuators: block says what law the model’s joints run under, and with which
gains, without editing the shared model file. Start from the names it keys on:
roqsim catalog model ur5e # lists the actuators, and the joint each drives
Then state the law once, and only what differs per actuator:
- spawn_arm:
model: ur5e
actuators:
control: impedance # position | velocity | effort | impedance
stiffness: 2.0 # N*m/rad
damping: 0.02 # N*m*s/rad
each:
shoulder_lift: {stiffness: 5.0, effort_limit: 150} # N*m
wrist_3: {control: position, p: 2000, d: 500}
Anything not stated keeps the model’s own value, so a world says what the experiment fixes and
nothing else. The names in each: are actuator names (wrist_3), not joint names
(wrist_3_joint) — a joint name is refused, naming the actuator that drives it.
A gripper’s finger servo is stated the same way. Where the hand is part of the model (panda,
frankie, gen3) it is named under the spawn’s actuators:; a gripper welded on with
end_effector: has a block of its own:
- spawn_arm:
model: panda
actuators:
each:
actuator8: {p: 3000, d: 50} # the Franka Hand: N/m, N*s/m on the finger tendon
- spawn_arm:
model: ur5e
end_effector:
model: robotiq_2f85
actuators:
each:
fingers_actuator: {p: 300, d: 20}
A finger servo on a tendon takes p and d only, both positive, and keeps its command and
force ranges: a commanded width still closes the fingers to that width, with the stiffness the
world stated. Unstated, the model’s own servo holds (2000 N/m and 40 N*s/m on the Franka Hand).
When the block also states a shared law for the arm, the finger entry names control: position.
The gains a real robot exposes are the ones written here: control is a ros2_control command
interface, p/d are a controller’s PID gains, effort_limit is URDF’s <limit effort=>.
That is a magnitude: it sets the larger bound of the model’s forcerange and keeps the range’s
shape, so a single-acting drive’s 0 F becomes 0 effort_limit and still cannot pull.
impedance is joint-impedance control — a position law that also carries the arm’s own weight, so
a soft stiffness holds a pose instead of folding; at zero gravity it is identical to position.
Which law and gains every joint ended up with is written into the run’s recording, so a result can
state what its joints ran under. See Architecture & porting playbook for the full mechanism.
Every sim: key is checked¶
sim: takes world, name, timestep, pacing, sync, seed, integrator,
cone, gravity, wind, contact_override, dedup_assets, view, and the MuJoCo
opt.* fields set by their own names: solver, iterations, ls_iterations,
noslip_iterations, impratio, density, viscosity (roqsim.config.SIM_KEYS).
Any other key is refused, not ignored, and the message names the nearest known one:
sim: unknown key(s) 'timstep' (did you mean 'timestep'?); it takes cone, contact_override, ...
Ignored, timstep: 0.004 would run at the model’s step, and the run would still finish and
report, with every number measuring something its author did not write. The check runs after
extends: resolves and after overrides merge, so a key is refused whether it came from the file,
a parent world or --set. Headless is a run switch (--headless), not a sim: key. The
opt.* keys are one tuple, roqsim.config.SIM_OPTION_KEYS, which both this check and the
engine read.
Overriding the world¶
A caller can override any part of the world before it is built, by passing a nested dict that
mirrors the YAML. Plugins are addressed by name (their name:, else their plugin ref), so
callers never depend on list indices:
from roqsim import load_config
cfg = load_config("world.yaml", {"sim": {"pacing": "asap"},
"components": {"floorplan": {"floor": {"reflectance": 0.3}}}})
Values deep-merge (scalars and lists replace). Overrides must be applied at load time – the scene is
compiled when the engine is built, so mutating a built SimConfig has no effect.
An override addresses sim.<key> or components.<name>.<key> and nothing else. Any other root
– a parameter name, say, or an inheritance key already consumed when the world loaded – is refused
rather than merged into a document where nothing reads it.
The standalone runner exposes the same thing on the command line, where
roqsim.overrides_from_dotlist parses the path=value form:
roqsim sim world.yaml --set components.floorplan.floor.reflectance=0.3
…and in a file, which is the same nested mapping kept somewhere a command line cannot keep it:
roqsim sim world.yaml --override debug.yaml
Reach for the file whenever the value is structured – a list of obstacle instances, a nested
plugin config – because flattening one onto argv loses it to quoting and word splitting. It is
also how a saved override set is reused, and how a run’s own settings are replayed afterwards: an
embedding driver that varies the world per run writes exactly this document beside the results.
Both flags are repeatable and compose, later winning, so a saved set plus one ad-hoc tweak is
--override debug.yaml --set sim.pacing=asap. Every command that answers about the world a run
would load takes the same pair, merged by the same function (roqsim.override_options):
roqsim sim, roqsim check, roqsim render, roqsim scenes describe, roqsim export
web, urdf, srdf, mesh and moveit, and roqsim sensors coverage. Where one of
them is given a bare MJCF or a model instead of a world, it refuses --set, --override and
the other options that act on a world’s plugins (--skip-plugins, --settle-steps) with exit
status 2, rather than exporting geometry the caller believes was overridden.
Driven from scenario-execution, MujocoSim takes the nested dict as a world_overrides
parameter – naturally an OSC struct, which the framework passes as a nested dict – and (re)builds
the world with it applied. That shape has no command line, so a deployment supplies the same
document through ROQSIM_WORLD_OVERRIDES (a path, alongside ROQSIM_WORLD); a scenario
passing world_overrides itself wins, being the experiment speaking rather than the deployment.
See Quickstart.
Selecting the world itself¶
A world is normally chosen once, by whoever starts the run: the positional argument to
roqsim sim, or ROQSIM_WORLD for the scenario-execution adapter (which is constructed with no
arguments). A scenario never has to know that this simulator has a thing called a world – and
neither does it need to when a run harness sweeps the world across configurations, since that
too is the deployment choosing, one process at a time.
The exception is a study whose experiment is the world – one problem instance per configuration.
Such a scenario declares a world parameter and MujocoSim.reset() takes it, rebuilding when it
changes, which makes that study one scenario instead of N. The world is part of the rebuild key, not
just the overrides: reusing the previous model for a new world would silently run the wrong one.
Adding ROS transport¶
A checked-in world is ROS-free, and deliberately so: a world that declares ros2_bridge cannot
be loaded where the bridge is not registered – it is a colcon package, absent from a pip-only
install – so keeping it out of the file is what makes the world standalone-runnable. Transport is a
property of how a run is deployed, not of the experiment.
So it is appended at load time instead, by roqsim.config.with_transport() – the exact inverse of
drop_transport_plugins, and idempotent, so a caller never has to know whether the author put one
there:
roqsim sim world.yaml --ros # append ros2_bridge
roqsim sim world.yaml --ros --tf-namespace robot # publish /robot/tf, frames unchanged
roqsim sim world.yaml --sim-control # also serve simulation_interfaces
--tf-namespace and --sim-control imply --ros. Going the other way – running a world whose
author did put the bridge in the file, on a machine without the middleware – is
--no-communication, which drops it and warns that the run now communicates with nothing (see
Transport plugins and the scene-only consumers). The two are refused together. The adapter reads the same three from the
environment (ROQSIM_ROS, ROQSIM_TF_NAMESPACE, ROQSIM_SIM_CONTROL), because there is
no command line to put them on – and because they must not become scenario parameters, for the same
reason the world is not one.
Once up, the bridge holds the graph to its endpoints’ types. A ROS 2 topic is one name and one
type, and the middleware never connects a publisher of another type to it – nor logs that it did
not – so a stack sending a plain Twist to a base subscribing TwistStamped shows up only as
a robot that never moves. The 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.
Choosing a GL backend¶
MUJOCO_GL selects the offscreen renderer, and which value works is a property of the machine:
egl needs a render device unless its EGL renders in software, and a CPU-only node needs
osmesa. Left unset, MuJoCo’s own default fails on such a node with a message about a broken GL
install – the wrong diagnosis.
The variable is read once, while ``import mujoco`` runs, and binds ``GLContext`` there and then.
Setting it afterwards moves the variable and nothing else. Unset is not an error either: an empty
value falls through to glfw, which on a headless node opens no display and aborts inside the
first mujoco.Renderer with mujoco.FatalError: gladLoadGL error.
So import roqsim picks one when MUJOCO_GL is unset (see
roqsim.gl.select_offscreen_gl()): a PYOPENGL_PLATFORM of egl or osmesa decides,
because MuJoCo’s egl and osmesa backends each refuse to import under the other’s; with neither
named, a render node means egl and its absence means osmesa. An explicit MUJOCO_GL is
always honoured, and ROQSIM_NO_GL_SELECT=1 opts out. This has to
happen where the simulator runs – a run configured on one machine and dispatched to another
cannot know.
The package __init__ is the call site, not a driver’s main, and that is load-bearing
rather than tidy. A driver’s own module-level imports reach mujoco long before its main body
executes, so a selection made there (in roqsim.runner.main, say) is made too late to bind
anything. It is silently ineffective for every headless run, and stays invisible because a world
with no camera never constructs a Renderer: the first camera world on a headless node is what
instantiates the mis-bound backend.
Because the residual case – a consumer that imports mujoco before roqsim – cannot be
reached from here, roqsim.rendering.check_gl_backend() guards every renderer in the tree and
names both the cause and the fix instead of letting gladLoadGL error stand.
DISPLAY is deliberately not consulted: this picks only the offscreen renderer, and a window
comes from mujoco.viewer’s own glfw context regardless. A base image may well set
DISPLAY=:0 unconditionally, so trusting it would make a headless run choose glfw and fail
against an X server that was never started.
MuJoCo’s warnings¶
Without a warning handler, MuJoCo prints each warning and appends it to MUJOCO_LOG.TXT in the
current directory. import roqsim installs one (roqsim.mujoco_log.route_warnings()) that
logs the warning at WARNING on the roqsim.mujoco logger, so no file is written. A handler
installed before import roqsim is kept, one installed after replaces it, and
mujoco.set_mju_user_warning(None) restores MuJoCo’s own file. MuJoCo’s errors are not routed:
the bindings raise each as mujoco.FatalError.
Listing what a world is made of¶
A world is never one file: it is the YAML, whatever it extends, the MJCF that chain settles on,
and the meshes and textures that MJCF names – all referenced by paths relative to each other:
roqsim scenes inputs worlds/depot.yaml
{"world": "/abs/worlds/depot.yaml", "packaged": false, "inputs": ["/abs/...", ...]}
One line of JSON, the same machine contract roqsim render uses. It exists as a command because the
caller is often not a roqsim process: something staging a world into a container has no other
reason to have roqsim installed, so it asks the image that does. packaged: true means the files
arrive with an installed package and nothing has to travel.
The walk is best-effort: a world that does not fully resolve yields what was resolved, so a
caller about to report its own error is not pre-empted by this one. --require-complete is for
the caller who cannot use that answer – one copying these files somewhere the originals are
unreachable – and it fails instead, naming on stderr every part it gave up on: an extends that
does not resolve, a YAML in the chain it cannot read, a world that does not load, a plugin it
cannot ask. A file that is simply absent is not one of those: dropping it is the contract
Plugin.sources is written against, where an optional file needs no guard. Without the flag a
short list and a whole one are the same value, and what is missing surfaces wherever the files were
going – after the copy.
Listing what a world provides¶
The other half of the same question, for a caller holding an override rather than staging files:
roqsim scenes describe worlds/turtlebot_nav2.yaml
{"world": "...", "packaged": false, "inputs": [...],
"components": [{"address": "robot", "ref": "spawn_robot", "name": "robot",
"entity": null, "enabled": true, "origin": "document",
"paths": ["components.robot.model", "components.robot.pose.orientation.yaw",
"components.robot.pose.position.x", "components.robot.pose.position.y"]},
...,
{"address": "robot.rplidar.lidar", "ref": "lidar", "name": null,
"entity": "robot.rplidar", "enabled": true, "origin": "manifest",
"paths": ["components.robot.rplidar.lidar.angle_max", ...,
"components.robot.rplidar.lidar.rays", ...]}, ...],
"addresses": ["robot", "robot.bumper", ..., "robot.diff_drive", ..., "robot.oakd",
"robot.oakd.oakd_camera", "robot.rplidar", "robot.rplidar.lidar", "ros2_bridge",
"sim_interfaces"],
"entities": null, "flexes": null, "warnings": null, ...}
components reports every component that will run – the document’s own entries and everything its
models’ manifests contribute – under the address an override names it by, with the dotted paths
into its config that already exist. origin says which of the two a component came from.
addresses is that set on its own, and it is exactly what resolution accepts: a caller checks a
sweep key against it before spending an image pull. Note the world above declares three entries
and gets the rest – drive, the lidar and camera devices and the sensors on them, bumper, cliff
and IR sensors – from the turtlebot4’s manifest, and those are the ones a sweep is most likely to
want.
A path not listed is not necessarily wrong (a plugin may accept a key its world leaves at the default), so a caller reports an unlisted path as unverifiable. What the list does settle is the expensive mistake: an address matching nothing, refused at load – inside the container, after the image pull.
entities is null unless --entities is passed, because naming them means compiling the
model. There is no cheaper way to ask: which entities exist is settled at compile time, since roqsim
never recompiles mid-run – SpawnEntity makes a declared entity present, it adds none. A caller checking
that a scenario only drives entities the world has pays for it; one resolving paths does not.
flexes comes from the same compile, so it is null without --entities too: one row per flex
(MuJoCo’s <flexcomp>) saying what it compiled into – dim, vertices, elements, the
dof mode (full/trilinear/quadratic) and its nodes, how many of its vertices (or
nodes) are pinned to its parent body, the entity that body belongs to, and whether it is
rigid, elastic and has passive_contact. Its modes and damping are roqsim check’s, since
they cost an eigen solve (quickstart).
warnings comes with --entities as well, because the build it rides on is then also reset,
as a run does before each trial: it lists what the state a trial starts from holds that will not stop
the world from loading but is likely to make a run misbehave, in roqsim check’s
{"check", "message", "hint"} shape – two bodies placed inside one another deeper than the
contact’s tolerance (interpenetration, architecture §2). []
is a start state with nothing to say and null one that was not reset. A plugin whose on_reset
raises leaves warnings null, sets errors.reset and exits non-zero – a world no trial of
which can start – while entities and flexes still answer.
overridable answers the same question one layer down, for the model values a run can change while
it is in progress (the model_override plugin, architecture §9.2):
roqsim scenes describe roqsim_mobile_manipulation:tiago_pro_demo --overridable 'gripper_right*'
{..., "overridable": {
"fields": [{"field": "geom_friction", "namespace": "geom", "write": "live",
"does": "...", "caveats": "...", "measured": "..."}, ...],
"targets": {"geom": [{"name": "gripper_right_left_pad1",
"body": "gripper_right_fingertip_left_link",
"geom_priority": 1, "geom_friction": [0.7, 0.02, 0.001],
"geom_contype": 2, "geom_conaffinity": 1}, ...],
"actuator": [{"name": "gripper_right_finger_pos",
"actuator_forcerange": [-10.0, 10.0]}]}}}
fields is always present and costs nothing: mjModel’s field set is a property of MuJoCo rather
than of this world, so the allowlist needs no model built. Each row carries what the field does and
how it can silently do nothing, because that is what a caller choosing an override needs and cannot
infer from a field name.
targets is the world-specific half – the names an override can select and their current values
– and is null unless --overridable GLOB is passed, for the same reason entities is. The
glob is not a convenience: a mobile-manipulator world has hundreds of geoms, and unnamed ones are
omitted because nothing can address them. A geom also reports its geom_priority, which is what
decides whether overriding this side of a contact does anything at all.
Both halves come from one build when both flags are given: compiling the world is the expensive part.
--override FILE applies an override tree first, and --set PATH=VALUE a value over it –
roqsim sim’s own options, both repeatable.
It is what makes the build-fed halves answer about the world a run would load rather than the one
the file declares: which entities a world compiles depends on its plugins’ config, so a caller whose
obstacles come from its own overrides sees none of them without it. Here world.yaml declares an
obstacle_0 entry with enabled: false and run.overrides.yaml turns it on:
roqsim scenes describe world.yaml --entities --override run.overrides.yaml
{..., "entities": ["obstacle_0", "robot", "robot.velodyne"], "errors": null}
An address the world does not have is still refused, exactly as it is refused when a run loads – which is the expensive mistake this command exists to catch first.
That build has no transport in it, and dropped_transport names what went:
roqsim scenes describe worlds/depot_nav2.yaml --entities
describing the scene without transport: dropped ros2_bridge, sim_interfaces # on stderr
{..., "entities": ["robot", ...], "dropped_transport": ["ros2_bridge", "sim_interfaces"]}
A describe publishes nothing, so a world’s bridge is dead weight here exactly as it is for roqsim
render and the exporters – and since the ROS bridge ships in a colcon package, a pip-only
environment cannot resolve it at all, so requiring it would fail a describe over plugins that
contribute no geometry. The build is a preview engine, so only identified transport goes
(roqsim.config.drop_transport(), without skip_unloadable): a misspelt geometry plugin has to stay fatal, because dropping it would
leave an entity missing from a list a caller reads as complete. The bridge is still in components,
so components.ros2_bridge.* remains a checkable override.
When only the build fails, the reply is still printed – with errors.build set and the build-fed
keys left null:
{"components": [...], "entities": null, "dropped_transport": [],
"errors": {"build": "mesh not found: ..."}}
A caller keeps the half that cost nothing (which plugin keys exist) instead of losing the lot. The
exit code is still 2 (Exit status): 0 goes on meaning “fully answered”, so a caller
reading only the status is never told a partial reply was a complete one. A world that cannot load
has no half to hand back and prints nothing.
Extending another world¶
Overrides modify an existing world; extends inherits one. A world YAML may name a parent to
inherit its sim block and components list, then turn off, add, or modify elements:
extends: roqsim_scenes:depot # a parent world YAML: "<package>:<world>" ref or a path
sim:
timestep: 0.001 # deep-merged over the parent's sim (child wins per key)
disable: # OPTIONAL: turn inherited entries off by label (needs ``extends``)
- ceiling
components: # child entries are APPENDED after the (kept) parent entries
- spawn_robot: {model: oli, prefix: oli_, pose: {position: {x: 13.2, y: 2.6}}}
name: oli
The extends value resolves like sim.world – a <package>:<world> ref against a registered
roqsim.worlds provider (to that provider’s <world>.yaml), or a path relative to the child
YAML’s dir. The parent’s relative sim.world keeps resolving from the child’s location: a path
parent’s becomes an absolute path, and a package parent’s becomes a <package>:<path> ref
(roqsim_scenes:depot/depot.xml) – by reference, never by where this interpreter has the package
installed, so a run’s provenance rebuilds on any machine that has the package. Parent worlds may
themselves extends (cycles are rejected).
disable selectors match an entry’s label – its reserved name:, else its plugin ref – and
set enabled: false on it, so the entry stays in the document, addressable and in the run’s
record; a selector that matches nothing is an error, not a silent no-op. There is no separate
“modify” key – to change an inherited entry, override its keys, or disable it and add a tweaked
copy in the child’s components, under its own label or another.
Reusing a world with a different robot is that second form, under the same label:
extends: roqsim_mobile:husky_demo # a world whose robot is labelled `robot`
disable: [robot] # replace the inherited robot ...
components:
- spawn_robot: {model: turtlebot3_waffle, pose: {position: {x: 1.0, y: 0.0}}}
name: robot # ... with this one, under the same label
The new robot replaces the disabled one. It gets exactly the components a world declaring it
directly gets – its own model’s drive, sensors and controllers from its manifest, with the same
configs – and nothing from the model it replaced; nest entries under it to change a default, as
anywhere else. The label, and every override that names it (components.robot.diff_drive.*),
addresses the new robot alone. The replaced entry stays in the record, turned off, with what the
parent declared for it. Leaving out disable is refused, and the message says to add it: two live
components cannot share one label. For a one-off run, --set components.robot.model=<model>
swaps the model without a new world, and brings in that model’s manifest the same way.
Drawing on a render (roqsim.render_overlays)¶
roqsim render draws a recording one sample per frame, and an overlay paints on each frame
after the scene is rasterised and before it is encoded – in pixels, with the sample’s simulated time
in hand. clock ships with roqsim; any installed package adds its own under the
roqsim.render_overlays entry-point group, and it is then available by name on the command line and in a
shot document without roqsim knowing it:
[project.entry-points."roqsim.render_overlays"]
costmap = "some_package.video:CostmapOverlay"
The contract is small and duck-typed. An overlay is constructed as cls(placement, **options) –
or through a from_spec(options, placement) classmethod where it wants to validate them – and
provides:
name: str
prepare(width, height, *, state) -> None # optional; once, before the first frame
draw(frame, t) -> frame # every frame
frame is the rendered picture as an HxWx3 uint8 array and may be painted in place; what
comes back must be the same shape and type, and a frame that is not is refused by the overlay’s
name rather than handed to the encoder, which would silently produce a sheared video. state is
the recording being drawn (a path, or None), so an overlay that reads files beside it can find them
without being told where. placement (roqsim.render_overlays.Placement) carries the three
options every overlay shares – anchor, width as a fraction of the frame, margin – and
roqsim.render_overlays.paste() composites a PIL image at it.
roqsim render --overlay list prints what this environment registers, with where each comes from.
The plugin lifecycle¶
A plugin subclasses roqsim.plugin.Plugin and implements any subset of these hooks (the engine
only calls the ones you override):
Hook |
When |
Use |
|---|---|---|
|
once, pre-compile |
mutate the |
|
once, post-compile |
resolve ids/handles, open resources, advertise services, register entities |
|
each reset |
restore initial state |
|
each tick, before |
write controls/actuators |
|
each tick, after |
read state, publish, record |
|
teardown (reverse order) |
release resources |
validate_config(config) -> list[str] returns error strings (empty = valid).
SimContext¶
Every hook receives a SimContext with:
model/data/dt/sim_time— the MuJoCo handles (specduringbuild).config— the parsed world dict.blackboard— a typed key/value store for cross-plugin cooperation (set/get/require). E.g. a controller registers aRobotHandleunderrobot:<name>for in-process consumers (teleop, standalone drivers).interface— the interface registry (add/all/by_direction): where a plugin declares itsEndpoints (see below). A transport/bridge plugin reads it to wire the robot up.entities— the entity registry (add/get/names); backssimulation_interfaces.post(cmd)— the thread-safe command queue. External threads (ROS callbacks) must use this; the engine drains it on the physics thread at the start ofpre_step. Never touchdatafrom another thread.control— run-control (play / pause / step / reset) consulted by the standalone driver.
Switching an arm between controllers¶
A robot that registers controllers is served a controller_manager at
/<namespace>/controller_manager, with the message set and the semantics ros2_control uses –
so ros2 control list_controllers and ros2 run controller_manager spawner work against a
world, and a scenario that switches here is the scenario that switches on the robot. Nothing in a
world asks for it: on real hardware nobody opts into a controller manager, and a robot with no
controllers is served none.
service |
what it does |
|---|---|
|
every controller of that robot, with its state and what it holds |
|
activate and deactivate, atomically |
|
move a declared controller to |
|
refused while the controller is active, as upstream refuses it |
|
the command and state interfaces, and which are claimed |
Each controller also publishes <controller>/transition_event stamped with the simulation
time, which is where a run reads the instant of a hand-over rather than inferring it from when the
motion changed.
A reset returns every controller to the state the world configured, so a hand-over belongs to the trial that made it. Each restore is a transition like any other and is published there too, stamped with the new trial’s time zero.
The world file is the parameter file. ros2_control’s manager is given its controllers as
parameters and load_controller instantiates one of those; here the robot’s components: is
that list. A controller the world never declared cannot be loaded – which is what spawner does
against the real robot for a name absent from its parameters, so it is the behaviour rather than a
limitation.
A Universal Robots arm under the driver’s names. A stack written for ur_robot_driver looks
for that driver’s controllers by name. The world gives them: arm_controller with
controller_name: scaled_joint_trajectory_controller and controller_type:
ur_controllers/ScaledJointTrajectoryController, a force_torque entry named
force_torque_sensor_broadcaster, and a ur_driver_interface entry, which adds
speed_scaling_state_broadcaster and io_and_status_controller. The speed scaling starts at
100 % and io_and_status_controller/set_speed_slider (ur_msgs/SetSpeedSliderFraction) sets it:
a fraction in [0.01, 1.0] is applied, anything else is answered success: false and changes
nothing, as on the driver. The scaled controller advances trajectory time at that factor, for an
in-process trajectory and a follow_joint_trajectory goal alike, so at 0.5 the arm takes twice as
long over the same path; speed_scaling_state_broadcaster/speed_scaling publishes the factor in
effect, in percent. io_and_status_controller/zero_ftsensor is the wrist sensor’s tare. The
service type comes from ur_msgs, which the ROS side must have installed. The world also lists the
driver’s unscaled joint_trajectory_controller inactive, as the driver does, since MoveIt chooses
between the two by their state; activating it is refused. The driver’s other GPIO surface has no
simulated counterpart and is not served, so a stack that relies on it fails at the missing name:
- spawn_arm: {model: ur5e, prefix: ur5e_}
name: ur5e
components:
- arm_controller:
controller_name: scaled_joint_trajectory_controller
controller_type: ur_controllers/ScaledJointTrajectoryController
name: arm_controller
- force_torque: {site: fts_site, controller_name: force_torque_sensor_broadcaster}
name: force_torque_sensor_broadcaster
- ur_driver_interface: {ft: force_torque_sensor_broadcaster}
name: ur_driver
A FANUC arm under the driver’s names (fanuc_driver). The m20id25 (M-20iD/25) and
crx25ia (CRX-25iA) manifests give a bare spawn_arm the names, types and replies of FANUC’s
ROS 2 driver (FANUC-CORPORATION/fanuc_driver, pinned at da5db3f611cd): arm_controller as
joint_trajectory_controller of type fanuc_controllers/ScaledJointTrajectoryController with
the driver’s constraints, and a fanuc_driver_interface entry with the driver’s own gpio map,
which adds the GPIO controller, the force sensor broadcasters and the motion gate. Trajectory time
runs at speed_scaling_factor (std_msgs/Int32, clamped to [0, 100] silently, through the
driver’s 0.2 s first-order lag) times the CRX’s collaborative speed scaling, for an in-process
trajectory and a follow_joint_trajectory goal alike. set_gen_override is the controller’s
general override: stored, range-checked as the controller checks it and read back, and it retimes
nothing, since FANUC says to keep it at 100 while streaming. Where the M-20iD/25 and the CRX differ
on the robot they differ here: only the CRX senses force (embedded, fs_type 1), stops on contact
(an alarm until reset), and has collaborative speed scaling and set_payload_comp; their I/O is the gpio map FANUC’s launch files load for each.
The ROS side needs fanuc_msgs (built from the driver’s repository; it has no binary release).
Every name the driver exposes, and what the simulated arm does with it:
kind |
name |
type |
here |
why |
|---|---|---|---|---|
controller |
|
|
served with a difference |
The bridge’s manager (list, switch, load, configure, unload, list_hardware_interfaces). 500 Hz is the physics step (2 ms); the |
controller |
|
|
served |
Active at start, as the driver’s |
controller |
|
|
served |
|
controller |
|
|
served |
Defined, not spawned: listed once |
controller |
|
|
served with a difference |
Its topics and services exist for the whole run rather than from configure to deactivate. |
controller |
|
|
served |
|
controller |
|
|
served |
|
controller |
|
|
not served |
RMI’s motion-instruction interpreter is not simulated; not listed, so a spawner or a call fails at the name. |
topic |
|
|
served with a difference |
Every control period, position and velocity, no effort. The velocity is the simulator’s joint velocity, not the driver’s finite difference over the control period. |
topic |
|
|
served |
The joints and the hardware’s other state interfaces: the configured I/O, |
topic |
|
|
served |
Subscribed: clamped to [0, 100] silently, through a 0.2 s first-order lag. |
topic |
|
|
served |
Subscribed. |
topic |
|
|
served |
100 Hz. |
topic |
|
|
served |
Subscribed; applied while that controller is active. |
topic |
|
|
served |
In |
topic |
|
|
served with a difference |
CRX: |
topic |
|
|
served |
The gpio map’s |
topic |
|
|
served |
|
topic |
|
|
served |
|
topic |
|
|
served |
Subscribed; unconfigured entries ignored. |
topic |
|
|
served |
Subscribed, indexed as the driver indexes it (a second block is mis-indexed there too). |
topic |
|
|
served |
Subscribed. |
topic |
|
|
served with a difference |
Always true: the simulator streams for as long as it runs. No network connection exists to lose. |
topic |
|
|
served with a difference |
No teach pendant or e-stop chain is simulated: |
topic |
|
|
served |
1.0 on an industrial arm; on a CRX, what the simulation sets. |
topic |
|
|
served with a difference |
~30 Hz. |
topic |
|
|
not served |
It reports the state of an RMI program, and no RMI session exists. |
service |
|
|
served with a difference |
DI, RI, DO, RO, F, UO, UI; else |
service |
|
|
served |
DO, RO, F; an output the gpio map’s |
service |
|
|
served |
AI, AO. |
service |
|
|
served |
AO. |
service |
|
|
served |
GI, GO. |
service |
|
|
served |
GO. |
service |
|
|
served |
|
service |
|
|
served |
|
service |
|
|
served with a difference |
An unset register reads as Cartesian zeros. |
service |
|
|
served |
Configuration flags clamped to 1. |
service |
|
|
served |
1..100 stored and read back in |
service |
|
|
served |
|
service |
|
|
served |
|
service |
|
|
served |
Stored per schedule and read back; streaming goes on, as the driver only forwards the payload to the controller. The declared mass feeds the CRX’s force estimate. |
service |
|
|
served |
Centre of gravity / 100 and inertia / 10000, as the driver returns them. |
service |
|
|
served |
CRX only; else |
service |
|
|
served |
CRX only. |
service |
|
|
served with a difference |
The simulator’s alarms ( |
service |
|
|
served |
|
service |
|
|
served |
|
service |
|
|
served |
|
service |
|
|
served |
|
service |
|
|
served |
|
service |
|
|
served |
|
service |
|
|
served with a difference |
mm and degrees in FANUC’s world frame (the description’s |
service |
|
|
served |
mm/s. |
service |
|
|
served |
STOP closes the arm to motion, START opens it, another status is -1. |
service |
|
|
served |
Clears an alarm (a CRX contact stop). |
service |
|
|
served |
|
service |
|
|
not served |
The bridge feeds a goal as setpoints and keeps no trajectory to sample at a requested time. |
service |
|
|
not served |
See |
action |
|
|
served with a difference |
Graded by the driver’s constraints: 0.05 rad goal and 0.25 rad path per joint, no goal time limit; partial goals and a moving end rejected; a new goal ends the running one; aborted with the driver’s “Aborted: STMO is inactive (!motion_possible)” while motion is not possible. A replaced goal ends ABORTED, where upstream may end it CANCELED. |
parameter |
|
|
not served |
The hardware plugin’s connection and session settings; there is no hardware plugin. The gpio map is the world’s |
parameter |
|
|
not served |
A controller’s parameters are not readable over ROS; the world’s configuration holds them. |
FZI’s Cartesian controllers under their own law. cartesian_admittance answers to the names of
FZI’s cartesian_controllers with a law of its own. fzi_cartesian_controllers runs FZI’s law
– the forward-dynamics solver over a virtual model, pd_gains, solver.error_scale and
iterations, stiffness – for any of the motion, force and compliance controllers it is given,
each registered under its own name and switched like the rest. A stack’s FZI gain file is therefore
the world’s, key for key. How well a compliant press holds its force depends on how faithfully the
arm’s servo realises each commanded position, as it does on the robot; the plugin’s docstring states
the measurement.
A Universal Robots arm driven over RTDE, without ROS. A control loop that runs on a PC and
drives a UR through ur_rtde’s RTDEControlInterface and RTDEReceiveInterface is written as
a function of those two objects. ur_rtde builds them for the robot; for the simulated arm, a
ur_rtde entry builds them, under the same method names, units and the controller’s base frame.
Its handle (ur_rtde:<arm>) runs such a function in lock-step with the physics, so one
waitPeriod is one control period of simulated time and a run is reproducible. It serves
speedL, moveL, zeroFtSensor, setTcp, the watchdog and the TCP pose, speed and force.
It does not emulate the controller’s own force law (forceMode), payload compensation or the
safety system, and a method it does not serve fails at its name. The plugin’s docstring states each
semantic:
- spawn_arm: {model: ur5e, prefix: ur5e_}
name: ur5e
components:
- force_torque: {site: fts_site, frame: world}
name: ft
- ur_rtde: {ft: ft}
A Franka Research 3 under libfranka, as the robot serves it. The fr3 model (franka_description
2.9.0, torque motors, no hand) takes a franka_fci entry, which is the robot’s controller and its
FCI. With bind: set it serves the robot’s side of the network protocol (libfranka-common’s
headers, protocol version 10, libfranka 0.21.3), so an unmodified libfranka program, pylibfranka and
franka_ros2’s hardware interface (robot_ip:=<bind>) connect to the simulated arm as to a robot,
and in lock-step: one control callback per millisecond of simulated time, the physics waiting for
each command, however slow it is. While the physics does not step – a paused run, one stepped on
request, a slow tick – the last state is sent again every 0.1 s, so libfranka’s 1 s UDP timeout
does not end the client; a state that is not newer changes nothing for it. One wait is bounded in
wall time: libfranka reads one state of a
motion before it sends its first command, so the simulation waits for that command at most 20 ms
of wall time and steps on without it. The tick a motion’s first command lands on can
therefore depend on how fast the client answers; from that command on, a run is reproducible.
GetRobotModel serves
franka_description’s URDF, from which libfranka builds its Model. The rate limiter and the
low-pass filter are libfranka’s own code on the client. The robot side is the core’s:
gravity from the robot’s model and the configured end effector and load (
setLoad,end_effector:), so a wrong load sags the arm and biases the estimate as on the robot;the joint torque controller (
joint_torque_control):tau_J_dis the desired link-side torque, and by default (link) the robot’s torque loop leaves only a residual of the motor in front of the program – a share of the rotor’s inertia and damping and the link-side friction measured on the Panda, each overridable per arm;motorapplies the command at the motor, against the model’s whole armature, damping and friction loss. Neither Franka’s torque loop nor its bandwidth is published: the values and their sources are in the plugin’s docstring;the motion-generator checks at
rate_limiting.h’s limits, the internal joint and Cartesian impedance controllers, and the reflexes atsetCollisionBehavior’s thresholds, each ending the motion with libfranka’s own error flag;tau_ext_hat_filtered,O_F_ext_hat_KandK_F_ext_hat_Kestimated from the link-side joint torques and the robot’s model; the arm has no wrist sensor.
The world must state collision_behavior: the robot’s own start-up thresholds are not published,
and whether the arm stops on a contact turns on them. The timestep must be 1 ms / N. Two arms are two
entries with two addresses (libfranka always connects to port 1337), stepped by one physics, so a
law that coordinates them sees one clock. In process, the handle franka_fci:<arm> runs a law
law(state, period) -> command with libfranka’s field names. What Franka does not publish – the
estimator’s filter, the internal impedance laws, when the “acceleration” thresholds apply – is a
stated assumption in the plugin’s docstring, and absent are guiding mode, PTPMotion, power and
self-collision limits and the gripper. The error flags the robot raises and the simulated one never
does are roqsim_manipulation.franka.core.NOT_RAISED; among them are the robot’s checks of a
Cartesian motion beyond its start pose and the rate limits (the Cartesian limits, the elbow, the
joint motion its inverse kinematics makes), so a Cartesian program that runs here can still fail on
the arm. A world reset returns the controller to the world’s configuration: a load, collision
behaviour, impedance or frame a client set in the run before is undone, a request still queued is
answered there (a Move as aborted, a setting as refused), and only a request still on its way
over the network is taken in the next run. One client is served at a time, as by the robot; each
request is carried out and answered only for the connection that sent it, and a motion waits only
for its own client’s commands, so a client that replaces another hears nothing of the old one’s
and the old one’s motion ends as preempted. The tests
(roqsim_manipulation/tests/test_franka_*.py) read Franka’s files at the pinned commits
(external/franka_upstream.py) and build and run the real libfranka against the server:
sim: {timestep: 0.001}
components:
- spawn_arm: {model: fr3, prefix: left_, pose: {position: {y: 0.5}}}
name: left
components:
- franka_fci:
bind: 127.0.0.2
collision_behavior: {lower_torque: [20, 20, 20, 20, 20, 20, 20],
upper_torque: [40, 40, 40, 40, 40, 40, 40],
lower_force: [20, 20, 20, 20, 20, 20],
upper_force: [60, 60, 60, 60, 60, 60]}
Three semantics are worth stating because getting them wrong makes a scenario that works here fail on the arm:
Only command interfaces are claimed, and only while a controller is active. A broadcaster claims nothing, which is why it reads a joint another controller drives.
claimed_interfacesis empty while inactive;required_command_interfacesis what a controller would take.Neither ``STRICT`` nor ``BEST_EFFORT`` deactivates a controller the caller did not name. A hand-over names both sides in one request.
FORCE_AUTOis the one that arbitrates.``strictness`` has no zero. A default-constructed request carries one and it is read as best effort, so pass the field explicitly from a scenario:
service_call('/ur5e/controller_manager/switch_controller', 'controller_manager_msgs.srv.SwitchController', '{\"activate_controllers\": [\"cartesian_compliance_controller\"], \"deactivate_controllers\": [\"scaled_joint_trajectory_controller\"], \"strictness\": 2}')
Controller parameters are not settable at runtime. A real controller is retuned with
ros2 param set; here the gains are world-authored, because a campaign varies them by varying the
world and a run whose gains changed mid-flight is not reproducible.
Declaring a robot interface (endpoints)¶
A robot describes its own I/O so a bridge can wire it to any transport (ROS 2, and later zenoh /
zmq) without the robot package importing that transport. A plugin declares its ports by decorating
the methods that serve them (@endpoint.out / @endpoint.command / @endpoint.stream, see
Available plugins, Declaring a plugin’s endpoints), and the engine registers them as Endpoints
on ctx.interface and marshals every inbound call onto the physics thread. The method’s signature
is the endpoint’s schema, carried as params (what write takes, by name), result (what
read returns, or a command’s outcome) and payload_type (the neutral type a transport
carries, one of roqsim.types or a plugin’s dataclass), so a bridge can describe, check and map a
port without knowing the plugin – the ROS bridge gives every neutral type its message, so such a
plugin names no ROS type. Every entity also has a core pose endpoint, sim/entities/<name>/pose.
A port known only at run time is registered by hand in configure:
from roqsim.context import Endpoint
ctx.interface.add(Endpoint(
name="scan", direction="out", owner=self.robot,
read=lambda: self._scan, # returns a neutral payload (numpy/tuple/dataclass)
rate_hz=10.0,
backend={"ros2": {"type": "sensor_msgs.msg.LaserScan", "topic": "scan",
"frame_id": self.frame_id}}, # the site the rays are cast from
))
direction—"out"(sim → world; provideread) or"in"(world → sim; providewrite).read/writetraffic in neutral payloads, never wire messages — this is what keeps the robot package backend-independent.An
inendpoint also says what kind of interaction it is, through its backend hints, and the choice is about the interaction rather than about taste:Hint
Served as
Use when
typea subscription
the input is a stream and the sender needs no answer (
cmd_vel).servicea service
the input is a command whose outcome the caller needs, so it can fail on it (
model_override’sstd_srvs/SetBool: the reply says whether the fault landed).actionan action server
the input is a goal that takes time, with feedback and cancellation (
FollowJointTrajectoryfor MoveIt 2).An action handler whose only output is a stream of setpoints must command a STOP when its goal is cancelled, because the producer holds the last target it was given every tick: ending the stream leaves that setpoint standing and the robot converging on a path nobody wants any more. The trajectory and gripper handlers post the measured position as that hold before they return, and grade the cancelled goal on the pose it stopped in – so a caller that cancels and reads the joints reads an arm that has stopped, and a result it can tell from a goal that ran to its end.
A bridge’s inbound callback returns a future for a command, holding what the producer’s method returned or raised; a service handler waits on it, so a producer that raised is a failed reply. The rest of a reply is assembled by the backend’s handler from the producer’s published state — named by a
state_keyhint — which is what keepsEndpointfree of any backend’s reply types. Both the service and action handlers come from per-type registries inroqsim_ros_bridge(services.py/actions.py), so a new srv or action type is a handler there and no change here. A handler, converter or decoder in another package is registered by naming its module in theroqsim_ros_bridge.extensionsentry-point group, which the bridge imports at start-up; a module that fails to import fails the start (seeroqsim_ros_bridge/extensions.py;roqsim_nav_rosis an example).owner— the entity the port belongs to, so a bridge can serve one robot in a many-robot world.backend— inert per-backend hints keyed by backend name. Naming the message type as a string (resolved by the bridge) means the robot package imports nothing transport-specific. Anything transport-specific a robot needs lives here. One hint is worth knowing about because it saves writing a converter:fieldnames a member of a structured payload to publish as a primitive message, so a producer keeps its rich payload for in-process consumers and still gets a single-field topic.contact_monitorreads itsContactReportin-process and publishesbackend={"ros2": {"type": "std_msgs.msg.Bool", "field": "in_contact", "topic": "collision"}}
Without it the bridge’s reflective fallback would assign the whole dataclass to
Bool.data. The alternative — astd_msgs.msg.Boolconverter in the bridge registry — would put one plugin’s attribute names in shared code, and the next primitive endpoint would add another.model_overrideis the second user and publishes two members of one report this way (aBoolofactiveand aStringofverified), which is the shape to copy when a producer has several primitives each worth a topic.has_subscribers— optional performance hint a bridge sets after wiring the endpoint (e.g. from a ROS 2 publisher’s subscription count). A producer whosereadis expensive to produce (a rendered camera frame) may check it inpost_stepand skip the work when it’sFalse;None(no bridge loaded, or one that doesn’t report this) means “assume yes”. Seeroqsim_sensors’s camera plugins.claims/claim()/release()/wanted()— the in-process side of the same question. A plugin that reads another’s endpoint directly, on the physics thread (a task plugin estimating a pose from a camera frame), is a consumer no transport can count, so with a bridge loaded and no transport subscriber the producer would skip the work it needs. It callsclaim()once (andrelease()when done);wanted()is true for a claim, a transport subscriber, orhas_subscribers is None, and is what the camera plugins’ render gate asks. A camera withon_demand: truedrops the last case: with no transport able to tell, it renders only while a plugin holds a claim, so a stepped run pays for the frames it reads and no others. A renderedImagecarriesstamp, the sim time of its capture, so such a reader tells a fresh frame from the one it already has.lazy— opt this endpoint out of publishing whilehas_subscribersreports nobody listening, so its payload is never even read. Distinct from the check above, and both are needed: the producer’s own check is an OR over every endpoint one render feeds (one depth subscriber justifies the whole GL pass), whilelazyis per-endpoint (a raw-image subscriber must not make the camera pay for a JPEG nobody wants). DefaultFalse, because a publish can carry more than its message — a bridge deriving TF from an odometry payload would stop broadcasting the transform whenever nothing subscribed to/odom— and because it buys nothing for a cheap payload. Set on the camera plugins’image,image_compressed,depth,depth_compressedandpoints.
Running the ROS 2 bridge then needs no per-topic config — add ros2_bridge to the world. One
bridge serves every robot: give each spawn its own namespace: and its topics and frames land
under /<namespace>/... (see Architecture & porting playbook §13, Namespacing, for the bridge’s own
namespace and its owner filter).
RobotHandle(name, drive(vx, vy, w), read_odom() -> (x, y, yaw, vx, vy, w)) remains the uniform way
a controller exposes a robot to in-process consumers (teleop, the standalone driver).
simulation_interfaces services (ROS 2)¶
The sim_interfaces plugin (in roqsim_ros_bridge) exposes a subset of
ros-simulation/simulation_interfaces:
GetSimulatorFeatures— advertised capabilities.GetEntities,GetEntityState,SetEntityState— list and read/teleport entities.GetEntitiesnarrows by its namefilter, a POSIX Extended regular expression searched in each name (unanchored, asregexecmatches; character classes such as[[:digit:]]are read in the POSIX locale, and a backslash before an ordinary character, which POSIX leaves undefined, is refused). It also narrows byboundsofTYPE_SPHEREin the world frame, keeping each entity with a geom whose bounding sphere overlaps it – a conservative test that may keep an entity whose surface stops just short. It refuses acategoriesortagsfilter andTYPE_BOXorTYPE_CONVEX_HULLbounds withRESULT_FEATURE_UNSUPPORTED, and a pattern or sphere that is malformed withRESULT_OPERATION_FAILEDnaming the fault.SetEntityStatetakes a state in a reference frame (see below) and refuses a zero-length quaternion and a NaN or infinite component withINVALID_POSE.GetEntityStatereports the world frame. The acceleration is ignored. A non-zero twist or acceleration fails withRESULT_OPERATION_FAILEDfor an entity without a free joint (a mocap body or welded scenery), which cannot carry one.GetSpawnables— the absent entitiesSpawnEntitycan select.SpawnEntity,DeleteEntity— make an entity appear or disappear (see below).GetSimulationState,SetSimulationState— play / pause / stop.StepSimulation— step N times while paused; answers once the steps have run, and fails when the simulation stops stepping or leaves the pause first.ResetSimulation— reset the world; answers once the reset has run, and fails under a driver that does not reset on request.
Reference frames¶
SpawnEntity’s initial_pose and SetEntityState’s state name their frame in
header.frame_id. Two kinds of name are accepted:
the world frame: an empty
frame_idorworld;a present entity, by its name exactly as
GetEntitieslists it, meaning that entity’s root body. The pose is composed with that entity’s world pose, read on the physics thread in the same transaction that writes the new pose, so it is relative to where the entity is at that moment.
Every other frame_id is refused with INVALID_POSE: a body path such as
robot/base_link, a TF frame name, an absent entity (it is not listed, so it is not known),
and the entity being placed named as its own frame, since the write moves that frame.
A SetEntityState twist in an entity’s frame is expressed in that entity’s axes: its linear
and angular parts are rotated into the world by the entity’s orientation, and the entity’s own
velocity is not added. EntityState says the twist is “observed in” the header’s frame and
refers to the geometry_msgs/VelocityStamped convention, which tells the frame a velocity is
observed in apart from the frame it is measured against; EntityState names only the first, so
the motion stays measured against the world, as GetEntityState reports it.
Spawning is activation, not creation¶
roqsim never recompiles the model at runtime, so there is no body to add. A world declares
everything a trial may bring in, and SpawnEntity selects one of those by uri: the entity’s
name, as GetSpawnables lists it. name may be left empty or repeat the uri; a different
one would be a rename, which a compiled entity cannot take. A request with no uri selects by
name, which the service does not define but older callers rely on. A uri the world does not
carry is refused rather than approximated, because the alternative is a trial that believes it
spawned something; one already present is refused with NAME_NOT_UNIQUE, since its name is
taken and renaming is never allowed. Spawning CONSUMES a spawnable, since it activates one entity rather than
copying a model: GetSpawnables lists the absent ones, GetEntities the present ones, and an
entity moves between the two lists as it is spawned and deleted. spawn_formats is therefore empty — offering mjcf would invite a
caller to send geometry that nothing can load.
DeleteEntity makes an entity absent: excluded from raycasts, from rendering, from contacts,
and from what GetEntities lists. Its pose does not move, which is the point — parking it out
of sight leaves a free body accelerating under gravity for as long as it is away, so it comes
back with whatever velocity it accumulated. See roqsim.presence for the three model fields
this flips (on its geoms, and on a flex’s own copies of them) and why disabling contact alone is
not enough: mj_multiRay ignores contype/conaffinity and tests the real triangles, so
it is the zeroed alpha, and the absent geom group that roqsim’s raycasts mask by default, that take
an absent obstacle out of a lidar’s returns.
An absent entity is not found. The service identifies an entity as GetEntities or
SpawnEntity returns it, and an absent one is neither: GetEntities does not list it and
GetSpawnables offers it. So DeleteEntity, GetEntityState and SetEntityState naming
one answer RESULT_NOT_FOUND, with a message saying it is absent and can be spawned. Only
SpawnEntity takes it, which is how it appears; the pose it should appear at is the
request’s initial_pose.
A world can declare an entity absent from the start, with present: false on the entry that
registers it:
- spawn_model: {model: graspable_box, pose: {position: {x: 4.0, y: 1.0}}, motion: physics, present: false}
name: obstacle
That is what gives a trial something to spawn. A population entry (boxes, cylinders)
forwards it to every instance, and each instance is an entity of its own, so a pool of spares is a
uri per spare – obstacle_0, obstacle_1, or whatever an instance names itself – and each
leaves the list as it is spawned. The declared value is restored on every reset, so a
spare brought in during one repetition is a spare again in the next. Do not confuse it with
enabled: false, which removes the entry entirely – no body is built, and there is nothing left
to spawn.
Moving one needs a free joint¶
SetEntityState places an entity by writing its base free joint or its mocap pose, and
SpawnEntity does the same with its initial_pose – always, since a request that states no
pose asks for the origin; to bring an entity back where it was, state that pose. A body compiled
with neither is welded scenery: it holds the pose the world gave it, and both services refuse to
move it, naming the weld and the motion: driven or motion: physics that resolves it.
This is worth stating because nothing else about such a world looks wrong. It compiles, the entity
exists under the name the caller uses, and GetEntities lists it – so a world that parks an
obstacle out of the way and teleports it in on cue fails on its first call, every run, and the
count and names all agree. A placement is motion: physics by default, so this is what a world
says when it has welded something with motion: static that the trial then tries to move.
Asking a welded entity for the pose it already holds succeeds. Only a move is what a weld refuses, so a world that states a pose twice is not an error.