🧱

Adding Objects to Your Simulation

This tutorial walks you through adding both primitive shapes and URDF-based objects into your simulation environment using Ark.


✅ Prerequisites

Before proceeding, ensure:


📁 Project Structure Overview

Make sure your folder structure resembles this:

text
CopyEdit
project_root/
├── config/
│   ├── global_config.yaml        # Main simulation config
│   ├── objects/                  # Object definitions live here
│   │   └── ball.yaml             # Your new object file
│   └── ...
└── sim_node.py


🧩 Step 1: Link Object in Global Config

Edit global_config.yaml to include your object:

simulator:
  # ... your existing sim config

objects:
  - "objects/ball.yaml"

🌍 Step 2: Enable Ground Truth Publishing

To have Ark automatically publish an object’s true position and orientation, add:

publish_ground_truth: Tru

This works for both primitive and URDF-based objects.


⚙️ Adding a Primitive Object

Ark supports two basic primitives:


🏀 Example: Ball (Sphere)

File: config/objects/ball.yaml

name: "ball"
config:
  source: "primitive"
  publish_ground_truth: True

  visual:
    shape_type: "GEOM_SPHERE"
    visual_shape:
      radius: 0.05
      rgbaColor: [0.0, 1.0, 0.0, 1.0]  # Green

  collision:
    shape_type: "GEOM_SPHERE"
    collision_shape:
      radius: 0.05

  multi_body:
    baseMass: 0.1  # Dynamic object

  base_position: [-0.5, 0.0, 0.5]
  base_orientation: [0.0, 0.0, 0.0, 1.0]

💡 Explanation

FieldDescription
sourceUse "primitive" for built-in shapes
shape_typeSphere geometry (GEOM_SPHERE)
radius5 cm
rgbaColorGreen with full opacity
baseMass0.1 kg; object can move and be affected by physics
base_positionx = -0.5, y = 0.0, z = 0.5
base_orientationQuaternion for no rotation
ℹ️

Note: If baseMass = 0, the object becomes static (immovable).


🧱 Example: Floor (Box)

File: config/objects/floor.yaml

yaml
CopyEdit
name: "floor"
config:
  source: "primitive"
  publish_ground_truth: False

  visual:
    shape_type: "GEOM_BOX"
    visual_shape:
      halfExtents: [1, 1, 0.1]
      rgbaColor: [1.0, 0.0, 0.5, 1.0]  # Pink

  collision:
    shape_type: "GEOM_BOX"
    collision_shape:
      halfExtents: [1, 1, 0.1]

  multi_body:
    baseMass: 0  # Static object

  base_position: [0.0, 0.0, 0.0]
  base_orientation: [0.0, 0.0, 0.0, 1.0]


🦾 Adding a URDF Object

You can also load more complex objects from a URDF file.

Example: Power Drill

name: "power_drill"
config:
  source: "urdf"
  urdf_path: "config/objects/power_drill/model.urdf"
  publish_ground_truth: False

  base_position: [-0.5, 0.5, 0.3]
  base_orientation: [0.0, 0.0, 0.0, 1.0]
  global_scaling: 1.5

Key Parameters:


🚀 Running the Simulation

After adding objects to your config, run the simulation. You should see the ball, floor, and any URDF models appear in your simulated world.

✅ If everything is set up correctly, it should look like this:

Code can be found:

https://github.com/Robotics-Ark/franka_gym_example

Next Steps