Skip to content

Commit 5f494d5

Browse files
hexbabehexbabeandf-viam
authored
RSDK-4648: Document namespace nomenclature better (#417)
Co-authored-by: hexbabe <[email protected]> Co-authored-by: andf-viam <[email protected]>
1 parent 59f3e3e commit 5f494d5

File tree

6 files changed

+23
-13
lines changed

6 files changed

+23
-13
lines changed

docs/examples/example.ipynb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
"\n",
322322
"class MySensor(Sensor):\n",
323323
" # Subclass the Viam Sensor component and implement the required functions\n",
324-
" MODEL: ClassVar[Model] = Model(ModelFamily(\"acme\",\"wifi_sensor\"), \"linux\")\n",
324+
" MODEL: ClassVar[Model] = Model(ModelFamily(\"viam\",\"sensor\"), \"linux-wifi\")\n",
325325
"\n",
326326
" @classmethod\n",
327327
" def new(cls, config: ComponentConfig, dependencies: Mapping[ResourceName, ResourceBase]) -> Self:\n",
@@ -511,15 +511,15 @@
511511
"### 5. Configure a modular resource\n",
512512
"**NOTE:** *If you are adding your module to the registry, follow [these instructions](https://docs.viam.com/extend/modular-resources/configure/) instead. Otherwise, continue with these instructions, which will show you how to configure the module locally.*\n",
513513
"\n",
514-
"[Configure your new module](https://docs.viam.com/extend/modular-resources/#configure-your-module) on your robot by navigating to the **Config** tab of the robot's page on the Viam app, then click on the **Modules** subtab. Add the name of your module and the executable path. For our example, the path would be `<path-on-your-filesystem>/wifi-sensor/run.sh`.\n",
514+
"[Configure your new module](https://docs.viam.com/extend/modular-resources/#configure-your-module) on your robot by navigating to the **Config** tab of the robot's page on the Viam app, then click on the **Modules** subtab. Add the name of your module and the executable path. For our example, the path would be `<path-on-your-filesystem>/linux-wifi/run.sh`.\n",
515515
"\n",
516516
"Once you have configured a module as part of your robot configuration, [configure your modular resource](https://docs.viam.com/extend/modular-resources/#configure-your-modular-resource) made available by that module by adding new components or services configured with your modular resources' new type or model. To instantiate a new resource from your module, specify the `type`, `model`, and `name` of your modular resource. The aforementioned `type`, `model`, and `name` should be the same as those in the `MODEL` class attribute defined in your [component class](#2-register-the-custom-component). This is a JSON example:\n",
517517
"\n",
518518
"```json\n",
519519
"{\n",
520520
" \"components\": [\n",
521521
" {\n",
522-
" \"model\": \"acme:wifi_sensor:linux\",\n",
522+
" \"model\": \"viam:sensor:linux-wifi\",\n",
523523
" \"attributes\": {},\n",
524524
" \"depends_on\": [],\n",
525525
" \"name\": \"my-sensor\",\n",
@@ -528,12 +528,18 @@
528528
" ],\n",
529529
" \"modules\": [\n",
530530
" {\n",
531-
" \"executable_path\": \"<path-on-your-filesystem>/wifi-sensor/run.sh\",\n",
531+
" \"executable_path\": \"<path-on-your-filesystem>/linux-wifi/run.sh\",\n",
532532
" \"name\": \"wifi_sensor\"\n",
533533
" }\n",
534534
" ]\n",
535535
"}\n",
536-
"```\n"
536+
"```\n",
537+
"\n",
538+
"Note the nomenclature of the above `model` field, `viam:sensor:linux-wifi`. Models are uniquely namespaced as colon-delimited-triplets in the form `namespace:family:name`, and are named according to the Viam API that your model implements. A model with the `viam` namespace is always Viam-provided. Read more about making custom namespaces [here](https://docs.viam.com/extend/modular-resources/key-concepts/#models).\n",
539+
"\n",
540+
"Viam also provides many built-in models that implement API capabilities, each using `rdk` as the `namespace`, and `builtin` as the `family`:\n",
541+
"- The `rdk:builtin:gpio` model of the `rdk:component:motor` API provides RDK support for [GPIO-controlled DC motors](https://docs.viam.com/components/motor/gpio/).\n",
542+
"- The `rdk:builtin:DMC4000` model of the same `rdk:component:motor` API provides RDK support for the [DMC4000](https://docs.viam.com/components/motor/dmc4000/) motor."
537543
]
538544
},
539545
{
@@ -566,7 +572,7 @@
566572
"\n",
567573
"class MyModularArm(Arm):\n",
568574
" # Subclass the Viam Arm component and implement the required functions\n",
569-
" MODEL: ClassVar[Model] = Model(ModelFamily(\"acme\", \"demo\"), \"myarm\")\n",
575+
" MODEL: ClassVar[Model] = Model(ModelFamily(\"viam\", \"arm\"), \"my-arm\")\n",
570576
"\n",
571577
" def __init__(self, name: str):\n",
572578
" # Starting joint positions\n",

examples/complex_module/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ These steps assume that you have a robot available at [app.viam.com](app.viam.co
3434

3535
The `run.sh` script is the entrypoint for this module. To connect this module with your robot, you must add this module's entrypoint to the robot's config. For example, the entrypoint file may be at `/home/viam-python-sdk/examples/complex_module/run.sh` and you must add this file path to your configuration. See the [documentation](https://docs.viam.com/program/extend/modular-resources/#use-a-modular-resource-with-your-robot) for more details.
3636

37-
Once the module has been added to your robot, add a `Gizmo` component that uses the `MyGizmo` model. See the [documentation](https://docs.viam.com/program/extend/modular-resources/#configure-a-component-instance-for-a-modular-resource) for more details. You can also add an `Arm` component that uses the `MyArm` model and a `Summation` service that uses the `MySum` model in a similar manner.
37+
Once the module has been added to your robot, add a `Gizmo` component that uses the `MyGizmo` model. See the [documentation](https://docs.viam.com/extend/modular-resources/configure/) for more details. You can also add an `Arm` component that uses the `MyArm` model and a `Summation` service that uses the `MySum` model in a similar manner.
38+
39+
Models are uniquely namespaced as colon-delimited-triplets in the form `namespace:family:name`, and are named according to the Viam API that your model implements. A model with the `viam` namespace is always Viam-provided. Read more about making custom namespaces [here](https://docs.viam.com/extend/modular-resources/key-concepts/#models).
3840

3941
An example configuration for an Arm component, a Gizmo component, and a Summation service could look like this:
4042

@@ -44,7 +46,7 @@ An example configuration for an Arm component, a Gizmo component, and a Summatio
4446
{
4547
"name": "arm1",
4648
"type": "arm",
47-
"model": "acme:demo:myarm",
49+
"model": "viam:arm:myarm",
4850
"attributes": {},
4951
"depends_on": []
5052
},
@@ -92,7 +94,7 @@ An example configuration for an Arm component, a Gizmo component, and a Summatio
9294
"left": "motor1",
9395
"right": "motor2"
9496
},
95-
"model": "acme:demo:mybase",
97+
"model": "viam:base:mybase",
9698
"depends_on": []
9799
}
98100
],

examples/complex_module/src/arm/my_arm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class MyArm(Arm):
1616
# Subclass the Viam Arm component and implement the required functions
17-
MODEL: ClassVar[Model] = Model(ModelFamily("acme", "demo"), "myarm")
17+
MODEL: ClassVar[Model] = Model(ModelFamily("viam", "arm"), "myarm")
1818

1919
def __init__(self, name: str):
2020
# Starting position

examples/complex_module/src/base/my_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class MyBase(Base, Reconfigurable):
2424
"""
2525

2626
# Subclass the Viam Base component and implement the required functions
27-
MODEL: ClassVar[Model] = Model(ModelFamily("acme", "demo"), "mybase")
27+
MODEL: ClassVar[Model] = Model(ModelFamily("viam", "base"), "mybase")
2828

2929
def __init__(self, name: str):
3030
super().__init__(name)

examples/simple_module/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ The `run.sh` script is the entrypoint for this module. To connect this module wi
2626

2727
Once the module has been added to your robot, add a new component that uses the `MySensor` model. See the [documentation](https://docs.viam.com/program/extend/modular-resources/#configure-a-component-instance-for-a-modular-resource) for more details.
2828

29+
Models are uniquely namespaced as colon-delimited-triplets in the form `namespace:family:name`, and are named according to the Viam API that your model implements. A model with the `viam` namespace is always Viam-provided. Read more about making custom namespaces [here](https://docs.viam.com/extend/modular-resources/key-concepts/#models).
30+
2931
An example configuration for a Sensor component could look like this:
3032
```json
3133
{
3234
"components": [
3335
{
3436
"name": "sensor1",
3537
"type": "sensor",
36-
"model": "acme:demo:mysensor",
38+
"model": "viam:sensor:mysensor",
3739
"attributes": {},
3840
"depends_on": []
3941
}

examples/simple_module/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class MySensor(Sensor):
1717
# Subclass the Viam Sensor component and implement the required functions
18-
MODEL: ClassVar[Model] = Model(ModelFamily("acme", "demo"), "mysensor")
18+
MODEL: ClassVar[Model] = Model(ModelFamily("viam", "sensor"), "mysensor")
1919
multiplier: float
2020

2121
def __init__(self, name: str):

0 commit comments

Comments
 (0)