diff --git a/docs/extend/modular-resources/examples/csi.md b/docs/extend/modular-resources/examples/csi.md index c0e15f8cec..78fe6d6042 100644 --- a/docs/extend/modular-resources/examples/csi.md +++ b/docs/extend/modular-resources/examples/csi.md @@ -8,7 +8,6 @@ tags: ["board", "csi", "jetson", "serial", "module", "modular resources", "Pytho # SMEs: Sean --- - Many boards, like the Jetson Orin Nano, come with the option to use Camera Serial Interface (CSI) cameras, like [these cameras from E-con Systems](https://www.e-consystems.com/nvidia-jetson-agx-orin-cameras.asp) or [this camera from Seed Technologies](https://www.digikey.com/en/products/detail/seeed-technology-co.,-ltd/114992263/12396924). These cameras are excellent for utilizing embedded vision systems like Viam's [vision service](/services/vision/). Not all CSI cameras are supported by the [webcam camera model](/components/camera/webcam/). @@ -22,7 +21,7 @@ To use the CSI camera module, follow the [installation](#installation) and [conf ## Installation -On your robot's computer, download [the `viam:camera:csi` appimage](https://github.com/viamrobotics/odrive) and make it executable: +On your robot's computer, download [the `viam:camera:csi` appimage](https://github.com/seanavery/viam-csi) and make it executable: ``` {class="command-line" data-prompt="$"} sudo wget https://github.com/seanavery/viam-csi/releases/download/v0.0.2/viam-csi-0.0.2-aarch64.AppImage -O /usr/local/bin/viam-csi @@ -32,6 +31,32 @@ sudo chmod 755 /usr/local/bin/viam-csi ## Configuration {{< tabs name="Connect your CSI Module and Modular Resource">}} +{{% tab name="Config Builder" %}} + +Navigate to the **Config** tab of your robot's page in [the Viam app](https://app.viam.com). + +Click on the **Modules** subtab and navigate to the **Local** section. +Enter a name, for example `my_csi_cam_module_name`, then enter the executable path. +If you used the above install command, the executable path should be: `/usr/local/bin/viam-csi`. +Then click **Add module**. + +Click on the **Components** subtab and click **Create component**. +Select the `local modular resource` type. +Then select `camera` as the type, enter the triplet `viam:camera:csi`, and give your resource a name, for example `my_test_csi_cam`. +Click **Create**. + +On the new component panel, copy and paste the following JSON object into the attributes field: + +```json +{ + "width_px": , + "height_px": , + "frame_rate": , + "debug": "" +} +``` + +{{% /tab %}} {{% tab name="JSON Template" %}} Go to your robot's page on the [Viam app](https://app.viam.com/). @@ -39,33 +64,30 @@ Navigate to the **Config** tab on your robot's page and select **Raw JSON** mode Copy and paste the JSON object for the module into the modules array to add Viam's `csi-mr` module: -```json {class="line-numbers linkable-line-numbers"} +```json { - "modules": [ - { - "executable_path": "", - "name": "" - } - ] + "executable_path": "", + "name": "", + "type": "local" } ``` Next, add the following JSON object to your components array to configure a `csi` [camera](/components/camera/) component with the name `my_test_csi_cam`: ```json {class="line-numbers linkable-line-numbers"} - { - "model": "viam:camera:csi", - "attributes": { - "width_px": , - "height_px": , - "frame_rate": , - "debug": "" - }, - "depends_on": [], - "name": "", - "namespace": "rdk", - "type": "camera" - } +{ + "model": "viam:camera:csi", + "attributes": { + "width_px": , + "height_px": , + "frame_rate": , + "debug": "" + }, + "depends_on": [], + "name": "", + "namespace": "rdk", + "type": "camera" +} ``` {{% /tab %}} @@ -76,7 +98,8 @@ Next, add the following JSON object to your components array to configure a `csi "modules": [ { "executable_path": "/usr/bin/csi-mr", - "name": "csi_cam_module" + "name": "csi_cam_module", + "type": "local" } ], "components": [ @@ -100,10 +123,7 @@ Next, add the following JSON object to your components array to configure a `csi {{% /tab %}} {{< /tabs >}} -Save the config. -Edit and fill in the attributes as applicable. - -Check the [**Logs** tab](/program/debug/) of your robot in the Viam app to make sure your camera has connected and no errors are being raised. +Edit and fill in the attributes to configure your component. The following attributes are available for the `viam:camera:csi` model: @@ -114,3 +134,7 @@ The following attributes are available for the `viam:camera:csi` model: | `frame_rate` | int | Optional | The image capture frame rate this camera should use.
Default: `30` | | `video_path` | string | Optional | The filepath to the input sensor of this camera on your board. If none is given, your robot will attempt to detect the video path automatically.
Default: `"0"`
| | `debug` | boolean | Optional | Whether or not you want debug input from this camera in your robot's logs.
Default: `false` | + +Then, save the config. + +Check the [**Logs** tab](/program/debug/) of your robot in the Viam app to make sure your camera has connected and no errors are being raised. diff --git a/docs/extend/modular-resources/examples/odrive.md b/docs/extend/modular-resources/examples/odrive.md index b52d00c02d..4675a5ea90 100644 --- a/docs/extend/modular-resources/examples/odrive.md +++ b/docs/extend/modular-resources/examples/odrive.md @@ -35,7 +35,7 @@ pip3 install python-can cantools viam-sdk Follow [these instructions](https://docs.odriverobotics.com/v/latest/odrivetool.html) to install `odrivetool`. -Find and copy the path (either absolute, or relative to the working directory) to the executable module file `run.sh` on your robot's computer to provide when [configuring the module](#module). +Find and copy the path (either absolute, or relative to the working directory) to the executable module file `run.sh` on your robot's computer to provide when [configuring the module](#configuration). {{% alert title="Tip" color="tip" %}} @@ -52,7 +52,7 @@ pwd 1. Read through the [ODrive documentation](https://docs.odriverobotics.com/v/latest/getting-started.html) to wire, calibrate, and configure your ODrive natively. -{{% alert title="Tip" color="tip" %}} + {{% alert title="Tip" color="tip" %}} This configuration remains on the same ODrive motor controller across reboots, and only changes when you go through the configuration of the ODrive again. @@ -62,26 +62,26 @@ See [add an `odrive_config_file`](#add-an-odrive_config_file) for more informati This option is not recommend for the `canbus` model. -{{% /alert %}} + {{% /alert %}} -Note that `iq_msg_rate_ms` in the `odrive_config_file` defaults to `0`, and you must set this to or around `100` to use the [motor API's `SetPower` method](https://docs.viam.com/components/motor/#setpower). + Note that `iq_msg_rate_ms` in the `odrive_config_file` defaults to `0`, and you must set this to or around `100` to use the [motor API's `SetPower` method](https://docs.viam.com/components/motor/#setpower). 2. Follow [this guide](https://docs.odriverobotics.com/v/latest/control.html#control-doc) to tune your ODrive motor. 3. See the [ODrive CAN documentation](https://docs.odriverobotics.com/v/latest/can-guide.html) for detailed information on how to set up CAN on your ODrive. -{{% alert title="Tip" color="tip" %}} + {{% alert title="Tip" color="tip" %}} If you are using a Raspberry Pi as your [board](/components/board/), you must run `sudo ip link set can0 up type can bitrate ` in your terminal to receive CAN messages. See "[Troubleshooting](#troubleshooting): [CAN Link Issues](https://github.com/viamrobotics/odrive#can-link-issues)" for more information. Additionally, make sure you have [enabled SPI communication on your Pi](/installation/prepare/rpi-setup/) to use several common CANHats. -{{% /alert %}} + {{% /alert %}} 4. Make sure your ODrive is connected to your [board](/components/board/) as follows, depending on your preferred connection method: -{{< tabs name="Connect your ODrive">}} + {{< tabs name="Connect your ODrive">}} {{% tab name="serial" %}} Plug the [USB Isolator for Odrive](https://odriverobotics.com/shop/usb-c-to-usb-a-cable-and-usb-isolator) into a USB port on your board. @@ -93,62 +93,69 @@ Plug a USB-C to USB-A cable from the isolator to the ODrive. Wire the CANH and CANL pins from your board to your ODrive. Refer to your board and the [ODrive's pinout](https://docs.odriverobotics.com/v/latest/pinout.html) diagrams for the location of these pins. -You must make a serial connection to set up your ODrive. If CAN chains together multiple ODrives, only one at a time must have this serial connection for reconfiguration +You must make a serial connection to set up your ODrive. +If CAN chains together multiple ODrives, only one at a time must have this serial connection for reconfiguration After setting up the ODrive, if you wish to use the `canbus` model, you can either leave the serial connection plugged in or remove it and leave only the CANH and CANL pins wired. Note that if you want to only use the CAN pins, you cannot specify an `"odrive_config_file"` in your Viam configuration. The ODrive would not be able to make the serial connection it needs to perform reconfiguration. {{% /tab %}} -{{< /tabs >}} + {{< /tabs >}} -After preparing your ODrive, configure the module to configure `serial` or `canbus` model motors on your robot. + After preparing your ODrive, configure the module to configure `serial` or `canbus` model motors on your robot. ## Configuration -### Module - -{{< tabs name="Add the ODrive module">}} +{{< tabs name="Connect your Odrive Module and Modular Resource">}} {{% tab name="Config Builder" %}} -Go to your robot's page on the [Viam app](https://app.viam.com/). -Navigate to the **Config** tab on your robot's page, and click on the **Modules** subtab. +Navigate to the **Config** tab of your robot's page in [the Viam app](https://app.viam.com). -Add the ODrive module with a name of your choice and an `"executable_path"` that points to the location where your ODrive module’s run script, run.sh, is stored on your robot’s computer. +Click on the **Modules** subtab and navigate to the **Local** section. +Enter a name, for example `my_odrive_motor`, and the executable path, that points to the location where your ODrive module’s run script, run.sh, is stored on your robot’s computer. +Then click **Add module**. ![The ODrive module with the name 'odrive' and executable path '~/desktop/odrive/odrive-motor/run.sh' added to a robot in the Viam app config builder](/extend/modular-resources/add-odrive/add-odrive-module-ui.png) -{{% /tab %}} -{{% tab name="JSON Template" %}} +Click on the **Components** subtab and click **Create component**. +Select the `local modular resource` type. +Then select `motor` as the type, enter the triplet `viam:odrive:serial`, and give your resource a name, for example `my_test_odrive`. +Click **Create**. + +On the new component panel, copy and paste the following JSON object into the attributes field: ```json {class="line-numbers linkable-line-numbers"} -"modules": [ - { - "name": "odrive", - "executable_path": "" - } -] +{ + "width_px": , + "height_px": , + "frame_rate": , + "debug": "" +} ``` {{% /tab %}} -{{< /tabs >}} +{{% tab name="JSON Template" %}} -### Modular Resource + Navigate to the **Config** tab. + Select the **Raw JSON** mode. -Go to your robot's page on the [Viam app](https://app.viam.com/). -Navigate to the **Config** tab on your robot's page, and click on the **Components** subtab. -Select **Raw JSON** mode. + To add the module, copy and paste the JSON object into the `"modules"` array: -Copy and paste the following JSON along with your module JSON depending on your preferred communication type: + ```json {class="line-numbers linkable-line-numbers"} + { + "name": "odrive", + "executable_path": "" + } + ``` -{{< tabs name="Add an ODrive motor">}} -{{% tab name="serial" %}} + To add the modular resource from the module, copy and paste the JSON object into the `"components"` array: -```json {class="line-numbers linkable-line-numbers"} -{ - // "modules": [ {"name": "odrive" ... } ] MODULE JSON - "components": [ - { + {{< tabs name="Add an ODrive motor">}} + {{% tab name="serial" %}} + + ```json {class="line-numbers linkable-line-numbers"} + { "model": "viam:odrive:serial", "namespace": "rdk", "attributes": { @@ -156,19 +163,14 @@ Copy and paste the following JSON along with your module JSON depending on your "depends_on": [], "type": "motor", "name": "" - } - ] -} -``` + } + ``` -{{% /tab %}} -{{% tab name="canbus" %}} + {{% /tab %}} + {{% tab name="canbus" %}} -```json {class="line-numbers linkable-line-numbers"} -{ - // "modules": [ {"name": "odrive" ... } ] MODULE JSON - "components": [ - { + ```json {class="line-numbers linkable-line-numbers"} + { "model": "viam:odrive:canbus", "namespace": "rdk", "attributes": { @@ -177,10 +179,11 @@ Copy and paste the following JSON along with your module JSON depending on your "depends_on": [], "type": "motor", "name": "" - } - ] -} -``` + } + ``` + + {{% /tab %}} + {{< /tabs >}} {{% /tab %}} {{% tab name="JSON Example" %}} @@ -222,11 +225,11 @@ Copy and paste the following JSON along with your module JSON depending on your } ``` -Edit and fill in the attributes as applicable to your model of ODrive. - {{% /tab %}} {{< /tabs >}} +Edit and fill in the attributes as applicable to your model of ODrive. + The following attributes are available for the motor resources available in the Viam ODrive module: | Name | Type | Inclusion | Description | @@ -245,7 +248,7 @@ The `"canbus"` type allows you to connect multiple ODrives without providing a ` {{% /alert %}} -#### Add an `odrive_config_file` +### Add an `odrive_config_file` To add an `odrive_config_file` and reconfigure your ODrive natively each time the motor is initialized on the robot, use [`odrivetool`](https://docs.odriverobotics.com/v/latest/odrivetool.html) to extract your configuration from your ODrive: diff --git a/docs/extend/modular-resources/examples/rplidar.md b/docs/extend/modular-resources/examples/rplidar.md index 3a1048b674..df119760d7 100644 --- a/docs/extend/modular-resources/examples/rplidar.md +++ b/docs/extend/modular-resources/examples/rplidar.md @@ -8,6 +8,7 @@ image: "/program/modular-resources/rplidar-on-robot.png" imageAlt: "An R-P-lidar mounted to a Viam rover." images: ["/program/modular-resources/rplidar-on-robot.png"] tags: ["slam", "services", "modular resources", "lidar", "rplidar"] +no_list: true aliases: - "/program/extend/modular-resources/add-rplidar-module/" - "/program/extend/modular-resources/examples/add-rplidar-module/" @@ -55,101 +56,176 @@ For example, if you are using the [RPlidar A1](https://www.slamtec.com/en/Lidar/ Then, go to your robot's page on the [Viam app](https://app.viam.com/). {{< tabs name="Add the RPlidar component">}} +{{% tab name="Config Builder" %}} + +Navigate to the **Config** tab of your robot's page in [the Viam app](https://app.viam.com). + + {{< tabs name="Add the RPlidar component - configs" >}} + {{% tab name="Linux" %}} + +Click on the **Modules** subtab and navigate to the **Local** section. +Enter a name, for example `my_rplidar_module_name`, and the executable path `/usr/bin/csi-mr`. +Then click **Add module**. + +Click on the **Components** subtab and click **Create component**. +Select the `local modular resources` type. +Then select the `camera` as the type, enter the triplet `viam:lidar:rplidar` and give your resource a name, for example `rplidar`. +Click **Create**. + + {{% /tab %}} + {{% tab name="macOS x86_64" %}} + +Click on the **Modules** subtab and navigate to the **Local** section. +Enter a name, for example `my_rplidar_module_name`, and the executable path `/usr/bin/csi-mr`. +Then click **Add module**. + +Click on the **Components** subtab and click **Create component**. +Select the `local modular resources` type. +Then select the `camera` as the type, enter the triplet `viam:lidar:rplidar` and give your resource a name, for example `rplidar`. +Click **Create**. + +On the new component panel, copy and paste the following JSON object into the attributes field: + +```json +{ + "device_path": "/dev/tty.SLAB_USBtoUART" +} +``` + + {{% /tab %}} + {{% tab name="macOS ARM64 (M1 & M2)" %}} + +Click on the **Modules** subtab and navigate to the **Local** section. +Enter a name, for example `my_rplidar_module_name`, and the executable path `/opt/homebrew/bin/rplidar-module`. +Then click **Add module**. + +Click on the **Components** subtab and click **Create component**. +Select the `local modular resources` type. +Then select the `camera` as the type, enter the triplet `viam:lidar:rplidar` and give your resource a name, for example `rplidar`. +Click **Create**. + +On the new component panel, copy and paste the following JSON object into the attributes field: + +```json +{ + "device_path": "/dev/tty.usbserial-XXX" +} +``` + +If you are on an M1 or M2 Macbook, determine the device path by running the following command: + +```sh {class="command-line" data-prompt="$"} +ls /dev/ | grep tty.usbserial +``` + +For example, you may see `tty.usbserial-130`, in which case your device path would be `/dev/tty.usbserial-130`. +Replace the `XXX` at the end of the `device_path` value in the attributes configuration with the number at the end of your device path. + + {{% /tab %}} + {{< /tabs >}} + +{{% /tab %}} {{% tab name="JSON Template" %}} Navigate to the **Config** tab. -Select the **Raw JSON** mode, then copy/paste the following `"components"` and `"modules"` JSON: + +Select the **Raw JSON** mode. {{< tabs name="Add the RPlidar component - configs" >}} {{% tab name="Linux" %}} + Copy and paste the JSON object for the module into the modules array to add the module: + + ```json + { + "executable_path": "/usr/local/bin/rplidar-module", + "name": "my_rplidar_module_name" + } + ``` + + Next, add the following JSON object to your components array to configure a `rplidar` [camera](/components/camera/) component with the name `rplidar`: + ```json { - "modules": [ - { - "executable_path": "/usr/local/bin/rplidar-module", - "name": "rplidar-module" - } - ], - "components": [ - { - "namespace": "rdk", - "type": "camera", - "depends_on": [], - "model": "viam:lidar:rplidar", - "name": "rplidar" - } - ] + "namespace": "rdk", + "type": "camera", + "depends_on": [], + "model": "viam:lidar:rplidar", + "name": "rplidar" } ``` {{% /tab %}} {{% tab name="macOS x86_64" %}} + Copy and paste the JSON object for the module into the modules array to add the module: + + ```json + { + "executable_path": "/usr/local/bin/rplidar-module", + "name": "my_rplidar_module_name" + } + ``` + + Next, add the following JSON object to your components array to configure a `rplidar` [camera](/components/camera/) component with the name `rplidar`: + ```json { - "modules": [ - { - "executable_path": "/usr/local/bin/rplidar-module", - "name": "rplidar-module" - } - ], - "components": [ - { - "namespace": "rdk", - "type": "camera", - "depends_on": [], - "model": "viam:lidar:rplidar", - "attributes": { - "device_path": "/dev/tty.SLAB_USBtoUART" - }, - "name": "rplidar" - } - ] + "namespace": "rdk", + "type": "camera", + "depends_on": [], + "model": "viam:lidar:rplidar", + "attributes": { + "device_path": "/dev/tty.SLAB_USBtoUART" + }, + "name": "rplidar" } ``` {{% /tab %}} {{% tab name="macOS ARM64 (M1 & M2)" %}} -If you are on an M1 or M2 Macbook, determine the device path by running the following command: + Copy and paste the JSON object for the module into the modules array to add the module: -```sh {class="command-line" data-prompt="$"} -ls /dev/ | grep tty.usbserial -``` + ```json + { + "executable_path": "/usr/local/bin/rplidar-module", + "name": "my_rplidar_module_name" + } + ``` -For example, you may see `tty.usbserial-130`, in which case your device path would be `/dev/tty.usbserial-130`. -Use the device path in your configuration: + Next, add the following JSON object to your components array to configure a `rplidar` [camera](/components/camera/) component with the name `rplidar`: ```json { - "modules": [ - { - "executable_path": "/opt/homebrew/bin/rplidar-module", - "name": "rplidar-module" - } - ], - "components": [ - { - "namespace": "rdk", - "type": "camera", - "depends_on": [], - "model": "viam:lidar:rplidar", - "attributes": { - "device_path": "/dev/tty.usbserial-XXX" - }, - "name": "rplidar" - } - ] + "namespace": "rdk", + "type": "camera", + "depends_on": [], + "model": "viam:lidar:rplidar", + "attributes": { + "device_path": "/dev/tty.usbserial-XXX" + }, + "name": "rplidar" } ``` + If you are on an M1 or M2 Macbook, determine the device path by running the following command: + + ```sh {class="command-line" data-prompt="$"} + ls /dev/ | grep tty.usbserial + ``` + + For example, you may see `tty.usbserial-130`, in which case your device path would be `/dev/tty.usbserial-130`. + Replace the `XXX` at the end of the `device_path` value in the attributes configuration with the number at the end of your device path. + {{% /tab %}} {{< /tabs >}} {{% /tab %}} {{< /tabs >}} +Then, save the config. + Check the **Logs** tab of your robot in the Viam app to make sure your RPlidar has connected and no errors are being raised. ## Troubleshooting diff --git a/docs/extend/modular-resources/examples/tflite-module.md b/docs/extend/modular-resources/examples/tflite-module.md index d2b97dbb4d..4163fe4022 100644 --- a/docs/extend/modular-resources/examples/tflite-module.md +++ b/docs/extend/modular-resources/examples/tflite-module.md @@ -228,7 +228,12 @@ To generate your robot's configuration using `example_audio_classification_clien ``` 1. Copy the contents of this file. - Then return to your robot's page on [the Viam app](https://app.viam.com), select the **Config** tab, select **Raw JSON**, and paste the configuration into the text area. + Then return to your robot's page on [the Viam app](https://app.viam.com), select the **Config** tab, select **Raw JSON**, and add the configuration into the text area. + + {{< alert title="Important" color="note" >}} + If you already have other configured components, you will need to add each generated JSON object to the respective `modules` or `services` array. + If you do not already have configured components, you can replace the contents in **Raw JSON** with the generated contents. + {{< /alert >}} 1. Click the **Save config** button at the bottom of the page. Now, when you switch back to **Builder** mode, you can see the new configuration settings under the **Services** and **Modules** subtabs.