Skip to content

Commit

Permalink
Merge branch 'main' into test-flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
npentrel authored Sep 16, 2023
2 parents 545e64a + 23e15e1 commit 9682f87
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 11 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/moved-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Alias reminder

on: pull_request

jobs:
alias-reminder:
name: Check for moved files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}
fetch-depth: 0
- name: Check for moved files
shell: pwsh
id: check_files_moved
outputs:
docs_changed: ${{ steps.check_files_moved.outputs.files_moved }}
run: |
$diff = git diff -M --find-renames=10 --summary main
$SourceDiff = $diff | Where-Object { $_ -match '.md$' }
$HasDiff = $SourceDiff.Length -gt 0
Write-Host "::set-output name=files_moved::$HasDiff"
- name: Comment on PR with changed files
if: steps.check_file_changed.outputs.files_moved == 'True'
uses: marocchino/[email protected]
with:
recreate: true
message: 'It looks like the following files were renamed. Please ensure you set aliases correctly:\n $(git diff -M --find-renames=10 --summary main | grep md)'
GITHUB_TOKEN: ${{ secrets.PR_TOKEN }}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/adxl345.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ Name | Type | Inclusion | Default Value | Description
`interrupt_pin` | string | **Required** | The `name` of the [digital interrupt](/components/board/#digital_interrupts) you configured for the pin on the [board](/components/board/) wired to the `accelerometer_pin`.
`threshold` | float | Optional | The acceleration on each axis is compared with this value to determine if a free-fall event occurred (in milligrams, between 0 and 15,937). <br> Default: `437.5`
`time_ms` | float | Optional | Unsigned time value representing the minimum time that the value of all axes must be less than `threshold` to generate a free-fall interrupt (in milliseconds, between 0 and 1,275). <br> Default: `160`

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/cameramono.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ Name | Type | Inclusion | Description
---- | ---- | --------- | -----------
`camera` | string | **Required** | The `name` of the [camera](/components/camera/) you want to use for visual odometry.
`motion_estimation_config` | object | **Required** | See [motionestimation.go in RDK](https://github.com/viamrobotics/rdk/blob/99f62a1640f4c267b744bdfc2924e9fd4f7a3c60/vision/odometry/motionestimation.go).

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/fake.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ Edit and fill in the attributes as applicable.

{{% /tab %}}
{{< /tabs >}}

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/gps/gps-nmea-rtk-pmtk.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,5 @@ You will need to research the options available to you.
If you are not sure where to start, check out this [GPS-RTK2 Hookup Guide from SparkFun](https://learn.sparkfun.com/tutorials/gps-rtk2-hookup-guide/connecting-the-zed-f9p-to-a-correction-source).

{{% /alert %}}

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/gps/gps-nmea-rtk-serial.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ You will need to research the options available to you.
If you are not sure where to start, check out this [GPS-RTK2 Hookup Guide from SparkFun](https://learn.sparkfun.com/tutorials/gps-rtk2-hookup-guide/connecting-the-zed-f9p-to-a-correction-source).

{{% /alert %}}

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/gps/gps-nmea.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,5 @@ Name | Type | Inclusion | Description

{{% /tab %}}
{{< /tabs >}}

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/imu/imu-vectornav.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ Name | Type | Inclusion | Description |
`chip_select_pin` | string | **Required** | The ({{< glossary_tooltip term_id="pin-number" text="pin number" >}}) of the pin on the board (other than the SPI bus pins) connected to the IMU chip. Used to tell the chip whether the current SPI message is meant for it or for another device.
`spi_baud_rate` | int | **Required** | The rate at which data is sent from the IMU. <br> Default: `115200`
`polling_frequency_hz` | int | **Required** | How many times per second the sensor is polled.

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/imu/imu-wit.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,5 @@ Name | Type | Inclusion | Description
---- | ---- | --------- | -----------
`serial_path` | string | **Required** | The full filesystem path to the serial device, starting with <file>/dev/</file>. With your serial device connected, you can run `sudo dmesg \| grep tty` to show relevant device connection log messages, and then match the returned device name, such as `ttyS0`, to its device file, such as <file>/dev/ttyS0</file>. If you omit this attribute, Viam will attempt to automatically detect the path.
`serial_baud_rate` | int | Optional | The rate at which data is sent from the sensor over the serial connection. Valid rates are `9600` and `115200`. The default rate will work for all models. *Only the HWT901B can have a different serial baud rate.* Refer to your model's data sheet. <br>Default: `115200`

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/merged.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ Name | Type | Inclusion | Description
Note that only one sensor from each array can be used to retrieve each type of reading.
Your robot uses the first sensor in the array that has implemented the relevant API method in its model and does not raise an error at runtime.
For instance, in the **JSON Example** above, if both `"vectornav"` and `"mpu6050"` support returning `angular_velocity`, `"mpu6050"` is only used to read angular velocity on the robot if `"vectornav"` returns an error at runtime.

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/mpu6050.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ Name | Type | Inclusion | Description
`board` | string | **Required** | The `name` of the [board](/components/board/) to which the device is wired.
`i2c_bus` | string | **Required** | The `name` of the [I<sup>2</sup>C bus configured](/components/board/#i2cs) on your [board](/components/board/) wired to this device.
`use_alt_i2c_address` | boolean | **Required** | Depends on whether you wire AD0 low (leaving the default address of 0x68) or high (making the address 0x69). If high, set `true`. If low, set `false`. <br> Default: `false`

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/viam-visual-odometry.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,5 @@ The following attributes are available to configure the `viam-visual-odometry` m
| `ransac_threshold_px` | float | Optional | `0.5` | Maximum error to be classified as an inlier.|

See the [ORB openCV documentation](https://docs.opencv.org/3.4/db/d95/classcv_1_1ORB.html) for more details.

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
2 changes: 2 additions & 0 deletions docs/components/movement-sensor/wheeled-odometry.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ The following attributes are available for `wheeled-odometry` movement sensors:
| `left_motors` | object | **Required** | A list containing the name of each of the bases' left [position-reporting motors](/components/motor/gpio/). |
| `right_motors` | object | **Required** | A list containing the name of each of the bases' right [position-reporting motors](/components/motor/gpio/). |
| `time_interval_msec` | number | Optional | The time in milliseconds between each wheeled odometry calculation.<br>Default: `500.0`</br> |

{{< readfile "/static/include/components/movement-sensor-control.md" >}}
71 changes: 71 additions & 0 deletions docs/program/python-venv.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: "Prepare your Python Virtual Environment"
linkTitle: "Prepare Virtualenv"
weight: 10
type: "docs"
description: "Prepare your Python Virtual Environment to program machines with the Python SDK."
images: ["/services/icons/sdk.svg"]
tags: ["client", "sdk", "application", "sdk", "fleet", "program", "python", "venv"]
---

To manage Python packages for your Viam application, it is recommended that you use a virtual environment, or `venv`.
By using a `venv`, you can install Python packages like Viam's client SDK within a virtual environment, avoiding conflicts with other projects or your system.

Follow this guide to set up a fresh virtual environment on your working computer and install the Python SDK as a requirement for your Viam client application.

## Setup your project

First, create a directory for your project.
For example, name your directory `viam-python`:

```sh {class="command-line" data-prompt="$"}
mkdir viam-python
cd viam-python
```

## Create and Activate a Virtual Environment

In the project directory, create and activate a virtual environment for Python to run in.

```bash
python3 -m venv viam-env
source viam-env/bin/activate
```

Now, `(viam-env)` prepends the commands in your terminal window to indicate the Python packages being used are from this particular environment.
You can exit this environment by running `deactivate`.

## Install Viam

Inside the activated `viam-env` python environment, you can now install the Viam SDK:

```bash
pip3 install viam-sdk
```

This installs Viam and all required dependencies.

If you need to install your own requirements, also install them in this virtual environment.
To make your required packages easier to install in the future, you can also [create a](https://openclassrooms.com/en/courses/6900846-set-up-a-python-environment/6990546-manage-virtual-environments-using-requirements-files) <file>requirements.txt</file> file with a list of all the packages you need and then install the requirements for your client application by running `pip3 install -r requirements.txt`.

## Setup your IDE

If you would like to be able to use the environment you created with your IDE, point your IDE to use the python interpreter of your new environment, rather than the default interpreter, likely the global python interpreter.

The following steps are for VS Code.
If you're not using VS Code, please read your IDE's documentation on selecting python interpreters.

1. Open the `viam-python` directory in VS Code
1. Open the Command Palette (using `⇧⌘P` or through the menus View -> Command Palette)
1. Select the command `Python: Select Interpreter`.
There, you should see all the interpreters available to you.
You're looking for the on you just made: `viam-env`.
It will look something like: `Python 3.XX.X ('viam-env': venv) ./viam-env/bin/python`.
If you don't see it, click the `Refresh` icon on the top right of the Command Palette.
Select the `viam-env` interpreter.

Your IDE will now recognize all packages installed in this environment.

## Start building

You are now ready to [start using Viam's Python SDK](/program/)!
1 change: 1 addition & 0 deletions layouts/docs/tutorials.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</aside>
<main class="col-12 col-md-9 col-xl-10 pl-md-5" role="main">
<div class="td-content">
{{ if not .Site.Params.ui.breadcrumb_disable }}{{ partial "breadcrumb.html" . }}{{ end }}
<h1>{{ .Title }}</h1>
<div id="tutorial-menu" class="lozad">
<div id="tutorial-filters">
Expand Down
9 changes: 4 additions & 5 deletions layouts/partials/breadcrumb.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
{{ template "breadcrumbnav" (dict "p1" .p1.Site.Home "p2" .p2 ) -}}
{{ end -}}
{{ $isActive := eq .p1 .p2 }}
{{if .p1.Params.empty_node}}
{{ else }}
<li class="breadcrumb-item{{ if $isActive }} active{{ end }}"
{{- if $isActive }} aria-current="page"{{ end }}>
{{if .p1.Params.empty_node}}
{{ .p1.LinkTitle }}
{{ else }}
<a href="{{ .p1.Permalink }}">{{ .p1.LinkTitle }}</a>
{{ end }}
</li>
{{- end -}}
{{ end }}
{{- end -}}
7 changes: 7 additions & 0 deletions static/include/components/movement-sensor-control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Test the movement sensor

After you configure your movement sensor, navigate to the [Control tab](/manage/fleet/robots/#control) and select the dedicated movement sensor dropdown panel.
This panel presents the data collected by the movement sensor.
The sections in the panel include the position, orientation, angular velocity, linear velocity, and linear acceleration.

{{<imgproc src="/components/movement-sensor/movement-sensor-control-tab.png" resize="800x" declaredimensions=true alt="The movement sensor component in the control tab">}}
15 changes: 9 additions & 6 deletions static/js/tabpane-persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const _tdSupportsLocalStorage = () => typeof Storage !== 'undefined';
// Helpers
function tdPersistKey(key, value) {
// @requires: tdSupportsLocalStorage();
console.log("key", key, "value", value);
try {
if (value) {
localStorage.setItem(key, value);
Expand Down Expand Up @@ -36,10 +35,15 @@ function tdGetTabSelectEventCountAndInc() {

// Main functions

function tdActivateTabsWithKey(key) {
function tdActivateTabsWithKey(key, clicked_element, rectangle) {
if (!key) return;

document.querySelectorAll(`.nav-tabs > .nav-item > a[data-td-tp-persist='${key}']`).forEach((element) => {
document.querySelectorAll(`.nav-tabs > .nav-item > a[data-td-tp-persist='${key}']`).forEach((element) => {
if (element == clicked_element) {
// Ensures that if the dom changes above the element, the user's view
// doesn't jump
window.scrollBy(0, element.getBoundingClientRect().top - rectangle.top);
}
new bootstrap.Tab(element).show();
});
}
Expand All @@ -51,7 +55,6 @@ function tdPersistActiveTab(activeTabKey) {
_tdStoragePersistKey(activeTabKey),
tdGetTabSelectEventCountAndInc()
);
tdActivateTabsWithKey(activeTabKey);
}

// Handlers
Expand Down Expand Up @@ -86,10 +89,10 @@ function tdGetAndActivatePersistedTabs(tabs) {

function tdRegisterTabClickHandler(tabs) {
tabs.forEach((tab) => {
tab.addEventListener('click', () => {
tab.addEventListener('click', (event) => {
const activeTabKey = tab.getAttribute("data-td-tp-persist");
tdPersistActiveTab(activeTabKey);
tdActivateTabsWithKey(activeTabKey)
tdActivateTabsWithKey(activeTabKey, event.srcElement, event.srcElement.getBoundingClientRect())
});
});
}
Expand Down

0 comments on commit 9682f87

Please sign in to comment.