This tutorial will give a toy example on how to use PS4 controller to collect demonstrations in the PyBullet simulation within the Ark framework,

Load objects in the simulation

In this section, we'll demonstrate how to load both a URDF model and a primitive shape into the PyBullet simulation. You can define your own objects using a YAML configuration file and place it under the config/objects directory.

Define a primitive object

To load a simple primitive shape like a cube, you can define its properties in a YAML file. Below is an example for a cube:

name: "Cube"
config:
  source: "primitive"
  publish_ground_truth: False
  visual:
    shape_type: "GEOM_BOX"
    visual_shape:
      halfExtents:
        - 0.03
        - 0.015
        - 0.03
      rgbaColor:
        - 1.0
        - 0.0
        - 0.5
        - 1.0
  collision:
    shape_type: "GEOM_BOX"
    collision_shape:
      halfExtents:
        - 0.03
        - 0.015
        - 0.03
  multi_body:
    baseMass: 2
  base_position:
    - 0.0
    - -0.2
    - 0.7
  base_orientation:
    - 0.0
    - 0.0
    - 0.0
    - 1.0

Define a customized object (URDF object)

You can also load customized objects, such as a URDF-based object. Below is an example for a drill:

name: "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: # x, y, z, w
    - 0.0
    - 0.0
    - 0.0
    - 1.0
  global_scaling: 1.5

Add object YAML files to global configuration

Once you've defined the objects in the YAML files, you'll need to add them to the global configuration file so that they are loaded into the environment.

In the config/global_config.yaml file, add the paths to your object YAML files under the objects section:

objects:
  - "objects/drill.yaml"
  - "objects/cube.yaml"

Load a robot into the simulation

Define a robot

To load a robot into the simulation, you first need to create a YAML configuration file for your robot in the config/robots directory. Below is an example of how to define a robot configuration for the Franka:

name: "Franka"
config:
  source: "urdf"
  urdf_path: "panda_with_gripper.urdf"
  class_dir: "../ark_robots/ark_franka/franka_panda"
  frequency: 10 # The default frequency is 240Hz
  merge_fixed_links: False
  ee_index: 11 # End-effector index
  base_position:
    - -0.55
    - 0.0
    - 0.6
  base_orientation: # Orientation as [x, y, z, w]
    - 0
    - 0
    - 0
    - 1
  use_fixed_base: True
  initial_configuration:
    - 0
    - -0.785
    - 0
    - -2.356
    - 0
    - 1.571
    - 0.785
    - 0
    - 0
    - 0
    - 0
    - 0
  joint_groups:
    arm:
      control_mode: "position"
      joints:
        - "panda_joint1"
        - "panda_joint2"
        - "panda_joint3"
        - "panda_joint4"
        - "panda_joint5"
        - "panda_joint6"
        - "panda_joint7"
    gripper:
      control_mode: "position"
      joints:
        - "panda_finger_joint1"
    all:
      control_mode: "position"
      joints:
        - "panda_joint1"
        - "panda_joint2"
        - "panda_joint3"
        - "panda_joint4"
        - "panda_joint5"
        - "panda_joint6"
        - "panda_joint7"
        - "panda_finger_joint1"

Add robot YAML files to global configuration

Once the robot YAML file has been created, you need to add its path to the robots section in the global configuration file config/global_config.yaml. Here’s how you can do it: