telekinesis-isaacsim-server 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. telekinesis_isaacsim_server-0.1.0/PKG-INFO +125 -0
  2. telekinesis_isaacsim_server-0.1.0/README.md +108 -0
  3. telekinesis_isaacsim_server-0.1.0/pyproject.toml +40 -0
  4. telekinesis_isaacsim_server-0.1.0/setup.cfg +4 -0
  5. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/__init__.py +2 -0
  6. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/__main__.py +21 -0
  7. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/api/__init__.py +1 -0
  8. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/api/deps.py +19 -0
  9. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/api/main.py +8 -0
  10. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/api/routes/__init__.py +1 -0
  11. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/api/routes/robots.py +88 -0
  12. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/api/routes/utils.py +31 -0
  13. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/core/__init__.py +1 -0
  14. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/core/config.py +17 -0
  15. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/core/exceptions.py +49 -0
  16. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/main.py +38 -0
  17. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/models.py +161 -0
  18. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/services/__init__.py +1 -0
  19. telekinesis_isaacsim_server-0.1.0/src/telekinesis/isaacsim_server/services/robots.py +283 -0
  20. telekinesis_isaacsim_server-0.1.0/src/telekinesis_isaacsim_server.egg-info/PKG-INFO +125 -0
  21. telekinesis_isaacsim_server-0.1.0/src/telekinesis_isaacsim_server.egg-info/SOURCES.txt +24 -0
  22. telekinesis_isaacsim_server-0.1.0/src/telekinesis_isaacsim_server.egg-info/dependency_links.txt +1 -0
  23. telekinesis_isaacsim_server-0.1.0/src/telekinesis_isaacsim_server.egg-info/entry_points.txt +2 -0
  24. telekinesis_isaacsim_server-0.1.0/src/telekinesis_isaacsim_server.egg-info/requires.txt +10 -0
  25. telekinesis_isaacsim_server-0.1.0/src/telekinesis_isaacsim_server.egg-info/top_level.txt +1 -0
  26. telekinesis_isaacsim_server-0.1.0/tests/test_ci_version.py +36 -0
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: telekinesis-isaacsim-server
3
+ Version: 0.1.0
4
+ Summary: Local server that gives the Telekinesis Isaac Sim Bridge robot kinematics from Telekinesis Synapse.
5
+ Author-email: Telekinesis <support@telekinesis.ai>
6
+ Requires-Python: <3.13,>=3.11
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastapi[standard]==0.141.1
9
+ Requires-Dist: loguru
10
+ Requires-Dist: numpy
11
+ Requires-Dist: pydantic-settings
12
+ Requires-Dist: telekinesis-synapse==0.10.13
13
+ Requires-Dist: telekinesis-tf
14
+ Provides-Extra: dev
15
+ Requires-Dist: ruff==0.15.8; extra == "dev"
16
+ Requires-Dist: pylint==4.0.5; extra == "dev"
17
+
18
+ # Telekinesis Isaac Sim Server
19
+
20
+ A local FastAPI server that gives the Telekinesis Isaac Sim Bridge robot kinematics from
21
+ Telekinesis Synapse. It loads **robots**: Synapse robots built for kinematics only. A loaded
22
+ robot is never connected to hardware or to Isaac Sim, and the server commands no motion.
23
+
24
+ The server keeps robots in memory only. Stopping it forgets them.
25
+
26
+ ## Setup
27
+
28
+ Requires Python 3.11 or 3.12 on Windows or Linux (x86_64).
29
+
30
+ ```bash
31
+ conda create -n telekinesis-isaacsim-server python=3.11
32
+ conda activate telekinesis-isaacsim-server
33
+ pip install telekinesis-isaacsim-server
34
+ ```
35
+
36
+ To work on the server itself, install it from a clone instead:
37
+
38
+ ```bash
39
+ git clone https://gitlab.com/telekinesis/isaac-sim-server.git
40
+ cd isaac-sim-server
41
+ pip install -e .
42
+ ```
43
+
44
+ ## Start the server
45
+
46
+ ```bash
47
+ telekinesis-isaacsim-server
48
+ ```
49
+
50
+ `python -m telekinesis.isaacsim_server` does the same. In a clone,
51
+ `fastapi run --host 127.0.0.1 --port 8770` also works.
52
+
53
+ It listens on `http://127.0.0.1:8770`, the address the bridge expects. Keep `--host 127.0.0.1`:
54
+ the server has no authentication and is meant for local clients only. Stop it with Ctrl-C; every
55
+ robot is shut down.
56
+
57
+ While developing, `fastapi dev --port 8770` restarts the server whenever the code changes. A
58
+ restart forgets all robots.
59
+
60
+ The interactive API docs are at `http://127.0.0.1:8770/docs`.
61
+
62
+ ## Routes
63
+
64
+ Every route is under `/api/v1`.
65
+
66
+ | Method | Path | Body | Returns |
67
+ |---|---|---|---|
68
+ | GET | `/robot_class_names` | | Synapse robot class names, e.g. `UniversalRobotsUR10E` |
69
+ | POST | `/robots` | `{"class_name": ...}`, in any case | The new robot's description (201) |
70
+ | GET | `/robots` | | The description of every robot |
71
+ | GET | `/robots/{robot_id}` | | The robot's description |
72
+ | DELETE | `/robots/{robot_id}` | | Nothing (204) |
73
+ | POST | `/robots/{robot_id}/inverse_kinematics` | `{"poses", "seed"?}` | `{"joint_names", "joint_positions"}`, one solution per pose |
74
+ | POST | `/robots/{robot_id}/link_poses` | `{"joint_names", "joint_positions"}` | `{"link_poses": {link_name: pose}}`, every URDF link in the base frame |
75
+
76
+ `POST /robots` loads the robot before answering; the first time a robot class is used, Synapse
77
+ downloads its URDF from the Telekinesis asset server. Every call loads a new robot under a new id.
78
+
79
+ The server assigns each robot a random UUID as its id. An id saved by a client stays valid until
80
+ the server stops; after a restart it answers 404 and is never reused for another robot.
81
+
82
+ | Status | When |
83
+ |---|---|
84
+ | 404 | No robot has the id, e.g. because the server restarted |
85
+ | 422 | Unknown `class_name`, malformed id, malformed body, a robot joint missing from the seed, or a request Synapse rejects |
86
+ | 503 | The robot description could not be fetched |
87
+
88
+ ### Inverse kinematics
89
+
90
+ `POST /robots/{robot_id}/inverse_kinematics` solves each pose in `poses`, in order, for the
91
+ robot's `default_tcp` in its `base_frame`. It returns the robot's `joint_names` and one solution
92
+ in radians per pose, or `null` for a pose it cannot reach.
93
+
94
+ The optional `seed` is where every search starts, usually the robot's current joints, given as
95
+ `joint_names` with matching `joint_positions` in radians. The names must include every joint of
96
+ the robot, in any order; other names, such as gripper fingers, are ignored. A seed on or past a
97
+ joint limit is moved just inside it.
98
+
99
+ ### Link poses
100
+
101
+ `POST /robots/{robot_id}/link_poses` takes the robot's joints the same way, `joint_names` with
102
+ matching `joint_positions` in radians, and returns the pose of every link of the robot's URDF in
103
+ its `base_frame`, by link name. Joint positions outside the joint limits answer 422. A client uses
104
+ it to draw the robot in a given configuration, such as an inverse-kinematics solution.
105
+
106
+ ### Robot description
107
+
108
+ | Field | Meaning |
109
+ |---|---|
110
+ | `id` | Id the server assigned to the robot |
111
+ | `class_name` | Synapse robot class |
112
+ | `base_frame` | Root link of the robot's URDF; poses are expressed in this frame |
113
+ | `default_tcp` | Frame that ghost objects place: the robot's flange frame, e.g. `tool0` |
114
+ | `mount_link` | Link that tools are mounted on in Isaac Sim, or `null` |
115
+ | `flange_in_mount_link` | Pose of `default_tcp` in `mount_link`, or `null` |
116
+
117
+ ## Units
118
+
119
+ Poses are `[x, y, z, rx, ry, rz]`: metres, then extrinsic XYZ Euler angles in degrees. Joint
120
+ positions are in radians.
121
+
122
+ ## Notes
123
+
124
+ - Robots are loaded on a server worker thread, so Synapse logs that it could not install a signal
125
+ handler. This is expected; the server shuts every robot down when it stops.
@@ -0,0 +1,108 @@
1
+ # Telekinesis Isaac Sim Server
2
+
3
+ A local FastAPI server that gives the Telekinesis Isaac Sim Bridge robot kinematics from
4
+ Telekinesis Synapse. It loads **robots**: Synapse robots built for kinematics only. A loaded
5
+ robot is never connected to hardware or to Isaac Sim, and the server commands no motion.
6
+
7
+ The server keeps robots in memory only. Stopping it forgets them.
8
+
9
+ ## Setup
10
+
11
+ Requires Python 3.11 or 3.12 on Windows or Linux (x86_64).
12
+
13
+ ```bash
14
+ conda create -n telekinesis-isaacsim-server python=3.11
15
+ conda activate telekinesis-isaacsim-server
16
+ pip install telekinesis-isaacsim-server
17
+ ```
18
+
19
+ To work on the server itself, install it from a clone instead:
20
+
21
+ ```bash
22
+ git clone https://gitlab.com/telekinesis/isaac-sim-server.git
23
+ cd isaac-sim-server
24
+ pip install -e .
25
+ ```
26
+
27
+ ## Start the server
28
+
29
+ ```bash
30
+ telekinesis-isaacsim-server
31
+ ```
32
+
33
+ `python -m telekinesis.isaacsim_server` does the same. In a clone,
34
+ `fastapi run --host 127.0.0.1 --port 8770` also works.
35
+
36
+ It listens on `http://127.0.0.1:8770`, the address the bridge expects. Keep `--host 127.0.0.1`:
37
+ the server has no authentication and is meant for local clients only. Stop it with Ctrl-C; every
38
+ robot is shut down.
39
+
40
+ While developing, `fastapi dev --port 8770` restarts the server whenever the code changes. A
41
+ restart forgets all robots.
42
+
43
+ The interactive API docs are at `http://127.0.0.1:8770/docs`.
44
+
45
+ ## Routes
46
+
47
+ Every route is under `/api/v1`.
48
+
49
+ | Method | Path | Body | Returns |
50
+ |---|---|---|---|
51
+ | GET | `/robot_class_names` | | Synapse robot class names, e.g. `UniversalRobotsUR10E` |
52
+ | POST | `/robots` | `{"class_name": ...}`, in any case | The new robot's description (201) |
53
+ | GET | `/robots` | | The description of every robot |
54
+ | GET | `/robots/{robot_id}` | | The robot's description |
55
+ | DELETE | `/robots/{robot_id}` | | Nothing (204) |
56
+ | POST | `/robots/{robot_id}/inverse_kinematics` | `{"poses", "seed"?}` | `{"joint_names", "joint_positions"}`, one solution per pose |
57
+ | POST | `/robots/{robot_id}/link_poses` | `{"joint_names", "joint_positions"}` | `{"link_poses": {link_name: pose}}`, every URDF link in the base frame |
58
+
59
+ `POST /robots` loads the robot before answering; the first time a robot class is used, Synapse
60
+ downloads its URDF from the Telekinesis asset server. Every call loads a new robot under a new id.
61
+
62
+ The server assigns each robot a random UUID as its id. An id saved by a client stays valid until
63
+ the server stops; after a restart it answers 404 and is never reused for another robot.
64
+
65
+ | Status | When |
66
+ |---|---|
67
+ | 404 | No robot has the id, e.g. because the server restarted |
68
+ | 422 | Unknown `class_name`, malformed id, malformed body, a robot joint missing from the seed, or a request Synapse rejects |
69
+ | 503 | The robot description could not be fetched |
70
+
71
+ ### Inverse kinematics
72
+
73
+ `POST /robots/{robot_id}/inverse_kinematics` solves each pose in `poses`, in order, for the
74
+ robot's `default_tcp` in its `base_frame`. It returns the robot's `joint_names` and one solution
75
+ in radians per pose, or `null` for a pose it cannot reach.
76
+
77
+ The optional `seed` is where every search starts, usually the robot's current joints, given as
78
+ `joint_names` with matching `joint_positions` in radians. The names must include every joint of
79
+ the robot, in any order; other names, such as gripper fingers, are ignored. A seed on or past a
80
+ joint limit is moved just inside it.
81
+
82
+ ### Link poses
83
+
84
+ `POST /robots/{robot_id}/link_poses` takes the robot's joints the same way, `joint_names` with
85
+ matching `joint_positions` in radians, and returns the pose of every link of the robot's URDF in
86
+ its `base_frame`, by link name. Joint positions outside the joint limits answer 422. A client uses
87
+ it to draw the robot in a given configuration, such as an inverse-kinematics solution.
88
+
89
+ ### Robot description
90
+
91
+ | Field | Meaning |
92
+ |---|---|
93
+ | `id` | Id the server assigned to the robot |
94
+ | `class_name` | Synapse robot class |
95
+ | `base_frame` | Root link of the robot's URDF; poses are expressed in this frame |
96
+ | `default_tcp` | Frame that ghost objects place: the robot's flange frame, e.g. `tool0` |
97
+ | `mount_link` | Link that tools are mounted on in Isaac Sim, or `null` |
98
+ | `flange_in_mount_link` | Pose of `default_tcp` in `mount_link`, or `null` |
99
+
100
+ ## Units
101
+
102
+ Poses are `[x, y, z, rx, ry, rz]`: metres, then extrinsic XYZ Euler angles in degrees. Joint
103
+ positions are in radians.
104
+
105
+ ## Notes
106
+
107
+ - Robots are loaded on a server worker thread, so Synapse logs that it could not install a signal
108
+ handler. This is expected; the server shuts every robot down when it stops.
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "telekinesis-isaacsim-server"
7
+ version = "0.1.0"
8
+ description = "Local server that gives the Telekinesis Isaac Sim Bridge robot kinematics from Telekinesis Synapse."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11,<3.13"
11
+ authors = [
12
+ { name = "Telekinesis", email = "support@telekinesis.ai" },
13
+ ]
14
+ dependencies = [
15
+ "fastapi[standard]==0.141.1",
16
+ "loguru",
17
+ "numpy",
18
+ "pydantic-settings",
19
+ "telekinesis-synapse==0.10.13",
20
+ "telekinesis-tf",
21
+ ]
22
+
23
+ [project.scripts]
24
+ telekinesis-isaacsim-server = "telekinesis.isaacsim_server.__main__:main"
25
+
26
+ [project.optional-dependencies]
27
+ dev = [
28
+ "ruff==0.15.8",
29
+ "pylint==4.0.5",
30
+ ]
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
34
+ namespaces = true
35
+
36
+ [tool.ruff]
37
+ line-length = 100
38
+
39
+ [tool.fastapi]
40
+ entrypoint = "telekinesis.isaacsim_server.main:app"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ """Telekinesis Isaac Sim Server: robot kinematics from Telekinesis Synapse for the Isaac Sim
2
+ Bridge."""
@@ -0,0 +1,21 @@
1
+ """Command line entry point that starts the Telekinesis Isaac Sim Server.
2
+
3
+ Installed as the ``telekinesis-isaacsim-server`` command and also runnable as
4
+ ``python -m telekinesis.isaacsim_server``.
5
+ """
6
+
7
+ import uvicorn
8
+
9
+ from telekinesis.isaacsim_server import main as server_main
10
+
11
+
12
+ def main() -> None:
13
+ """Serve the API on ``http://127.0.0.1:8770``, the address the bridge expects, until Ctrl-C.
14
+
15
+ The server has no authentication, so it listens on the loopback interface only.
16
+ """
17
+ uvicorn.run(server_main.app, host="127.0.0.1", port=8770)
18
+
19
+
20
+ if __name__ == "__main__":
21
+ main()
@@ -0,0 +1 @@
1
+ """HTTP layer of the server: routers and the dependencies they use."""
@@ -0,0 +1,19 @@
1
+ """Shared FastAPI dependencies for the API layer.
2
+
3
+ Each dependency reads one service from ``app.state``, where the application's lifespan put it,
4
+ so routes declare the service they need instead of importing a global.
5
+ """
6
+
7
+ from typing import Annotated
8
+
9
+ from fastapi import Depends, Request
10
+
11
+ from telekinesis.isaacsim_server.services import robots
12
+
13
+
14
+ def get_robot_service(request: Request) -> robots.RobotService:
15
+ """Return the server's robot service."""
16
+ return request.app.state.robot_service
17
+
18
+
19
+ RobotServiceDep = Annotated[robots.RobotService, Depends(get_robot_service)]
@@ -0,0 +1,8 @@
1
+ """Aggregates every route module under one `APIRouter` for `main.py` to mount."""
2
+
3
+ from fastapi import APIRouter
4
+
5
+ from telekinesis.isaacsim_server.api.routes import robots
6
+
7
+ api_router = APIRouter()
8
+ api_router.include_router(robots.router)
@@ -0,0 +1 @@
1
+ """Route modules of the server, one per topic."""
@@ -0,0 +1,88 @@
1
+ """Routes that load, list, describe and delete robots.
2
+
3
+ Routes are plain ``def`` so FastAPI runs them in its threadpool: loading a robot fetches its URDF
4
+ and must not block the event loop.
5
+ """
6
+
7
+ import uuid
8
+ from typing import Annotated
9
+
10
+ from fastapi import APIRouter, Body, Path, status
11
+
12
+ from telekinesis.isaacsim_server import models
13
+ from telekinesis.isaacsim_server.api import deps
14
+ from telekinesis.isaacsim_server.api.routes import utils
15
+
16
+ router = APIRouter(tags=["robots"])
17
+
18
+ RobotId = Annotated[
19
+ uuid.UUID, Path(description="Id the server assigned to the robot when it was created.")
20
+ ]
21
+
22
+
23
+ @router.get("/robot_class_names", summary="List Robot Class Names")
24
+ def list_robot_class_names(service: deps.RobotServiceDep) -> list[str]:
25
+ """List the Synapse robot classes a robot can be loaded from, e.g. `UniversalRobotsUR10E`."""
26
+ return service.list_robot_class_names()
27
+
28
+
29
+ @router.post("/robots", summary="Create Robot", status_code=status.HTTP_201_CREATED)
30
+ def create_robot(
31
+ request: Annotated[models.CreateRobotRequest, Body()], service: deps.RobotServiceDep
32
+ ) -> models.RobotDescription:
33
+ """Load a new robot of `class_name`, matched in any case, under a new id and return its
34
+ description, which holds the exactly cased class name.
35
+
36
+ Answers 422 for an unknown `class_name` and 503 if the robot description cannot be fetched.
37
+ """
38
+ with utils.handle_operation_errors("create_robot"):
39
+ return service.create_robot(request.class_name)
40
+
41
+
42
+ @router.get("/robots", summary="List Robots")
43
+ def list_robots(service: deps.RobotServiceDep) -> list[models.RobotDescription]:
44
+ """List the description of every loaded robot."""
45
+ return service.list_robots()
46
+
47
+
48
+ @router.get("/robots/{robot_id}", summary="Describe Robot")
49
+ def describe_robot(robot_id: RobotId, service: deps.RobotServiceDep) -> models.RobotDescription:
50
+ """Return the robot's description. Answers 404 if no robot has that id."""
51
+ return service.describe_robot(robot_id)
52
+
53
+
54
+ @router.delete("/robots/{robot_id}", summary="Delete Robot", status_code=status.HTTP_204_NO_CONTENT)
55
+ def delete_robot(robot_id: RobotId, service: deps.RobotServiceDep) -> None:
56
+ """Shut the robot down and forget it. Answers 404 if no robot has that id."""
57
+ service.delete_robot(robot_id)
58
+
59
+
60
+ @router.post("/robots/{robot_id}/inverse_kinematics", summary="Inverse Kinematics")
61
+ def inverse_kinematics(
62
+ robot_id: RobotId,
63
+ request: Annotated[models.InverseKinematicsRequest, Body()],
64
+ service: deps.RobotServiceDep,
65
+ ) -> models.InverseKinematicsResponse:
66
+ """Solve the joint positions in radians that bring the robot's default TCP to each pose.
67
+
68
+ Poses are in the robot's base frame. Unreachable poses get null. Answers 404 if no robot has
69
+ that id, and 422 if a joint of the robot is missing from the seed or the request is invalid.
70
+ """
71
+ with utils.handle_operation_errors("inverse_kinematics"):
72
+ return service.inverse_kinematics(robot_id, request.poses, request.seed)
73
+
74
+
75
+ @router.post("/robots/{robot_id}/link_poses", summary="Link Poses")
76
+ def link_poses(
77
+ robot_id: RobotId,
78
+ joints: Annotated[models.JointPositions, Body()],
79
+ service: deps.RobotServiceDep,
80
+ ) -> models.LinkPosesResponse:
81
+ """Return the pose of every link of the robot's URDF in its base frame for the given joint
82
+ positions in radians.
83
+
84
+ Answers 404 if no robot has that id, and 422 if a joint of the robot is missing or the
85
+ positions are outside the joint limits.
86
+ """
87
+ with utils.handle_operation_errors("link_poses"):
88
+ return service.link_poses(robot_id, joints)
@@ -0,0 +1,31 @@
1
+ """Shared error handling for the routes."""
2
+
3
+ import contextlib
4
+ from collections.abc import Iterator
5
+
6
+ from fastapi import HTTPException, status
7
+ from loguru import logger
8
+
9
+
10
+ @contextlib.contextmanager
11
+ def handle_operation_errors(route_name: str) -> Iterator[None]:
12
+ """Turn a ``ValueError`` from the wrapped service call into a 422 response.
13
+
14
+ A service raises ``ValueError`` for input it cannot use, such as an unknown robot class. Its
15
+ message is returned as the detail, because the server is local and the client needs the
16
+ reason to fix the request. Other exceptions pass through: a :class:`RobotServiceError` is
17
+ answered by its registered handler, and anything else becomes FastAPI's 500 response.
18
+
19
+ Args:
20
+ route_name: Name of the calling route, used to prefix the log message.
21
+
22
+ Raises:
23
+ HTTPException: 422 if the wrapped code raises ``ValueError``.
24
+ """
25
+ try:
26
+ yield
27
+ except ValueError as error:
28
+ logger.warning(f"[{route_name}] Invalid input: {error}")
29
+ raise HTTPException(
30
+ status_code=status.HTTP_422_UNPROCESSABLE_CONTENT, detail=str(error)
31
+ ) from error
@@ -0,0 +1 @@
1
+ """Server-wide settings and exceptions."""
@@ -0,0 +1,17 @@
1
+ """Server settings."""
2
+
3
+ from pydantic_settings import BaseSettings
4
+
5
+
6
+ class Settings(BaseSettings):
7
+ """Server settings. Each one can be overridden by an environment variable of the same name.
8
+
9
+ Example:
10
+ Settings().API_V1_STR # "/api/v1"
11
+ """
12
+
13
+ PROJECT_NAME: str = "Telekinesis Isaac Sim Server"
14
+ API_V1_STR: str = "/api/v1"
15
+
16
+
17
+ settings = Settings()
@@ -0,0 +1,49 @@
1
+ """Exceptions the services raise for the client, and the handlers that turn them into responses."""
2
+
3
+ import uuid
4
+
5
+ from fastapi import FastAPI, Request, status
6
+ from fastapi.responses import JSONResponse
7
+
8
+
9
+ class RobotServiceError(Exception):
10
+ """Base of the errors a service raises for the client, each with its HTTP status code."""
11
+
12
+ status_code: int
13
+
14
+ def __init__(self, detail: str) -> None:
15
+ self.detail = detail
16
+ super().__init__(detail)
17
+
18
+
19
+ class RobotNotFoundError(RobotServiceError):
20
+ """Raised when no robot has the requested id, e.g. after the server restarted."""
21
+
22
+ status_code = status.HTTP_404_NOT_FOUND
23
+
24
+ def __init__(self, robot_id: uuid.UUID) -> None:
25
+ super().__init__(
26
+ f"No robot with id {robot_id}. The server keeps robots only until it stops; "
27
+ "connect the robot again."
28
+ )
29
+
30
+
31
+ class RobotDescriptionUnavailableError(RobotServiceError):
32
+ """Raised when a robot's description cannot be fetched from the Telekinesis asset server."""
33
+
34
+ status_code = status.HTTP_503_SERVICE_UNAVAILABLE
35
+
36
+
37
+ def register_exception_handlers(app: FastAPI) -> None:
38
+ """Register the handler that answers every :class:`RobotServiceError` with its status code.
39
+
40
+ Args:
41
+ app: FastAPI application to attach the handler to.
42
+ """
43
+
44
+ @app.exception_handler(RobotServiceError)
45
+ async def robot_service_error_handler(
46
+ _request: Request, error: RobotServiceError
47
+ ) -> JSONResponse:
48
+ """Convert a service error into a JSON response with its status code and detail."""
49
+ return JSONResponse(status_code=error.status_code, content={"detail": error.detail})
@@ -0,0 +1,38 @@
1
+ """FastAPI application of the Telekinesis Isaac Sim Server.
2
+
3
+ The lifespan creates the robot service when the server starts and puts it on ``app.state`` for
4
+ the routes; when the server stops, it shuts every robot down. Routes are mounted under
5
+ ``settings.API_V1_STR``.
6
+ """
7
+
8
+ import contextlib
9
+ from collections.abc import AsyncIterator
10
+ from importlib import metadata
11
+
12
+ from fastapi import FastAPI
13
+
14
+ from telekinesis.isaacsim_server.api.main import api_router
15
+ from telekinesis.isaacsim_server.core.config import settings
16
+ from telekinesis.isaacsim_server.core.exceptions import register_exception_handlers
17
+ from telekinesis.isaacsim_server.services import robots
18
+
19
+
20
+ @contextlib.asynccontextmanager
21
+ async def lifespan(fastapi_app: FastAPI) -> AsyncIterator[None]:
22
+ """Own the robot service for the life of the server."""
23
+ robot_service = robots.RobotService()
24
+ fastapi_app.state.robot_service = robot_service
25
+ try:
26
+ yield
27
+ finally:
28
+ robot_service.shutdown_all_robots()
29
+
30
+
31
+ app = FastAPI(
32
+ title=settings.PROJECT_NAME,
33
+ version=metadata.version("telekinesis-isaacsim-server"),
34
+ openapi_url=f"{settings.API_V1_STR}/openapi.json",
35
+ lifespan=lifespan,
36
+ )
37
+ app.include_router(api_router, prefix=settings.API_V1_STR)
38
+ register_exception_handlers(app)
@@ -0,0 +1,161 @@
1
+ """Request and response bodies of the server's routes."""
2
+
3
+ import uuid
4
+ from typing import Annotated, Self
5
+
6
+ import pydantic
7
+
8
+ FiniteFloat = Annotated[float, pydantic.Field(allow_inf_nan=False)]
9
+
10
+ Pose = Annotated[
11
+ list[FiniteFloat],
12
+ pydantic.Field(
13
+ min_length=6,
14
+ max_length=6,
15
+ description=(
16
+ "Pose [x, y, z, rx, ry, rz]: metres, then extrinsic XYZ Euler angles in degrees."
17
+ ),
18
+ ),
19
+ ]
20
+
21
+
22
+ class CreateRobotRequest(pydantic.BaseModel):
23
+ """Body of ``POST /robots``.
24
+
25
+ Example:
26
+ CreateRobotRequest(class_name="UniversalRobotsUR10E")
27
+ """
28
+
29
+ class_name: str = pydantic.Field(
30
+ description=(
31
+ "Synapse robot class to load, one of `GET /robot_class_names`, in any case."
32
+ ),
33
+ examples=["UniversalRobotsUR10E"],
34
+ )
35
+
36
+
37
+ class RobotDescription(pydantic.BaseModel):
38
+ """A robot loaded on the server and the frames a client needs to place poses on it.
39
+
40
+ Example:
41
+ RobotDescription(
42
+ id=uuid.UUID("6f1c2b0e-8d3a-4c5e-9f7b-2a1d0c9e8b7a"),
43
+ class_name="UniversalRobotsUR10E",
44
+ base_frame="base_link",
45
+ default_tcp="tool0",
46
+ mount_link="wrist_3_link",
47
+ flange_in_mount_link=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
48
+ )
49
+ """
50
+
51
+ id: uuid.UUID = pydantic.Field(description="Id the server assigned to the robot.")
52
+ class_name: str = pydantic.Field(description="Synapse robot class of the robot.")
53
+ base_frame: str = pydantic.Field(
54
+ description="Root link of the robot's URDF. Poses on the wire are expressed in this frame."
55
+ )
56
+ default_tcp: str = pydantic.Field(
57
+ description="Frame that ghost objects place: the robot's flange frame, e.g. `tool0`."
58
+ )
59
+ mount_link: str | None = pydantic.Field(
60
+ description=(
61
+ "Link that tools are mounted on in Isaac Sim, or null if the robot declares none."
62
+ )
63
+ )
64
+ flange_in_mount_link: list[float] | None = pydantic.Field(
65
+ description=(
66
+ "Pose of `default_tcp` in `mount_link`: x, y, z in metres, then extrinsic XYZ Euler "
67
+ "angles in degrees. Null when `mount_link` is null."
68
+ )
69
+ )
70
+
71
+
72
+ class JointPositions(pydantic.BaseModel):
73
+ """Joint positions keyed by joint name.
74
+
75
+ The names must include every joint of the robot, in any order; names of other joints, such as
76
+ gripper fingers, are ignored.
77
+
78
+ Example:
79
+ JointPositions(
80
+ joint_names=["shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint",
81
+ "wrist_1_joint", "wrist_2_joint", "wrist_3_joint"],
82
+ joint_positions=[0.0, -1.5708, -1.5708, 0.0, 1.5708, 0.0],
83
+ )
84
+ """
85
+
86
+ joint_names: list[str] = pydantic.Field(
87
+ description="Joint names, one per entry of `joint_positions`.",
88
+ examples=[
89
+ [
90
+ "shoulder_pan_joint",
91
+ "shoulder_lift_joint",
92
+ "elbow_joint",
93
+ "wrist_1_joint",
94
+ "wrist_2_joint",
95
+ "wrist_3_joint",
96
+ ]
97
+ ],
98
+ )
99
+ joint_positions: list[FiniteFloat] = pydantic.Field(
100
+ description="Joint positions in radians.",
101
+ examples=[[0.0, -1.5708, -1.5708, 0.0, 1.5708, 0.0]],
102
+ )
103
+
104
+ @pydantic.model_validator(mode="after")
105
+ def check_one_position_per_name(self) -> Self:
106
+ """Reject bodies whose name and position lists differ in length."""
107
+ if len(self.joint_names) != len(self.joint_positions):
108
+ raise ValueError("joint_names and joint_positions must have the same length.")
109
+ return self
110
+
111
+
112
+ class InverseKinematicsRequest(pydantic.BaseModel):
113
+ """Body of ``POST /robots/{robot_id}/inverse_kinematics``.
114
+
115
+ Example:
116
+ InverseKinematicsRequest(poses=[[0.6881, -0.17415, 0.91325, -90.0, 0.0, -90.0]])
117
+ """
118
+
119
+ poses: list[Pose] = pydantic.Field(
120
+ min_length=1,
121
+ description="Target poses of the default TCP in the robot's base frame, solved in order.",
122
+ examples=[[[0.6881, -0.17415, 0.91325, -90.0, 0.0, -90.0]]],
123
+ )
124
+ seed: JointPositions | None = pydantic.Field(
125
+ default=None,
126
+ description=(
127
+ "Joint positions to start every pose's search from, usually the robot's current "
128
+ "joints. Positions on or past a joint limit are moved just inside it."
129
+ ),
130
+ )
131
+
132
+
133
+ class LinkPosesResponse(pydantic.BaseModel):
134
+ """Answer of ``POST /robots/{robot_id}/link_poses``.
135
+
136
+ Example:
137
+ LinkPosesResponse(link_poses={"base_link": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]})
138
+ """
139
+
140
+ link_poses: dict[str, Pose] = pydantic.Field(
141
+ description="Pose of every link of the robot's URDF in its base frame, by link name."
142
+ )
143
+
144
+
145
+ class InverseKinematicsResponse(pydantic.BaseModel):
146
+ """Answer of ``POST /robots/{robot_id}/inverse_kinematics``.
147
+
148
+ Example:
149
+ InverseKinematicsResponse(
150
+ joint_names=["shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint",
151
+ "wrist_1_joint", "wrist_2_joint", "wrist_3_joint"],
152
+ joint_positions=[[0.0, -1.5708, -1.5708, 0.0, 1.5708, 0.0], None],
153
+ )
154
+ """
155
+
156
+ joint_names: list[str] = pydantic.Field(
157
+ description="The robot's joint names, in the order of every solution."
158
+ )
159
+ joint_positions: list[list[float] | None] = pydantic.Field(
160
+ description="One solution in radians per target pose, or null if the pose is unreachable."
161
+ )
@@ -0,0 +1 @@
1
+ """Services behind the server's routes."""
@@ -0,0 +1,283 @@
1
+ """Robots: Synapse robots loaded for kinematics only and kept in memory by id."""
2
+
3
+ import dataclasses
4
+ import importlib
5
+ import threading
6
+ import uuid
7
+ from xml.etree import ElementTree
8
+
9
+ import numpy as np
10
+ from loguru import logger
11
+ from telekinesis.synapse.robots.manipulators import abstract_robot, registry
12
+ from telekinesis.tf import tfutils
13
+
14
+ from telekinesis.isaacsim_server import models
15
+ from telekinesis.isaacsim_server.core import exceptions
16
+
17
+
18
+ @dataclasses.dataclass
19
+ class LoadedRobot:
20
+ """A robot loaded on the server and the lock that serializes its use.
21
+
22
+ Synapse serializes inverse kinematics on a robot itself, but not link transforms, which share
23
+ the robot's kinematic model.
24
+ """
25
+
26
+ robot: abstract_robot.AbstractManipulator
27
+ lock: threading.Lock = dataclasses.field(default_factory=threading.Lock)
28
+
29
+
30
+ class RobotService:
31
+ """The robots loaded on the server, each a Synapse robot used for kinematics only.
32
+
33
+ A robot is loaded under an id the service assigns, a random UUID, and kept in memory until it
34
+ is deleted or the server stops; nothing is written to disk. Because ids are random, an id a
35
+ client saved before a server restart never names a different robot afterwards. A robot is
36
+ never connected, so Synapse runs it offline with no control loop, and it is built without a
37
+ name, so it publishes no state or transforms.
38
+
39
+ Example:
40
+ service = RobotService()
41
+ description = service.create_robot("UniversalRobotsUR10E")
42
+ service.describe_robot(description.id).default_tcp # "tool0"
43
+ """
44
+
45
+ def __init__(self):
46
+ self._robots: dict[uuid.UUID, LoadedRobot] = {}
47
+
48
+ def list_robot_class_names(self) -> list[str]:
49
+ """Return the Synapse robot classes a robot can be loaded from, sorted by name."""
50
+ return sorted(registry.MANIPULATORS)
51
+
52
+ def create_robot(self, class_name: str) -> models.RobotDescription:
53
+ """Load a new ``class_name`` robot under a new id.
54
+
55
+ Fetches the robot's URDF from the Telekinesis asset server the first time a class is
56
+ used.
57
+
58
+ Args:
59
+ class_name: Synapse robot class, one of :meth:`list_robot_class_names`, in any
60
+ case: ``universalrobotsur10e`` loads ``UniversalRobotsUR10E``.
61
+
62
+ Returns:
63
+ The new robot's description, including its id and its exactly cased class name.
64
+
65
+ Raises:
66
+ ValueError: If ``class_name`` is not a known robot class.
67
+ RobotDescriptionUnavailableError: If the robot's description cannot be fetched.
68
+ """
69
+ # Clients that know a robot only by its catalogue identifier send it lowercased.
70
+ class_names_by_lowercase = {name.lower(): name for name in registry.MANIPULATORS}
71
+ if class_name.lower() not in class_names_by_lowercase:
72
+ raise ValueError(
73
+ f"Unknown class_name '{class_name}'. GET /robot_class_names lists them."
74
+ )
75
+ module_name, robot_class_name = registry.MANIPULATORS[
76
+ class_names_by_lowercase[class_name.lower()]
77
+ ]
78
+ robot_class = getattr(importlib.import_module(module_name), robot_class_name)
79
+ try:
80
+ # No name: the robot starts no state or transform publishers.
81
+ robot = robot_class(name=None)
82
+ except RuntimeError as error:
83
+ # Synapse raises RuntimeError when the URDF bundle cannot be fetched.
84
+ raise exceptions.RobotDescriptionUnavailableError(
85
+ f"Could not load {class_name}: {error}"
86
+ ) from error
87
+ robot_id = uuid.uuid4()
88
+ loaded_robot = LoadedRobot(robot)
89
+ self._robots[robot_id] = loaded_robot
90
+ logger.info(f"Created robot {robot_id} ({class_name})")
91
+ return self._describe_loaded_robot(robot_id, loaded_robot)
92
+
93
+ def list_robots(self) -> list[models.RobotDescription]:
94
+ """Return the description of every loaded robot."""
95
+ # dict.copy() is a single step under the GIL, so a concurrent create or delete never
96
+ # changes the dict while it is iterated.
97
+ return [
98
+ self._describe_loaded_robot(robot_id, loaded_robot)
99
+ for robot_id, loaded_robot in self._robots.copy().items()
100
+ ]
101
+
102
+ def describe_robot(self, robot_id: uuid.UUID) -> models.RobotDescription:
103
+ """Return the description of robot ``robot_id``.
104
+
105
+ Raises:
106
+ RobotNotFoundError: If no robot has that id.
107
+ """
108
+ return self._describe_loaded_robot(robot_id, self._get_loaded_robot(robot_id))
109
+
110
+ def delete_robot(self, robot_id: uuid.UUID) -> None:
111
+ """Shut robot ``robot_id`` down and forget it.
112
+
113
+ Raises:
114
+ RobotNotFoundError: If no robot has that id.
115
+ """
116
+ loaded_robot = self._robots.pop(robot_id, None)
117
+ if loaded_robot is None:
118
+ raise exceptions.RobotNotFoundError(robot_id)
119
+ with loaded_robot.lock:
120
+ loaded_robot.robot.shutdown()
121
+ logger.info(f"Deleted robot {robot_id}")
122
+
123
+ def inverse_kinematics(
124
+ self,
125
+ robot_id: uuid.UUID,
126
+ poses: list[list[float]],
127
+ seed: models.JointPositions | None,
128
+ ) -> models.InverseKinematicsResponse:
129
+ """Solve the joint positions that bring the robot's default TCP to each pose.
130
+
131
+ The search uses the robot's stored solver settings. A seed on or past a joint limit is
132
+ moved to the nearest position strictly inside the limits, because Synapse rejects seeds
133
+ on a limit while Isaac Sim lets joints rest on one.
134
+
135
+ Args:
136
+ robot_id: Id of the robot.
137
+ poses: Target poses of the default TCP in the robot's base frame, solved in order.
138
+ seed: Joint positions in radians to start every pose's search from, or None.
139
+
140
+ Returns:
141
+ The robot's joint names and one solution in radians per pose, None for a pose that
142
+ has no solution.
143
+
144
+ Raises:
145
+ RobotNotFoundError: If no robot has that id.
146
+ ValueError: If a joint of the robot is missing from ``seed``, or Synapse rejects the
147
+ request.
148
+ """
149
+ robot = self._get_loaded_robot(robot_id).robot
150
+ seeds = None
151
+ if seed is not None:
152
+ lower, upper = robot.joint_limits[:, 0], robot.joint_limits[:, 1]
153
+ seed_positions = np.clip(
154
+ _joint_positions_in_robot_order(robot, seed),
155
+ np.nextafter(lower, upper),
156
+ np.nextafter(upper, lower),
157
+ )
158
+ seeds = [seed_positions] * len(poses)
159
+ # Synapse serializes inverse kinematics on the robot itself, so no lock is taken here.
160
+ solutions = robot.inverse_kinematics(poses, frame_name=robot.default_tcp, q_inits=seeds)
161
+ return models.InverseKinematicsResponse(
162
+ joint_names=list(robot.joint_names),
163
+ joint_positions=[
164
+ None if solution is None else np.deg2rad(solution).tolist()
165
+ for solution in solutions
166
+ ],
167
+ )
168
+
169
+ def link_poses(
170
+ self, robot_id: uuid.UUID, joints: models.JointPositions
171
+ ) -> models.LinkPosesResponse:
172
+ """Return the pose of every link of the robot's URDF for the given joint positions.
173
+
174
+ Args:
175
+ robot_id: Id of the robot.
176
+ joints: Positions of every joint of the robot, in radians.
177
+
178
+ Returns:
179
+ Every link's pose in the robot's base frame, by link name.
180
+
181
+ Raises:
182
+ RobotNotFoundError: If no robot has that id.
183
+ ValueError: If a joint of the robot is missing from ``joints``, or the positions are
184
+ outside the joint limits.
185
+ """
186
+ loaded_robot = self._get_loaded_robot(robot_id)
187
+ robot = loaded_robot.robot
188
+ joint_positions = _joint_positions_in_robot_order(robot, joints)
189
+ link_names = [
190
+ link.get("name")
191
+ for link in ElementTree.parse(robot.urdf_path).getroot().findall("link")
192
+ ]
193
+ # Synapse serializes inverse kinematics but not forward kinematics, which shares the
194
+ # robot's kinematic model.
195
+ with loaded_robot.lock:
196
+ link_poses = {
197
+ link_name: [
198
+ float(value)
199
+ for value in robot.forward_kinematics(joint_positions, frame_name=link_name)
200
+ ]
201
+ for link_name in link_names
202
+ }
203
+ return models.LinkPosesResponse(link_poses=link_poses)
204
+
205
+ def shutdown_all_robots(self) -> None:
206
+ """Shut every robot down and forget all robots. Called when the server stops."""
207
+ loaded_robots = list(self._robots.values())
208
+ self._robots.clear()
209
+ for loaded_robot in loaded_robots:
210
+ with loaded_robot.lock:
211
+ loaded_robot.robot.shutdown()
212
+
213
+ def _get_loaded_robot(self, robot_id: uuid.UUID) -> LoadedRobot:
214
+ """Return robot ``robot_id``.
215
+
216
+ Raises:
217
+ RobotNotFoundError: If no robot has that id.
218
+ """
219
+ loaded_robot = self._robots.get(robot_id)
220
+ if loaded_robot is None:
221
+ raise exceptions.RobotNotFoundError(robot_id)
222
+ return loaded_robot
223
+
224
+ def _describe_loaded_robot(
225
+ self, robot_id: uuid.UUID, loaded_robot: LoadedRobot
226
+ ) -> models.RobotDescription:
227
+ """Build the description of a loaded robot.
228
+
229
+ The base frame is the URDF's root link: the one link that is no joint's child. The
230
+ flange offset is computed from the link transforms at the robot's current configuration;
231
+ both frames sit on the last link, so it is the same at any configuration.
232
+ """
233
+ robot = loaded_robot.robot
234
+ urdf = ElementTree.parse(robot.urdf_path).getroot()
235
+ child_links = {joint.find("child").get("link") for joint in urdf.findall("joint")}
236
+ base_frame = next(
237
+ link.get("name") for link in urdf.findall("link") if link.get("name") not in child_links
238
+ )
239
+
240
+ mount_link = robot.simulation_mount_link
241
+ flange_in_mount_link = None
242
+ if mount_link:
243
+ with loaded_robot.lock:
244
+ link_transforms = robot.get_link_transforms()
245
+ flange_in_mount_link_matrix = (
246
+ tfutils.invert_transformation_matrix(link_transforms[mount_link])
247
+ @ link_transforms[robot.default_tcp]
248
+ )
249
+ flange_in_mount_link = [
250
+ float(value)
251
+ for value in tfutils.transformation_matrix_to_pose(
252
+ flange_in_mount_link_matrix, rot_type="deg"
253
+ )
254
+ ]
255
+
256
+ return models.RobotDescription(
257
+ id=robot_id,
258
+ class_name=type(robot).__name__,
259
+ base_frame=base_frame,
260
+ default_tcp=robot.default_tcp,
261
+ mount_link=mount_link,
262
+ flange_in_mount_link=flange_in_mount_link,
263
+ )
264
+
265
+
266
+ def _joint_positions_in_robot_order(
267
+ robot: abstract_robot.AbstractManipulator, joints: models.JointPositions
268
+ ) -> np.ndarray:
269
+ """Return ``joints`` as Synapse expects them: in the robot's joint order and in degrees.
270
+
271
+ Names that are not joints of the robot are ignored.
272
+
273
+ Raises:
274
+ ValueError: If a joint of the robot is missing from ``joints``.
275
+ """
276
+ positions_by_name = dict(zip(joints.joint_names, joints.joint_positions))
277
+ missing_joints = [name for name in robot.joint_names if name not in positions_by_name]
278
+ if missing_joints:
279
+ raise ValueError(
280
+ f"Missing positions for joints {missing_joints}. "
281
+ f"{type(robot).__name__} has joints {robot.joint_names}."
282
+ )
283
+ return np.rad2deg([positions_by_name[name] for name in robot.joint_names])
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: telekinesis-isaacsim-server
3
+ Version: 0.1.0
4
+ Summary: Local server that gives the Telekinesis Isaac Sim Bridge robot kinematics from Telekinesis Synapse.
5
+ Author-email: Telekinesis <support@telekinesis.ai>
6
+ Requires-Python: <3.13,>=3.11
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastapi[standard]==0.141.1
9
+ Requires-Dist: loguru
10
+ Requires-Dist: numpy
11
+ Requires-Dist: pydantic-settings
12
+ Requires-Dist: telekinesis-synapse==0.10.13
13
+ Requires-Dist: telekinesis-tf
14
+ Provides-Extra: dev
15
+ Requires-Dist: ruff==0.15.8; extra == "dev"
16
+ Requires-Dist: pylint==4.0.5; extra == "dev"
17
+
18
+ # Telekinesis Isaac Sim Server
19
+
20
+ A local FastAPI server that gives the Telekinesis Isaac Sim Bridge robot kinematics from
21
+ Telekinesis Synapse. It loads **robots**: Synapse robots built for kinematics only. A loaded
22
+ robot is never connected to hardware or to Isaac Sim, and the server commands no motion.
23
+
24
+ The server keeps robots in memory only. Stopping it forgets them.
25
+
26
+ ## Setup
27
+
28
+ Requires Python 3.11 or 3.12 on Windows or Linux (x86_64).
29
+
30
+ ```bash
31
+ conda create -n telekinesis-isaacsim-server python=3.11
32
+ conda activate telekinesis-isaacsim-server
33
+ pip install telekinesis-isaacsim-server
34
+ ```
35
+
36
+ To work on the server itself, install it from a clone instead:
37
+
38
+ ```bash
39
+ git clone https://gitlab.com/telekinesis/isaac-sim-server.git
40
+ cd isaac-sim-server
41
+ pip install -e .
42
+ ```
43
+
44
+ ## Start the server
45
+
46
+ ```bash
47
+ telekinesis-isaacsim-server
48
+ ```
49
+
50
+ `python -m telekinesis.isaacsim_server` does the same. In a clone,
51
+ `fastapi run --host 127.0.0.1 --port 8770` also works.
52
+
53
+ It listens on `http://127.0.0.1:8770`, the address the bridge expects. Keep `--host 127.0.0.1`:
54
+ the server has no authentication and is meant for local clients only. Stop it with Ctrl-C; every
55
+ robot is shut down.
56
+
57
+ While developing, `fastapi dev --port 8770` restarts the server whenever the code changes. A
58
+ restart forgets all robots.
59
+
60
+ The interactive API docs are at `http://127.0.0.1:8770/docs`.
61
+
62
+ ## Routes
63
+
64
+ Every route is under `/api/v1`.
65
+
66
+ | Method | Path | Body | Returns |
67
+ |---|---|---|---|
68
+ | GET | `/robot_class_names` | | Synapse robot class names, e.g. `UniversalRobotsUR10E` |
69
+ | POST | `/robots` | `{"class_name": ...}`, in any case | The new robot's description (201) |
70
+ | GET | `/robots` | | The description of every robot |
71
+ | GET | `/robots/{robot_id}` | | The robot's description |
72
+ | DELETE | `/robots/{robot_id}` | | Nothing (204) |
73
+ | POST | `/robots/{robot_id}/inverse_kinematics` | `{"poses", "seed"?}` | `{"joint_names", "joint_positions"}`, one solution per pose |
74
+ | POST | `/robots/{robot_id}/link_poses` | `{"joint_names", "joint_positions"}` | `{"link_poses": {link_name: pose}}`, every URDF link in the base frame |
75
+
76
+ `POST /robots` loads the robot before answering; the first time a robot class is used, Synapse
77
+ downloads its URDF from the Telekinesis asset server. Every call loads a new robot under a new id.
78
+
79
+ The server assigns each robot a random UUID as its id. An id saved by a client stays valid until
80
+ the server stops; after a restart it answers 404 and is never reused for another robot.
81
+
82
+ | Status | When |
83
+ |---|---|
84
+ | 404 | No robot has the id, e.g. because the server restarted |
85
+ | 422 | Unknown `class_name`, malformed id, malformed body, a robot joint missing from the seed, or a request Synapse rejects |
86
+ | 503 | The robot description could not be fetched |
87
+
88
+ ### Inverse kinematics
89
+
90
+ `POST /robots/{robot_id}/inverse_kinematics` solves each pose in `poses`, in order, for the
91
+ robot's `default_tcp` in its `base_frame`. It returns the robot's `joint_names` and one solution
92
+ in radians per pose, or `null` for a pose it cannot reach.
93
+
94
+ The optional `seed` is where every search starts, usually the robot's current joints, given as
95
+ `joint_names` with matching `joint_positions` in radians. The names must include every joint of
96
+ the robot, in any order; other names, such as gripper fingers, are ignored. A seed on or past a
97
+ joint limit is moved just inside it.
98
+
99
+ ### Link poses
100
+
101
+ `POST /robots/{robot_id}/link_poses` takes the robot's joints the same way, `joint_names` with
102
+ matching `joint_positions` in radians, and returns the pose of every link of the robot's URDF in
103
+ its `base_frame`, by link name. Joint positions outside the joint limits answer 422. A client uses
104
+ it to draw the robot in a given configuration, such as an inverse-kinematics solution.
105
+
106
+ ### Robot description
107
+
108
+ | Field | Meaning |
109
+ |---|---|
110
+ | `id` | Id the server assigned to the robot |
111
+ | `class_name` | Synapse robot class |
112
+ | `base_frame` | Root link of the robot's URDF; poses are expressed in this frame |
113
+ | `default_tcp` | Frame that ghost objects place: the robot's flange frame, e.g. `tool0` |
114
+ | `mount_link` | Link that tools are mounted on in Isaac Sim, or `null` |
115
+ | `flange_in_mount_link` | Pose of `default_tcp` in `mount_link`, or `null` |
116
+
117
+ ## Units
118
+
119
+ Poses are `[x, y, z, rx, ry, rz]`: metres, then extrinsic XYZ Euler angles in degrees. Joint
120
+ positions are in radians.
121
+
122
+ ## Notes
123
+
124
+ - Robots are loaded on a server worker thread, so Synapse logs that it could not install a signal
125
+ handler. This is expected; the server shuts every robot down when it stops.
@@ -0,0 +1,24 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/telekinesis/isaacsim_server/__init__.py
4
+ src/telekinesis/isaacsim_server/__main__.py
5
+ src/telekinesis/isaacsim_server/main.py
6
+ src/telekinesis/isaacsim_server/models.py
7
+ src/telekinesis/isaacsim_server/api/__init__.py
8
+ src/telekinesis/isaacsim_server/api/deps.py
9
+ src/telekinesis/isaacsim_server/api/main.py
10
+ src/telekinesis/isaacsim_server/api/routes/__init__.py
11
+ src/telekinesis/isaacsim_server/api/routes/robots.py
12
+ src/telekinesis/isaacsim_server/api/routes/utils.py
13
+ src/telekinesis/isaacsim_server/core/__init__.py
14
+ src/telekinesis/isaacsim_server/core/config.py
15
+ src/telekinesis/isaacsim_server/core/exceptions.py
16
+ src/telekinesis/isaacsim_server/services/__init__.py
17
+ src/telekinesis/isaacsim_server/services/robots.py
18
+ src/telekinesis_isaacsim_server.egg-info/PKG-INFO
19
+ src/telekinesis_isaacsim_server.egg-info/SOURCES.txt
20
+ src/telekinesis_isaacsim_server.egg-info/dependency_links.txt
21
+ src/telekinesis_isaacsim_server.egg-info/entry_points.txt
22
+ src/telekinesis_isaacsim_server.egg-info/requires.txt
23
+ src/telekinesis_isaacsim_server.egg-info/top_level.txt
24
+ tests/test_ci_version.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ telekinesis-isaacsim-server = telekinesis.isaacsim_server.__main__:main
@@ -0,0 +1,10 @@
1
+ fastapi[standard]==0.141.1
2
+ loguru
3
+ numpy
4
+ pydantic-settings
5
+ telekinesis-synapse==0.10.13
6
+ telekinesis-tf
7
+
8
+ [dev]
9
+ ruff==0.15.8
10
+ pylint==4.0.5
@@ -0,0 +1,36 @@
1
+ """Checks for the version helper used by the release pipeline."""
2
+
3
+ import tempfile
4
+ import unittest
5
+ from pathlib import Path
6
+
7
+ from scripts.ci_version import read_version, release_version, write_version
8
+
9
+
10
+ class VersionHelperTest(unittest.TestCase):
11
+ def test_release_version_accepts_numeric_version(self):
12
+ with tempfile.TemporaryDirectory() as directory:
13
+ path = Path(directory) / "pyproject.toml"
14
+ path.write_text('[project]\nversion = "1.2.3"\n', encoding="utf-8")
15
+ self.assertEqual(release_version(path), "1.2.3")
16
+
17
+ def test_release_version_rejects_prerelease(self):
18
+ with tempfile.TemporaryDirectory() as directory:
19
+ path = Path(directory) / "pyproject.toml"
20
+ path.write_text('[project]\nversion = "1.2.3.dev4"\n', encoding="utf-8")
21
+ with self.assertRaises(ValueError):
22
+ release_version(path)
23
+
24
+ def test_write_version_preserves_other_sections(self):
25
+ with tempfile.TemporaryDirectory() as directory:
26
+ path = Path(directory) / "pyproject.toml"
27
+ path.write_bytes(
28
+ b'[build-system]\r\nrequires = []\r\n\r\n[project]\r\nversion = "1.2.3"\r\n'
29
+ )
30
+ write_version(path, "1.2.4")
31
+ self.assertEqual(read_version(path), "1.2.4")
32
+ self.assertIn(b"[build-system]\r\nrequires = []", path.read_bytes())
33
+
34
+
35
+ if __name__ == "__main__":
36
+ unittest.main()