|
232 | 232 | ] |
233 | 233 | }, |
234 | 234 | { |
| 235 | + "attachments": {}, |
235 | 236 | "cell_type": "markdown", |
236 | 237 | "metadata": {}, |
237 | 238 | "source": [ |
|
240 | 241 | "While the main RDK is written in golang, you can create custom components in python and connect them to a robot as a `remote` component. This allows you to extend the functionality of a robot, or even create an entire robot exclusively in python.\n", |
241 | 242 | "\n", |
242 | 243 | "The steps required in creating a custom component and connecting it to the RDK are\n", |
243 | | - "1. Subclass a component and implement desired functions\n", |
244 | | - "2. Create an `rpc.server.Server` instance and register the custom component\n", |
245 | | - "3. Start the `Server` and register the running server as a remote\n", |
| 244 | + "1. **Subclass a component and implement desired functions**. This will be your custom component.\n", |
| 245 | + "1. **Create an `rpc.server.Server` instance and register the custom component**. This is the `RPC` server that enables communication with your custom component.\n", |
| 246 | + "1. **Start the `Server` and register the running server as a remote**. Registering this `RPC` server as a remote allows the RDK to communicate with the server.\n", |
246 | 247 | "\n", |
247 | 248 | "But before we start, we need to cover one additional topic: Operations.\n", |
248 | 249 | "\n", |
|
457 | 458 | ] |
458 | 459 | }, |
459 | 460 | { |
| 461 | + "attachments": {}, |
460 | 462 | "cell_type": "markdown", |
461 | 463 | "metadata": {}, |
462 | 464 | "source": [ |
463 | 465 | "### 2. Register the custom component\n", |
464 | 466 | "\n", |
465 | | - "Now that we've created the custom component, we must register it with a server so that it will be visible to any robots connecting to it.\n", |
| 467 | + "Now that we've created the custom component, we must register it so that it will be visible to any robots connecting to it. This is done by creating an `RPC` server and adding `MyCoolArm` as a connected component. This `RPC` server will receive gRPC requests from the Viam Server or any other connections and forward those requests to your custom component.\n", |
466 | 468 | "\n", |
467 | | - "In the same `my-python-robot` directory, create a new file called `python_server.py`." |
| 469 | + "In the same `my-python-robot` directory, create a new file called `main.py`." |
468 | 470 | ] |
469 | 471 | }, |
470 | 472 | { |
|
483 | 485 | } |
484 | 486 | ], |
485 | 487 | "source": [ |
486 | | - "# my-python-robot/python_server.py\n", |
| 488 | + "# my-python-robot/main.py\n", |
487 | 489 | "\n", |
488 | 490 | "import asyncio\n", |
489 | 491 | "from viam.rpc.server import Server\n", |
|
502 | 504 | ] |
503 | 505 | }, |
504 | 506 | { |
| 507 | + "attachments": {}, |
505 | 508 | "cell_type": "markdown", |
506 | 509 | "metadata": {}, |
507 | 510 | "source": [ |
|
510 | 513 | "Now that we have a server that knows about our custom Arm component, we need to start the server so it can receive gRPC calls. Once it's started, we can then register this server as a remote.\n", |
511 | 514 | "\n", |
512 | 515 | "```python3\n", |
513 | | - "# my-python-robot/python_server.py\n", |
| 516 | + "# my-python-robot/main.py\n", |
514 | 517 | "\n", |
515 | 518 | "async def main():\n", |
516 | 519 | " ...\n", |
|
537 | 540 | " \"log\": true,\n", |
538 | 541 | " \"name\": \"python\",\n", |
539 | 542 | " \"args\": [\n", |
540 | | - " \"/home/pi/my-python-robot/python_server.py\"\n", |
| 543 | + " \"/home/pi/my-python-robot/main.py\"\n", |
541 | 544 | " ]\n", |
542 | 545 | " }\n", |
543 | 546 | "]\n", |
|
554 | 557 | " \"-u\",\n", |
555 | 558 | " \"pi\",\n", |
556 | 559 | " \"python\",\n", |
557 | | - " \"/home/pi/my-python-robot/python-server.py\"\n", |
| 560 | + " \"/home/pi/my-python-robot/main.py\"\n", |
558 | 561 | " ]\n", |
559 | 562 | " }\n", |
560 | 563 | "]\n", |
|
0 commit comments