Examples

The following describes some examples for the Command Line as well as Picking up a block. It is helpful to read the System and Robot setup and the Configuration sections.

Command Line

RoBits provides entry points for quick interaction. You can use the rb entry point in your shell. Here are some examples:

# Using the speech modules
rb speech say "Hello World!"

# Moving the robot to the default pose
rb move home

# Closing the gripper
rb gripper close

# Opening the Robotiq gripper as specified in the gripper_robotiq_real config
rb gripper open --gripper-name gripper_robotiq_real

# Showing available RealSense cameras
rb camera list

# Getting an overview of available configurations
rb config list

# Editing the robot_panda_real config
rb config edit robot_panda_real

Picking up a block

The following command-line interface script performs a basic robotic pick task by initializing the robot, opening the gripper, executing a series of Cartesian movements to approach and grasp an object, lifting it with a relative motion, and returning the robot to its home position. The control is context-managed Cartesian control mode (see robits.core.abc.control.control_types) For more information on CLI setup and options, refer to robits.cli.cli_utils and robits.cli.cli_options.robot(). Please note that the grasp pose is relative to the robot. See robits.utils.transform_utils.transform_pose() to transform it into the robot’s coordinate system.

 1#!/usr/bin/env python3
 2
 3import rich_click as click
 4
 5from robits.core.abc.control import control_types
 6
 7from robits.cli import cli_utils
 8from robits.cli import cli_options
 9
10
11@click.command
12@cli_options.robot()
13def cli(robot):
14    console = cli_utils.console
15    console.rule("Initializing")
16
17    default_robot_orientation = [0, -1, 0, 0]
18    # robot.control.move_home()
19    robot.gripper.open()
20
21    console.rule("Starting")
22
23    # If the robot pose is not identity then you to
24    # transform the pose to the robot's coordinate system
25
26    with robot.control(control_types.cartesian) as ctrl:
27
28        ctrl.update(([0.52, -0.2, 0.15], default_robot_orientation))
29        ctrl.update(([0.52, -0.2, 0.02], default_robot_orientation))
30        robot.gripper.close()
31        ctrl.update(([0.0, 0.0, 0.2], [0, 0, 0, 1]), relative=True)
32
33    robot.control.move_home()
34
35    console.rule("Done")
36
37
38if __name__ == "__main__":
39    cli_utils.setup_cli()
40
41    cli()

Shell integration

You can directly interact with the robot using rb shell. To launch a MuJoCo simulation with the Panda use rb shell --robot robot_panda_sim or export ROBITS_DEFAULT_ROBOT=robot_panda_sim. Note that for MuJoCo simulation the environment is built once you interact with it. Just access robot.env in the IPython shell to trigger a build of the environment. Next paste the following to pick up the blue block: