Metadata-Version: 2.4
Name: telekinesis-isaacsim-server
Version: 0.1.0
Summary: Local server that gives the Telekinesis Isaac Sim Bridge robot kinematics from Telekinesis Synapse.
Author-email: Telekinesis <support@telekinesis.ai>
Requires-Python: <3.13,>=3.11
Description-Content-Type: text/markdown
Requires-Dist: fastapi[standard]==0.141.1
Requires-Dist: loguru
Requires-Dist: numpy
Requires-Dist: pydantic-settings
Requires-Dist: telekinesis-synapse==0.10.13
Requires-Dist: telekinesis-tf
Provides-Extra: dev
Requires-Dist: ruff==0.15.8; extra == "dev"
Requires-Dist: pylint==4.0.5; extra == "dev"

# Telekinesis Isaac Sim Server

A local FastAPI server that gives the Telekinesis Isaac Sim Bridge robot kinematics from
Telekinesis Synapse. It loads **robots**: Synapse robots built for kinematics only. A loaded
robot is never connected to hardware or to Isaac Sim, and the server commands no motion.

The server keeps robots in memory only. Stopping it forgets them.

## Setup

Requires Python 3.11 or 3.12 on Windows or Linux (x86_64).

```bash
conda create -n telekinesis-isaacsim-server python=3.11
conda activate telekinesis-isaacsim-server
pip install telekinesis-isaacsim-server
```

To work on the server itself, install it from a clone instead:

```bash
git clone https://gitlab.com/telekinesis/isaac-sim-server.git
cd isaac-sim-server
pip install -e .
```

## Start the server

```bash
telekinesis-isaacsim-server
```

`python -m telekinesis.isaacsim_server` does the same. In a clone,
`fastapi run --host 127.0.0.1 --port 8770` also works.

It listens on `http://127.0.0.1:8770`, the address the bridge expects. Keep `--host 127.0.0.1`:
the server has no authentication and is meant for local clients only. Stop it with Ctrl-C; every
robot is shut down.

While developing, `fastapi dev --port 8770` restarts the server whenever the code changes. A
restart forgets all robots.

The interactive API docs are at `http://127.0.0.1:8770/docs`.

## Routes

Every route is under `/api/v1`.

| Method | Path | Body | Returns |
|---|---|---|---|
| GET | `/robot_class_names` | | Synapse robot class names, e.g. `UniversalRobotsUR10E` |
| POST | `/robots` | `{"class_name": ...}`, in any case | The new robot's description (201) |
| GET | `/robots` | | The description of every robot |
| GET | `/robots/{robot_id}` | | The robot's description |
| DELETE | `/robots/{robot_id}` | | Nothing (204) |
| POST | `/robots/{robot_id}/inverse_kinematics` | `{"poses", "seed"?}` | `{"joint_names", "joint_positions"}`, one solution per pose |
| POST | `/robots/{robot_id}/link_poses` | `{"joint_names", "joint_positions"}` | `{"link_poses": {link_name: pose}}`, every URDF link in the base frame |

`POST /robots` loads the robot before answering; the first time a robot class is used, Synapse
downloads its URDF from the Telekinesis asset server. Every call loads a new robot under a new id.

The server assigns each robot a random UUID as its id. An id saved by a client stays valid until
the server stops; after a restart it answers 404 and is never reused for another robot.

| Status | When |
|---|---|
| 404 | No robot has the id, e.g. because the server restarted |
| 422 | Unknown `class_name`, malformed id, malformed body, a robot joint missing from the seed, or a request Synapse rejects |
| 503 | The robot description could not be fetched |

### Inverse kinematics

`POST /robots/{robot_id}/inverse_kinematics` solves each pose in `poses`, in order, for the
robot's `default_tcp` in its `base_frame`. It returns the robot's `joint_names` and one solution
in radians per pose, or `null` for a pose it cannot reach.

The optional `seed` is where every search starts, usually the robot's current joints, given as
`joint_names` with matching `joint_positions` in radians. The names must include every joint of
the robot, in any order; other names, such as gripper fingers, are ignored. A seed on or past a
joint limit is moved just inside it.

### Link poses

`POST /robots/{robot_id}/link_poses` takes the robot's joints the same way, `joint_names` with
matching `joint_positions` in radians, and returns the pose of every link of the robot's URDF in
its `base_frame`, by link name. Joint positions outside the joint limits answer 422. A client uses
it to draw the robot in a given configuration, such as an inverse-kinematics solution.

### Robot description

| Field | Meaning |
|---|---|
| `id` | Id the server assigned to the robot |
| `class_name` | Synapse robot class |
| `base_frame` | Root link of the robot's URDF; poses are expressed in this frame |
| `default_tcp` | Frame that ghost objects place: the robot's flange frame, e.g. `tool0` |
| `mount_link` | Link that tools are mounted on in Isaac Sim, or `null` |
| `flange_in_mount_link` | Pose of `default_tcp` in `mount_link`, or `null` |

## Units

Poses are `[x, y, z, rx, ry, rz]`: metres, then extrinsic XYZ Euler angles in degrees. Joint
positions are in radians.

## Notes

- Robots are loaded on a server worker thread, so Synapse logs that it could not install a signal
  handler. This is expected; the server shuts every robot down when it stops.
