๐Ÿ“ Site#

Overview#

A Site is an important concept in MotrixSim, representing a point of interest in the model. A Site is essentially a virtual marker used to indicate specific positions and orientations within the model framework.

Key Features#

  • Virtual Reference Point: A Site is a virtual marker and does not participate in collision detection or inertia calculations

  • Reference Location: Used to specify spatial properties for sensors, endpoints, and other objects

  • Lightweight: Compared to physical geometries, a Site does not participate in physics calculations and has minimal overhead

Usage and Examples#

Usage#

You can access all Site information or retrieve a specific Site by name via the SceneModel object:

# ----------Try to access site----------
# How many sites are in the model?
num_sites = model.num_sites
# Site objects
sites = model.sites
# Site names
site_names = model.site_names
print(f"num_sites : {num_sites}, sites : {sites}, site_names : {site_names}")

# Get site by name
car_imu = model.get_site("car_imu")
print(f"car_imu's site index : {car_imu.index}")
print(f"The car_imu site is on : [{car_imu.parent_link.name}] link")
print(f"site_name of car_imu : {car_imu.name}")
print(f"car_imu's local position : {car_imu.local_pos}")
print(f"car_imu's local rotation : {car_imu.local_quat}")
print(f"car_imu's world pose : {car_imu.get_pose(data)}")
# ----------End----------

For a complete example, see examples/site_and_sensor.py.

Application Scenarios#

Site can be used in various scenarios:

  • Sensor Mounting: Installation points for IMUs, cameras, LiDARs, etc.

  • Reference Markers: Marking key locations such as joint centers, centers of mass, etc.

  • Debugging Aid: Visualizing important points to help verify model correctness

  • Path Planning: Used as waypoints or target points in path planning

Defining Site in MJCF#

In MJCF files, a Site is defined using the <site> tag. For detailed tag attributes and usage, refer to the MJCF Format Documentation.

Note: MotrixSim currently supports the core features and common attributes of Site. Some <site> attributes are still under development. Please refer to the support list for details.

Below is an example of a Site definition from site_and_sensor.xml:

<geom name="floor" type="plane" size="5 5 0.1" pos="0 0 -0.245" rgba="0.4 0.4 0.4 1" material="motphys-ground"/>

<body>
  <freejoint/>
  <geom name="freebox" type="box" size="0.1 0.1 0.1" pos="0.8 0 1" rgba="1 0 1 1"/>
</body>

<body name="car" pos = "0 0 0">
  <joint name="slider" type="slide" axis="1 0 0" limited="true" range = "-2 2"/>
  <geom name = "box" type="box" size="0.25 0.25 0.25" pos = "0 0 0 " rgba="1 0 0 1"/>
  <site name="car_imu" type="sphere" size="0.03" rgba="0 1 0 1" pos="0 0 0"/>

For the complete XML file, see: examples/assets/site_and_sensor.xml

Notes#

  1. Coordinate System: The position and orientation of a Site are relative to its parent linkโ€™s coordinate frame

  2. Unique Naming: Each Site should have a unique name within the model

  3. Visualization: Site can be displayed in the renderer, which is helpful for debugging and verifying positions

  4. Virtual Nature: Site is virtual; use the <geom> tag if physical interaction is required

API Reference#

For more APIs related to Site, see Site API