Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-4648: Document namespace nomenclature better #417

Merged
merged 11 commits into from
Sep 13, 2023
18 changes: 12 additions & 6 deletions docs/examples/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
"\n",
"class MySensor(Sensor):\n",
" # Subclass the Viam Sensor component and implement the required functions\n",
" MODEL: ClassVar[Model] = Model(ModelFamily(\"acme\",\"wifi_sensor\"), \"linux\")\n",
" MODEL: ClassVar[Model] = Model(ModelFamily(\"viam\",\"sensor\"), \"linux-wifi\")\n",
hexbabe marked this conversation as resolved.
Show resolved Hide resolved
"\n",
" @classmethod\n",
" def new(cls, config: ComponentConfig, dependencies: Mapping[ResourceName, ResourceBase]) -> Self:\n",
Expand Down Expand Up @@ -483,15 +483,15 @@
"### 5. Configure a modular resource\n",
"**NOTE:** *These instructions are for local development. Soon we will launch a `Registry` which will allow users to upload modules to app.viam.com directly. We will update the documentation with instructions on how to do that shortly.*\n",
"\n",
"[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",
"[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",
"\n",
"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. This is a JSON example:\n",
"\n",
"```json\n",
"{\n",
" \"components\": [\n",
" {\n",
" \"model\": \"acme:wifi_sensor:linux\",\n",
" \"model\": \"viam:sensor:linux-wifi\",\n",
hexbabe marked this conversation as resolved.
Show resolved Hide resolved
" \"attributes\": {},\n",
" \"depends_on\": [],\n",
" \"name\": \"my-sensor\",\n",
Expand All @@ -500,12 +500,18 @@
" ],\n",
" \"modules\": [\n",
" {\n",
" \"executable_path\": \"<path-on-your-filesystem>/wifi-sensor/run.sh\",\n",
" \"executable_path\": \"<path-on-your-filesystem>/linux-wifi/run.sh\",\n",
" \"name\": \"wifi_sensor\"\n",
" }\n",
" ]\n",
"}\n",
"```\n"
"```\n",
"\n",
"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",
hexbabe marked this conversation as resolved.
Show resolved Hide resolved
"\n",
"Viam also provides many built-in models that implement API capabilities, each using `rdk` as the `namespace`, and `builtin` as the `family`:\n",
"- 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",
"- 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."
]
},
{
Expand Down Expand Up @@ -538,7 +544,7 @@
"\n",
"class MyModularArm(Arm):\n",
" # Subclass the Viam Arm component and implement the required functions\n",
" MODEL: ClassVar[Model] = Model(ModelFamily(\"acme\", \"demo\"), \"myarm\")\n",
" MODEL: ClassVar[Model] = Model(ModelFamily(\"viam\", \"arm\"), \"my-arm\")\n",
"\n",
" def __init__(self, name: str):\n",
" # Starting joint positions\n",
Expand Down
8 changes: 5 additions & 3 deletions examples/complex_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ These steps assume that you have a robot available at [app.viam.com](app.viam.co

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.

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.
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.

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).

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

Expand All @@ -44,7 +46,7 @@ An example configuration for an Arm component, a Gizmo component, and a Summatio
{
"name": "arm1",
"type": "arm",
"model": "acme:demo:myarm",
"model": "viam:arm:myarm",
hexbabe marked this conversation as resolved.
Show resolved Hide resolved
"attributes": {},
"depends_on": []
},
Expand Down Expand Up @@ -92,7 +94,7 @@ An example configuration for an Arm component, a Gizmo component, and a Summatio
"left": "motor1",
"right": "motor2"
},
"model": "acme:demo:mybase",
"model": "viam:base:mybase",
"depends_on": []
}
],
Expand Down
2 changes: 1 addition & 1 deletion examples/complex_module/src/arm/my_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

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

def __init__(self, name: str):
# Starting position
Expand Down
2 changes: 1 addition & 1 deletion examples/complex_module/src/base/my_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MyBase(Base, Reconfigurable):
"""

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

def __init__(self, name: str):
super().__init__(name)
Expand Down
4 changes: 3 additions & 1 deletion examples/simple_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ The `run.sh` script is the entrypoint for this module. To connect this module wi

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.

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).

An example configuration for a Sensor component could look like this:
```json
{
"components": [
{
"name": "sensor1",
"type": "sensor",
"model": "acme:demo:mysensor",
"model": "viam:sensor:mysensor",
"attributes": {},
"depends_on": []
}
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_module/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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

def __init__(self, name: str):
Expand Down
Loading